Make GrResourceProvider more sk_spified
Change-Id: If191553093031705756358f4551a5b1e96439742
Reviewed-on: https://skia-review.googlesource.com/60000
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index d5fd311..42237a7 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -76,7 +76,7 @@
GrBufferType intendedType,
size_t size, const void* data) {
GrResourceProvider* rp = fDrawingMgr->getContext()->resourceProvider();
- sk_sp<GrBuffer> buffer(rp->findAndRefTByUniqueKey<GrBuffer>(key));
+ sk_sp<GrBuffer> buffer(rp->findByUniqueKey<GrBuffer>(key));
if (!buffer) {
buffer.reset(rp->createBuffer(size, intendedType, kStatic_GrAccessPattern, 0, data));
if (!buffer) {
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index e43c910..585a512 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -70,13 +70,13 @@
///////////////////////////////////////////////////////////////////////////////
-bool GrRenderTargetPriv::attachStencilAttachment(GrStencilAttachment* stencil) {
+bool GrRenderTargetPriv::attachStencilAttachment(sk_sp<GrStencilAttachment> stencil) {
if (!stencil && !fRenderTarget->fStencilAttachment) {
// No need to do any work since we currently don't have a stencil attachment and
// we're not actually adding one.
return true;
}
- fRenderTarget->fStencilAttachment = stencil;
+ fRenderTarget->fStencilAttachment = stencil.release();
if (!fRenderTarget->completeStencilAttachment()) {
SkSafeSetNull(fRenderTarget->fStencilAttachment);
return false;
diff --git a/src/gpu/GrRenderTargetPriv.h b/src/gpu/GrRenderTargetPriv.h
index 271dd44..e228518 100644
--- a/src/gpu/GrRenderTargetPriv.h
+++ b/src/gpu/GrRenderTargetPriv.h
@@ -28,7 +28,7 @@
* currently attached GrStencilAttachment will be removed if one was previously attached. This
* function returns false if there were any failure in attaching the GrStencilAttachment.
*/
- bool attachStencilAttachment(GrStencilAttachment* stencil);
+ bool attachStencilAttachment(sk_sp<GrStencilAttachment> stencil);
int numStencilBits() const;
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index d68a5e6..5139ee3 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -284,20 +284,10 @@
fCache->processInvalidProxyUniqueKey(key, proxy, true);
}
-GrGpuResource* GrResourceProvider::findAndRefResourceByUniqueKey(const GrUniqueKey& key) {
+sk_sp<GrGpuResource> GrResourceProvider::findResourceByUniqueKey(const GrUniqueKey& key) {
ASSERT_SINGLE_OWNER
- return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key);
-}
-
-GrTexture* GrResourceProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& key) {
- ASSERT_SINGLE_OWNER
- GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key);
- if (resource) {
- GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture();
- SkASSERT(texture);
- return texture;
- }
- return nullptr;
+ return this->isAbandoned() ? nullptr
+ : sk_sp<GrGpuResource>(fCache->findAndRefUniqueResource(key));
}
void GrResourceProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
@@ -322,11 +312,11 @@
return this->isAbandoned() ? nullptr : fCache->findOrCreateProxyByUniqueKey(key, origin);
}
-const GrBuffer* GrResourceProvider::createPatternedIndexBuffer(const uint16_t* pattern,
- int patternSize,
- int reps,
- int vertCount,
- const GrUniqueKey& key) {
+sk_sp<const GrBuffer> GrResourceProvider::createPatternedIndexBuffer(const uint16_t* pattern,
+ int patternSize,
+ int reps,
+ int vertCount,
+ const GrUniqueKey& key) {
size_t bufferSize = patternSize * reps * sizeof(uint16_t);
// This is typically used in GrMeshDrawOps, so we assume kNoPendingIO.
@@ -356,15 +346,14 @@
buffer->unmap();
}
this->assignUniqueKeyToResource(key, buffer.get());
- return buffer.release();
+ return std::move(buffer);
}
static constexpr int kMaxQuads = 1 << 12; // max possible: (1 << 14) - 1;
-const GrBuffer* GrResourceProvider::createQuadIndexBuffer() {
+sk_sp<const GrBuffer> GrResourceProvider::createQuadIndexBuffer() {
GR_STATIC_ASSERT(4 * kMaxQuads <= 65535);
static const uint16_t kPattern[] = { 0, 1, 2, 0, 2, 3 };
-
return this->createPatternedIndexBuffer(kPattern, 6, kMaxQuads, 4, fQuadIndexBufferKey);
}
@@ -461,24 +450,23 @@
SkDEBUGCODE(bool newStencil = false;)
GrStencilAttachment::ComputeSharedStencilAttachmentKey(width, height,
rt->numStencilSamples(), &sbKey);
- GrStencilAttachment* stencil = static_cast<GrStencilAttachment*>(
- this->findAndRefResourceByUniqueKey(sbKey));
+ auto stencil = this->findByUniqueKey<GrStencilAttachment>(sbKey);
if (!stencil) {
// Need to try and create a new stencil
- stencil = this->gpu()->createStencilAttachmentForRenderTarget(rt, width, height);
+ stencil.reset(this->gpu()->createStencilAttachmentForRenderTarget(rt, width, height));
if (stencil) {
- this->assignUniqueKeyToResource(sbKey, stencil);
+ this->assignUniqueKeyToResource(sbKey, stencil.get());
SkDEBUGCODE(newStencil = true;)
}
}
- if (rt->renderTargetPriv().attachStencilAttachment(stencil)) {
+ if (rt->renderTargetPriv().attachStencilAttachment(std::move(stencil))) {
#ifdef SK_DEBUG
// Fill the SB with an inappropriate value. opLists that use the
// SB should clear it properly.
if (newStencil) {
- SkASSERT(stencil->isDirty());
+ SkASSERT(rt->renderTargetPriv().getStencilAttachment()->isDirty());
this->gpu()->clearStencil(rt, 0xFFFF);
- SkASSERT(stencil->isDirty());
+ SkASSERT(rt->renderTargetPriv().getStencilAttachment()->isDirty());
}
#endif
}
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 7729e80..9bc4fae 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -41,8 +41,14 @@
public:
GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* owner);
- template <typename T> T* findAndRefTByUniqueKey(const GrUniqueKey& key) {
- return static_cast<T*>(this->findAndRefResourceByUniqueKey(key));
+ /**
+ * Finds a resource in the cache, based on the specified key. Prior to calling this, the caller
+ * must be sure that if a resource of exists in the cache with the given unique key then it is
+ * of type T.
+ */
+ template <typename T>
+ sk_sp<T> findByUniqueKey(const GrUniqueKey& key) {
+ return sk_sp<T>(static_cast<T*>(this->findResourceByUniqueKey(key).release()));
}
/*
@@ -138,12 +144,12 @@
*
* @return The index buffer if successful, otherwise nullptr.
*/
- const GrBuffer* findOrCreatePatternedIndexBuffer(const uint16_t* pattern,
- int patternSize,
- int reps,
- int vertCount,
- const GrUniqueKey& key) {
- if (GrBuffer* buffer = this->findAndRefTByUniqueKey<GrBuffer>(key)) {
+ sk_sp<const GrBuffer> findOrCreatePatternedIndexBuffer(const uint16_t* pattern,
+ int patternSize,
+ int reps,
+ int vertCount,
+ const GrUniqueKey& key) {
+ if (auto buffer = this->findByUniqueKey<GrBuffer>(key)) {
return buffer;
}
return this->createPatternedIndexBuffer(pattern, patternSize, reps, vertCount, key);
@@ -156,9 +162,8 @@
* Draw with GrPrimitiveType::kTriangles
* @ return the quad index buffer
*/
- const GrBuffer* refQuadIndexBuffer() {
- if (GrBuffer* buffer =
- this->findAndRefTByUniqueKey<GrBuffer>(fQuadIndexBufferKey)) {
+ sk_sp<const GrBuffer> refQuadIndexBuffer() {
+ if (auto buffer = this->findByUniqueKey<const GrBuffer>(fQuadIndexBufferKey)) {
return buffer;
}
return this->createQuadIndexBuffer();
@@ -230,13 +235,6 @@
*/
void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*);
- /**
- * Finds a resource in the cache, based on the specified key. This is intended for use in
- * conjunction with addResourceToCache(). The return value will be NULL if not found. The
- * caller must balance with a call to unref().
- */
- GrGpuResource* findAndRefResourceByUniqueKey(const GrUniqueKey&);
-
sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore(bool isOwned = true);
sk_sp<GrSemaphore> wrapBackendSemaphore(const GrBackendSemaphore&,
@@ -263,7 +261,7 @@
const GrCaps* caps() const { return fCaps.get(); }
private:
- GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key);
+ sk_sp<GrGpuResource> findResourceByUniqueKey(const GrUniqueKey&);
// Attempts to find a resource in the cache that exactly matches the GrSurfaceDesc. Failing that
// it returns null. If non-null, the resulting texture is always budgeted.
@@ -286,13 +284,13 @@
return !SkToBool(fCache);
}
- const GrBuffer* createPatternedIndexBuffer(const uint16_t* pattern,
- int patternSize,
- int reps,
- int vertCount,
- const GrUniqueKey& key);
+ sk_sp<const GrBuffer> createPatternedIndexBuffer(const uint16_t* pattern,
+ int patternSize,
+ int reps,
+ int vertCount,
+ const GrUniqueKey& key);
- const GrBuffer* createQuadIndexBuffer();
+ sk_sp<const GrBuffer> createQuadIndexBuffer();
GrResourceCache* fCache;
GrGpu* fGpu;
diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp
index 48f9f3b..fe45775 100644
--- a/src/gpu/ops/GrAAFillRectOp.cpp
+++ b/src/gpu/ops/GrAAFillRectOp.cpp
@@ -32,7 +32,7 @@
static const int kVertsPerAAFillRect = 8;
static const int kIndicesPerAAFillRect = 30;
-const GrBuffer* get_index_buffer(GrResourceProvider* resourceProvider) {
+static sk_sp<const GrBuffer> get_index_buffer(GrResourceProvider* resourceProvider) {
GR_DEFINE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
// clang-format off
@@ -251,7 +251,7 @@
size_t vertexStride = gp->getVertexStride();
- sk_sp<const GrBuffer> indexBuffer(get_index_buffer(target->resourceProvider()));
+ sk_sp<const GrBuffer> indexBuffer = get_index_buffer(target->resourceProvider());
PatternHelper helper(GrPrimitiveType::kTriangles);
void* vertices =
helper.init(target, vertexStride, indexBuffer.get(), kVertsPerAAFillRect,
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index 406be67..724f823 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -62,7 +62,7 @@
static const int kQuadsNumInIdxBuffer = 256;
GR_DECLARE_STATIC_UNIQUE_KEY(gQuadsIndexBufferKey);
-static const GrBuffer* ref_quads_index_buffer(GrResourceProvider* resourceProvider) {
+static sk_sp<const GrBuffer> get_quads_index_buffer(GrResourceProvider* resourceProvider) {
GR_DEFINE_STATIC_UNIQUE_KEY(gQuadsIndexBufferKey);
return resourceProvider->findOrCreatePatternedIndexBuffer(
kQuadIdxBufPattern, kIdxsPerQuad, kQuadsNumInIdxBuffer, kQuadNumVertices,
@@ -96,7 +96,7 @@
GR_DECLARE_STATIC_UNIQUE_KEY(gLinesIndexBufferKey);
-static const GrBuffer* ref_lines_index_buffer(GrResourceProvider* resourceProvider) {
+static sk_sp<const GrBuffer> get_lines_index_buffer(GrResourceProvider* resourceProvider) {
GR_DEFINE_STATIC_UNIQUE_KEY(gLinesIndexBufferKey);
return resourceProvider->findOrCreatePatternedIndexBuffer(
kLineSegIdxBufPattern, kIdxsPerLineSeg, kLineSegsNumInIdxBuffer, kLineSegNumVertices,
@@ -945,8 +945,7 @@
*geometryProcessorViewM);
}
- sk_sp<const GrBuffer> linesIndexBuffer(
- ref_lines_index_buffer(target->resourceProvider()));
+ sk_sp<const GrBuffer> linesIndexBuffer = get_lines_index_buffer(target->resourceProvider());
const GrBuffer* vertexBuffer;
int firstVertex;
@@ -994,8 +993,7 @@
const GrBuffer* vertexBuffer;
int firstVertex;
- sk_sp<const GrBuffer> quadsIndexBuffer(
- ref_quads_index_buffer(target->resourceProvider()));
+ sk_sp<const GrBuffer> quadsIndexBuffer = get_quads_index_buffer(target->resourceProvider());
size_t vertexStride = sizeof(BezierVertex);
int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * conicCount;
diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp
index d4f9bde..ad2367c 100644
--- a/src/gpu/ops/GrAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrAAStrokeRectOp.cpp
@@ -213,7 +213,7 @@
static const int kBevelVertexCnt = 24;
static const int kNumBevelRectsInIndexBuffer = 256;
- static const GrBuffer* GetIndexBuffer(GrResourceProvider* resourceProvider, bool miterStroke);
+ static sk_sp<const GrBuffer> GetIndexBuffer(GrResourceProvider*, bool miterStroke);
const SkMatrix& viewMatrix() const { return fViewMatrix; }
bool miterStroke() const { return fMiterStroke; }
@@ -272,8 +272,7 @@
int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexCnt;
int instanceCount = fRects.count();
- const sk_sp<const GrBuffer> indexBuffer(
- GetIndexBuffer(target->resourceProvider(), this->miterStroke()));
+ sk_sp<const GrBuffer> indexBuffer = GetIndexBuffer(target->resourceProvider(), this->miterStroke());
PatternHelper helper(GrPrimitiveType::kTriangles);
void* vertices =
helper.init(target, vertexStride, indexBuffer.get(),
@@ -301,8 +300,8 @@
helper.recordDraw(target, gp.get(), fHelper.makePipeline(target));
}
-const GrBuffer* AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* resourceProvider,
- bool miterStroke) {
+sk_sp<const GrBuffer> AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* resourceProvider,
+ bool miterStroke) {
if (miterStroke) {
// clang-format off
static const uint16_t gMiterIndices[] = {
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index 1166fd8..1c67fe7 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -117,7 +117,7 @@
void* vertices = target->makeVertexSpace(
vertexStride, glyphCount * kVerticesPerGlyph, &vertexBuffer, &flushInfo.fVertexOffset);
flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
- flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer());
+ flushInfo.fIndexBuffer = target->resourceProvider()->refQuadIndexBuffer();
if (!vertices || !flushInfo.fVertexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index a5473ce..1f98433 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -106,7 +106,7 @@
return;
}
- sk_sp<const GrBuffer> indexBuffer(target->resourceProvider()->refQuadIndexBuffer());
+ sk_sp<const GrBuffer> indexBuffer = target->resourceProvider()->refQuadIndexBuffer();
PatternHelper helper(GrPrimitiveType::kTriangles);
void* vertices = helper.init(target, vertexStride, indexBuffer.get(), kVertsPerRect,
kIndicesPerRect, numRects);
diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp
index 026781a..9174d8b 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -50,7 +50,7 @@
}
void* GrMeshDrawOp::QuadHelper::init(Target* target, size_t vertexStride, int quadsToDraw) {
- sk_sp<const GrBuffer> quadIndexBuffer(target->resourceProvider()->refQuadIndexBuffer());
+ sk_sp<const GrBuffer> quadIndexBuffer = target->resourceProvider()->refQuadIndexBuffer();
if (!quadIndexBuffer) {
SkDebugf("Could not get quad index buffer.");
return nullptr;
diff --git a/src/gpu/ops/GrNonAAFillRectOp.cpp b/src/gpu/ops/GrNonAAFillRectOp.cpp
index 6eaef69..e0a4b21 100644
--- a/src/gpu/ops/GrNonAAFillRectOp.cpp
+++ b/src/gpu/ops/GrNonAAFillRectOp.cpp
@@ -182,7 +182,7 @@
size_t vertexStride = gp->getVertexStride();
int rectCount = fRects.count();
- sk_sp<const GrBuffer> indexBuffer(target->resourceProvider()->refQuadIndexBuffer());
+ sk_sp<const GrBuffer> indexBuffer = target->resourceProvider()->refQuadIndexBuffer();
PatternHelper helper(GrPrimitiveType::kTriangles);
void* vertices = helper.init(target, vertexStride, indexBuffer.get(), kVertsPerRect,
kIndicesPerRect, rectCount);
@@ -310,7 +310,7 @@
size_t vertexStride = gp->getVertexStride();
int rectCount = fRects.count();
- sk_sp<const GrBuffer> indexBuffer(target->resourceProvider()->refQuadIndexBuffer());
+ sk_sp<const GrBuffer> indexBuffer = target->resourceProvider()->refQuadIndexBuffer();
PatternHelper helper(GrPrimitiveType::kTriangles);
void* vertices = helper.init(target, vertexStride, indexBuffer.get(), kVertsPerRect,
kIndicesPerRect, rectCount);
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index da4668f..e55651e 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -2063,8 +2063,8 @@
GR_DECLARE_STATIC_UNIQUE_KEY(gStrokeRRectOnlyIndexBufferKey);
GR_DECLARE_STATIC_UNIQUE_KEY(gRRectOnlyIndexBufferKey);
-static const GrBuffer* ref_rrect_index_buffer(RRectType type,
- GrResourceProvider* resourceProvider) {
+static sk_sp<const GrBuffer> get_rrect_index_buffer(RRectType type,
+ GrResourceProvider* resourceProvider) {
GR_DEFINE_STATIC_UNIQUE_KEY(gStrokeRRectOnlyIndexBufferKey);
GR_DEFINE_STATIC_UNIQUE_KEY(gRRectOnlyIndexBufferKey);
switch (type) {
@@ -2203,8 +2203,8 @@
// drop out the middle quad if we're stroked
int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPerFillRRect;
- sk_sp<const GrBuffer> indexBuffer(ref_rrect_index_buffer(
- fStroked ? kStroke_RRectType : kFill_RRectType, target->resourceProvider()));
+ sk_sp<const GrBuffer> indexBuffer = get_rrect_index_buffer(
+ fStroked ? kStroke_RRectType : kFill_RRectType, target->resourceProvider());
PatternHelper helper(GrPrimitiveType::kTriangles);
EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(
diff --git a/src/gpu/ops/GrRegionOp.cpp b/src/gpu/ops/GrRegionOp.cpp
index 177a185..1bfed80 100644
--- a/src/gpu/ops/GrRegionOp.cpp
+++ b/src/gpu/ops/GrRegionOp.cpp
@@ -123,7 +123,7 @@
return;
}
size_t vertexStride = gp->getVertexStride();
- sk_sp<const GrBuffer> indexBuffer(target->resourceProvider()->refQuadIndexBuffer());
+ sk_sp<const GrBuffer> indexBuffer = target->resourceProvider()->refQuadIndexBuffer();
PatternHelper helper(GrPrimitiveType::kTriangles);
void* vertices =
helper.init(target, vertexStride, indexBuffer.get(), kVertsPerInstance,
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp
index 27eaf15..6d1959f 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -276,7 +276,7 @@
&vertexBuffer,
&flushInfo.fVertexOffset);
flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
- flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer());
+ flushInfo.fIndexBuffer = target->resourceProvider()->refQuadIndexBuffer();
if (!vertices || !flushInfo.fIndexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
diff --git a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
index 3179eba..20c02c8 100644
--- a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
@@ -49,14 +49,13 @@
return CanDrawPath::kYes;
}
-static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const GrShape& shape) {
+static sk_sp<GrPath> get_gr_path(GrResourceProvider* resourceProvider, const GrShape& shape) {
GrUniqueKey key;
bool isVolatile;
GrPath::ComputeKey(shape, &key, &isVolatile);
sk_sp<GrPath> path;
if (!isVolatile) {
- path.reset(
- static_cast<GrPath*>(resourceProvider->findAndRefResourceByUniqueKey(key)));
+ path = resourceProvider->findByUniqueKey<GrPath>(key);
}
if (!path) {
SkPath skPath;
@@ -72,7 +71,7 @@
SkASSERT(path->isEqualTo(skPath, shape.style()));
#endif
}
- return path.release();
+ return path;
}
void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp
index 13e4af5..8602d00 100644
--- a/src/gpu/ops/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp
@@ -250,7 +250,7 @@
memset(&builder[shapeKeyDataCnt], 0, sizeof(fDevClipBounds));
}
builder.finish();
- sk_sp<GrBuffer> cachedVertexBuffer(rp->findAndRefTByUniqueKey<GrBuffer>(key));
+ sk_sp<GrBuffer> cachedVertexBuffer(rp->findByUniqueKey<GrBuffer>(key));
int actualCount;
SkScalar tol = GrPathUtils::kDefaultTolerance;
tol = GrPathUtils::scaleToleranceToSrc(tol, fViewMatrix, fShape.bounds());
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 3606a01..133c2fd 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -346,7 +346,7 @@
}
sk_sp<const GrBuffer> ibuffer;
if (fDraws.count() > 1) {
- ibuffer.reset(target->resourceProvider()->refQuadIndexBuffer());
+ ibuffer = target->resourceProvider()->refQuadIndexBuffer();
if (!ibuffer) {
SkDebugf("Could not allocate quad indices\n");
return;
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index 7d04a14..7c1fab0 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -528,10 +528,8 @@
sk_sp<GrPathRange> GrStencilAndCoverTextContext::TextRun::createGlyphs(
GrResourceProvider* resourceProvider) const {
- sk_sp<GrPathRange> glyphs;
-
- glyphs.reset(static_cast<GrPathRange*>(
- resourceProvider->findAndRefResourceByUniqueKey(fGlyphPathsKey)));
+ sk_sp<GrPathRange> glyphs =
+ resourceProvider->findByUniqueKey<GrPathRange>(fGlyphPathsKey);
if (!glyphs) {
if (fUsingRawGlyphPaths) {
SkScalerContextEffects noeffects;
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index c2b1f2d..ed6f6f5 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -362,9 +362,8 @@
sk_sp<const GrBuffer> DrawMeshHelper::getIndexBuffer() {
GR_DEFINE_STATIC_UNIQUE_KEY(gIndexBufferKey);
- return sk_sp<const GrBuffer>(
- fState->resourceProvider()->findOrCreatePatternedIndexBuffer(
- kIndexPattern, 6, kIndexPatternRepeatCount, 4, gIndexBufferKey));
+ return fState->resourceProvider()->findOrCreatePatternedIndexBuffer(
+ kIndexPattern, 6, kIndexPatternRepeatCount, 4, gIndexBufferKey);
}
void DrawMeshHelper::drawMesh(const GrMesh& mesh) {