OLD | NEW |
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // device into it. Note that this flushes the SkGpuDevice but | 78 // device into it. Note that this flushes the SkGpuDevice but |
79 // doesn't force an OpenGL flush. | 79 // doesn't force an OpenGL flush. |
80 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { | 80 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { |
81 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 81 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
82 // are we sharing our render target with the image? | 82 // are we sharing our render target with the image? |
83 SkASSERT(this->getCachedImage()); | 83 SkASSERT(this->getCachedImage()); |
84 if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { | 84 if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { |
85 // We call createCompatibleDevice because it uses the texture cache. Thi
s isn't | 85 // We call createCompatibleDevice because it uses the texture cache. Thi
s isn't |
86 // necessarily correct (http://skbug.com/2252), but never using the cach
e causes | 86 // necessarily correct (http://skbug.com/2252), but never using the cach
e causes |
87 // a Chromium regression. (http://crbug.com/344020) | 87 // a Chromium regression. (http://crbug.com/344020) |
88 SkGpuDevice* newDevice = static_cast<SkGpuDevice*>( | 88 SkGpuDevice* newDevice = fDevice->cloneDevice(this->props()); |
89 fDevice->createCompatibleDevice(fDevice->imageInfo())); | |
90 SkAutoTUnref<SkGpuDevice> aurd(newDevice); | 89 SkAutoTUnref<SkGpuDevice> aurd(newDevice); |
91 if (kRetain_ContentChangeMode == mode) { | 90 if (kRetain_ContentChangeMode == mode) { |
92 fDevice->context()->copySurface(newDevice->accessRenderTarget(), rt-
>asTexture()); | 91 fDevice->context()->copySurface(newDevice->accessRenderTarget(), rt-
>asTexture()); |
93 } | 92 } |
94 SkASSERT(this->getCachedCanvas()); | 93 SkASSERT(this->getCachedCanvas()); |
95 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); | 94 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); |
96 | 95 |
97 this->getCachedCanvas()->setRootDevice(newDevice); | 96 this->getCachedCanvas()->setRootDevice(newDevice); |
98 SkRefCnt_SafeAssign(fDevice, newDevice); | 97 SkRefCnt_SafeAssign(fDevice, newDevice); |
99 } else if (kDiscard_ContentChangeMode == mode) { | 98 } else if (kDiscard_ContentChangeMode == mode) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 SkAutoTUnref<GrTexture> tex(ctx->refScratchTexture(desc, GrContext::kExact_S
cratchTexMatch)); | 150 SkAutoTUnref<GrTexture> tex(ctx->refScratchTexture(desc, GrContext::kExact_S
cratchTexMatch)); |
152 | 151 |
153 if (NULL == tex) { | 152 if (NULL == tex) { |
154 return NULL; | 153 return NULL; |
155 } | 154 } |
156 | 155 |
157 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), props, true)); | 156 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), props, true)); |
158 } | 157 } |
159 | 158 |
160 #endif | 159 #endif |
OLD | NEW |