From c91fd3447e1d3452d5e43e70e371896c80645b61 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Mon, 25 Apr 2016 12:32:54 -0700 Subject: [PATCH] Add another dollop of sk_sp to SkSpecialImage and SkSpecialSurface This is split out of https://codereview.chromium.org/1914883002/ (Refactor drawContext/RenderTarget creation) GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1913743002 Review URL: https://codereview.chromium.org/1913743002 --- src/core/SkImageFilter.cpp | 3 +- src/core/SkSpecialImage.cpp | 74 ++++++++++++------------- src/core/SkSpecialImage.h | 8 ++- src/core/SkSpecialSurface.cpp | 32 ++++------- src/core/SkSpecialSurface.h | 4 +- src/effects/SkBlurImageFilter.cpp | 20 +++---- src/effects/SkDisplacementMapEffect.cpp | 4 +- src/effects/SkLightingImageFilter.cpp | 2 +- src/effects/SkMorphologyImageFilter.cpp | 8 +-- src/effects/SkXfermodeImageFilter.cpp | 8 +-- src/gpu/GrLayerHoister.cpp | 6 +- tests/ImageFilterCacheTest.cpp | 2 +- tests/ImageFilterTest.cpp | 5 +- tests/SpecialImageTest.cpp | 16 +++--- tests/SpecialSurfaceTest.cpp | 4 +- 15 files changed, 94 insertions(+), 102 deletions(-) diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index ab1758844c..fdd78f8f73 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -313,8 +313,7 @@ sk_sp SkImageFilter::DrawWithFP(GrContext* context, return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()), kNeedNewImageUniqueID_SpecialImage, - dst.get()); - + std::move(dst)); } #endif diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index bbc7635b66..f18e6a7c7c 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -32,7 +32,9 @@ public: virtual GrTexture* onPeekTexture() const { return nullptr; } - virtual GrTexture* onAsTextureRef(GrContext* context) const = 0; +#if SK_SUPPORT_GPU + virtual sk_sp onAsTextureRef(GrContext* context) const = 0; +#endif // Delete this entry point ASAP (see skbug.com/4965) virtual bool getBitmapDeprecated(SkBitmap* result) const = 0; @@ -80,8 +82,9 @@ sk_sp SkSpecialImage::makeTextureImage(GrContext* context) { return SkSpecialImage::MakeFromRaster(SkIRect::MakeEmpty(), bmp, &this->props()); } - SkAutoTUnref resultTex( - GrRefCachedBitmapTexture(context, bmp, GrTextureParams::ClampNoFilter())); + sk_sp resultTex(GrRefCachedBitmapTexture(context, + bmp, + GrTextureParams::ClampNoFilter())); if (!resultTex) { return nullptr; } @@ -123,10 +126,11 @@ GrContext* SkSpecialImage::getContext() const { return nullptr; } - -GrTexture* SkSpecialImage::asTextureRef(GrContext* context) const { +#if SK_SUPPORT_GPU +sk_sp SkSpecialImage::asTextureRef(GrContext* context) const { return as_SIB(this)->onAsTextureRef(context); } +#endif sk_sp SkSpecialImage::makeSurface(const SkImageInfo& info) const { return as_SIB(this)->onMakeSurface(info); @@ -151,13 +155,15 @@ sk_sp SkSpecialImage::makeTightSubset(const SkIRect& subset) const { sk_sp SkSpecialImage::internal_fromBM(const SkBitmap& src, const SkSurfaceProps* props) { +#if SK_SUPPORT_GPU // Need to test offset case! (see skbug.com/4967) if (src.getTexture()) { return SkSpecialImage::MakeFromGpu(src.bounds(), src.getGenerationID(), - src.getTexture(), + sk_ref_sp(src.getTexture()), props); } +#endif return SkSpecialImage::MakeFromRaster(src.bounds(), src, props); } @@ -217,13 +223,12 @@ public: GrTexture* onPeekTexture() const override { return as_IB(fImage)->peekTexture(); } - GrTexture* onAsTextureRef(GrContext* context) const override { #if SK_SUPPORT_GPU - return as_IB(fImage)->asTextureRef(context, GrTextureParams::ClampNoFilter()); -#else - return nullptr; -#endif + sk_sp onAsTextureRef(GrContext* context) const override { + return sk_sp(as_IB(fImage)->asTextureRef(context, + GrTextureParams::ClampNoFilter())); } +#endif bool getBitmapDeprecated(SkBitmap* result) const override { #if SK_SUPPORT_GPU @@ -356,15 +361,17 @@ public: return true; } - GrTexture* onAsTextureRef(GrContext* context) const override { #if SK_SUPPORT_GPU + sk_sp onAsTextureRef(GrContext* context) const override { if (context) { - return GrRefCachedBitmapTexture(context, fBitmap, GrTextureParams::ClampNoFilter()); + return sk_ref_sp(GrRefCachedBitmapTexture(context, + fBitmap, + GrTextureParams::ClampNoFilter())); } -#endif return nullptr; } +#endif bool getBitmapDeprecated(SkBitmap* result) const override { *result = fBitmap; @@ -437,10 +444,10 @@ sk_sp SkSpecialImage::MakeFromPixmap(const SkIRect& subset, class SkSpecialImage_Gpu : public SkSpecialImage_Base { public: SkSpecialImage_Gpu(const SkIRect& subset, - uint32_t uniqueID, GrTexture* tex, SkAlphaType at, + uint32_t uniqueID, sk_sp tex, SkAlphaType at, const SkSurfaceProps* props) : INHERITED(subset, uniqueID, props) - , fTexture(SkRef(tex)) + , fTexture(std::move(tex)) , fAlphaType(at) , fAddedRasterVersionToCache(false) { } @@ -463,16 +470,16 @@ public: SkBitmap bm; - GrWrapTextureInBitmap(fTexture, + GrWrapTextureInBitmap(fTexture.get(), fTexture->width(), fTexture->height(), this->isOpaque(), &bm); canvas->drawBitmapRect(bm, this->subset(), dst, paint, SkCanvas::kStrict_SrcRectConstraint); } - GrTexture* onPeekTexture() const override { return fTexture; } + GrTexture* onPeekTexture() const override { return fTexture.get(); } - GrTexture* onAsTextureRef(GrContext*) const override { return SkRef(fTexture.get()); } + sk_sp onAsTextureRef(GrContext*) const override { return fTexture; } bool onGetROPixels(SkBitmap* dst) const override { if (SkBitmapCache::Find(this->uniqueID(), dst)) { @@ -502,7 +509,7 @@ public: } bool getBitmapDeprecated(SkBitmap* result) const override { - const SkImageInfo info = GrMakeInfoFromTexture(fTexture, + const SkImageInfo info = GrMakeInfoFromTexture(fTexture.get(), this->width(), this->height(), this->isOpaque()); if (!result->setInfo(info)) { @@ -511,7 +518,7 @@ public: const SkImageInfo prInfo = info.makeWH(fTexture->width(), fTexture->height()); - SkAutoTUnref pixelRef(new SkGrPixelRef(prInfo, fTexture)); + SkAutoTUnref pixelRef(new SkGrPixelRef(prInfo, fTexture.get())); result->setPixelRef(pixelRef, this->subset().fLeft, this->subset().fTop); return true; } @@ -542,7 +549,7 @@ public: // The existing GrTexture is already tight so reuse it in the SkImage return sk_make_sp(fTexture->width(), fTexture->height(), kNeedNewImageUniqueID, - fAlphaType, fTexture, SkBudgeted::kYes); + fAlphaType, fTexture.get(), SkBudgeted::kYes); } GrContext* ctx = fTexture->getContext(); @@ -550,14 +557,13 @@ public: desc.fWidth = subset.width(); desc.fHeight = subset.height(); - SkAutoTUnref subTx(ctx->textureProvider()->createTexture(desc, - SkBudgeted::kYes)); + sk_sp subTx(ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes)); if (!subTx) { return nullptr; } - ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0)); + ctx->copySurface(subTx.get(), fTexture.get(), subset, SkIPoint::Make(0, 0)); return sk_make_sp(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, - fAlphaType, subTx, SkBudgeted::kYes); + fAlphaType, subTx.get(), SkBudgeted::kYes); } sk_sp onMakeTightSurface(const SkImageInfo& info) const override { @@ -565,7 +571,7 @@ public: } private: - SkAutoTUnref fTexture; + sk_sp fTexture; const SkAlphaType fAlphaType; mutable SkAtomic fAddedRasterVersionToCache; @@ -574,21 +580,11 @@ private: sk_sp SkSpecialImage::MakeFromGpu(const SkIRect& subset, uint32_t uniqueID, - GrTexture* tex, + sk_sp tex, const SkSurfaceProps* props, SkAlphaType at) { SkASSERT(rect_fits(subset, tex->width(), tex->height())); - return sk_make_sp(subset, uniqueID, tex, at, props); -} - -#else - -sk_sp SkSpecialImage::MakeFromGpu(const SkIRect& subset, - uint32_t uniqueID, - GrTexture* tex, - const SkSurfaceProps* props, - SkAlphaType at) { - return nullptr; + return sk_make_sp(subset, uniqueID, std::move(tex), at, props); } #endif diff --git a/src/core/SkSpecialImage.h b/src/core/SkSpecialImage.h index d6497a035e..6771f257e3 100644 --- a/src/core/SkSpecialImage.h +++ b/src/core/SkSpecialImage.h @@ -73,11 +73,13 @@ public: static sk_sp MakeFromRaster(const SkIRect& subset, const SkBitmap&, const SkSurfaceProps* = nullptr); +#if SK_SUPPORT_GPU static sk_sp MakeFromGpu(const SkIRect& subset, uint32_t uniqueID, - GrTexture*, + sk_sp, const SkSurfaceProps* = nullptr, SkAlphaType at = kPremul_SkAlphaType); +#endif static sk_sp MakeFromPixmap(const SkIRect& subset, const SkPixmap&, RasterReleaseProc, @@ -123,11 +125,13 @@ public: */ GrContext* getContext() const; +#if SK_SUPPORT_GPU /** * Regardless of the underlying backing store, return the contents as a GrTexture. * The active portion of the texture can be retrieved via 'subset'. */ - GrTexture* asTextureRef(GrContext*) const; + sk_sp asTextureRef(GrContext*) const; +#endif // TODO: hide this whe the imagefilter all have a consistent draw path (see skbug.com/5063) /** diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp index 2e2d8cc54a..2973aa1f9b 100644 --- a/src/core/SkSpecialSurface.cpp +++ b/src/core/SkSpecialSurface.cpp @@ -112,11 +112,11 @@ sk_sp SkSpecialSurface::MakeRaster(const SkImageInfo& info, class SkSpecialSurface_Gpu : public SkSpecialSurface_Base { public: - SkSpecialSurface_Gpu(GrTexture* texture, + SkSpecialSurface_Gpu(sk_sp texture, const SkIRect& subset, const SkSurfaceProps* props) : INHERITED(subset, props) - , fTexture(SkRef(texture)) { + , fTexture(std::move(texture)) { SkASSERT(fTexture->asRenderTarget()); @@ -133,25 +133,27 @@ public: ~SkSpecialSurface_Gpu() override { } sk_sp onMakeImageSnapshot() override { + // Note: we are intentionally zeroing out 'fTexture' here return SkSpecialImage::MakeFromGpu(this->subset(), - kNeedNewImageUniqueID_SpecialImage, fTexture, + kNeedNewImageUniqueID_SpecialImage, + std::move(fTexture), &this->props()); } private: - SkAutoTUnref fTexture; + sk_sp fTexture; typedef SkSpecialSurface_Base INHERITED; }; sk_sp SkSpecialSurface::MakeFromTexture(const SkIRect& subset, - GrTexture* texture, + sk_sp texture, const SkSurfaceProps* props) { if (!texture->asRenderTarget()) { return nullptr; } - return sk_make_sp(texture, subset, props); + return sk_make_sp(std::move(texture), subset, props); } sk_sp SkSpecialSurface::MakeRenderTarget(GrContext* context, @@ -161,28 +163,14 @@ sk_sp SkSpecialSurface::MakeRenderTarget(GrContext* context, return nullptr; } - SkAutoTUnref temp(context->textureProvider()->createApproxTexture(desc)); + sk_sp temp(context->textureProvider()->createApproxTexture(desc)); if (!temp) { return nullptr; } const SkIRect subset = SkIRect::MakeWH(desc.fWidth, desc.fHeight); - return sk_make_sp(temp, subset, props); -} - -#else - -sk_sp SkSpecialSurface::MakeFromTexture(const SkIRect& subset, - GrTexture*, - const SkSurfaceProps*) { - return nullptr; -} - -sk_sp SkSpecialSurface::MakeRenderTarget(GrContext* context, - const GrSurfaceDesc& desc, - const SkSurfaceProps* props) { - return nullptr; + return sk_make_sp(std::move(temp), subset, props); } #endif diff --git a/src/core/SkSpecialSurface.h b/src/core/SkSpecialSurface.h index 6ed8a77da5..2135347e35 100644 --- a/src/core/SkSpecialSurface.h +++ b/src/core/SkSpecialSurface.h @@ -50,10 +50,11 @@ public: */ sk_sp makeImageSnapshot(); +#if SK_SUPPORT_GPU /** * Use an existing (renderTarget-capable) GrTexture as the backing store. */ - static sk_sp MakeFromTexture(const SkIRect& subset, GrTexture*, + static sk_sp MakeFromTexture(const SkIRect& subset, sk_sp, const SkSurfaceProps* = nullptr); /** @@ -62,6 +63,7 @@ public: */ static sk_sp MakeRenderTarget(GrContext*, const GrSurfaceDesc&, const SkSurfaceProps* = nullptr); +#endif /** * Use and existing SkBitmap as the backing store. diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index d233c04ea7..bbe351db47 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -106,7 +106,7 @@ sk_sp SkBlurImageFilter::onFilterImage(SkSpecialImage* source, #if SK_SUPPORT_GPU if (source->isTextureBacked()) { GrContext* context = source->getContext(); - SkAutoTUnref inputTexture(input->asTextureRef(context)); + sk_sp inputTexture(input->asTextureRef(context)); SkASSERT(inputTexture); if (0 == sigma.x() && 0 == sigma.y()) { @@ -121,21 +121,21 @@ sk_sp SkBlurImageFilter::onFilterImage(SkSpecialImage* source, inputBounds.offset(-inputOffset); dstBounds.offset(-inputOffset); SkRect inputBoundsF(SkRect::Make(inputBounds)); - SkAutoTUnref tex(SkGpuBlurUtils::GaussianBlur(context, - inputTexture, - false, - source->props().isGammaCorrect(), - SkRect::Make(dstBounds), - &inputBoundsF, - sigma.x(), - sigma.y())); + sk_sp tex(SkGpuBlurUtils::GaussianBlur(context, + inputTexture.get(), + false, + source->props().isGammaCorrect(), + SkRect::Make(dstBounds), + &inputBoundsF, + sigma.x(), + sigma.y())); if (!tex) { return nullptr; } return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), dstBounds.height()), kNeedNewImageUniqueID_SpecialImage, - tex, &source->props()); + std::move(tex), &source->props()); } #endif diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index c52b958746..a8f0b81d73 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -323,7 +323,7 @@ sk_sp SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou desc.fHeight = bounds.height(); desc.fConfig = kSkia8888_GrPixelConfig; - SkAutoTUnref dst(context->textureProvider()->createApproxTexture(desc)); + sk_sp dst(context->textureProvider()->createApproxTexture(desc)); if (!dst) { return nullptr; } @@ -357,7 +357,7 @@ sk_sp SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou offset->fY = bounds.top(); return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()), kNeedNewImageUniqueID_SpecialImage, - dst); + std::move(dst)); } #endif diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 7f0e3eab4b..4252831c1b 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -462,7 +462,7 @@ sk_sp SkLightingImageFilterInternal::filterImageGPU(SkSpecialIma return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height()), kNeedNewImageUniqueID_SpecialImage, - dst.get()); + std::move(dst)); } #endif diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index d5a048c6ce..810d0e13e4 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -474,7 +474,7 @@ static sk_sp apply_morphology(GrContext* context, const SkIRect& rect, GrMorphologyEffect::MorphologyType morphType, SkISize radius) { - SkAutoTUnref srcTexture(input->asTextureRef(context)); + sk_sp srcTexture(input->asTextureRef(context)); SkASSERT(srcTexture); // setup new clip @@ -502,7 +502,7 @@ static sk_sp apply_morphology(GrContext* context, return nullptr; } - apply_morphology_pass(dstDrawContext, clip, srcTexture, + apply_morphology_pass(dstDrawContext, clip, srcTexture.get(), srcRect, dstRect, radius.fWidth, morphType, Gr1DKernelEffect::kX_Direction); SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, @@ -526,7 +526,7 @@ static sk_sp apply_morphology(GrContext* context, return nullptr; } - apply_morphology_pass(dstDrawContext, clip, srcTexture, + apply_morphology_pass(dstDrawContext, clip, srcTexture.get(), srcRect, dstRect, radius.fHeight, morphType, Gr1DKernelEffect::kY_Direction); @@ -535,7 +535,7 @@ static sk_sp apply_morphology(GrContext* context, return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(rect.width(), rect.height()), kNeedNewImageUniqueID_SpecialImage, - srcTexture, &input->props()); + std::move(srcTexture), &input->props()); } #endif diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index 25a750eefb..f4e896ece6 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -169,11 +169,11 @@ sk_sp SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour sk_sp backgroundTex, foregroundTex; if (background) { - backgroundTex.reset(background->asTextureRef(context)); + backgroundTex = background->asTextureRef(context); } if (foreground) { - foregroundTex.reset(foreground->asTextureRef(context)); + foregroundTex = foreground->asTextureRef(context); } GrSurfaceDesc desc; @@ -181,7 +181,7 @@ sk_sp SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour desc.fWidth = bounds.width(); desc.fHeight = bounds.height(); desc.fConfig = kSkia8888_GrPixelConfig; - SkAutoTUnref dst(context->textureProvider()->createApproxTexture(desc)); + sk_sp dst(context->textureProvider()->createApproxTexture(desc)); if (!dst) { return nullptr; } @@ -259,7 +259,7 @@ sk_sp SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()), kNeedNewImageUniqueID_SpecialImage, - dst.get()); + std::move(dst)); } #endif diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp index c768b7f3a4..a2d42e02a9 100644 --- a/src/gpu/GrLayerHoister.cpp +++ b/src/gpu/GrLayerHoister.cpp @@ -303,7 +303,7 @@ void GrLayerHoister::FilterLayer(GrContext* context, const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->texture()->height()); sk_sp img(SkSpecialImage::MakeFromGpu(subset, kNeedNewImageUniqueID_SpecialImage, - layer->texture(), + sk_ref_sp(layer->texture()), props)); SkIPoint offset = SkIPoint::Make(0, 0); @@ -316,8 +316,8 @@ void GrLayerHoister::FilterLayer(GrContext* context, } SkASSERT(result->isTextureBacked()); - SkAutoTUnref texture(result->asTextureRef(context)); - layer->setTexture(texture, result->subset(), false); + sk_sp texture(result->asTextureRef(context)); + layer->setTexture(texture.get(), result->subset(), false); layer->setOffset(offset); } diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp index 40c805a14e..58d279c1c7 100644 --- a/tests/ImageFilterCacheTest.cpp +++ b/tests/ImageFilterCacheTest.cpp @@ -213,7 +213,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, ctxInfo) { - SkAutoTUnref srcTexture(create_texture(ctxInfo.fGrContext)); + sk_sp srcTexture(create_texture(ctxInfo.fGrContext)); if (!srcTexture) { return; } diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index 952e5e5ba8..54e9a60007 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -368,6 +368,7 @@ static sk_sp make_blue(sk_sp input, } static sk_sp create_empty_special_surface(GrContext* context, int widthHeight) { +#if SK_SUPPORT_GPU if (context) { GrSurfaceDesc desc; desc.fConfig = kSkia8888_GrPixelConfig; @@ -375,7 +376,9 @@ static sk_sp create_empty_special_surface(GrContext* context, desc.fWidth = widthHeight; desc.fHeight = widthHeight; return SkSpecialSurface::MakeRenderTarget(context, desc); - } else { + } else +#endif + { const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight, kOpaque_SkAlphaType); return SkSpecialSurface::MakeRaster(info); diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp index 18d023f9cd..f5174478ef 100644 --- a/tests/SpecialImageTest.cpp +++ b/tests/SpecialImageTest.cpp @@ -243,10 +243,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) desc.fWidth = kFullSize; desc.fHeight = kFullSize; - SkAutoTUnref texture(context->textureProvider()->createTexture(desc, - SkBudgeted::kNo, - bm.getPixels(), - 0)); + sk_sp texture(context->textureProvider()->createTexture(desc, + SkBudgeted::kNo, + bm.getPixels(), + 0)); if (!texture) { return; } @@ -255,7 +255,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) SkIRect::MakeWH(kFullSize, kFullSize), kNeedNewImageUniqueID_SpecialImage, - texture)); + std::move(texture))); { sk_sp fromGPU(gpuImage->makeTextureImage(context)); @@ -281,9 +281,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { desc.fWidth = kFullSize; desc.fHeight = kFullSize; - SkAutoTUnref texture(context->textureProvider()->createTexture(desc, - SkBudgeted::kNo, - bm.getPixels(), 0)); + sk_sp texture(context->textureProvider()->createTexture(desc, + SkBudgeted::kNo, + bm.getPixels(), 0)); if (!texture) { return; } diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp index 7169b5e8e2..8c560fef79 100644 --- a/tests/SpecialSurfaceTest.cpp +++ b/tests/SpecialSurfaceTest.cpp @@ -98,12 +98,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SpecialSurface_Gpu2, reporter, ctxInfo) { desc.fWidth = kFullSize; desc.fHeight = kFullSize; - SkAutoTUnref temp(ctxInfo.fGrContext->textureProvider()->createApproxTexture(desc)); + sk_sp temp(ctxInfo.fGrContext->textureProvider()->createApproxTexture(desc)); SkASSERT_RELEASE(temp); const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); - sk_sp surf(SkSpecialSurface::MakeFromTexture(subset, temp)); + sk_sp surf(SkSpecialSurface::MakeFromTexture(subset, std::move(temp))); test_surface(surf, reporter, kPad); -- 2.34.1