From cefc43112c8f6fe3702facb89447bdfcc2715345 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Fri, 4 Nov 2016 16:26:16 -0400 Subject: gm: s/SkAutoTUnref/sk_sp/ GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4434 Change-Id: Ib2bea321617a17012190b33f2c7c439a5b6b3025 Reviewed-on: https://skia-review.googlesource.com/4434 Commit-Queue: Ben Wagner Reviewed-by: Ben Wagner --- gm/aaclip.cpp | 2 +- gm/all_bitmap_configs.cpp | 4 ++-- gm/beziereffects.cpp | 15 +++++++-------- gm/bigrrectaaeffect.cpp | 4 ++-- gm/constcolorprocessor.cpp | 4 ++-- gm/convexpolyeffect.cpp | 8 ++++---- gm/drawable.cpp | 10 +++++----- gm/dstreadshuffle.cpp | 6 +++--- gm/fontmgr.cpp | 20 ++++++++++---------- gm/fontscalerdistortable.cpp | 2 +- gm/gradients_no_texture.cpp | 2 +- gm/image.cpp | 2 +- gm/image_pict.cpp | 10 +++++----- gm/rrects.cpp | 4 ++-- gm/showmiplevels.cpp | 4 ++-- gm/texdata.cpp | 2 +- gm/texturedomaineffect.cpp | 14 +++++++------- gm/verttext.cpp | 2 +- gm/yuvtorgbeffect.cpp | 26 +++++++++++++++----------- 19 files changed, 72 insertions(+), 69 deletions(-) (limited to 'gm') diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp index f00a4cdcec..dd83b7c730 100644 --- a/gm/aaclip.cpp +++ b/gm/aaclip.cpp @@ -182,7 +182,7 @@ static void test_image(SkCanvas* canvas, const SkImageInfo& info) { SkBitmap bm; bm.allocPixels(info); - SkAutoTUnref newc(make_canvas(bm)); + sk_sp newc(make_canvas(bm)); if (info.isOpaque()) { bm.eraseColor(SK_ColorGREEN); } else { diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp index 90df5bb3e4..e954fc33e5 100644 --- a/gm/all_bitmap_configs.cpp +++ b/gm/all_bitmap_configs.cpp @@ -124,10 +124,10 @@ static SkBitmap indexed_bitmap() { pmColors[i] = premultiply_color(colors[i]); } SkBitmap bm; - SkAutoTUnref ctable(new SkColorTable(pmColors, SK_ARRAY_COUNT(pmColors))); + sk_sp ctable(new SkColorTable(pmColors, SK_ARRAY_COUNT(pmColors))); SkImageInfo info = SkImageInfo::Make(SCALE, SCALE, kIndex_8_SkColorType, kPremul_SkAlphaType); - bm.allocPixels(info, nullptr, ctable); + bm.allocPixels(info, nullptr, ctable.get()); SkAutoLockPixels autoLockPixels1(n32bitmap); SkAutoLockPixels autoLockPixels2(bm); for (int y = 0; y < SCALE; ++y) { diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp index 6c0049b004..3447df4106 100644 --- a/gm/beziereffects.cpp +++ b/gm/beziereffects.cpp @@ -192,10 +192,10 @@ protected: GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); - SkAutoTUnref batch( - new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, klmSigns[c])); + sk_sp batch = sk_make_sp( + gp, bounds, color, klmEqs, klmSigns[c]); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); } ++col; if (numCols == col) { @@ -324,10 +324,10 @@ protected: GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); - SkAutoTUnref batch( + sk_sp batch( new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, 1.f)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); } ++col; if (numCols == col) { @@ -536,10 +536,9 @@ protected: GrPathUtils::QuadUVMatrix DevToUV(pts); - SkAutoTUnref batch( - new BezierQuadTestBatch(gp, bounds, color, DevToUV)); + sk_sp batch(new BezierQuadTestBatch(gp, bounds, color, DevToUV)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); } ++col; if (numCols == col) { diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp index be37d70568..47e5a73384 100644 --- a/gm/bigrrectaaeffect.cpp +++ b/gm/bigrrectaaeffect.cpp @@ -87,10 +87,10 @@ protected: SkRect bounds = testBounds; bounds.offset(SkIntToScalar(x), SkIntToScalar(y)); - SkAutoTUnref batch( + sk_sp batch( GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(), bounds, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); } canvas->restore(); x = x + fTestOffsetX; diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp index 53aca18872..f6a9dae0a5 100644 --- a/gm/constcolorprocessor.cpp +++ b/gm/constcolorprocessor.cpp @@ -109,10 +109,10 @@ protected: grPaint.addColorFragmentProcessor(std::move(fp)); - SkAutoTUnref batch( + sk_sp batch( GrRectBatchFactory::CreateNonAAFill(grPaint.getColor(), viewMatrix, renderRect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); // Draw labels for the input to the processor and the processor to the right of // the test rect. The input label appears above the processor label. diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp index d62838dd1e..fdeef299dd 100644 --- a/gm/convexpolyeffect.cpp +++ b/gm/convexpolyeffect.cpp @@ -183,9 +183,9 @@ protected: grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); grPaint.addCoverageFragmentProcessor(std::move(fp)); - SkAutoTUnref batch(new PolyBoundsBatch(p.getBounds(), 0xff000000)); + sk_sp batch(new PolyBoundsBatch(p.getBounds(), 0xff000000)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); x += SkScalarCeilToScalar(path->getBounds().width() + kDX); } @@ -222,9 +222,9 @@ protected: grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); grPaint.addCoverageFragmentProcessor(std::move(fp)); - SkAutoTUnref batch(new PolyBoundsBatch(rect, 0xff000000)); + sk_sp batch(new PolyBoundsBatch(rect, 0xff000000)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); x += SkScalarCeilToScalar(rect.width() + kDX); } diff --git a/gm/drawable.cpp b/gm/drawable.cpp index c7bc76185b..9428e32c4d 100644 --- a/gm/drawable.cpp +++ b/gm/drawable.cpp @@ -32,16 +32,16 @@ struct MyDrawable : public SkDrawable { * Test calling drawables w/ translate and matrices */ DEF_SIMPLE_GM(drawable, canvas, 180, 275) { - SkAutoTUnref drawable(new MyDrawable); + sk_sp drawable(new MyDrawable); canvas->translate(10, 10); - canvas->drawDrawable(drawable); - canvas->drawDrawable(drawable, 0, 150); + canvas->drawDrawable(drawable.get()); + canvas->drawDrawable(drawable.get(), 0, 150); SkMatrix m = SkMatrix::MakeScale(1.5f, 0.8f); m.postTranslate(70, 0); - canvas->drawDrawable(drawable, &m); + canvas->drawDrawable(drawable.get(), &m); m.postTranslate(0, 150); - canvas->drawDrawable(drawable, &m); + canvas->drawDrawable(drawable.get(), &m); } diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp index 72a68b1d9d..2c3cbc87f9 100644 --- a/gm/dstreadshuffle.cpp +++ b/gm/dstreadshuffle.cpp @@ -180,9 +180,9 @@ private: enum { kNumShapes = 100, }; - SkAutoTUnref fBG; - SkPath fConcavePath; - SkPath fConvexPath; + sk_sp fBG; + SkPath fConcavePath; + SkPath fConvexPath; static constexpr int kWidth = 900; static constexpr int kHeight = 400; typedef GM INHERITED; diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp index 50b83836f2..216fdd8249 100644 --- a/gm/fontmgr.cpp +++ b/gm/fontmgr.cpp @@ -86,7 +86,7 @@ protected: paint.setSubpixelText(true); paint.setTextSize(17); - SkFontMgr* fm = fFM; + SkFontMgr* fm = fFM.get(); int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); for (int i = 0; i < count; ++i) { @@ -97,7 +97,7 @@ protected: SkScalar x = 220; - SkAutoTUnref set(fm->createStyleSet(i)); + sk_sp set(fm->createStyleSet(i)); for (int j = 0; j < set->count(); ++j) { SkString sname; SkFontStyle fs; @@ -118,13 +118,13 @@ protected: } private: - SkAutoTUnref fFM; + sk_sp fFM; SkString fName; typedef GM INHERITED; }; class FontMgrMatchGM : public skiagm::GM { - SkAutoTUnref fFM; + sk_sp fFM; public: FontMgrMatchGM() : fFM(SkFontMgr::RefDefault()) { @@ -192,7 +192,7 @@ protected: "Helvetica Neue", "Arial" }; - SkAutoTUnref fset; + sk_sp fset; for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) { fset.reset(fFM->matchFamily(gNames[i])); if (fset->count() > 0) { @@ -204,9 +204,9 @@ protected: } canvas->translate(20, 40); - this->exploreFamily(canvas, paint, fset); + this->exploreFamily(canvas, paint, fset.get()); canvas->translate(150, 0); - this->iterateFamily(canvas, paint, fset); + this->iterateFamily(canvas, paint, fset.get()); } private: @@ -263,7 +263,7 @@ protected: const SkColor boundsColors[2] = { SK_ColorRED, SK_ColorBLUE }; - SkFontMgr* fm = fFM; + SkFontMgr* fm = fFM.get(); int count = SkMin32(fm->countFamilies(), 32); int index = 0; @@ -272,7 +272,7 @@ protected: canvas->translate(80, 120); for (int i = 0; i < count; ++i) { - SkAutoTUnref set(fm->createStyleSet(i)); + sk_sp set(fm->createStyleSet(i)); for (int j = 0; j < set->count(); ++j) { paint.setTypeface(sk_sp(set->createTypeface(j))); if (paint.getTypeface()) { @@ -292,7 +292,7 @@ protected: } private: - SkAutoTUnref fFM; + sk_sp fFM; SkString fName; SkScalar fScaleX, fSkewX; typedef GM INHERITED; diff --git a/gm/fontscalerdistortable.cpp b/gm/fontscalerdistortable.cpp index 712400cbe1..c557ec573d 100644 --- a/gm/fontscalerdistortable.cpp +++ b/gm/fontscalerdistortable.cpp @@ -33,7 +33,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); paint.setLCDRenderText(true); - SkAutoTUnref fontMgr(SkFontMgr::RefDefault()); + sk_sp fontMgr(SkFontMgr::RefDefault()); std::unique_ptr distortable(GetResourceAsStream("/fonts/Distortable.ttf")); if (!distortable) { diff --git a/gm/gradients_no_texture.cpp b/gm/gradients_no_texture.cpp index 5d0d4c9202..e012178450 100644 --- a/gm/gradients_no_texture.cpp +++ b/gm/gradients_no_texture.cpp @@ -215,7 +215,7 @@ class GradientsManyColorsGM : public GM { enum { W = 800, }; - SkAutoTUnref fShader; + sk_sp fShader; typedef void (*Proc)(ColorPos*); public: diff --git a/gm/image.cpp b/gm/image.cpp index d15919e2be..5454ac3966 100644 --- a/gm/image.cpp +++ b/gm/image.cpp @@ -319,7 +319,7 @@ protected: } private: - SkAutoTUnref fImg; + sk_sp fImg; typedef SkImageGenerator INHERITED; }; diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp index 2e2c284351..8cbd287f3b 100644 --- a/gm/image_pict.cpp +++ b/gm/image_pict.cpp @@ -189,8 +189,8 @@ static SkImageGenerator* make_ctable_generator(GrContext*, SkPicture* pic) { SkImageInfo info = SkImageInfo::Make(100, 100, kIndex_8_SkColorType, kPremul_SkAlphaType); SkBitmap bm2; - SkAutoTUnref ct(new SkColorTable(colors, count)); - bm2.allocPixels(info, nullptr, ct); + sk_sp ct(new SkColorTable(colors, count)); + bm2.allocPixels(info, nullptr, ct.get()); for (int y = 0; y < info.height(); ++y) { for (int x = 0; x < info.width(); ++x) { *bm2.getAddr8(x, y) = find_closest(*bm.getAddr32(x, y), colors, count); @@ -239,12 +239,12 @@ protected: desc.fHeight = subset->height(); GrTexture* dst = fCtx->textureProvider()->createTexture(desc, SkBudgeted::kNo); - fCtx->copySurface(dst, fTexture, *subset, SkIPoint::Make(0, 0)); + fCtx->copySurface(dst, fTexture.get(), *subset, SkIPoint::Make(0, 0)); return dst; } private: - SkAutoTUnref fCtx; - SkAutoTUnref fTexture; + sk_sp fCtx; + sk_sp fTexture; }; static SkImageGenerator* make_tex_generator(GrContext* ctx, SkPicture* pic) { const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); diff --git a/gm/rrects.cpp b/gm/rrects.cpp index c252ec6303..29e81bd298 100644 --- a/gm/rrects.cpp +++ b/gm/rrects.cpp @@ -115,10 +115,10 @@ protected: SkRect bounds = rrect.getBounds(); bounds.outset(2.f, 2.f); - SkAutoTUnref batch( + sk_sp batch( GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(), bounds, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); } else { drew = false; } diff --git a/gm/showmiplevels.cpp b/gm/showmiplevels.cpp index 05395bd118..2386e1d3c1 100644 --- a/gm/showmiplevels.cpp +++ b/gm/showmiplevels.cpp @@ -140,7 +140,7 @@ protected: baseBM.peekPixels(&prevPM); SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore; - SkAutoTUnref mm(SkMipMap::Build(baseBM, treatment, nullptr)); + sk_sp mm(SkMipMap::Build(baseBM, treatment, nullptr)); int index = 0; SkMipMap::Level level; @@ -251,7 +251,7 @@ protected: SkScalar y = 4; SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore; - SkAutoTUnref mm(SkMipMap::Build(baseBM, treatment, nullptr)); + sk_sp mm(SkMipMap::Build(baseBM, treatment, nullptr)); int index = 0; SkMipMap::Level level; diff --git a/gm/texdata.cpp b/gm/texdata.cpp index 05441ac4f1..4a74468ac5 100644 --- a/gm/texdata.cpp +++ b/gm/texdata.cpp @@ -81,7 +81,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) { if (!texture) { return; } - SkAutoTUnref au(texture); + sk_sp au(texture); // setup new clip GrFixedClip clip(SkIRect::MakeWH(2*S, 2*S)); diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp index 06c6518f5d..cac193b205 100644 --- a/gm/texturedomaineffect.cpp +++ b/gm/texturedomaineffect.cpp @@ -82,9 +82,9 @@ protected: return; } - SkAutoTUnref texture(GrRefCachedBitmapTexture(context, fBmp, - GrTextureParams::ClampNoFilter(), - SkSourceGammaTreatment::kRespect)); + sk_sp texture(GrRefCachedBitmapTexture(context, fBmp, + GrTextureParams::ClampNoFilter(), + SkSourceGammaTreatment::kRespect)); if (!texture) { return; } @@ -116,8 +116,8 @@ protected: GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); sk_sp fp( - GrTextureDomainEffect::Make(texture, nullptr, textureMatrices[tm], - GrTextureDomain::MakeTexelDomain(texture, + GrTextureDomainEffect::Make(texture.get(), nullptr, textureMatrices[tm], + GrTextureDomain::MakeTexelDomain(texture.get(), texelDomains[d]), mode, GrTextureParams::kNone_FilterMode)); @@ -127,10 +127,10 @@ protected: const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y); grPaint.addColorFragmentProcessor(std::move(fp)); - SkAutoTUnref batch( + sk_sp batch( GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); x += renderRect.width() + kTestPad; } y += renderRect.height() + kTestPad; diff --git a/gm/verttext.cpp b/gm/verttext.cpp index 700fb25e41..9c9ddb0e11 100644 --- a/gm/verttext.cpp +++ b/gm/verttext.cpp @@ -46,7 +46,7 @@ public: { } - //SkAutoTUnref fFace; + //sk_sp fFace; protected: diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp index 34f5e2b7c5..e3b78a6b66 100644 --- a/gm/yuvtorgbeffect.cpp +++ b/gm/yuvtorgbeffect.cpp @@ -80,7 +80,7 @@ protected: return; } - SkAutoTUnref texture[3]; + sk_sp texture[3]; texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0], GrTextureParams::ClampBilerp(), SkSourceGammaTreatment::kRespect)); @@ -115,17 +115,21 @@ protected: for (int i = 0; i < 6; ++i) { GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); - sk_sp fp(GrYUVEffect::MakeYUVToRGB( - texture[indices[i][0]], texture[indices[i][1]], texture[indices[i][2]], sizes, - static_cast(space), false)); + sk_sp fp( + GrYUVEffect::MakeYUVToRGB(texture[indices[i][0]].get(), + texture[indices[i][1]].get(), + texture[indices[i][2]].get(), + sizes, + static_cast(space), + false)); if (fp) { SkMatrix viewMatrix; viewMatrix.setTranslate(x, y); grPaint.addColorFragmentProcessor(std::move(fp)); - SkAutoTUnref batch( + sk_sp batch( GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); } x += renderRect.width() + kTestPad; } @@ -201,7 +205,7 @@ protected: return; } - SkAutoTUnref texture[3]; + sk_sp texture[3]; texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0], GrTextureParams::ClampBilerp(), SkSourceGammaTreatment::kRespect)); texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1], GrTextureParams::ClampBilerp(), @@ -229,15 +233,15 @@ protected: GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); sk_sp fp( - GrYUVEffect::MakeYUVToRGB(texture[0], texture[1], texture[2], sizes, - static_cast(space), true)); + GrYUVEffect::MakeYUVToRGB(texture[0].get(), texture[1].get(), texture[2].get(), + sizes, static_cast(space), true)); if (fp) { SkMatrix viewMatrix; viewMatrix.setTranslate(x, y); grPaint.addColorFragmentProcessor(fp); - SkAutoTUnref batch(GrRectBatchFactory::CreateNonAAFill( + sk_sp batch(GrRectBatchFactory::CreateNonAAFill( GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get()); } } } -- cgit v1.2.3