aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private/GrSurfaceProxy.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/private/GrSurfaceProxy.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/private/GrSurfaceProxy.h')
-rw-r--r--include/private/GrSurfaceProxy.h49
1 files changed, 43 insertions, 6 deletions
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index 1e846c5223..dd5ece1e2c 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -99,7 +99,44 @@ public:
int height() const { return fDesc.fHeight; }
GrPixelConfig config() const { return fDesc.fConfig; }
- uint32_t uniqueID() const { return fUniqueID; }
+ class UniqueID {
+ public:
+ // wrapped
+ explicit UniqueID(const GrGpuResource::UniqueID& id) : fID(id.asUInt()) { }
+ // deferred
+ UniqueID() : fID(GrGpuResource::CreateUniqueID()) { }
+
+ 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);
+ }
+
+ bool isInvalid() const { return SK_InvalidUniqueID == fID; }
+
+ private:
+ const uint32_t fID;
+ };
+
+ /*
+ * The contract for the uniqueID is:
+ * for wrapped resources:
+ * the uniqueID will match that of the wrapped resource
+ *
+ * for deferred resources:
+ * the uniqueID will be different from the real resource, when it is allocated
+ * the proxy's uniqueID will not change across the instantiate call
+ *
+ * the uniqueIDs of the proxies and the resources draw from the same pool
+ *
+ * What this boils down to is that the uniqueID of a proxy can be used to consistently
+ * track/identify a proxy but should never be used to distinguish between
+ * resources and proxies - beware!
+ */
+ UniqueID uniqueID() const { return fUniqueID; }
GrSurface* instantiate(GrTextureProvider* texProvider);
@@ -151,9 +188,9 @@ protected:
: fDesc(desc)
, fFit(fit)
, fBudgeted(budgeted)
- , fUniqueID(GrGpuResource::CreateUniqueID())
, fGpuMemorySize(kInvalidGpuMemorySize)
, fLastOpList(nullptr) {
+ // Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources
}
// Wrapped version
@@ -162,10 +199,10 @@ protected:
virtual ~GrSurfaceProxy();
// For wrapped resources, 'fDesc' will always be filled in from the wrapped resource.
- const GrSurfaceDesc fDesc;
- const SkBackingFit fFit; // always exact for wrapped resources
- const SkBudgeted fBudgeted; // set from the backing resource for wrapped resources
- const uint32_t fUniqueID; // set from the backing resource for wrapped resources
+ const GrSurfaceDesc fDesc;
+ const SkBackingFit fFit; // always exact for wrapped resources
+ const SkBudgeted fBudgeted; // set from the backing resource for wrapped resources
+ const UniqueID fUniqueID; // set from the backing resource for wrapped resources
static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0);
SkDEBUGCODE(size_t getRawGpuMemorySize_debugOnly() const { return fGpuMemorySize; })