Have GrSurfaceProxys and GrGpuResources draw from the same pool of unique ids
authorrobertphillips <robertphillips@google.com>
Wed, 31 Aug 2016 21:04:06 +0000 (14:04 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 31 Aug 2016 21:04:06 +0000 (14:04 -0700)
The idea here is that, for wrapped Proxy objects, we want the uniqueID to reflect that of the wrapped object. For this to work the IDs for the non-wrapped versions can't conflict with GrGpuResource's pool of IDs.

Split off of: https://codereview.chromium.org/2215323003/ (Start using RenderTargetProxy (omnibus))

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2301523003

Review-Url: https://codereview.chromium.org/2301523003

26 files changed:
include/gpu/GrGpuResource.h
include/private/GrSurfaceProxy.h
include/private/GrTextureProxy.h
src/gpu/GrDrawTarget.cpp
src/gpu/GrGpuResource.cpp
src/gpu/GrRenderTargetProxy.cpp
src/gpu/GrSurfaceProxy.cpp
src/gpu/GrTextureProxy.cpp
src/gpu/batches/GrClearBatch.h
src/gpu/batches/GrClearStencilClipBatch.h
src/gpu/batches/GrCopySurfaceBatch.h
src/gpu/batches/GrDiscardBatch.h
src/gpu/batches/GrDrawBatch.h
src/gpu/batches/GrStencilPathBatch.h
src/gpu/effects/GrSingleTextureEffect.h
src/gpu/gl/GrGLGpu.cpp
src/gpu/gl/GrGLRenderTarget.cpp
src/gpu/gl/GrGLTextureRenderTarget.cpp
src/gpu/gl/GrGLVertexArray.cpp
src/gpu/instanced/GLInstancedRendering.cpp
src/gpu/text/GrStencilAndCoverTextContext.cpp
tests/ClearTest.cpp
tests/ProxyTest.cpp
tests/ResourceCacheTest.cpp
tests/SurfaceTest.cpp
tools/debugger/SkDebugCanvas.cpp

index fb7cb8c..9305c16 100644 (file)
@@ -180,7 +180,7 @@ public:
      * not change when the content of the GrGpuResource object changes. This will never return
      * 0.
      */
-    uint32_t getUniqueID() const { return fUniqueID; }
+    uint32_t uniqueID() const { return fUniqueID; }
 
     /** Returns the current unique key for the resource. It will be invalid if the resource has no
         associated unique key. */
@@ -217,6 +217,8 @@ public:
      **/
     virtual void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
 
+    static uint32_t CreateUniqueID();
+
 protected:
     // This must be called by every non-wrapped GrGpuObject. It should be called once the object is
     // fully initialized (i.e. only from the constructors of the final class).
@@ -279,9 +281,6 @@ private:
 #ifdef SK_DEBUG
     friend class GrGpu; // for assert in GrGpu to access getGpu
 #endif
-
-    static uint32_t CreateUniqueID();
-
     // An index into a heap when this resource is purgeable or an array when not. This is maintained
     // by the cache.
     int                         fCacheArrayIndex;
index 01c5267..ad2ea91 100644 (file)
@@ -41,11 +41,21 @@ public:
     virtual const GrRenderTargetProxy* asRenderTargetProxy() const { return nullptr; }
 
 protected:
+    // Deferred version
     GrSurfaceProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted)
         : fDesc(desc)
         , fFit(fit)
         , fBudgeted(budgeted)
-        , fUniqueID(CreateUniqueID()) {
+        , fUniqueID(GrGpuResource::CreateUniqueID()) {
+    }
+
+    // Wrapped version
+    GrSurfaceProxy(const GrSurfaceDesc& desc, SkBackingFit fit, 
+                   SkBudgeted budgeted, uint32_t uniqueID)
+        : fDesc(desc)
+        , fFit(fit)
+        , fBudgeted(budgeted)
+        , fUniqueID(uniqueID) {
     }
 
     virtual ~GrSurfaceProxy() {}
@@ -54,10 +64,9 @@ protected:
     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;
+    const uint32_t      fUniqueID; // set from the backing resource for wrapped resources
 
 private:
-    static uint32_t CreateUniqueID();
 
     // See comment in GrGpuResource.h.
     void notifyAllCntsAreZero(CntType) const { delete this; }
index eb82ca7..63cb3c8 100644 (file)
@@ -30,12 +30,9 @@ public:
     GrTexture* instantiate(GrTextureProvider* texProvider);
 
 private:
-    GrTextureProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted,
-                   const void* /*srcData*/, size_t /*rowBytes*/)
-        : INHERITED(desc, fit, budgeted) {
-        // TODO: Handle 'srcData' here
-    }
-
+    // Deferred version
+    GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
+                   const void* srcData, size_t srcRowBytes);
     // Wrapped version
     GrTextureProxy(sk_sp<GrTexture> tex);
 
index f568f7e..3b9f1ec 100644 (file)
@@ -116,7 +116,7 @@ void GrDrawTarget::addDependency(GrSurface* dependedOn) {
 #ifdef SK_DEBUG
 void GrDrawTarget::dump() const {
     SkDebugf("--------------------------------------------------------------\n");
-    SkDebugf("node: %d -> RT: %d\n", fDebugID, fRenderTarget ? fRenderTarget->getUniqueID() : -1);
+    SkDebugf("node: %d -> RT: %d\n", fDebugID, fRenderTarget ? fRenderTarget->uniqueID() : -1);
     SkDebugf("relies On (%d): ", fDependencies.count());
     for (int i = 0; i < fDependencies.count(); ++i) {
         SkDebugf("%d, ", fDependencies[i]->fDebugID);
@@ -452,7 +452,7 @@ void GrDrawTarget::fullClear(GrRenderTarget* renderTarget, GrColor color) {
     // remove all the previously recorded batches and change the load op to clear with supplied
     // color.
     if (fLastFullClearBatch &&
-        fLastFullClearBatch->renderTargetUniqueID() == renderTarget->getUniqueID()) {
+        fLastFullClearBatch->renderTargetUniqueID() == renderTarget->uniqueID()) {
         // As currently implemented, fLastFullClearBatch should be the last batch because we would
         // have cleared it when another batch was recorded.
         SkASSERT(fRecordedBatches.back().fBatch.get() == fLastFullClearBatch);
index 49b9349..e64339b 100644 (file)
@@ -69,7 +69,7 @@ void GrGpuResource::abandon() {
 void GrGpuResource::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
     // Dump resource as "skia/gpu_resources/resource_#".
     SkString dumpName("skia/gpu_resources/resource_");
-    dumpName.appendS32(this->getUniqueID());
+    dumpName.appendS32(this->uniqueID());
 
     traceMemoryDump->dumpNumericValue(dumpName.c_str(), "size", "bytes", this->gpuMemorySize());
 
index 3d6587f..fa6bd26 100644 (file)
@@ -32,7 +32,8 @@ GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc
 
 // Wrapped version
 GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, sk_sp<GrRenderTarget> rt)
-    : INHERITED(rt->desc(), SkBackingFit::kExact, rt->resourcePriv().isBudgeted())
+    : INHERITED(rt->desc(), SkBackingFit::kExact,
+                rt->resourcePriv().isBudgeted(), rt->uniqueID())
     , fTarget(std::move(rt))
     , fFlags(fTarget->renderTargetPriv().flags())
     , fLastDrawTarget(nullptr) {
index b8b5d75..f5c401f 100644 (file)
@@ -7,13 +7,3 @@
 
 #include "GrSurfaceProxy.h"
 
-#include "SkAtomics.h"
-
-uint32_t GrSurfaceProxy::CreateUniqueID() {
-    static int32_t gUniqueID = SK_InvalidUniqueID;
-    uint32_t id;
-    do {
-        id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
-    } while (id == SK_InvalidUniqueID);
-    return id;
-}
index f28b29e..205dfdd 100644 (file)
 #include "GrTextureProvider.h"
 #include "GrGpuResourcePriv.h"
 
+GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted,
+                               const void* /*srcData*/, size_t /*rowBytes*/)
+    : INHERITED(srcDesc, fit, budgeted) {
+    // TODO: Handle 'srcData' here
+}
+
 GrTextureProxy::GrTextureProxy(sk_sp<GrTexture> tex)
-    : INHERITED(tex->desc(), SkBackingFit::kExact, tex->resourcePriv().isBudgeted())
+    : INHERITED(tex->desc(), SkBackingFit::kExact,
+                tex->resourcePriv().isBudgeted(), tex->uniqueID())
     , fTexture(std::move(tex)) {
 }
 
index 7d84bc3..27e19fa 100644 (file)
@@ -29,7 +29,7 @@ public:
 
     const char* name() const override { return "Clear"; }
 
-    uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
+    uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->uniqueID(); }
     GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
 
     SkString dumpInfo() const override {
@@ -38,7 +38,7 @@ public:
             const SkIRect& r = fClip.scissorRect();
             string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
         }
-        string.appendf("], Color: 0x%08x, RT: %d", fColor, fRenderTarget.get()->getUniqueID());
+        string.appendf("], Color: 0x%08x, RT: %d", fColor, fRenderTarget.get()->uniqueID());
         string.append(INHERITED::dumpInfo());
         return string;
     }
index d13d3dc..e510821 100644 (file)
@@ -31,7 +31,7 @@ public:
 
     const char* name() const override { return "ClearStencilClip"; }
 
-    uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
+    uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->uniqueID(); }
     GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
 
     SkString dumpInfo() const override {
@@ -40,7 +40,7 @@ public:
             const SkIRect& r = fClip.scissorRect();
             string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
         }
-        string.appendf("], IC: %d, RT: %d", fInsideStencilMask, fRenderTarget.get()->getUniqueID());
+        string.appendf("], IC: %d, RT: %d", fInsideStencilMask, fRenderTarget.get()->uniqueID());
         string.append(INHERITED::dumpInfo());
         return string;
     }
index 05b30b2..fea8aae 100644 (file)
@@ -34,7 +34,7 @@ public:
 
     uint32_t renderTargetUniqueID() const override {
         GrRenderTarget* rt = fDst.get()->asRenderTarget();
-        return rt ? rt->getUniqueID() : 0;
+        return rt ? rt->uniqueID() : 0;
     }
     GrRenderTarget* renderTarget() const override { return nullptr; }
 
index 5dafe54..33ffa25 100644 (file)
@@ -26,12 +26,12 @@ public:
 
     const char* name() const override { return "Discard"; }
 
-    uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
+    uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->uniqueID(); }
     GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
 
     SkString dumpInfo() const override {
         SkString string;
-        string.printf("RT: %d", fRenderTarget.get()->getUniqueID());
+        string.printf("RT: %d", fRenderTarget.get()->uniqueID());
         string.append(INHERITED::dumpInfo());
         return string;
     }
index 0386650..5f37b7b 100644 (file)
@@ -76,7 +76,7 @@ public:
 
     uint32_t renderTargetUniqueID() const final {
         SkASSERT(fPipelineInstalled);
-        return this->pipeline()->getRenderTarget()->getUniqueID();
+        return this->pipeline()->getRenderTarget()->uniqueID();
     }
 
     GrRenderTarget* renderTarget() const final {
index cc55659..f505a53 100644 (file)
@@ -33,7 +33,7 @@ public:
 
     const char* name() const override { return "StencilPath"; }
 
-    uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
+    uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->uniqueID(); }
     GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
 
     SkString dumpInfo() const override {
index ae7c694..65b515a 100644 (file)
@@ -26,7 +26,7 @@ public:
 
     SkString dumpInfo() const override {
         SkString str;
-        str.appendf("Texture: %d", fTextureAccess.getTexture()->getUniqueID());
+        str.appendf("Texture: %d", fTextureAccess.getTexture()->uniqueID());
         return str;
     }
 
index a141767..466af6c 100644 (file)
@@ -2149,7 +2149,7 @@ GrGLenum GrGLGpu::bindBuffer(GrBufferType type, const GrBuffer* buffer) {
     SkASSERT(type >= 0 && type <= kLast_GrBufferType);
     auto& bufferState = fHWBufferState[type];
 
-    if (buffer->getUniqueID() != bufferState.fBoundBufferUniqueID) {
+    if (buffer->uniqueID() != bufferState.fBoundBufferUniqueID) {
         if (buffer->isCPUBacked()) {
             if (!bufferState.fBufferZeroKnownBound) {
                 GL_CALL(BindBuffer(bufferState.fGLTarget, 0));
@@ -2159,7 +2159,7 @@ GrGLenum GrGLGpu::bindBuffer(GrBufferType type, const GrBuffer* buffer) {
             GL_CALL(BindBuffer(bufferState.fGLTarget, glBuffer->bufferID()));
         }
         bufferState.fBufferZeroKnownBound = buffer->isCPUBacked();
-        bufferState.fBoundBufferUniqueID = buffer->getUniqueID();
+        bufferState.fBoundBufferUniqueID = buffer->uniqueID();
     }
 
     return bufferState.fGLTarget;
@@ -2168,7 +2168,7 @@ GrGLenum GrGLGpu::bindBuffer(GrBufferType type, const GrBuffer* buffer) {
 void GrGLGpu::notifyBufferReleased(const GrGLBuffer* buffer) {
     if (buffer->hasAttachedToTexture()) {
         // Detach this buffer from any textures to ensure the underlying memory is freed.
-        uint32_t uniqueID = buffer->getUniqueID();
+        uint32_t uniqueID = buffer->uniqueID();
         for (int i = fHWMaxUsedBufferTextureUnit; i >= 0; --i) {
             auto& buffTex = fHWBufferTextures[i];
             if (uniqueID != buffTex.fAttachedBufferUniqueID) {
@@ -2656,7 +2656,7 @@ void GrGLGpu::finishDrawTarget() {
 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bounds, bool disableSRGB) {
     SkASSERT(target);
 
-    uint32_t rtID = target->getUniqueID();
+    uint32_t rtID = target->uniqueID();
     if (fHWBoundRenderTargetUniqueID != rtID) {
         fStats.incRenderTargetBinds();
         GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID()));
@@ -3178,7 +3178,7 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool allow
         this->onResolveRenderTarget(texRT);
     }
 
-    uint32_t textureID = texture->getUniqueID();
+    uint32_t textureID = texture->uniqueID();
     GrGLenum target = texture->target();
     if (fHWBoundTextureUniqueIDs[unitIdx] != textureID) {
         this->setTextureUnit(unitIdx);
@@ -3296,7 +3296,7 @@ void GrGLGpu::bindTexelBuffer(int unitIdx, GrPixelConfig texelConfig, GrGLBuffer
         buffTex.fKnownBound = true;
     }
 
-    if (buffer->getUniqueID() != buffTex.fAttachedBufferUniqueID ||
+    if (buffer->uniqueID() != buffTex.fAttachedBufferUniqueID ||
         buffTex.fTexelConfig != texelConfig) {
 
         this->setTextureUnit(unitIdx);
@@ -3305,7 +3305,7 @@ void GrGLGpu::bindTexelBuffer(int unitIdx, GrPixelConfig texelConfig, GrGLBuffer
                           buffer->bufferID()));
 
         buffTex.fTexelConfig = texelConfig;
-        buffTex.fAttachedBufferUniqueID = buffer->getUniqueID();
+        buffTex.fAttachedBufferUniqueID = buffer->uniqueID();
 
         if (this->glCaps().textureSwizzleSupport() &&
             this->glCaps().configSwizzle(texelConfig) != buffTex.fSwizzle) {
index d9bbb73..f6ad3ba 100644 (file)
@@ -190,7 +190,7 @@ void GrGLRenderTarget::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump)
         // Due to this resource having both a texture and a renderbuffer component, dump as
         // skia/gpu_resources/resource_#/renderbuffer
         SkString dumpName("skia/gpu_resources/resource_");
-        dumpName.appendS32(this->getUniqueID());
+        dumpName.appendS32(this->uniqueID());
         dumpName.append("/renderbuffer");
 
         traceMemoryDump->dumpNumericValue(dumpName.c_str(), "size", "bytes", size);
index 1fa0a21..2ba469a 100644 (file)
@@ -18,7 +18,7 @@ void GrGLTextureRenderTarget::dumpMemoryStatistics(
   // texture and a
   // renderbuffer component, dump as skia/gpu_resources/resource_#/texture
   SkString dumpName("skia/gpu_resources/resource_");
-  dumpName.appendS32(this->getUniqueID());
+  dumpName.appendS32(this->uniqueID());
   dumpName.append("/texture");
 
   // Use the texture's gpuMemorySize, not our own, which includes the
index abf6502..04299d7 100644 (file)
@@ -50,7 +50,7 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
         array->fEnableIsValid = true;
         array->fEnabled = true;
     }
-    if (array->fVertexBufferUniqueID != vertexBuffer->getUniqueID() ||
+    if (array->fVertexBufferUniqueID != vertexBuffer->uniqueID() ||
         array->fType != type ||
         array->fStride != stride ||
         array->fOffset != offset) {
@@ -72,7 +72,7 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
                                                                 stride,
                                                                 offset));
         }
-        array->fVertexBufferUniqueID = vertexBuffer->getUniqueID();
+        array->fVertexBufferUniqueID = vertexBuffer->uniqueID();
         array->fType = type;
         array->fStride = stride;
         array->fOffset = offset;
@@ -114,7 +114,7 @@ GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
 
 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const GrBuffer* ibuff) {
     GrGLAttribArrayState* state = this->bind(gpu);
-    if (state && fIndexBufferUniqueID != ibuff->getUniqueID()) {
+    if (state && fIndexBufferUniqueID != ibuff->uniqueID()) {
         if (ibuff->isCPUBacked()) {
             GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, 0));
         } else {
@@ -122,7 +122,7 @@ GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const G
             GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER,
                                                       glBuffer->bufferID()));
         }
-        fIndexBufferUniqueID = ibuff->getUniqueID();
+        fIndexBufferUniqueID = ibuff->uniqueID();
     }
     return state;
 }
index 3af1aa7..3d9058e 100644 (file)
@@ -264,7 +264,7 @@ void GLInstancedRendering::flushInstanceAttribs(int baseInstance) {
     this->glGpu()->bindVertexArray(fVertexArrayID);
 
     SkASSERT(fInstanceBuffer);
-    if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->getUniqueID() ||
+    if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->uniqueID() ||
         fInstanceAttribsBaseInstance != baseInstance) {
         Instance* offsetInBuffer = (Instance*) nullptr + baseInstance;
 
@@ -298,7 +298,7 @@ void GLInstancedRendering::flushInstanceAttribs(int baseInstance) {
                                     sizeof(Instance), &offsetInBuffer->fLocalRect));
         GL_CALL(VertexAttribDivisor((int)Attrib::kLocalRect, 1));
 
-        fInstanceAttribsBufferUniqueId = fInstanceBuffer->getUniqueID();
+        fInstanceAttribsBufferUniqueId = fInstanceBuffer->uniqueID();
         fInstanceAttribsBaseInstance = baseInstance;
     }
 }
index 6c5be0a..02b7ffd 100644 (file)
@@ -620,10 +620,10 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
         );
 
         SkAutoTUnref<GrPathRange> glyphs(this->createGlyphs(ctx));
-        if (fLastDrawnGlyphsID != glyphs->getUniqueID()) {
+        if (fLastDrawnGlyphsID != glyphs->uniqueID()) {
             // Either this is the first draw or the glyphs object was purged since last draw.
             glyphs->loadPathsIfNeeded(fInstanceData->indices(), fInstanceData->count());
-            fLastDrawnGlyphsID = glyphs->getUniqueID();
+            fLastDrawnGlyphsID = glyphs->uniqueID();
         }
 
         // Don't compute a bounding box. For dst copy texture, we'll opt instead for it to just copy
index 4dba4bb..b9ece6b 100644 (file)
@@ -40,14 +40,14 @@ static bool check_rect(GrDrawContext* dc, const SkIRect& rect, uint32_t expected
 static bool reset_dc(sk_sp<GrDrawContext>* dc, GrContext* context, int w, int h) {
     SkDEBUGCODE(uint32_t oldID = 0;)
     if (*dc) {
-        SkDEBUGCODE(oldID = (*dc)->accessRenderTarget()->getUniqueID();)
+        SkDEBUGCODE(oldID = (*dc)->accessRenderTarget()->uniqueID();)
         dc->reset(nullptr);
     }
     context->freeGpuResources();
 
     *dc = context->makeDrawContext(SkBackingFit::kExact, w, h, kRGBA_8888_GrPixelConfig, nullptr);
 
-    SkASSERT((*dc)->accessRenderTarget()->getUniqueID() != oldID);
+    SkASSERT((*dc)->accessRenderTarget()->uniqueID() != oldID);
 
     return *dc != nullptr;
 }
index 45d3945..016ce5e 100644 (file)
 #include "GrTextureProxy.h"
 #include "GrRenderTargetProxy.h"
 
+// Check that the surface proxy's member vars are set as expected
 static void check_surface(skiatest::Reporter* reporter,
                           GrSurfaceProxy* proxy,
                           GrSurfaceOrigin origin,
                           int width, int height, 
-                          GrPixelConfig config) {
+                          GrPixelConfig config,
+                          uint32_t uniqueID) {
     REPORTER_ASSERT(reporter, proxy->origin() == origin);
     REPORTER_ASSERT(reporter, proxy->width() == width);
     REPORTER_ASSERT(reporter, proxy->height() == height);
     REPORTER_ASSERT(reporter, proxy->config() == config);
+    if (SK_InvalidUniqueID != uniqueID) {
+        REPORTER_ASSERT(reporter, proxy->uniqueID() == uniqueID);    
+    }
 }
 
 static void check_rendertarget(skiatest::Reporter* reporter,
@@ -77,7 +82,7 @@ static void check_texture(skiatest::Reporter* reporter,
 }
 
 
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AllocedProxyTest, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
     GrTextureProvider* provider = ctxInfo.grContext()->textureProvider();
 
     for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
@@ -104,7 +109,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AllocedProxyTest, reporter, ctxInfo) {
                                                                     fit,
                                                                     budgeted));
                                 check_surface(reporter, rtProxy.get(), origin,
-                                              widthHeight, widthHeight, config);
+                                              widthHeight, widthHeight, config, SK_InvalidUniqueID);
                                 check_rendertarget(reporter, provider, rtProxy.get(), fit);
                             }
 
@@ -114,7 +119,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AllocedProxyTest, reporter, ctxInfo) {
                                                                                 fit,
                                                                                 budgeted));
                             check_surface(reporter, texProxy.get(), origin,
-                                          widthHeight, widthHeight, config);
+                                          widthHeight, widthHeight, config, SK_InvalidUniqueID);
                             check_texture(reporter, provider, texProxy.get(), fit);
                         }
                     }
@@ -162,7 +167,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
                         sk_sp<GrRenderTargetProxy> rtProxy(
                             GrRenderTargetProxy::Make(caps, defaultFBO));
                         check_surface(reporter, rtProxy.get(), origin,
-                                      kWidthHeight, kWidthHeight, config);
+                                      kWidthHeight, kWidthHeight, config, defaultFBO->uniqueID());
                         check_rendertarget(reporter, provider, rtProxy.get(), SkBackingFit::kExact);
                     }
 
@@ -178,7 +183,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
 
                         sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy::Make(caps, rt));
                         check_surface(reporter, rtProxy.get(), origin,
-                                      kWidthHeight, kWidthHeight, config);
+                                      kWidthHeight, kWidthHeight, config, rt->uniqueID());
                         check_rendertarget(reporter, provider, rtProxy.get(), SkBackingFit::kExact);
                     }
 
@@ -190,7 +195,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
 
                     sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make(tex));
                     check_surface(reporter, texProxy.get(), origin,
-                                  kWidthHeight, kWidthHeight, config);
+                                  kWidthHeight, kWidthHeight, config, tex->uniqueID());
                     check_texture(reporter, provider, texProxy.get(), SkBackingFit::kExact);
                 }
             }
index 14705cb..2cbf81c 100644 (file)
@@ -1296,7 +1296,7 @@ static void test_abandoned(skiatest::Reporter* reporter) {
 
     // Call all the public methods on resource in the abandoned state. They shouldn't crash.
 
-    resource->getUniqueID();
+    resource->uniqueID();
     resource->getUniqueKey();
     resource->wasDestroyed();
     resource->gpuMemorySize();
index 27b1524..58555d3 100644 (file)
@@ -310,7 +310,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) {
                 ERRORF(reporter, "Not texture backed.");
                 return static_cast<intptr_t>(0);
             }
-            return static_cast<intptr_t>(texture->getUniqueID());
+            return static_cast<intptr_t>(texture->uniqueID());
         };
 
         auto surfaceBackingStore = [reporter](SkSurface* surface) {
@@ -320,7 +320,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) {
                 ERRORF(reporter, "Not render target backed.");
                 return static_cast<intptr_t>(0);
             }
-            return static_cast<intptr_t>(rt->getUniqueID());
+            return static_cast<intptr_t>(rt->uniqueID());
         };
 
         test_unique_image_snap(reporter, surface.get(), false, imageBackingStore,
index 6d5619f..86125b8 100644 (file)
@@ -356,7 +356,7 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index, int m) {
         // get the render target of the top device so we can ignore batches drawn offscreen
         SkBaseDevice* bd = canvas->getDevice_just_for_deprecated_compatibility_testing();
         SkGpuDevice* gbd = reinterpret_cast<SkGpuDevice*>(bd);
-        uint32_t rtID = gbd->accessDrawContext()->accessRenderTarget()->getUniqueID();
+        uint32_t rtID = gbd->accessDrawContext()->accessRenderTarget()->uniqueID();
 
         // get the bounding boxes to draw
         SkTArray<GrAuditTrail::BatchInfo> childrenBounds;