Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index d98b005b1993de606b350629bb14659c42904672..0f4b93140ef2ef902164595ba62074b2d62fd786 100644 |
--- a/src/gpu/SkGpuDevice.cpp |
+++ b/src/gpu/SkGpuDevice.cpp |
@@ -344,15 +344,34 @@ void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y, |
config, bitmap.getPixels(), bitmap.rowBytes(), flags); |
} |
+namespace { |
+void purgeClipCB(int genID, void* ) { |
+ |
+ if (SkClipStack::kInvalidGenID == genID || |
+ SkClipStack::kEmptyGenID == genID || |
+ SkClipStack::kWideOpenGenID == genID) { |
+ // none of these cases will have a cached clip mask |
+ return; |
+ } |
+ |
+} |
+}; |
+ |
void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { |
INHERITED::onAttachToCanvas(canvas); |
// Canvas promises that this ptr is valid until onDetachFromCanvas is called |
fClipData.fClipStack = canvas->getClipStack(); |
+ |
+ fClipData.fClipStack->addPurgeClipCallback(purgeClipCB, fContext); |
} |
void SkGpuDevice::onDetachFromCanvas() { |
INHERITED::onDetachFromCanvas(); |
+ |
+ // TODO: iterate through the clip stack and clean up any cached clip masks |
+ fClipData.fClipStack->removePurgeClipCallback(purgeClipCB, fContext); |
+ |
fClipData.fClipStack = NULL; |
} |