aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrGpu.cpp6
-rw-r--r--src/gpu/GrGpu.h17
-rw-r--r--src/gpu/GrPathRendering.cpp8
-rw-r--r--src/gpu/GrPathRendering.h15
-rw-r--r--src/gpu/GrResourceProvider.cpp26
-rw-r--r--src/gpu/GrResourceProvider.h15
-rw-r--r--src/gpu/GrSurfaceProxy.cpp4
-rw-r--r--src/gpu/gl/GrGLGpu.cpp25
-rw-r--r--src/gpu/gl/GrGLGpu.h4
-rw-r--r--src/gpu/gl/GrGLPathRendering.cpp10
-rw-r--r--src/gpu/gl/GrGLPathRendering.h6
-rw-r--r--src/gpu/ops/GrStencilAndCoverPathRenderer.cpp2
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.cpp12
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.h2
-rw-r--r--src/gpu/vk/GrVkGpu.cpp10
-rw-r--r--src/gpu/vk/GrVkGpu.h4
-rw-r--r--src/gpu/vk/GrVkTexture.cpp8
-rw-r--r--src/gpu/vk/GrVkTexture.h4
-rw-r--r--src/gpu/vk/GrVkTextureRenderTarget.cpp50
-rw-r--r--src/gpu/vk/GrVkTextureRenderTarget.h16
-rw-r--r--tests/ProxyTest.cpp4
-rw-r--r--tools/gpu/GrTest.cpp4
22 files changed, 129 insertions, 123 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 12a2d92281..e9f4f93b19 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -126,8 +126,8 @@ static bool check_texture_creation_params(const GrCaps& caps, const GrSurfaceDes
return true;
}
-GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budgeted,
- const SkTArray<GrMipLevel>& texels) {
+sk_sp<GrTexture> GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>& texels) {
GrSurfaceDesc desc = origDesc;
const GrCaps* caps = this->caps();
@@ -148,7 +148,7 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget
}
this->handleDirtyContext();
- GrTexture* tex = this->onCreateTexture(desc, budgeted, texels);
+ sk_sp<GrTexture> tex = this->onCreateTexture(desc, budgeted, texels);
if (tex) {
if (!caps->reuseScratchTextures() && !isRT) {
tex->resourcePriv().removeScratchKey();
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 897f2b8737..dd63839db5 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -105,19 +105,20 @@ public:
* uninitialized.
* @return The texture object if successful, otherwise nullptr.
*/
- GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
- const SkTArray<GrMipLevel>& texels);
+ sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>& texels);
/**
* Simplified createTexture() interface for when there is no initial texel data to upload.
*/
- GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted) {
+ sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted) {
return this->createTexture(desc, budgeted, SkTArray<GrMipLevel>());
}
/** Simplified createTexture() interface for when there is only a base level */
- GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* level0Data,
- size_t rowBytes) {
+ sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ const void* level0Data,
+ size_t rowBytes) {
SkASSERT(level0Data);
GrMipLevel level = { level0Data, rowBytes };
SkSTArray<1, GrMipLevel> array;
@@ -546,9 +547,9 @@ private:
// overridden by backend-specific derived class to create objects.
// Texture size and sample size will have already been validated in base class before
// onCreateTexture is called.
- virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc,
- SkBudgeted budgeted,
- const SkTArray<GrMipLevel>& texels) = 0;
+ virtual sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc& desc,
+ SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>& texels) = 0;
virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
GrSurfaceOrigin,
diff --git a/src/gpu/GrPathRendering.cpp b/src/gpu/GrPathRendering.cpp
index 18d000a177..ad60726cd4 100644
--- a/src/gpu/GrPathRendering.cpp
+++ b/src/gpu/GrPathRendering.cpp
@@ -70,10 +70,10 @@ private:
#endif
};
-GrPathRange* GrPathRendering::createGlyphs(const SkTypeface* typeface,
- const SkScalerContextEffects& effects,
- const SkDescriptor* desc,
- const GrStyle& style) {
+sk_sp<GrPathRange> GrPathRendering::createGlyphs(const SkTypeface* typeface,
+ const SkScalerContextEffects& effects,
+ const SkDescriptor* desc,
+ const GrStyle& style) {
if (nullptr == typeface) {
typeface = SkTypeface::GetDefaultTypeface();
SkASSERT(nullptr != typeface);
diff --git a/src/gpu/GrPathRendering.h b/src/gpu/GrPathRendering.h
index f2c02d9e81..23c731f951 100644
--- a/src/gpu/GrPathRendering.h
+++ b/src/gpu/GrPathRendering.h
@@ -81,30 +81,27 @@ public:
/**
* Creates a new gpu path, based on the specified path and stroke and returns it.
- * The caller owns a ref on the returned path which must be balanced by a call to unref.
*
* @param SkPath the geometry.
* @param GrStyle the style applied to the path. Styles with non-dash path effects are not
* allowed.
* @return a new GPU path object.
*/
- virtual GrPath* createPath(const SkPath&, const GrStyle&) = 0;
+ virtual sk_sp<GrPath> createPath(const SkPath&, const GrStyle&) = 0;
/**
- * Creates a range of gpu paths with a common style. The caller owns a ref on the
- * returned path range which must be balanced by a call to unref.
+ * Creates a range of gpu paths with a common style.
*
* @param PathGenerator class that generates SkPath objects for each path in the range.
* @param GrStyle the common style applied to each path in the range. Styles with non-dash
* path effects are not allowed.
* @return a new path range.
*/
- virtual GrPathRange* createPathRange(GrPathRange::PathGenerator*, const GrStyle&) = 0;
+ virtual sk_sp<GrPathRange> createPathRange(GrPathRange::PathGenerator*, const GrStyle&) = 0;
/**
* Creates a range of glyph paths, indexed by glyph id. The glyphs will have an
- * inverted y-direction in order to match the raw font path data. The caller owns
- * a ref on the returned path range which must be balanced by a call to unref.
+ * inverted y-direction in order to match the raw font path data.
*
* @param SkTypeface Typeface that defines the glyphs.
* If null, the default typeface will be used.
@@ -129,8 +126,8 @@ public:
*
* @return a new path range populated with glyphs.
*/
- GrPathRange* createGlyphs(const SkTypeface*, const SkScalerContextEffects&,
- const SkDescriptor*, const GrStyle&);
+ sk_sp<GrPathRange> createGlyphs(const SkTypeface*, const SkScalerContextEffects&,
+ const SkDescriptor*, const GrStyle&);
/** None of these params are optional, pointers used just to avoid making copies. */
struct StencilPathArgs {
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index d8611fe0ae..ea699fbe10 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -12,6 +12,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrGpu.h"
+#include "GrPath.h"
#include "GrPathRendering.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetPriv.h"
@@ -198,11 +199,11 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk
return tex;
}
- tex.reset(fGpu->createTexture(desc, budgeted));
- return tex;
+ return fGpu->createTexture(desc, budgeted);
}
-GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) {
+sk_sp<GrTexture> GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc,
+ uint32_t flags) {
ASSERT_SINGLE_OWNER
SkASSERT(0 == flags || kNoPendingIO_Flag == flags);
@@ -217,7 +218,8 @@ GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, ui
return this->refScratchTexture(desc, flags);
}
-GrTexture* GrResourceProvider::refScratchTexture(const GrSurfaceDesc& inDesc, uint32_t flags) {
+sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& inDesc,
+ uint32_t flags) {
ASSERT_SINGLE_OWNER
SkASSERT(!this->isAbandoned());
SkASSERT(validate_desc(inDesc, *fCaps));
@@ -250,7 +252,7 @@ GrTexture* GrResourceProvider::refScratchTexture(const GrSurfaceDesc& inDesc, ui
scratchFlags);
if (resource) {
GrSurface* surface = static_cast<GrSurface*>(resource);
- return surface->asTexture();
+ return sk_sp<GrTexture>(surface->asTexture());
}
}
@@ -379,21 +381,21 @@ const GrBuffer* GrResourceProvider::createQuadIndexBuffer() {
return this->createPatternedIndexBuffer(kPattern, 6, kMaxQuads, 4, fQuadIndexBufferKey);
}
-GrPath* GrResourceProvider::createPath(const SkPath& path, const GrStyle& style) {
+sk_sp<GrPath> GrResourceProvider::createPath(const SkPath& path, const GrStyle& style) {
SkASSERT(this->gpu()->pathRendering());
return this->gpu()->pathRendering()->createPath(path, style);
}
-GrPathRange* GrResourceProvider::createPathRange(GrPathRange::PathGenerator* gen,
- const GrStyle& style) {
+sk_sp<GrPathRange> GrResourceProvider::createPathRange(GrPathRange::PathGenerator* gen,
+ const GrStyle& style) {
SkASSERT(this->gpu()->pathRendering());
return this->gpu()->pathRendering()->createPathRange(gen, style);
}
-GrPathRange* GrResourceProvider::createGlyphs(const SkTypeface* tf,
- const SkScalerContextEffects& effects,
- const SkDescriptor* desc,
- const GrStyle& style) {
+sk_sp<GrPathRange> GrResourceProvider::createGlyphs(const SkTypeface* tf,
+ const SkScalerContextEffects& effects,
+ const SkDescriptor* desc,
+ const GrStyle& style) {
SkASSERT(this->gpu()->pathRendering());
return this->gpu()->pathRendering()->createGlyphs(tf, effects, desc, style);
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 2c5e873b29..2e9b8a824d 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -64,10 +64,9 @@ public:
* Finds a texture that approximately matches the descriptor. Will be at least as large in width
* and height as desc specifies. If desc specifies that the texture should be a render target
* then result will be a render target. Format and sample count will always match the request.
- * The contents of the texture are undefined. The caller owns a ref on the returned texture and
- * must balance with a call to unref.
+ * The contents of the texture are undefined.
*/
- GrTexture* createApproxTexture(const GrSurfaceDesc&, uint32_t flags);
+ sk_sp<GrTexture> createApproxTexture(const GrSurfaceDesc&, uint32_t flags);
/** Create an exact fit texture with no initial data to upload.
*/
@@ -148,10 +147,10 @@ public:
* Factories for GrPath and GrPathRange objects. It's an error to call these if path rendering
* is not supported.
*/
- GrPath* createPath(const SkPath&, const GrStyle&);
- GrPathRange* createPathRange(GrPathRange::PathGenerator*, const GrStyle&);
- GrPathRange* createGlyphs(const SkTypeface*, const SkScalerContextEffects&,
- const SkDescriptor*, const GrStyle&);
+ sk_sp<GrPath> createPath(const SkPath&, const GrStyle&);
+ sk_sp<GrPathRange> createPathRange(GrPathRange::PathGenerator*, const GrStyle&);
+ sk_sp<GrPathRange> createGlyphs(const SkTypeface*, const SkScalerContextEffects&,
+ const SkDescriptor*, const GrStyle&);
/** These flags govern which scratch resources we are allowed to return */
enum Flags {
@@ -249,7 +248,7 @@ private:
this->assignUniqueKeyToResource(key, texture);
}
- GrTexture* refScratchTexture(const GrSurfaceDesc&, uint32_t scratchTextureFlags);
+ sk_sp<GrTexture> refScratchTexture(const GrSurfaceDesc&, uint32_t scratchTextureFlags);
/*
* Try to find an existing scratch texture that exactly matches 'desc'. If successful
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 54bcf0bafd..53529c2e3b 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -59,7 +59,7 @@ bool GrSurfaceProxy::instantiateImpl(GrResourceProvider* resourceProvider, int s
}
if (SkBackingFit::kApprox == fFit) {
- fTarget = resourceProvider->createApproxTexture(desc, fFlags);
+ fTarget = resourceProvider->createApproxTexture(desc, fFlags).release();
} else {
fTarget = resourceProvider->createTexture(desc, fBudgeted, fFlags).release();
}
@@ -172,7 +172,7 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceP
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
- tex.reset(resourceProvider->createApproxTexture(copyDesc, flags));
+ tex = resourceProvider->createApproxTexture(copyDesc, flags);
} else {
tex = resourceProvider->createTexture(copyDesc, budgeted, flags);
}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index c32d5d8fda..fc629d60d0 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1281,7 +1281,7 @@ FAILED:
}
// good to set a break-point here to know when createTexture fails
-static GrTexture* return_null_texture() {
+static sk_sp<GrTexture> return_null_texture() {
// SkDEBUGFAIL("null texture");
return nullptr;
}
@@ -1318,9 +1318,9 @@ static void set_initial_texture_params(const GrGLInterface* interface,
initialTexParams->fWrapT));
}
-GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
- SkBudgeted budgeted,
- const SkTArray<GrMipLevel>& origTexels) {
+sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
+ SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>& origTexels) {
// We fail if the MSAA was requested and is not available.
if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleCnt) {
//SkDebugf("MSAA RT requested but not supported on this platform.");
@@ -1361,7 +1361,7 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
wasMipMapDataProvided = true;
}
- GrGLTexture* tex;
+ sk_sp<GrGLTexture> tex;
if (isRenderTarget) {
// unbind the texture from the texture unit before binding it to the frame buffer
GL_CALL(BindTexture(idDesc.fInfo.fTarget, 0));
@@ -1371,10 +1371,10 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
return return_null_texture();
}
- tex = new GrGLTextureRenderTarget(this, budgeted, desc, idDesc, rtIDDesc,
- wasMipMapDataProvided);
+ tex = sk_make_sp<GrGLTextureRenderTarget>(this, budgeted, desc, idDesc, rtIDDesc,
+ wasMipMapDataProvided);
} else {
- tex = new GrGLTexture(this, budgeted, desc, idDesc, wasMipMapDataProvided);
+ tex = sk_make_sp<GrGLTexture>(this, budgeted, desc, idDesc, wasMipMapDataProvided);
}
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
#ifdef TRACE_TEXTURE_CREATION
@@ -1389,14 +1389,15 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
} else {
SkASSERT(!GrPixelConfigIsSint(desc.fConfig));
GrGLIRect viewport;
- this->bindSurfaceFBOForPixelOps(tex, GR_GL_FRAMEBUFFER, &viewport, kDst_TempFBOTarget);
+ this->bindSurfaceFBOForPixelOps(tex.get(), GR_GL_FRAMEBUFFER, &viewport,
+ kDst_TempFBOTarget);
this->disableScissor();
this->disableWindowRectangles();
GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
fHWWriteToColor = kYes_TriState;
GL_CALL(ClearColor(0, 0, 0, 0));
GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT));
- this->unbindTextureFBOForPixelOps(GR_GL_FRAMEBUFFER, tex);
+ this->unbindTextureFBOForPixelOps(GR_GL_FRAMEBUFFER, tex.get());
fHWBoundRenderTargetUniqueID.makeInvalid();
}
}
@@ -2034,7 +2035,7 @@ bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConf
desc.fWidth = desc.fHeight = 16;
if (this->glCaps().isConfigRenderable(rtConfig, false)) {
desc.fFlags = kRenderTarget_GrSurfaceFlag;
- temp.reset(this->createTexture(desc, SkBudgeted::kNo));
+ temp = this->createTexture(desc, SkBudgeted::kNo);
if (!temp) {
return false;
}
@@ -2042,7 +2043,7 @@ bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConf
this->flushRenderTarget(glrt, &SkIRect::EmptyIRect());
return true;
} else if (this->glCaps().canConfigBeFBOColorAttachment(rtConfig)) {
- temp.reset(this->createTexture(desc, SkBudgeted::kNo));
+ temp = this->createTexture(desc, SkBudgeted::kNo);
if (!temp) {
return false;
}
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 7b59c3b696..770c357c5f 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -184,8 +184,8 @@ private:
void xferBarrier(GrRenderTarget*, GrXferBarrierType) override;
- GrTexture* onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
- const SkTArray<GrMipLevel>& texels) override;
+ sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>& texels) override;
GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
const void* data) override;
diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp
index 6341aa897c..a0845e35ba 100644
--- a/src/gpu/gl/GrGLPathRendering.cpp
+++ b/src/gpu/gl/GrGLPathRendering.cpp
@@ -106,13 +106,13 @@ void GrGLPathRendering::resetContext() {
fHWPathStencilSettings.invalidate();
}
-GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const GrStyle& style) {
- return new GrGLPath(this->gpu(), inPath, style);
+sk_sp<GrPath> GrGLPathRendering::createPath(const SkPath& inPath, const GrStyle& style) {
+ return sk_make_sp<GrGLPath>(this->gpu(), inPath, style);
}
-GrPathRange* GrGLPathRendering::createPathRange(GrPathRange::PathGenerator* pathGenerator,
- const GrStyle& style) {
- return new GrGLPathRange(this->gpu(), pathGenerator, style);
+sk_sp<GrPathRange> GrGLPathRendering::createPathRange(GrPathRange::PathGenerator* pathGenerator,
+ const GrStyle& style) {
+ return sk_make_sp<GrGLPathRange>(this->gpu(), pathGenerator, style);
}
void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath* path) {
diff --git a/src/gpu/gl/GrGLPathRendering.h b/src/gpu/gl/GrGLPathRendering.h
index 8c3cd47f8f..ddbd75c577 100644
--- a/src/gpu/gl/GrGLPathRendering.h
+++ b/src/gpu/gl/GrGLPathRendering.h
@@ -34,9 +34,9 @@ public:
~GrGLPathRendering() override;
// GrPathRendering implementations.
- GrPath* createPath(const SkPath&, const GrStyle&) override;
- virtual GrPathRange* createPathRange(GrPathRange::PathGenerator*,
- const GrStyle&) override;
+ sk_sp<GrPath> createPath(const SkPath&, const GrStyle&) override;
+ virtual sk_sp<GrPathRange> createPathRange(GrPathRange::PathGenerator*,
+ const GrStyle&) override;
/* Called when the 3D context state is unknown. */
void resetContext();
diff --git a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
index 4822850d60..a3015645ad 100644
--- a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
@@ -59,7 +59,7 @@ static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const GrShape&
if (!path) {
SkPath skPath;
shape.asPath(&skPath);
- path.reset(resourceProvider->createPath(skPath, shape.style()));
+ path = resourceProvider->createPath(skPath, shape.style());
if (!isVolatile) {
resourceProvider->assignUniqueKeyToResource(key, path.get());
}
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index d2872d246f..6108e7ae44 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -527,11 +527,13 @@ void GrStencilAndCoverTextContext::TextRun::setPosText(const char text[], size_t
fFallbackTextBlob = fallback.makeIfNeeded(&fFallbackGlyphCount);
}
-GrPathRange* GrStencilAndCoverTextContext::TextRun::createGlyphs(
+sk_sp<GrPathRange> GrStencilAndCoverTextContext::TextRun::createGlyphs(
GrResourceProvider* resourceProvider) const {
- GrPathRange* glyphs = static_cast<GrPathRange*>(
- resourceProvider->findAndRefResourceByUniqueKey(fGlyphPathsKey));
- if (nullptr == glyphs) {
+ sk_sp<GrPathRange> glyphs;
+
+ glyphs.reset(static_cast<GrPathRange*>(
+ resourceProvider->findAndRefResourceByUniqueKey(fGlyphPathsKey)));
+ if (!glyphs) {
if (fUsingRawGlyphPaths) {
SkScalerContextEffects noeffects;
glyphs = resourceProvider->createGlyphs(fFont.getTypeface(), noeffects,
@@ -543,7 +545,7 @@ GrPathRange* GrStencilAndCoverTextContext::TextRun::createGlyphs(
&cache->getDescriptor(),
fStyle);
}
- resourceProvider->assignUniqueKeyToResource(fGlyphPathsKey, glyphs);
+ resourceProvider->assignUniqueKeyToResource(fGlyphPathsKey, glyphs.get());
}
return glyphs;
}
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.h b/src/gpu/text/GrStencilAndCoverTextContext.h
index 54c0a9d758..49bba4f4f6 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.h
+++ b/src/gpu/text/GrStencilAndCoverTextContext.h
@@ -89,7 +89,7 @@ private:
typedef GrDrawPathRangeOp::InstanceData InstanceData;
SkGlyphCache* getGlyphCache() const;
- GrPathRange* createGlyphs(GrResourceProvider*) const;
+ sk_sp<GrPathRange> createGlyphs(GrResourceProvider*) const;
void appendGlyph(const SkGlyph&, const SkPoint&, FallbackBlobBuilder*);
GrStyle fStyle;
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 4d305acab5..f76f06cfc0 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -679,8 +679,8 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex,
}
////////////////////////////////////////////////////////////////////////////////
-GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
- const SkTArray<GrMipLevel>& texels) {
+sk_sp<GrTexture> GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>& texels) {
bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
VkFormat pixelFormat;
@@ -724,7 +724,7 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget
imageDesc.fUsageFlags = usageFlags;
imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
- GrVkTexture* tex;
+ sk_sp<GrVkTexture> tex;
if (renderTarget) {
tex = GrVkTextureRenderTarget::CreateNewTextureRenderTarget(this, budgeted, desc,
imageDesc);
@@ -738,7 +738,7 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget
if (!texels.empty()) {
SkASSERT(texels.begin()->fPixels);
- if (!this->uploadTexDataOptimal(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
+ if (!this->uploadTexDataOptimal(tex.get(), 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
texels)) {
tex->unref();
return nullptr;
@@ -756,7 +756,7 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget
range.levelCount = 1;
tex->setImageLayout(this, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, false);
- this->currentCommandBuffer()->clearColorImage(this, tex, &zeroClearColor, 1, &range);
+ this->currentCommandBuffer()->clearColorImage(this, tex.get(), &zeroClearColor, 1, &range);
}
return tex;
}
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 913662dcd1..cce6883f8d 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -173,8 +173,8 @@ private:
void destroyResources();
- GrTexture* onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
- const SkTArray<GrMipLevel>&) override;
+ sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>&) override;
sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
GrSurfaceOrigin,
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 1525df34a1..2b1655f23d 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -69,9 +69,9 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
, fLinearTextureView(nullptr) {
}
-GrVkTexture* GrVkTexture::CreateNewTexture(GrVkGpu* gpu, SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
- const GrVkImage::ImageDesc& imageDesc) {
+sk_sp<GrVkTexture> GrVkTexture::CreateNewTexture(GrVkGpu* gpu, SkBudgeted budgeted,
+ const GrSurfaceDesc& desc,
+ const GrVkImage::ImageDesc& imageDesc) {
SkASSERT(imageDesc.fUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT);
GrVkImageInfo info;
@@ -87,7 +87,7 @@ GrVkTexture* GrVkTexture::CreateNewTexture(GrVkGpu* gpu, SkBudgeted budgeted,
return nullptr;
}
- return new GrVkTexture(gpu, budgeted, desc, info, imageView);
+ return sk_sp<GrVkTexture>(new GrVkTexture(gpu, budgeted, desc, info, imageView));
}
sk_sp<GrVkTexture> GrVkTexture::MakeWrappedTexture(GrVkGpu* gpu,
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index febd7ad294..fc3ffdff2e 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -18,8 +18,8 @@ struct GrVkImageInfo;
class GrVkTexture : public GrTexture, public virtual GrVkImage {
public:
- static GrVkTexture* CreateNewTexture(GrVkGpu*, SkBudgeted budgeted, const GrSurfaceDesc&,
- const GrVkImage::ImageDesc&);
+ static sk_sp<GrVkTexture> CreateNewTexture(GrVkGpu*, SkBudgeted budgeted, const GrSurfaceDesc&,
+ const GrVkImage::ImageDesc&);
static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&,
GrWrapOwnership, const GrVkImageInfo*);
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.cpp b/src/gpu/vk/GrVkTextureRenderTarget.cpp
index 2a6810d209..1b72c1f94b 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.cpp
+++ b/src/gpu/vk/GrVkTextureRenderTarget.cpp
@@ -18,11 +18,11 @@
#define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
-GrVkTextureRenderTarget* GrVkTextureRenderTarget::Create(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
- const GrVkImageInfo& info,
- SkBudgeted budgeted,
- GrVkImage::Wrapped wrapped) {
+sk_sp<GrVkTextureRenderTarget> GrVkTextureRenderTarget::Make(GrVkGpu* gpu,
+ const GrSurfaceDesc& desc,
+ const GrVkImageInfo& info,
+ SkBudgeted budgeted,
+ GrVkImage::Wrapped wrapped) {
VkImage image = info.fImage;
// Create the texture ImageView
const GrVkImageView* imageView = GrVkImageView::Create(gpu, image, info.fFormat,
@@ -87,34 +87,38 @@ GrVkTextureRenderTarget* GrVkTextureRenderTarget::Create(GrVkGpu* gpu,
return nullptr;
}
- GrVkTextureRenderTarget* texRT;
+ sk_sp<GrVkTextureRenderTarget> texRT;
if (desc.fSampleCnt) {
if (GrVkImage::kNot_Wrapped == wrapped) {
- texRT = new GrVkTextureRenderTarget(gpu, budgeted, desc,
- info, imageView, msInfo,
- colorAttachmentView,
- resolveAttachmentView);
+ texRT = sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
+ gpu, budgeted, desc,
+ info, imageView, msInfo,
+ colorAttachmentView,
+ resolveAttachmentView));
} else {
- texRT = new GrVkTextureRenderTarget(gpu, desc,
- info, imageView, msInfo,
- colorAttachmentView,
- resolveAttachmentView, wrapped);
+ texRT = sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
+ gpu, desc,
+ info, imageView, msInfo,
+ colorAttachmentView,
+ resolveAttachmentView, wrapped));
}
} else {
if (GrVkImage::kNot_Wrapped == wrapped) {
- texRT = new GrVkTextureRenderTarget(gpu, budgeted, desc,
- info, imageView,
- colorAttachmentView);
+ texRT = sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
+ gpu, budgeted, desc,
+ info, imageView,
+ colorAttachmentView));
} else {
- texRT = new GrVkTextureRenderTarget(gpu, desc,
- info, imageView,
- colorAttachmentView, wrapped);
+ texRT = sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
+ gpu, desc,
+ info, imageView,
+ colorAttachmentView, wrapped));
}
}
return texRT;
}
-GrVkTextureRenderTarget*
+sk_sp<GrVkTextureRenderTarget>
GrVkTextureRenderTarget::CreateNewTextureRenderTarget(GrVkGpu* gpu,
SkBudgeted budgeted,
const GrSurfaceDesc& desc,
@@ -127,7 +131,7 @@ GrVkTextureRenderTarget::CreateNewTextureRenderTarget(GrVkGpu* gpu,
return nullptr;
}
- GrVkTextureRenderTarget* trt = Create(gpu, desc, info, budgeted, GrVkImage::kNot_Wrapped);
+ sk_sp<GrVkTextureRenderTarget> trt = Make(gpu, desc, info, budgeted, GrVkImage::kNot_Wrapped);
if (!trt) {
GrVkImage::DestroyImageInfo(gpu, &info);
}
@@ -147,7 +151,7 @@ GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped = kBorrow_GrWrapOwnership == ownership ? GrVkImage::kBorrowed_Wrapped
: GrVkImage::kAdopted_Wrapped;
- return sk_sp<GrVkTextureRenderTarget>(Create(gpu, desc, *info, SkBudgeted::kNo, wrapped));
+ return Make(gpu, desc, *info, SkBudgeted::kNo, wrapped);
}
bool GrVkTextureRenderTarget::updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo) {
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.h b/src/gpu/vk/GrVkTextureRenderTarget.h
index 03f9fdbbb1..7639dc06ac 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.h
+++ b/src/gpu/vk/GrVkTextureRenderTarget.h
@@ -26,9 +26,9 @@ struct GrVkImageInfo;
class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget {
public:
- static GrVkTextureRenderTarget* CreateNewTextureRenderTarget(GrVkGpu*, SkBudgeted,
- const GrSurfaceDesc&,
- const GrVkImage::ImageDesc&);
+ static sk_sp<GrVkTextureRenderTarget> CreateNewTextureRenderTarget(GrVkGpu*, SkBudgeted,
+ const GrSurfaceDesc&,
+ const GrVkImage::ImageDesc&);
static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*,
const GrSurfaceDesc&,
@@ -106,11 +106,11 @@ private:
this->registerWithCacheWrapped();
}
- static GrVkTextureRenderTarget* Create(GrVkGpu*,
- const GrSurfaceDesc&,
- const GrVkImageInfo&,
- SkBudgeted budgeted,
- GrVkImage::Wrapped wrapped);
+ static sk_sp<GrVkTextureRenderTarget> Make(GrVkGpu*,
+ const GrSurfaceDesc&,
+ const GrVkImageInfo&,
+ SkBudgeted budgeted,
+ GrVkImage::Wrapped wrapped);
// GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
size_t onGpuMemorySize() const override {
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index dc34c76b66..75df5aaa3b 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -137,7 +137,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
{
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
- tex.reset(provider->createApproxTexture(desc, 0));
+ tex = provider->createApproxTexture(desc, 0);
} else {
tex = provider->createTexture(desc, budgeted);
}
@@ -170,7 +170,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
{
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
- tex.reset(provider->createApproxTexture(desc, 0));
+ tex = provider->createApproxTexture(desc, 0);
} else {
tex = provider->createTexture(desc, budgeted);
}
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 2504b3c998..bd85cff7ec 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -355,8 +355,8 @@ private:
void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {}
- GrTexture* onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
- const SkTArray<GrMipLevel>& texels) override {
+ sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>& texels) override {
return nullptr;
}