From e492ac4fb638678408e421c2b74dea106286bbbd Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Tue, 4 Mar 2014 22:37:29 +0000 Subject: [PATCH] Manual revert of https://code.google.com/p/skia/source/detail?r=13353 due to perf regression. BUG=344020 R=reed@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/187023002 git-svn-id: http://skia.googlecode.com/svn/trunk@13662 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/image/SkSurface_Gpu.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 746bb06..ae05ea8 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -72,19 +72,20 @@ void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { // are we sharing our render target with the image? SkASSERT(NULL != this->getCachedImage()); if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { - SkAutoTUnref newDevice(SkGpuDevice::Create(fDevice->context(), - fDevice->imageInfo(), - rt->numSamples())); - SkASSERT(newDevice.get()); - + // We call createCompatibleDevice because it uses the texture cache. This isn't + // necessarily correct (http://skbug.com/2252), but never using the cache causes + // a Chromium regression. (http://crbug.com/344020) + SkGpuDevice* newDevice = static_cast( + fDevice->createCompatibleDevice(fDevice->imageInfo())); + SkAutoTUnref aurd(newDevice); if (kRetain_ContentChangeMode == mode) { - fDevice->context()->copyTexture(rt->asTexture(), - reinterpret_cast(newDevice->accessRenderTarget())); + fDevice->context()->copyTexture(rt->asTexture(), newDevice->accessRenderTarget()); } SkASSERT(NULL != this->getCachedCanvas()); SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); + this->getCachedCanvas()->setRootDevice(newDevice); - SkRefCnt_SafeAssign(fDevice, newDevice.get()); + SkRefCnt_SafeAssign(fDevice, newDevice); } } -- 2.7.4