aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrOnFlushResourceProvider.cpp2
-rw-r--r--src/gpu/GrRenderTarget.cpp4
-rw-r--r--src/gpu/GrRenderTargetPriv.h2
-rw-r--r--src/gpu/GrResourceProvider.cpp44
-rw-r--r--src/gpu/GrResourceProvider.h48
-rw-r--r--src/gpu/ops/GrAAFillRectOp.cpp4
-rw-r--r--src/gpu/ops/GrAAHairLinePathRenderer.cpp10
-rw-r--r--src/gpu/ops/GrAAStrokeRectOp.cpp9
-rw-r--r--src/gpu/ops/GrAtlasTextOp.cpp2
-rw-r--r--src/gpu/ops/GrLatticeOp.cpp2
-rw-r--r--src/gpu/ops/GrMeshDrawOp.cpp2
-rw-r--r--src/gpu/ops/GrNonAAFillRectOp.cpp4
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp8
-rw-r--r--src/gpu/ops/GrRegionOp.cpp2
-rw-r--r--src/gpu/ops/GrSmallPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrStencilAndCoverPathRenderer.cpp7
-rw-r--r--src/gpu/ops/GrTessellatingPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrTextureOp.cpp2
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.cpp6
19 files changed, 71 insertions, 91 deletions
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index d5fd3110ca..42237a7eda 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -76,7 +76,7 @@ sk_sp<GrBuffer> GrOnFlushResourceProvider::findOrMakeStaticBuffer(const GrUnique
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 e43c910fd0..585a5126a9 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -70,13 +70,13 @@ void GrRenderTarget::onAbandon() {
///////////////////////////////////////////////////////////////////////////////
-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 271dd44dd7..e2285185a8 100644
--- a/src/gpu/GrRenderTargetPriv.h
+++ b/src/gpu/GrRenderTargetPriv.h
@@ -28,7 +28,7 @@ public:
* 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 d68a5e6701..5139ee3adf 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -284,20 +284,10 @@ void GrResourceProvider::removeUniqueKeyFromProxy(const GrUniqueKey& key, GrText
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 @@ sk_sp<GrTextureProxy> GrResourceProvider::findOrCreateProxyByUniqueKey(const GrU
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 @@ const GrBuffer* GrResourceProvider::createPatternedIndexBuffer(const uint16_t* p
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 @@ bool GrResourceProvider::attachStencilAttachment(GrRenderTarget* rt) {
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 7729e80a79..9bc4fae571 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -41,8 +41,14 @@ class GrResourceProvider {
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 @@ public:
*
* @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 @@ public:
* 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 @@ public:
*/
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 @@ public:
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 @@ private:
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 48f9f3bc58..fe45775ecf 100644
--- a/src/gpu/ops/GrAAFillRectOp.cpp
+++ b/src/gpu/ops/GrAAFillRectOp.cpp
@@ -32,7 +32,7 @@ static const int kNumAAFillRectsInIndexBuffer = 256;
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 @@ private:
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 406be677ea..724f82377d 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -62,7 +62,7 @@ static const int kQuadNumVertices = 5;
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 @@ static const int kLineSegsNumInIdxBuffer = 256;
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 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
*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 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
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 d4f9bdea41..ad2367c0eb 100644
--- a/src/gpu/ops/GrAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrAAStrokeRectOp.cpp
@@ -213,7 +213,7 @@ private:
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 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) {
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 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) {
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 1166fd83e3..1c67fe7db9 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -117,7 +117,7 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
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 a5473ceab7..1f98433199 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -106,7 +106,7 @@ private:
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 026781a972..9174d8b208 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -50,7 +50,7 @@ void GrMeshDrawOp::PatternHelper::recordDraw(Target* target, const GrGeometryPro
}
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 6eaef696cb..e0a4b219bc 100644
--- a/src/gpu/ops/GrNonAAFillRectOp.cpp
+++ b/src/gpu/ops/GrNonAAFillRectOp.cpp
@@ -182,7 +182,7 @@ private:
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 @@ private:
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 da4668fd4d..e55651ebc0 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -2063,8 +2063,8 @@ static const int kNumRRectsInIndexBuffer = 256;
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 @@ private:
// 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 177a18577a..1bfed8083f 100644
--- a/src/gpu/ops/GrRegionOp.cpp
+++ b/src/gpu/ops/GrRegionOp.cpp
@@ -123,7 +123,7 @@ private:
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 27eaf1523d..6d1959f1d5 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -276,7 +276,7 @@ private:
&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 3179ebacc8..20c02c8f97 100644
--- a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
@@ -49,14 +49,13 @@ GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const
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 @@ static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const GrShape&
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 13e4af5015..8602d008b2 100644
--- a/src/gpu/ops/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp
@@ -250,7 +250,7 @@ private:
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 3606a01096..133c2fdb7e 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -346,7 +346,7 @@ private:
}
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 7d04a14197..7c1fab0c39 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -528,10 +528,8 @@ void GrStencilAndCoverTextContext::TextRun::setPosText(const char text[], size_t
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;