Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/image/SkSurface_Gpu.cpp

Issue 187023002: Manual revert of https://code.google.com/p/skia/source/detail?r=13353 due to perf regression. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add comment Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSurface_Base.h" 8 #include "SkSurface_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 // Create a new SkGpuDevice and, if necessary, copy the contents of the old 67 // Create a new SkGpuDevice and, if necessary, copy the contents of the old
68 // device into it. Note that this flushes the SkGpuDevice but 68 // device into it. Note that this flushes the SkGpuDevice but
69 // doesn't force an OpenGL flush. 69 // doesn't force an OpenGL flush.
70 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { 70 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) {
71 GrRenderTarget* rt = fDevice->accessRenderTarget(); 71 GrRenderTarget* rt = fDevice->accessRenderTarget();
72 // are we sharing our render target with the image? 72 // are we sharing our render target with the image?
73 SkASSERT(NULL != this->getCachedImage()); 73 SkASSERT(NULL != this->getCachedImage());
74 if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { 74 if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) {
75 SkAutoTUnref<SkGpuDevice> newDevice(SkGpuDevice::Create(fDevice->context (), 75 // We call createCompatibleDevice because it uses the texture cache. Thi s isn't
76 fDevice->imageInfo(), 76 // necessarily correct (http://skbug.com/2252), but never using the cach e causes
77 rt->numSamples())); 77 // a Chromium regression. (http://crbug.com/344020)
78 SkASSERT(newDevice.get()); 78 SkGpuDevice* newDevice = static_cast<SkGpuDevice*>(
79 79 fDevice->createCompatibleDevice(fDevice->imageInfo()));
80 SkAutoTUnref<SkGpuDevice> aurd(newDevice);
80 if (kRetain_ContentChangeMode == mode) { 81 if (kRetain_ContentChangeMode == mode) {
81 fDevice->context()->copyTexture(rt->asTexture(), 82 fDevice->context()->copyTexture(rt->asTexture(), newDevice->accessRe nderTarget());
82 reinterpret_cast<GrRenderTarget*>(newDevice->accessRenderTarget( )));
83 } 83 }
84 SkASSERT(NULL != this->getCachedCanvas()); 84 SkASSERT(NULL != this->getCachedCanvas());
85 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); 85 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice);
86
86 this->getCachedCanvas()->setRootDevice(newDevice); 87 this->getCachedCanvas()->setRootDevice(newDevice);
87 SkRefCnt_SafeAssign(fDevice, newDevice.get()); 88 SkRefCnt_SafeAssign(fDevice, newDevice);
88 } 89 }
89 } 90 }
90 91
91 /////////////////////////////////////////////////////////////////////////////// 92 ///////////////////////////////////////////////////////////////////////////////
92 93
93 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target) { 94 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target) {
94 if (NULL == target) { 95 if (NULL == target) {
95 return NULL; 96 return NULL;
96 } 97 }
97 return SkNEW_ARGS(SkSurface_Gpu, (target)); 98 return SkNEW_ARGS(SkSurface_Gpu, (target));
(...skipping 13 matching lines...) Expand all
111 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); 112 desc.fConfig = SkBitmapConfig2GrPixelConfig(config);
112 desc.fSampleCnt = sampleCount; 113 desc.fSampleCnt = sampleCount;
113 114
114 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); 115 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0));
115 if (NULL == tex) { 116 if (NULL == tex) {
116 return NULL; 117 return NULL;
117 } 118 }
118 119
119 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget())); 120 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget()));
120 } 121 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698