aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrGpuResource.h
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-11-11 12:38:40 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-11 18:24:56 +0000
commit294870ff119b89fc902773643b054f14e5d1f554 (patch)
tree8666a14ff9bd50c9138dcbc6f3331e51b8113268 /include/gpu/GrGpuResource.h
parent498d403f7703cb2157bf3c877b84906db5a06cd4 (diff)
Add explicit UniqueID classes for GrGpuResource & GrSurfaceProxy
This sets the stage for using the Proxy's/RenderTargetContext's ID above the flush and the RenderTarget's/GrGpuResource's below the flush. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4650 Change-Id: I9f1e6b00c02a0691d90b58c49e1d8c60684884c1 Reviewed-on: https://skia-review.googlesource.com/4650 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/gpu/GrGpuResource.h')
-rw-r--r--include/gpu/GrGpuResource.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index 5f5ccbf8ee..4597464f02 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -175,12 +175,38 @@ public:
return fGpuMemorySize;
}
+ class UniqueID {
+ public:
+ static UniqueID InvalidID() {
+ return UniqueID(uint32_t(SK_InvalidUniqueID));
+ }
+
+ UniqueID() {}
+
+ explicit UniqueID(uint32_t id) : fID(id) {}
+
+ uint32_t asUInt() const { return fID; }
+
+ bool operator==(const UniqueID& other) const {
+ return fID == other.fID;
+ }
+ bool operator!=(const UniqueID& other) const {
+ return !(*this == other);
+ }
+
+ void makeInvalid() { fID = SK_InvalidUniqueID; }
+ bool isInvalid() const { return SK_InvalidUniqueID == fID; }
+
+ protected:
+ uint32_t fID;
+ };
+
/**
* Gets an id that is unique for this GrGpuResource object. It is static in that it does
* not change when the content of the GrGpuResource object changes. This will never return
* 0.
*/
- uint32_t uniqueID() const { return fUniqueID; }
+ UniqueID uniqueID() const { return fUniqueID; }
/** Returns the current unique key for the resource. It will be invalid if the resource has no
associated unique key. */
@@ -300,7 +326,7 @@ private:
SkBudgeted fBudgeted;
bool fRefsWrappedObjects;
- const uint32_t fUniqueID;
+ const UniqueID fUniqueID;
typedef GrIORef<GrGpuResource> INHERITED;
friend class GrIORef<GrGpuResource>; // to access notifyAllCntsAreZero and notifyRefCntIsZero.