Don't call purgeCache() from within GrResource memebers.
R=robertphillips@google.com
Review URL: https://codereview.chromium.org/14864020
git-svn-id: http://skia.googlecode.com/svn/trunk@9102 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 656761b..8e16db0 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -523,6 +523,8 @@
// these are mutable so they can be created on-demand
mutable GrIndexBuffer* fQuadIndexBuffer;
bool fContextIsDirty;
+ // Used to abandon/release all resources created by this GrGpu. TODO: Move this
+ // functionality to GrResourceCache.
ResourceList fResourceList;
typedef GrDrawTarget INHERITED;
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index 5630d58..1cbd5f5 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -95,28 +95,7 @@
}
void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
- if (stencilBuffer == fStencilBuffer) {
- return;
- }
-
- if (NULL != fStencilBuffer) {
- fStencilBuffer->unref();
-
- GrContext* context = this->getContext();
- if (NULL != context) {
- context->purgeCache();
- }
-
- if (NULL != context) {
- context->purgeCache();
- }
- }
-
- fStencilBuffer = stencilBuffer;
-
- if (NULL != fStencilBuffer) {
- fStencilBuffer->ref();
- }
+ SkRefCnt_SafeAssign(fStencilBuffer, stencilBuffer);
}
void GrRenderTarget::onRelease() {
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index f05ba98..c4ead34 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -206,6 +206,10 @@
* For even faster searches, a hash is computed from the Key. If there is
* a collision between two keys with the same hash, we fall back on the
* bsearch, and update the hash to reflect the most recent Key requested.
+ *
+ * It is a goal to make the GrResourceCache the central repository and bookkeeper
+ * of all resources. It should replace the linked list of GrResources that
+ * GrGpu uses to call abandon/release.
*/
class GrResourceCache {
public: