From: robertphillips Date: Wed, 31 Aug 2016 21:04:06 +0000 (-0700) Subject: Have GrSurfaceProxys and GrGpuResources draw from the same pool of unique ids X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~106^2~623 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8abb370aca280516f4861c6c942ec453aad018fa;p=platform%2Fupstream%2FlibSkiaSharp.git Have GrSurfaceProxys and GrGpuResources draw from the same pool of unique ids 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 --- diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h index fb7cb8c..9305c16 100644 --- a/include/gpu/GrGpuResource.h +++ b/include/gpu/GrGpuResource.h @@ -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; diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 01c5267..ad2ea91 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -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; } diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index eb82ca7..63cb3c8 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -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 tex); diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index f568f7e..3b9f1ec 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -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); diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp index 49b9349..e64339b 100644 --- a/src/gpu/GrGpuResource.cpp +++ b/src/gpu/GrGpuResource.cpp @@ -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()); diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp index 3d6587f..fa6bd26 100644 --- a/src/gpu/GrRenderTargetProxy.cpp +++ b/src/gpu/GrRenderTargetProxy.cpp @@ -32,7 +32,8 @@ GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc // Wrapped version GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, sk_sp 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) { diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index b8b5d75..f5c401f 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -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(sk_atomic_inc(&gUniqueID) + 1); - } while (id == SK_InvalidUniqueID); - return id; -} diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index f28b29e..205dfdd 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -10,8 +10,15 @@ #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 tex) - : INHERITED(tex->desc(), SkBackingFit::kExact, tex->resourcePriv().isBudgeted()) + : INHERITED(tex->desc(), SkBackingFit::kExact, + tex->resourcePriv().isBudgeted(), tex->uniqueID()) , fTexture(std::move(tex)) { } diff --git a/src/gpu/batches/GrClearBatch.h b/src/gpu/batches/GrClearBatch.h index 7d84bc3..27e19fa 100644 --- a/src/gpu/batches/GrClearBatch.h +++ b/src/gpu/batches/GrClearBatch.h @@ -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; } diff --git a/src/gpu/batches/GrClearStencilClipBatch.h b/src/gpu/batches/GrClearStencilClipBatch.h index d13d3dc..e510821 100644 --- a/src/gpu/batches/GrClearStencilClipBatch.h +++ b/src/gpu/batches/GrClearStencilClipBatch.h @@ -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; } diff --git a/src/gpu/batches/GrCopySurfaceBatch.h b/src/gpu/batches/GrCopySurfaceBatch.h index 05b30b2..fea8aae 100644 --- a/src/gpu/batches/GrCopySurfaceBatch.h +++ b/src/gpu/batches/GrCopySurfaceBatch.h @@ -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; } diff --git a/src/gpu/batches/GrDiscardBatch.h b/src/gpu/batches/GrDiscardBatch.h index 5dafe54..33ffa25 100644 --- a/src/gpu/batches/GrDiscardBatch.h +++ b/src/gpu/batches/GrDiscardBatch.h @@ -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; } diff --git a/src/gpu/batches/GrDrawBatch.h b/src/gpu/batches/GrDrawBatch.h index 0386650..5f37b7b 100644 --- a/src/gpu/batches/GrDrawBatch.h +++ b/src/gpu/batches/GrDrawBatch.h @@ -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 { diff --git a/src/gpu/batches/GrStencilPathBatch.h b/src/gpu/batches/GrStencilPathBatch.h index cc55659..f505a53 100644 --- a/src/gpu/batches/GrStencilPathBatch.h +++ b/src/gpu/batches/GrStencilPathBatch.h @@ -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 { diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h index ae7c694..65b515a 100644 --- a/src/gpu/effects/GrSingleTextureEffect.h +++ b/src/gpu/effects/GrSingleTextureEffect.h @@ -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; } diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index a141767..466af6c 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -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) { diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index d9bbb73..f6ad3ba 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -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); diff --git a/src/gpu/gl/GrGLTextureRenderTarget.cpp b/src/gpu/gl/GrGLTextureRenderTarget.cpp index 1fa0a21..2ba469a 100644 --- a/src/gpu/gl/GrGLTextureRenderTarget.cpp +++ b/src/gpu/gl/GrGLTextureRenderTarget.cpp @@ -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 diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp index abf6502..04299d7 100644 --- a/src/gpu/gl/GrGLVertexArray.cpp +++ b/src/gpu/gl/GrGLVertexArray.cpp @@ -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; } diff --git a/src/gpu/instanced/GLInstancedRendering.cpp b/src/gpu/instanced/GLInstancedRendering.cpp index 3af1aa7..3d9058e 100644 --- a/src/gpu/instanced/GLInstancedRendering.cpp +++ b/src/gpu/instanced/GLInstancedRendering.cpp @@ -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; } } diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp index 6c5be0a..02b7ffd 100644 --- a/src/gpu/text/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp @@ -620,10 +620,10 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx, ); SkAutoTUnref 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 diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp index 4dba4bb..b9ece6b 100644 --- a/tests/ClearTest.cpp +++ b/tests/ClearTest.cpp @@ -40,14 +40,14 @@ static bool check_rect(GrDrawContext* dc, const SkIRect& rect, uint32_t expected static bool reset_dc(sk_sp* 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; } diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index 45d3945..016ce5e 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -15,15 +15,20 @@ #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 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 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 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); } } diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index 14705cb..2cbf81c 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -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(); diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 27b1524..58555d3 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -310,7 +310,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) { ERRORF(reporter, "Not texture backed."); return static_cast(0); } - return static_cast(texture->getUniqueID()); + return static_cast(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(0); } - return static_cast(rt->getUniqueID()); + return static_cast(rt->uniqueID()); }; test_unique_image_snap(reporter, surface.get(), false, imageBackingStore, diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp index 6d5619f..86125b8 100644 --- a/tools/debugger/SkDebugCanvas.cpp +++ b/tools/debugger/SkDebugCanvas.cpp @@ -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(bd); - uint32_t rtID = gbd->accessDrawContext()->accessRenderTarget()->getUniqueID(); + uint32_t rtID = gbd->accessDrawContext()->accessRenderTarget()->uniqueID(); // get the bounding boxes to draw SkTArray childrenBounds;