aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrGpuResource.h
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-09-30 06:54:17 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-30 06:54:17 -0700
commitdbe6074a06efc5fb6883bb5e4f251ed67c8c0ab4 (patch)
tree9da0008e6fe68fbe2010ad14f5e6c54c7fa5008b /include/gpu/GrGpuResource.h
parent3d398c876440deaab39bbf2a9b881c337e6dc8d4 (diff)
Revert of GrResourceCache2 manages scratch texture. (patchset #14 id:260001 of https://codereview.chromium.org/608883003/)
Reason for revert: Turning bots red: Nanobench seems to be uniformly failing on Android (http://108.170.220.21:10117/builders/Perf-Android-Venue8-PowerVR-x86-Release/builds/99/steps/RunNanobench/logs/stdio) Ubuntu GTX660 32bit is failing in both Debug and Release on GM generation (it appears to be out of memory) (http://108.170.220.120:10117/builders/Test-Ubuntu12-ShuttleA-GTX660-x86-Debug/builds/2457/steps/GenerateGMs/logs/stdio) Original issue's description: > GrResourceCache2 manages scratch texture. > > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/3d398c876440deaab39bbf2a9b881c337e6dc8d4 R=bsalomon@google.com TBR=bsalomon@google.com NOTREECHECKS=true NOTRY=true BUG=skia: Author: robertphillips@google.com Review URL: https://codereview.chromium.org/611383003
Diffstat (limited to 'include/gpu/GrGpuResource.h')
-rw-r--r--include/gpu/GrGpuResource.h32
1 files changed, 14 insertions, 18 deletions
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index 17f34d62b2..61849e7232 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -49,21 +49,27 @@ 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 {
- 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 @@ public:
#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 @@ private:
this->validate();
--fPendingReads;
if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) {
- SkDELETE(this);
+ this->internal_dispose();
}
}
@@ -104,7 +111,7 @@ private:
this->validate();
--fPendingWrites;
if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) {
- SkDELETE(this);
+ this->internal_dispose();
}
}
@@ -115,17 +122,6 @@ 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;
};