Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: include/gpu/GrGpuResource.h

Issue 608883003: GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: fix and document hack Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/gpu/GrGpuResource.h
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index 61849e7232fd9f23df1219429d7355580a2606ef..17f34d62b2609fc1b641694bdafb0df30c216ce2 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -49,27 +49,21 @@ public:
// templated helper classes (e.g. SkAutoTUnref). However, we have different categories of
// refs (e.g. pending reads). We also don't require thread safety as GrCacheable objects are
// not intended to cross thread boundaries.
- // internal_dispose() exists because of GrTexture's reliance on it. It will be removed
- // soon.
void ref() const {
- ++fRefCnt;
- // pre-validate once internal_dispose is removed (and therefore 0 ref cnt is not allowed).
this->validate();
+ ++fRefCnt;
}
void unref() const {
this->validate();
--fRefCnt;
if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) {
- this->internal_dispose();
+ SkDELETE(this);
}
}
- virtual void internal_dispose() const { SkDELETE(this); }
-
- /** This is exists to service the old mechanism for recycling scratch textures. It will
- be removed soon. */
- bool unique() const { return 1 == (fRefCnt + fPendingReads + fPendingWrites); }
+ bool isPurgable() const { return this->reffedOnlyByCache() && !this->internalHasPendingIO(); }
+ bool reffedOnlyByCache() const { return 1 == fRefCnt; }
void validate() const {
#ifdef SK_DEBUG
@@ -80,9 +74,8 @@ public:
#endif
}
-
protected:
- GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) {}
+ GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0), fIsScratch(kNo_IsScratch) { }
bool internalHasPendingRead() const { return SkToBool(fPendingReads); }
bool internalHasPendingWrite() const { return SkToBool(fPendingWrites); }
@@ -98,7 +91,7 @@ private:
this->validate();
--fPendingReads;
if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) {
- this->internal_dispose();
+ SkDELETE(this);
}
}
@@ -111,7 +104,7 @@ private:
this->validate();
--fPendingWrites;
if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) {
- this->internal_dispose();
+ SkDELETE(this);
}
}
@@ -122,6 +115,17 @@ private:
// This class is used to manage conversion of refs to pending reads/writes.
friend class GrGpuResourceRef;
+
+ // This is temporary until GrResourceCache is fully replaced by GrResourceCache2.
+ enum IsScratch {
+ kNo_IsScratch,
+ kYes_IsScratch
+ } fIsScratch;
+
+ friend class GrContext; // to set the above field.
+ friend class GrResourceCache; // to check the above field.
+ friend class GrResourceCache2; // to check the above field.
+
template <typename, IOType> friend class GrPendingIOResource;
};

Powered by Google App Engine
This is Rietveld 408576698