From 8ec8bab7780cc458ad53c3c44f2027fbc7c14a54 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Wed, 14 May 2014 13:11:48 +0000 Subject: [PATCH] Update layer-pre-rendering for Chrome flag As currently plumbed into Chromium, EXPERIMENTAL_optimize can be called multiple times per picture. Additionally, Chromium generates a lot of pictures with no layers at all. R=bsalomon@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/283703007 git-svn-id: http://skia.googlecode.com/svn/trunk@14721 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/SkGpuDevice.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 0aee983f75..d87b1dc5e9 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1942,6 +1942,11 @@ SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) { SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey(); + const SkPicture::AccelData* existing = picture->EXPERIMENTAL_getAccelData(key); + if (NULL != existing) { + return; + } + SkAutoTUnref data(SkNEW_ARGS(GPUAccelData, (key))); picture->EXPERIMENTAL_addAccelData(data); @@ -1970,6 +1975,10 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) const GPUAccelData *gpuData = static_cast(data); + if (0 == gpuData->numSaveLayers()) { + return false; + } + SkAutoTArray pullForward(gpuData->numSaveLayers()); for (int i = 0; i < gpuData->numSaveLayers(); ++i) { pullForward[i] = false;