Index: src/image/SkSurface_Gpu.cpp |
=================================================================== |
--- src/image/SkSurface_Gpu.cpp (revision 8710) |
+++ src/image/SkSurface_Gpu.cpp (working copy) |
@@ -23,7 +23,7 @@ |
virtual SkImage* onNewImageSnapshot() SK_OVERRIDE; |
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, |
const SkPaint*) SK_OVERRIDE; |
- virtual void onCopyOnWrite() SK_OVERRIDE; |
+ virtual void onCopyOnWrite(ContentChangeMode) SK_OVERRIDE; |
private: |
SkGpuDevice* fDevice; |
@@ -86,9 +86,8 @@ |
// Create a new SkGpuDevice and, if necessary, copy the contents of the old |
// device into it. Note that this flushes the SkGpuDevice but |
// doesn't force an OpenGL flush. |
-void SkSurface_Gpu::onCopyOnWrite() { |
+void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { |
GrRenderTarget* rt = (GrRenderTarget*) fDevice->accessRenderTarget(); |
- |
// are we sharing our render target with the image? |
SkASSERT(NULL != this->getCachedImage()); |
if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { |
@@ -96,8 +95,10 @@ |
fDevice->createCompatibleDevice(fDevice->config(), fDevice->width(), |
fDevice->height(), fDevice->isOpaque())); |
SkAutoTUnref<SkGpuDevice> aurd(newDevice); |
- fDevice->context()->copyTexture(rt->asTexture(), |
- (GrRenderTarget*)newDevice->accessRenderTarget()); |
+ if (kRetain_ContentChangeMode == mode) { |
+ fDevice->context()->copyTexture(rt->asTexture(), |
+ reinterpret_cast<GrRenderTarget*>(newDevice->accessRenderTarget())); |
+ } |
SkASSERT(NULL != this->getCachedCanvas()); |
SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); |
this->getCachedCanvas()->setDevice(newDevice); |