aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrAuditTrail.cpp5
-rw-r--r--src/gpu/GrGpuResource.cpp2
-rw-r--r--src/gpu/GrOpList.cpp2
-rw-r--r--src/gpu/GrOpList.h1
-rw-r--r--src/gpu/GrRenderTargetContextPriv.h8
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp4
-rw-r--r--src/gpu/GrSurfaceProxy.cpp2
-rw-r--r--src/gpu/batches/GrBatch.h4
-rw-r--r--src/gpu/batches/GrClearBatch.h9
-rw-r--r--src/gpu/batches/GrClearStencilClipBatch.h8
-rw-r--r--src/gpu/batches/GrCopySurfaceBatch.h8
-rw-r--r--src/gpu/batches/GrDiscardBatch.h7
-rw-r--r--src/gpu/batches/GrDrawBatch.h7
-rw-r--r--src/gpu/batches/GrStencilPathBatch.h5
-rw-r--r--src/gpu/effects/GrSingleTextureEffect.h2
-rw-r--r--src/gpu/gl/GrGLGpu.cpp32
-rw-r--r--src/gpu/gl/GrGLGpu.h88
-rw-r--r--src/gpu/gl/GrGLRenderTarget.cpp2
-rw-r--r--src/gpu/gl/GrGLTextureRenderTarget.cpp2
-rw-r--r--src/gpu/gl/GrGLVertexArray.cpp2
-rw-r--r--src/gpu/gl/GrGLVertexArray.h29
-rw-r--r--src/gpu/instanced/GLInstancedRendering.cpp4
-rw-r--r--src/gpu/instanced/GLInstancedRendering.h2
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.h24
24 files changed, 148 insertions, 111 deletions
diff --git a/src/gpu/GrAuditTrail.cpp b/src/gpu/GrAuditTrail.cpp
index ff6debd032..93694cbe10 100644
--- a/src/gpu/GrAuditTrail.cpp
+++ b/src/gpu/GrAuditTrail.cpp
@@ -45,9 +45,8 @@ void GrAuditTrail::addBatch(const GrBatch* batch) {
// We use the batch pointer as a key to find the batchnode we are 'glomming' batches onto
fIDLookup.set(batch->uniqueID(), auditBatch->fBatchListID);
- BatchNode* batchNode = new BatchNode;
+ BatchNode* batchNode = new BatchNode(batch->renderTargetUniqueID());
batchNode->fBounds = batch->bounds();
- batchNode->fRenderTargetUniqueID = batch->renderTargetUniqueID();
batchNode->fChildren.push_back(auditBatch);
fBatchList.emplace_back(batchNode);
}
@@ -290,7 +289,7 @@ SkString GrAuditTrail::Batch::toJson() const {
SkString GrAuditTrail::BatchNode::toJson() const {
SkString json;
json.append("{");
- json.appendf("\"RenderTarget\": \"%u\",", fRenderTargetUniqueID);
+ json.appendf("\"RenderTarget\": \"%u\",", fRenderTargetUniqueID.asUInt());
skrect_to_json(&json, "Bounds", fBounds);
JsonifyTArray(&json, "Batches", fChildren, true);
json.append("}");
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index c1578b50ab..c3a9556588 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -70,7 +70,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->uniqueID());
+ dumpName.appendU32(this->uniqueID().asUInt());
traceMemoryDump->dumpNumericValue(dumpName.c_str(), "size", "bytes", this->gpuMemorySize());
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
index baecbd64b9..d354e59405 100644
--- a/src/gpu/GrOpList.cpp
+++ b/src/gpu/GrOpList.cpp
@@ -62,7 +62,7 @@ void GrOpList::addDependency(GrSurface* dependedOn) {
#ifdef SK_DEBUG
void GrOpList::dump() const {
SkDebugf("--------------------------------------------------------------\n");
- SkDebugf("node: %d -> RT: %d\n", fDebugID, fTarget ? fTarget->uniqueID() : -1);
+ SkDebugf("node: %d -> RT: %d\n", fDebugID, fTarget ? fTarget->uniqueID().asUInt() : -1);
SkDebugf("relies On (%d): ", fDependencies.count());
for (int i = 0; i < fDependencies.count(); ++i) {
SkDebugf("%d, ", fDependencies[i]->fDebugID);
diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h
index 043556855b..9c965f8f0f 100644
--- a/src/gpu/GrOpList.h
+++ b/src/gpu/GrOpList.h
@@ -23,6 +23,7 @@ public:
GrOpList(GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail);
~GrOpList() override;
+ // These two methods are invoked as flush time
virtual void prepareBatches(GrBatchFlushState* flushState) = 0;
virtual bool drawBatches(GrBatchFlushState* flushState) = 0;
diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h
index 802cba0d3e..8d682ac9a0 100644
--- a/src/gpu/GrRenderTargetContextPriv.h
+++ b/src/gpu/GrRenderTargetContextPriv.h
@@ -82,6 +82,14 @@ public:
int maxWindowRectangles() const;
+ /*
+ * This unique ID will not change for a given RenderTargetContext. However, it is _NOT_
+ * guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
+ */
+ GrSurfaceProxy::UniqueID uniqueID() const {
+ return fRenderTargetContext->fRenderTargetProxy->uniqueID();
+ }
+
void testingOnly_drawBatch(const GrPaint&,
GrDrawBatch* batch,
const GrUserStencilSettings* = nullptr,
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index b4e6870585..72a29ab8cd 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -178,6 +178,9 @@ void GrRenderTargetOpList::prepareBatches(GrBatchFlushState* flushState) {
}
}
+// TODO: this is where GrBatch::renderTarget is used (which is fine since it
+// is at flush time). However, we need to store the RenderTargetProxy in the
+// Batches and instantiate them here.
bool GrRenderTargetOpList::drawBatches(GrBatchFlushState* flushState) {
if (0 == fRecordedBatches.count()) {
return false;
@@ -406,6 +409,7 @@ void GrRenderTargetOpList::fullClear(GrRenderTarget* renderTarget, GrColor color
// Currently this just inserts or updates the last clear batch. However, once in MDB this can
// remove all the previously recorded batches and change the load op to clear with supplied
// color.
+ // TODO: this needs to be updated to use GrSurfaceProxy::UniqueID
if (fLastFullClearBatch &&
fLastFullClearBatch->renderTargetUniqueID() == renderTarget->uniqueID()) {
// As currently implemented, fLastFullClearBatch should be the last batch because we would
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index da552c917e..831cd3213c 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -17,7 +17,7 @@ GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit)
, fDesc(fTarget->desc())
, fFit(fit)
, fBudgeted(fTarget->resourcePriv().isBudgeted())
- , fUniqueID(fTarget->uniqueID())
+ , fUniqueID(fTarget->uniqueID()) // Note: converting from unique resource ID to a proxy ID!
, fGpuMemorySize(kInvalidGpuMemorySize)
, fLastOpList(nullptr) {
}
diff --git a/src/gpu/batches/GrBatch.h b/src/gpu/batches/GrBatch.h
index bef01b77c4..ec81ec9bc0 100644
--- a/src/gpu/batches/GrBatch.h
+++ b/src/gpu/batches/GrBatch.h
@@ -9,6 +9,7 @@
#define GrBatch_DEFINED
#include "../private/SkAtomics.h"
+#include "GrGpuResource.h"
#include "GrNonAtomicRef.h"
#include "SkMatrix.h"
#include "SkRect.h"
@@ -129,7 +130,8 @@ public:
/** Used to block batching across render target changes. Remove this once we store
GrBatches for different RTs in different targets. */
- virtual uint32_t renderTargetUniqueID() const = 0;
+ // TODO: this needs to be updated to return GrSurfaceProxy::UniqueID
+ virtual GrGpuResource::UniqueID renderTargetUniqueID() const = 0;
/** Used for spewing information about batches when debugging. */
virtual SkString dumpInfo() const {
diff --git a/src/gpu/batches/GrClearBatch.h b/src/gpu/batches/GrClearBatch.h
index f11d485536..ef38e74af8 100644
--- a/src/gpu/batches/GrClearBatch.h
+++ b/src/gpu/batches/GrClearBatch.h
@@ -29,7 +29,11 @@ public:
const char* name() const override { return "Clear"; }
- uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->uniqueID(); }
+ // TODO: this needs to be updated to return GrSurfaceProxy::UniqueID
+ GrGpuResource::UniqueID renderTargetUniqueID() const override {
+ return fRenderTarget.get()->uniqueID();
+ }
+ // TODO: store a GrRenderTargetContext instead
GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
SkString dumpInfo() const override {
@@ -38,7 +42,8 @@ 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()->uniqueID());
+ string.appendf("], Color: 0x%08x, RT: %d", fColor,
+ fRenderTarget.get()->uniqueID().asUInt());
string.append(INHERITED::dumpInfo());
return string;
}
diff --git a/src/gpu/batches/GrClearStencilClipBatch.h b/src/gpu/batches/GrClearStencilClipBatch.h
index 42d7c444db..f1e5b50d95 100644
--- a/src/gpu/batches/GrClearStencilClipBatch.h
+++ b/src/gpu/batches/GrClearStencilClipBatch.h
@@ -31,7 +31,10 @@ public:
const char* name() const override { return "ClearStencilClip"; }
- uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->uniqueID(); }
+ // TODO: this needs to be updated to return GrSurfaceProxy::UniqueID
+ GrGpuResource::UniqueID renderTargetUniqueID() const override {
+ return fRenderTarget.get()->uniqueID();
+ }
GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
SkString dumpInfo() const override {
@@ -40,7 +43,8 @@ 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()->uniqueID());
+ string.appendf("], IC: %d, RT: %d", fInsideStencilMask,
+ fRenderTarget.get()->uniqueID().asUInt());
string.append(INHERITED::dumpInfo());
return string;
}
diff --git a/src/gpu/batches/GrCopySurfaceBatch.h b/src/gpu/batches/GrCopySurfaceBatch.h
index c987d0d5df..a014ccb147 100644
--- a/src/gpu/batches/GrCopySurfaceBatch.h
+++ b/src/gpu/batches/GrCopySurfaceBatch.h
@@ -32,10 +32,14 @@ public:
const char* name() const override { return "CopySurface"; }
- uint32_t renderTargetUniqueID() const override {
+ // TODO: this needs to be updated to return GrSurfaceProxy::UniqueID
+ GrGpuResource::UniqueID renderTargetUniqueID() const override {
+ // TODO: When we have CopyContexts it seems that this should return the ID
+ // of the SurfaceProxy underlying the CopyContext.
GrRenderTarget* rt = fDst.get()->asRenderTarget();
- return rt ? rt->uniqueID() : 0;
+ return rt ? rt->uniqueID() : GrGpuResource::UniqueID::InvalidID();
}
+ // TODO: this seems odd - figure it out and add a comment!
GrRenderTarget* renderTarget() const override { return nullptr; }
SkString dumpInfo() const override {
diff --git a/src/gpu/batches/GrDiscardBatch.h b/src/gpu/batches/GrDiscardBatch.h
index 8a3be0e5f3..54f41b9ef4 100644
--- a/src/gpu/batches/GrDiscardBatch.h
+++ b/src/gpu/batches/GrDiscardBatch.h
@@ -26,12 +26,15 @@ public:
const char* name() const override { return "Discard"; }
- uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->uniqueID(); }
+ // TODO: this needs to be updated to return GrSurfaceProxy::UniqueID
+ GrGpuResource::UniqueID 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()->uniqueID());
+ string.printf("RT: %d", fRenderTarget.get()->uniqueID().asUInt());
string.append(INHERITED::dumpInfo());
return string;
}
diff --git a/src/gpu/batches/GrDrawBatch.h b/src/gpu/batches/GrDrawBatch.h
index e675f5fc4d..a5c153e903 100644
--- a/src/gpu/batches/GrDrawBatch.h
+++ b/src/gpu/batches/GrDrawBatch.h
@@ -74,11 +74,14 @@ public:
// TODO no GrPrimitiveProcessors yet read fragment position
bool willReadFragmentPosition() const { return false; }
- uint32_t renderTargetUniqueID() const final {
+ // TODO: this needs to be updated to return GrSurfaceProxy::UniqueID
+ // This is a bit more exciting than the other call sites since it uses the pipeline
+ GrGpuResource::UniqueID renderTargetUniqueID() const final {
SkASSERT(fPipelineInstalled);
return this->pipeline()->getRenderTarget()->uniqueID();
}
+ // TODO: store a GrRenderTargetContext instead
GrRenderTarget* renderTarget() const final {
SkASSERT(fPipelineInstalled);
return this->pipeline()->getRenderTarget();
@@ -86,7 +89,7 @@ public:
SkString dumpInfo() const override {
SkString string;
- string.appendf("RT: %d\n", this->renderTargetUniqueID());
+ string.appendf("RT: %d\n", this->renderTargetUniqueID().asUInt());
string.append("ColorStages:\n");
for (int i = 0; i < this->pipeline()->numColorFragmentProcessors(); i++) {
string.appendf("\t\t%s\n\t\t%s\n",
diff --git a/src/gpu/batches/GrStencilPathBatch.h b/src/gpu/batches/GrStencilPathBatch.h
index 73bec195d0..3a6f82d8a1 100644
--- a/src/gpu/batches/GrStencilPathBatch.h
+++ b/src/gpu/batches/GrStencilPathBatch.h
@@ -33,7 +33,10 @@ public:
const char* name() const override { return "StencilPath"; }
- uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->uniqueID(); }
+ // TODO: this needs to be updated to return GrSurfaceProxy::UniqueID
+ GrGpuResource::UniqueID 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 7d110bf2ae..12b3a8f791 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()->uniqueID());
+ str.appendf("Texture: %d", fTextureAccess.getTexture()->uniqueID().asUInt());
return str;
}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 9ccd073fe7..0e777e970a 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -551,7 +551,7 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
if (resetBits & kTextureBinding_GrGLBackendState) {
for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) {
- fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID;
+ fHWBoundTextureUniqueIDs[s].makeInvalid();
}
for (int b = 0; b < fHWBufferTextures.count(); ++b) {
SkASSERT(this->caps()->shaderCaps()->texelBufferSupport());
@@ -582,7 +582,7 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
}
if (resetBits & kRenderTarget_GrGLBackendState) {
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
fHWSRGBFramebuffer = kUnknown_TriState;
}
@@ -1511,7 +1511,7 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
}
// below here we may bind the FBO
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
if (idDesc->fRTFBOID != idDesc->fTexFBOID) {
SkASSERT(desc.fSampleCnt > 0);
GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, idDesc->fMSColorRenderbufferID));
@@ -1783,7 +1783,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
GrGLuint fb = 0;
GL_CALL(GenFramebuffers(1, &fb));
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fb));
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_TEXTURE_2D,
@@ -2151,7 +2151,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->uniqueID();
+ GrGpuResource::UniqueID uniqueID = buffer->uniqueID();
for (int i = fHWMaxUsedBufferTextureUnit; i >= 0; --i) {
auto& buffTex = fHWBufferTextures[i];
if (uniqueID != buffTex.fAttachedBufferUniqueID) {
@@ -2324,7 +2324,7 @@ bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConf
}
GrGLIRect vp;
this->bindSurfaceFBOForPixelOps(temp.get(), GR_GL_FRAMEBUFFER, &vp, kDst_TempFBOTarget);
- fHWBoundRenderTargetUniqueID = 0;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
return true;
}
return false;
@@ -2543,7 +2543,7 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
} else {
// Use a temporary FBO.
this->bindSurfaceFBOForPixelOps(surface, GR_GL_FRAMEBUFFER, &glvp, kSrc_TempFBOTarget);
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
}
// the read rect is viewport-relative
@@ -2661,7 +2661,7 @@ void GrGLGpu::finishOpList() {
void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bounds, bool disableSRGB) {
SkASSERT(target);
- uint32_t rtID = target->uniqueID();
+ GrGpuResource::UniqueID rtID = target->uniqueID();
if (fHWBoundRenderTargetUniqueID != rtID) {
fStats.incRenderTargetBinds();
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID()));
@@ -2902,7 +2902,7 @@ void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) {
GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()));
// make sure we go through flushRenderTarget() since we've modified
// the bound DRAW FBO ID.
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
const GrGLIRect& vp = rt->getViewport();
const SkIRect dirtyRect = rt->getResolveRect();
@@ -3198,7 +3198,7 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool allow
this->onResolveRenderTarget(texRT);
}
- uint32_t textureID = texture->uniqueID();
+ GrGpuResource::UniqueID textureID = texture->uniqueID();
GrGLenum target = texture->target();
if (fHWBoundTextureUniqueIDs[unitIdx] != textureID) {
this->setTextureUnit(unitIdx);
@@ -3474,7 +3474,7 @@ void GrGLGpu::setScratchTextureUnit() {
}
// clear out the this field so that if a program does use this unit it will rebind the correct
// texture.
- fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID;
+ fHWBoundTextureUniqueIDs[lastUnitIdx].makeInvalid();
}
// Determines whether glBlitFramebuffer could be used between src and dst by onCopySurface.
@@ -4188,7 +4188,7 @@ bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst,
GrGLIRect dstVP;
this->bindSurfaceFBOForPixelOps(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarget);
this->flushViewport(dstVP);
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h);
@@ -4265,7 +4265,7 @@ void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst,
GrGLTexture* dstTex = static_cast<GrGLTexture *>(dst->asTexture());
SkASSERT(dstTex);
// We modified the bound FBO
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
GrGLIRect srcGLRect;
srcGLRect.setRelativeTo(srcVP,
srcRect.fLeft,
@@ -4310,7 +4310,7 @@ bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst,
this->bindSurfaceFBOForPixelOps(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP, kDst_TempFBOTarget);
this->bindSurfaceFBOForPixelOps(src, GR_GL_READ_FRAMEBUFFER, &srcVP, kSrc_TempFBOTarget);
// We modified the bound FBO
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
GrGLIRect srcGLRect;
GrGLIRect dstGLRect;
srcGLRect.setRelativeTo(srcVP,
@@ -4414,7 +4414,7 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, bool gammaCorrect) {
GL_CALL(GenFramebuffers(1, &fTempDstFBOID));
}
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fTempDstFBOID));
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
// Bind the texture, to get things configured for filtering.
// We'll be changing our base level further below:
@@ -4570,7 +4570,7 @@ GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in
GL_CALL(ActiveTexture(GR_GL_TEXTURE0));
GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, 1));
GL_CALL(BindTexture(info->fTarget, info->fID));
- fHWBoundTextureUniqueIDs[0] = 0;
+ fHWBoundTextureUniqueIDs[0].makeInvalid();
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST));
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST));
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_EDGE));
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 32ce979c96..d0ca40bc9f 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -125,7 +125,7 @@ public:
const GrGpuCommandBuffer::LoadAndStoreInfo& stencilInfo) override;
void invalidateBoundRenderTarget() {
- fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+ fHWBoundRenderTargetUniqueID.makeInvalid();
}
GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
@@ -517,28 +517,28 @@ private:
GrGLAttribArrayState* bindInternalVertexArray(GrGLGpu*, const GrBuffer* ibuff = nullptr);
private:
- GrGLuint fBoundVertexArrayID;
- bool fBoundVertexArrayIDIsValid;
+ GrGLuint fBoundVertexArrayID;
+ bool fBoundVertexArrayIDIsValid;
// We return a non-const pointer to this from bindArrayAndBuffersToDraw when vertex array 0
// is bound. However, this class is internal to GrGLGpu and this object never leaks out of
// GrGLGpu.
- GrGLAttribArrayState fDefaultVertexArrayAttribState;
+ GrGLAttribArrayState fDefaultVertexArrayAttribState;
// This is used when we're using a core profile.
- GrGLVertexArray* fCoreProfileVertexArray;
- } fHWVertexArrayState;
+ GrGLVertexArray* fCoreProfileVertexArray;
+ } fHWVertexArrayState;
struct {
- GrGLenum fGLTarget;
- uint32_t fBoundBufferUniqueID;
- bool fBufferZeroKnownBound;
+ GrGLenum fGLTarget;
+ GrGpuResource::UniqueID fBoundBufferUniqueID;
+ bool fBufferZeroKnownBound;
void invalidate() {
- fBoundBufferUniqueID = SK_InvalidUniqueID;
+ fBoundBufferUniqueID.makeInvalid();
fBufferZeroKnownBound = false;
}
- } fHWBufferState[kGrBufferTypeCount];
+ } fHWBufferState[kGrBufferTypeCount];
struct {
GrBlendEquation fEquation;
@@ -555,38 +555,38 @@ private:
fConstColorValid = false;
fEnabled = kUnknown_TriState;
}
- } fHWBlendState;
+ } fHWBlendState;
TriState fMSAAEnabled;
- GrStencilSettings fHWStencilSettings;
- TriState fHWStencilTestEnabled;
+ GrStencilSettings fHWStencilSettings;
+ TriState fHWStencilTestEnabled;
- GrDrawFace fHWDrawFace;
- TriState fHWWriteToColor;
- uint32_t fHWBoundRenderTargetUniqueID;
- TriState fHWSRGBFramebuffer;
- SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs;
+ GrDrawFace fHWDrawFace;
+ TriState fHWWriteToColor;
+ GrGpuResource::UniqueID fHWBoundRenderTargetUniqueID;
+ TriState fHWSRGBFramebuffer;
+ SkTArray<GrGpuResource::UniqueID, true> fHWBoundTextureUniqueIDs;
struct BufferTexture {
BufferTexture() : fTextureID(0), fKnownBound(false),
fAttachedBufferUniqueID(SK_InvalidUniqueID),
fSwizzle(GrSwizzle::RGBA()) {}
- GrGLuint fTextureID;
- bool fKnownBound;
- GrPixelConfig fTexelConfig;
- uint32_t fAttachedBufferUniqueID;
- GrSwizzle fSwizzle;
+ GrGLuint fTextureID;
+ bool fKnownBound;
+ GrPixelConfig fTexelConfig;
+ GrGpuResource::UniqueID fAttachedBufferUniqueID;
+ GrSwizzle fSwizzle;
};
- SkTArray<BufferTexture, true> fHWBufferTextures;
- int fHWMaxUsedBufferTextureUnit;
+ SkTArray<BufferTexture, true> fHWBufferTextures;
+ int fHWMaxUsedBufferTextureUnit;
// EXT_raster_multisample.
- TriState fHWRasterMultisampleEnabled;
- int fHWNumRasterSamples;
+ TriState fHWRasterMultisampleEnabled;
+ int fHWNumRasterSamples;
///@}
/** IDs for copy surface program. */
@@ -595,23 +595,23 @@ private:
GrGLint fTextureUniform;
GrGLint fTexCoordXformUniform;
GrGLint fPosXformUniform;
- } fCopyPrograms[3];
- sk_sp<GrGLBuffer> fCopyProgramArrayBuffer;
+ } fCopyPrograms[3];
+ sk_sp<GrGLBuffer> fCopyProgramArrayBuffer;
/** IDs for texture mipmap program. (4 filter configurations) */
struct {
GrGLuint fProgram;
GrGLint fTextureUniform;
GrGLint fTexCoordXformUniform;
- } fMipmapPrograms[4];
- sk_sp<GrGLBuffer> fMipmapProgramArrayBuffer;
+ } fMipmapPrograms[4];
+ sk_sp<GrGLBuffer> fMipmapProgramArrayBuffer;
struct {
- GrGLuint fProgram;
- GrGLint fColorUniform;
- GrGLint fRectUniform;
- } fWireRectProgram;
- sk_sp<GrGLBuffer> fWireRectArrayBuffer;
+ GrGLuint fProgram;
+ GrGLint fColorUniform;
+ GrGLint fRectUniform;
+ } fWireRectProgram;
+ sk_sp<GrGLBuffer> fWireRectArrayBuffer;
static int TextureTargetToCopyProgramIdx(GrGLenum target) {
switch (target) {
@@ -634,15 +634,15 @@ private:
}
struct {
- GrGLuint fProgram;
- GrGLint fPosXformUniform;
- sk_sp<GrGLBuffer> fArrayBuffer;
- } fPLSSetupProgram;
+ GrGLuint fProgram;
+ GrGLint fPosXformUniform;
+ sk_sp<GrGLBuffer> fArrayBuffer;
+ } fPLSSetupProgram;
- bool fHWPLSEnabled;
- bool fPLSHasBeenUsed;
+ bool fHWPLSEnabled;
+ bool fPLSHasBeenUsed;
- float fHWMinSampleShading;
+ float fHWMinSampleShading;
typedef GrGpu INHERITED;
friend class GrGLPathRendering; // For accessing setTextureUnit.
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index 5af5e67676..45efba2f17 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -188,7 +188,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->uniqueID());
+ dumpName.appendU32(this->uniqueID().asUInt());
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 9c350f89ae..0abeb8ea61 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->uniqueID());
+ dumpName.appendU32(this->uniqueID().asUInt());
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 04299d7854..e03101a564 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -129,5 +129,5 @@ GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const G
void GrGLVertexArray::invalidateCachedState() {
fAttribArrays.invalidate();
- fIndexBufferUniqueID = SK_InvalidUniqueID;
+ fIndexBufferUniqueID.makeInvalid();
}
diff --git a/src/gpu/gl/GrGLVertexArray.h b/src/gpu/gl/GrGLVertexArray.h
index 639892690f..4c77d2b582 100644
--- a/src/gpu/gl/GrGLVertexArray.h
+++ b/src/gpu/gl/GrGLVertexArray.h
@@ -8,6 +8,7 @@
#ifndef GrGLVertexArray_DEFINED
#define GrGLVertexArray_DEFINED
+#include "GrGpuResource.h"
#include "GrTypesPriv.h"
#include "gl/GrGLDefines.h"
#include "gl/GrGLTypes.h"
@@ -68,17 +69,17 @@ private:
* Tracks the state of glVertexAttribArray for an attribute index.
*/
struct AttribArrayState {
- void invalidate() {
- fEnableIsValid = false;
- fVertexBufferUniqueID = SK_InvalidUniqueID;
- }
-
- bool fEnableIsValid;
- bool fEnabled;
- uint32_t fVertexBufferUniqueID;
- GrVertexAttribType fType;
- GrGLsizei fStride;
- GrGLvoid* fOffset;
+ void invalidate() {
+ fEnableIsValid = false;
+ fVertexBufferUniqueID.makeInvalid();
+ }
+
+ bool fEnableIsValid;
+ bool fEnabled;
+ GrGpuResource::UniqueID fVertexBufferUniqueID;
+ GrVertexAttribType fType;
+ GrGLsizei fStride;
+ GrGLvoid* fOffset;
};
SkSTArray<16, AttribArrayState, true> fAttribArrayStates;
@@ -110,9 +111,9 @@ public:
void invalidateCachedState();
private:
- GrGLuint fID;
- GrGLAttribArrayState fAttribArrays;
- uint32_t fIndexBufferUniqueID;
+ GrGLuint fID;
+ GrGLAttribArrayState fAttribArrays;
+ GrGpuResource::UniqueID fIndexBufferUniqueID;
};
#endif
diff --git a/src/gpu/instanced/GLInstancedRendering.cpp b/src/gpu/instanced/GLInstancedRendering.cpp
index dabfe4e02d..7503204a1c 100644
--- a/src/gpu/instanced/GLInstancedRendering.cpp
+++ b/src/gpu/instanced/GLInstancedRendering.cpp
@@ -104,7 +104,7 @@ void GLInstancedRendering::onBeginFlush(GrResourceProvider* rp) {
GL_CALL(VertexAttribIPointer((int)Attrib::kVertexAttrs, 1, GR_GL_INT, sizeof(ShapeVertex),
(void*) offsetof(ShapeVertex, fAttrs)));
- SkASSERT(SK_InvalidUniqueID == fInstanceAttribsBufferUniqueId);
+ SkASSERT(fInstanceAttribsBufferUniqueId.isInvalid());
}
// Create and map instance and draw-indirect buffers.
@@ -318,7 +318,7 @@ void GLInstancedRendering::onResetGpuResources(ResetType resetType) {
fVertexArrayID = 0;
fInstanceBuffer.reset();
fDrawIndirectBuffer.reset();
- fInstanceAttribsBufferUniqueId = SK_InvalidUniqueID;
+ fInstanceAttribsBufferUniqueId.makeInvalid();
}
}
diff --git a/src/gpu/instanced/GLInstancedRendering.h b/src/gpu/instanced/GLInstancedRendering.h
index 9ac2bfef3b..c9f0d8f8bb 100644
--- a/src/gpu/instanced/GLInstancedRendering.h
+++ b/src/gpu/instanced/GLInstancedRendering.h
@@ -51,7 +51,7 @@ private:
sk_sp<GrBuffer> fInstanceBuffer;
sk_sp<GrBuffer> fDrawIndirectBuffer;
SkAutoSTMalloc<1024, GLDrawCmdInfo> fGLDrawCmdsInfo;
- uint32_t fInstanceAttribsBufferUniqueId;
+ GrGpuResource::UniqueID fInstanceAttribsBufferUniqueId;
int fInstanceAttribsBaseInstance;
class GLBatch;
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.h b/src/gpu/text/GrStencilAndCoverTextContext.h
index 3cf4374e3a..f4773ffa5b 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.h
+++ b/src/gpu/text/GrStencilAndCoverTextContext.h
@@ -97,18 +97,18 @@ private:
GrPathRange* createGlyphs(GrContext*) const;
void appendGlyph(const SkGlyph&, const SkPoint&, FallbackBlobBuilder*);
- GrStyle fStyle;
- SkPaint fFont;
- SkScalar fTextRatio;
- float fTextInverseRatio;
- bool fUsingRawGlyphPaths;
- GrUniqueKey fGlyphPathsKey;
- int fTotalGlyphCount;
- sk_sp<InstanceData> fInstanceData;
- int fFallbackGlyphCount;
- sk_sp<SkTextBlob> fFallbackTextBlob;
- mutable SkGlyphCache* fDetachedGlyphCache;
- mutable uint32_t fLastDrawnGlyphsID;
+ GrStyle fStyle;
+ SkPaint fFont;
+ SkScalar fTextRatio;
+ float fTextInverseRatio;
+ bool fUsingRawGlyphPaths;
+ GrUniqueKey fGlyphPathsKey;
+ int fTotalGlyphCount;
+ sk_sp<InstanceData> fInstanceData;
+ int fFallbackGlyphCount;
+ sk_sp<SkTextBlob> fFallbackTextBlob;
+ mutable SkGlyphCache* fDetachedGlyphCache;
+ mutable GrGpuResource::UniqueID fLastDrawnGlyphsID;
};
// Text blobs/caches.