Attached ClipMaskManager to GPU resource freeing system
http://codereview.appspot.com/6208058/
git-svn-id: http://skia.googlecode.com/svn/trunk@3927 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 8d5b88f..aaf2ae4 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -110,6 +110,9 @@
void GrContext::freeGpuResources() {
this->flush();
+
+ fGpu->purgeResources();
+
fTextureCache->removeAll();
fFontCache->freeAll();
// a path renderer may be holding onto resources
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index c0e70dd..bf6e41b 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -545,6 +545,12 @@
*/
virtual void clear(const GrIRect* rect, GrColor color) = 0;
+ /**
+ * Release any resources that are cached but not currently in use. This
+ * is intended to give an application some recourse when resources are low.
+ */
+ virtual void purgeResources() {};
+
////////////////////////////////////////////////////////////////////////////
/**
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index aeb51f8..ba73f7d 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -318,6 +318,12 @@
// GrDrawTarget overrides
virtual void clear(const GrIRect* rect, GrColor color);
+ virtual void purgeResources() SK_OVERRIDE {
+ // The clip mask manager can rebuild all its clip masks so just
+ // get rid of them all.
+ fClipMaskManager.releaseResources();
+ }
+
// After the client interacts directly with the 3D context state the GrGpu
// must resync its internal state and assumptions about 3D context state.
// Each time this occurs the GrGpu bumps a timestamp.