diff options
author | reed <reed@google.com> | 2016-04-04 10:02:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-04 10:02:58 -0700 |
commit | efdfd51b68a300d5c6e28743fe0344ca05d1cec9 (patch) | |
tree | 3cd04d31a56219559e89f6eded6f7a894eb700ba /samplecode | |
parent | 175cf0e51b9fbb075588c4d29e7e4257cea6f4ad (diff) |
switch maskfilters to sk_sp
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1852113003
Review URL: https://codereview.chromium.org/1852113003
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleAll.cpp | 15 | ||||
-rw-r--r-- | samplecode/SampleAnimBlur.cpp | 8 | ||||
-rw-r--r-- | samplecode/SampleBigBlur.cpp | 5 | ||||
-rw-r--r-- | samplecode/SampleBlur.cpp | 12 | ||||
-rw-r--r-- | samplecode/SampleEffects.cpp | 9 | ||||
-rw-r--r-- | samplecode/SampleEmboss.cpp | 3 | ||||
-rw-r--r-- | samplecode/SampleFilterFuzz.cpp | 13 | ||||
-rw-r--r-- | samplecode/SampleFuzz.cpp | 3 | ||||
-rw-r--r-- | samplecode/SampleSlides.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleStrokePath.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleTextAlpha.cpp | 5 | ||||
-rw-r--r-- | samplecode/SampleTextureDomain.cpp | 12 | ||||
-rw-r--r-- | samplecode/SampleXfermodesBlur.cpp | 7 |
13 files changed, 40 insertions, 60 deletions
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index aa08261200..357a437a67 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -77,9 +77,9 @@ private: /////////////////////////////////////////////////////////// static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { - p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)), - SkBlurMaskFilter::kNone_BlurFlag))->unref(); + p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)), + SkBlurMaskFilter::kNone_BlurFlag)); rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); p.setMaskFilter(nullptr); @@ -250,9 +250,9 @@ static void apply_shader(SkPaint* paint, int index) { #if 1 SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 }; - paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss( + paint->setMaskFilter(SkBlurMaskFilter::MakeEmboss( SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)), dir, - SK_Scalar1/4, SkIntToScalar(4)))->unref(); + SK_Scalar1/4, SkIntToScalar(4))); paint->setColor(SK_ColorBLUE); #endif } @@ -379,8 +379,6 @@ protected: light.fDirection[2] = SK_Scalar1/3; light.fAmbient = 0x48; light.fSpecular = 0x80; - SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(12)/5); - SkMaskFilter* embossFilter = SkEmbossMaskFilter::Create(sigma, light); auto lightingFilter = SkColorMatrixFilter::MakeLightingFilter( 0xff89bc45, 0xff112233); @@ -420,7 +418,8 @@ protected: // circle w/ emboss & transparent (exercises 3dshader) canvas->translate(SkIntToScalar(50), 0); - paint.setMaskFilter(embossFilter)->unref(); + paint.setMaskFilter(SkEmbossMaskFilter::Make( + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(12)/5), light)); canvas->drawOval(rect, paint); canvas->translate(SkIntToScalar(10), SkIntToScalar(10)); // paint.setShader(transparentShader)->unref(); diff --git a/samplecode/SampleAnimBlur.cpp b/samplecode/SampleAnimBlur.cpp index 98a3560fe9..5330fdfa71 100644 --- a/samplecode/SampleAnimBlur.cpp +++ b/samplecode/SampleAnimBlur.cpp @@ -46,12 +46,10 @@ protected: SkRandom random; for (size_t i = 0; i < SK_ARRAY_COUNT(gStyles); ++i) { - SkMaskFilter* mf = SkBlurMaskFilter::Create( - gStyles[i], - fBlurSigma, - SkBlurMaskFilter::kHighQuality_BlurFlag); SkPaint paint; - SkSafeUnref(paint.setMaskFilter(mf)); + paint.setMaskFilter(SkBlurMaskFilter::Make(gStyles[i], + fBlurSigma, + SkBlurMaskFilter::kHighQuality_BlurFlag)); paint.setColor(random.nextU() | 0xff000000); canvas->drawCircle(200 * SK_Scalar1 + 400 * (i % 2) * SK_Scalar1, 200 * SK_Scalar1 + i / 2 * 400 * SK_Scalar1, diff --git a/samplecode/SampleBigBlur.cpp b/samplecode/SampleBigBlur.cpp index 800ae24fbd..cb7a419a80 100644 --- a/samplecode/SampleBigBlur.cpp +++ b/samplecode/SampleBigBlur.cpp @@ -29,11 +29,10 @@ protected: SkPaint paint; canvas->save(); paint.setColor(SK_ColorBLUE); - SkMaskFilter* mf = SkBlurMaskFilter::Create( + paint.setMaskFilter(SkBlurMaskFilter::Make( kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)), - SkBlurMaskFilter::kHighQuality_BlurFlag); - paint.setMaskFilter(mf)->unref(); + SkBlurMaskFilter::kHighQuality_BlurFlag)); canvas->translate(200, 200); canvas->drawCircle(100, 100, 200, paint); canvas->restore(); diff --git a/samplecode/SampleBlur.cpp b/samplecode/SampleBlur.cpp index b617691b65..7e6a32562d 100644 --- a/samplecode/SampleBlur.cpp +++ b/samplecode/SampleBlur.cpp @@ -98,10 +98,9 @@ protected: paint.setColor(SK_ColorBLUE); for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { if (gRecs[i].fStyle != NONE) { - SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle, + paint.setMaskFilter(SkBlurMaskFilter::Make(gRecs[i].fStyle, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)), - flags); - paint.setMaskFilter(mf)->unref(); + flags)); } else { paint.setMaskFilter(nullptr); } @@ -110,10 +109,9 @@ protected: } // draw text { - SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)), - flags); - paint.setMaskFilter(mf)->unref(); + paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(4), + flags)); SkScalar x = SkIntToScalar(70); SkScalar y = SkIntToScalar(400); paint.setColor(SK_ColorBLACK); diff --git a/samplecode/SampleEffects.cpp b/samplecode/SampleEffects.cpp index a8f793c160..c998052fab 100644 --- a/samplecode/SampleEffects.cpp +++ b/samplecode/SampleEffects.cpp @@ -22,18 +22,15 @@ static void paint_proc0(SkPaint*) { } static void paint_proc1(SkPaint* paint) { - paint->setMaskFilter(SkBlurMaskFilter::Create( + paint->setMaskFilter(SkBlurMaskFilter::Make( kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2))))->unref(); + SkBlurMask::ConvertRadiusToSigma(2))); } static void paint_proc2(SkPaint* paint) { SkScalar dir[3] = { 1, 1, 1}; paint->setMaskFilter( - SkBlurMaskFilter::CreateEmboss(SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)), - dir, - 0.1f, - 0.05f))->unref(); + SkBlurMaskFilter::MakeEmboss(SkBlurMask::ConvertRadiusToSigma(1), dir, 0.1f, 0.05f)); } static void paint_proc3(SkPaint* paint) { diff --git a/samplecode/SampleEmboss.cpp b/samplecode/SampleEmboss.cpp index 215a1e07d2..f1ea1fe547 100644 --- a/samplecode/SampleEmboss.cpp +++ b/samplecode/SampleEmboss.cpp @@ -50,8 +50,7 @@ protected: paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(SkIntToScalar(10)); - paint.setMaskFilter(SkEmbossMaskFilter::Create( - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)), fLight))->unref(); + paint.setMaskFilter(SkEmbossMaskFilter::Make(SkBlurMask::ConvertRadiusToSigma(4), fLight)); paint.setShader(SkShader::MakeColorShader(SK_ColorBLUE)); paint.setDither(true); diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index 6413aa103f..1b7d30be1d 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -461,13 +461,12 @@ static sk_sp<SkPathEffect> make_path_effect(bool canBeNull = true) { return pathEffect; } -static SkMaskFilter* make_mask_filter() { - SkMaskFilter* maskFilter; +static sk_sp<SkMaskFilter> make_mask_filter() { + sk_sp<SkMaskFilter> maskFilter; switch (R(3)) { case 0: - maskFilter = SkBlurMaskFilter::Create(make_blur_style(), - make_scalar(), - make_blur_mask_filter_flag()); + maskFilter = SkBlurMaskFilter::Make(make_blur_style(), make_scalar(), + make_blur_mask_filter_flag()); case 1: { SkEmbossMaskFilter::Light light; for (int i = 0; i < 3; ++i) { @@ -476,12 +475,10 @@ static SkMaskFilter* make_mask_filter() { light.fPad = R(65536); light.fAmbient = R(256); light.fSpecular = R(256); - maskFilter = SkEmbossMaskFilter::Create(make_scalar(), - light); + maskFilter = SkEmbossMaskFilter::Make(make_scalar(), light); } case 2: default: - maskFilter = nullptr; break; } return maskFilter; diff --git a/samplecode/SampleFuzz.cpp b/samplecode/SampleFuzz.cpp index b8c800ab16..76420f026a 100644 --- a/samplecode/SampleFuzz.cpp +++ b/samplecode/SampleFuzz.cpp @@ -189,8 +189,7 @@ static void do_fuzz(SkCanvas* canvas) { case 7: if (quick == true) break; - SkSafeUnref(paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, - make_number()))); + paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, make_number())); break; case 8: diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp index b4ebb3c30d..4748a766a0 100644 --- a/samplecode/SampleSlides.cpp +++ b/samplecode/SampleSlides.cpp @@ -462,8 +462,8 @@ static void mesh_slide(SkCanvas* canvas) { static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { - p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))))->unref(); + p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(3))); rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); p.setMaskFilter(nullptr); diff --git a/samplecode/SampleStrokePath.cpp b/samplecode/SampleStrokePath.cpp index f3cdee33a6..e69625e9bf 100644 --- a/samplecode/SampleStrokePath.cpp +++ b/samplecode/SampleStrokePath.cpp @@ -165,12 +165,10 @@ protected: kSolid_SkBlurStyle, }; for (int x = 0; x < 5; x++) { - SkMaskFilter* mf; SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)); for (int y = 0; y < 10; y++) { if (x) { - mf = SkBlurMaskFilter::Create(gStyle[x - 1], sigma); - paint.setMaskFilter(mf)->unref(); + paint.setMaskFilter(SkBlurMaskFilter::Make(gStyle[x - 1], sigma)); } canvas->drawText("Title Bar", 9, x*SkIntToScalar(100), y*SkIntToScalar(30), paint); sigma *= 0.75f; diff --git a/samplecode/SampleTextAlpha.cpp b/samplecode/SampleTextAlpha.cpp index a57c01632a..cb07e92b55 100644 --- a/samplecode/SampleTextAlpha.cpp +++ b/samplecode/SampleTextAlpha.cpp @@ -52,9 +52,8 @@ protected: paint.setARGB(fByte, 0xFF, 0xFF, 0xFF); - paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)))); - paint.getMaskFilter()->unref(); + paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(3))); SkRandom rand; diff --git a/samplecode/SampleTextureDomain.cpp b/samplecode/SampleTextureDomain.cpp index 59d0822b44..e615235a57 100644 --- a/samplecode/SampleTextureDomain.cpp +++ b/samplecode/SampleTextureDomain.cpp @@ -77,12 +77,11 @@ protected: // renders correctly srcRect.setXYWH(1, 1, 3, 3); dstRect.setXYWH(5, 405, 305, 305); - SkMaskFilter* mf = SkBlurMaskFilter::Create( + paint.setMaskFilter(SkBlurMaskFilter::Make( kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), SkBlurMaskFilter::kHighQuality_BlurFlag | - SkBlurMaskFilter::kIgnoreTransform_BlurFlag); - paint.setMaskFilter(mf)->unref(); + SkBlurMaskFilter::kIgnoreTransform_BlurFlag)); canvas->drawImageRect(image, srcRect, dstRect, &paint); // Blur and a rotation + nullptr src rect @@ -90,10 +89,9 @@ protected: // but it will test a code path in SkGpuDevice::drawBitmap // that handles blurs with rects transformed to non- // orthogonal rects. It also tests the nullptr src rect handling - mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(5), - SkBlurMaskFilter::kHighQuality_BlurFlag); - paint.setMaskFilter(mf)->unref(); + paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(5), + SkBlurMaskFilter::kHighQuality_BlurFlag)); dstRect.setXYWH(-150, -150, 300, 300); canvas->translate(550, 550); diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp index cab13391ed..af75f89388 100644 --- a/samplecode/SampleXfermodesBlur.cpp +++ b/samplecode/SampleXfermodesBlur.cpp @@ -42,10 +42,9 @@ class XfermodesBlurView : public SampleView { void draw_mode(SkCanvas* canvas, sk_sp<SkXfermode> mode, int alpha, SkScalar x, SkScalar y) { SkPaint p; - SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), - SkBlurMaskFilter::kNone_BlurFlag); - p.setMaskFilter(mf)->unref(); + p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(5), + SkBlurMaskFilter::kNone_BlurFlag)); SkScalar ww = SkIntToScalar(W); SkScalar hh = SkIntToScalar(H); |