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

Unified Diff: include/gpu/GrGpuResource.h

Issue 611383003: Revert of GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: Created 6 years, 3 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
« no previous file with comments | « include/gpu/GrContext.h ('k') | include/gpu/GrTexture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrGpuResource.h
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index 17f34d62b2609fc1b641694bdafb0df30c216ce2..61849e7232fd9f23df1219429d7355580a2606ef 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -49,21 +49,27 @@
// 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 {
- this->validate();
++fRefCnt;
+ // pre-validate once internal_dispose is removed (and therefore 0 ref cnt is not allowed).
+ this->validate();
}
void unref() const {
this->validate();
--fRefCnt;
if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) {
- SkDELETE(this);
+ this->internal_dispose();
}
}
- bool isPurgable() const { return this->reffedOnlyByCache() && !this->internalHasPendingIO(); }
- bool reffedOnlyByCache() const { return 1 == fRefCnt; }
+ 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); }
void validate() const {
#ifdef SK_DEBUG
@@ -74,8 +80,9 @@
#endif
}
+
protected:
- GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0), fIsScratch(kNo_IsScratch) { }
+ GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) {}
bool internalHasPendingRead() const { return SkToBool(fPendingReads); }
bool internalHasPendingWrite() const { return SkToBool(fPendingWrites); }
@@ -91,7 +98,7 @@
this->validate();
--fPendingReads;
if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) {
- SkDELETE(this);
+ this->internal_dispose();
}
}
@@ -104,7 +111,7 @@
this->validate();
--fPendingWrites;
if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) {
- SkDELETE(this);
+ this->internal_dispose();
}
}
@@ -115,17 +122,6 @@
// 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;
};
« no previous file with comments | « include/gpu/GrContext.h ('k') | include/gpu/GrTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698