aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-29 11:32:50 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-29 11:32:50 -0700
commitcfb6bdf767796c950f89985445738d2d8e7f12b0 (patch)
tree5b412fe9d767eef852f55316a99eb9776751ccaf /gm
parent3ebd2760dd34da6f5af23e9c7cb1b6a61e9cea9d (diff)
switch xfermodes over to sk_sp
Diffstat (limited to 'gm')
-rw-r--r--gm/aarectmodes.cpp10
-rw-r--r--gm/aaxfermodes.cpp10
-rw-r--r--gm/arithmode.cpp9
-rw-r--r--gm/avoidxfermode.cpp17
-rw-r--r--gm/avoidxfermode2.cpp19
-rw-r--r--gm/avoidxfermode3.cpp18
-rw-r--r--gm/bitmaprect.cpp5
-rw-r--r--gm/blurredclippedcircle.cpp2
-rw-r--r--gm/colortypexfermode.cpp4
-rw-r--r--gm/composeshader.cpp7
-rw-r--r--gm/drawatlascolor.cpp2
-rw-r--r--gm/hairmodes.cpp8
-rw-r--r--gm/imagefiltersgraph.cpp26
-rw-r--r--gm/lcdblendmodes.cpp6
-rw-r--r--gm/lcdoverlap.cpp4
-rw-r--r--gm/patch.cpp2
-rw-r--r--gm/pixelxorxfermode.cpp8
-rw-r--r--gm/vertices.cpp3
-rw-r--r--gm/xfermodeimagefilter.cpp38
-rw-r--r--gm/xfermodes.cpp20
-rw-r--r--gm/xfermodes2.cpp4
21 files changed, 85 insertions, 137 deletions
diff --git a/gm/aarectmodes.cpp b/gm/aarectmodes.cpp
index badd1ae450..10fa15a5ef 100644
--- a/gm/aarectmodes.cpp
+++ b/gm/aarectmodes.cpp
@@ -81,8 +81,7 @@ const int gHeight = 64;
const SkScalar W = SkIntToScalar(gWidth);
const SkScalar H = SkIntToScalar(gHeight);
-static SkScalar drawCell(SkCanvas* canvas, SkXfermode* mode,
- SkAlpha a0, SkAlpha a1) {
+static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, SkAlpha a1) {
SkPaint paint;
paint.setAntiAlias(true);
@@ -96,7 +95,7 @@ static SkScalar drawCell(SkCanvas* canvas, SkXfermode* mode,
paint.setColor(SK_ColorRED);
paint.setAlpha(a1);
- paint.setXfermode(mode);
+ paint.setXfermode(std::move(mode));
SkScalar offset = SK_Scalar1 / 3;
SkRect rect = SkRect::MakeXYWH(W / 4 + offset,
@@ -154,17 +153,14 @@ namespace skiagm {
canvas->translate(W * 5, 0);
canvas->save();
}
- SkXfermode* mode = SkXfermode::Create(gModes[i].fMode);
-
canvas->drawRect(bounds, fBGPaint);
canvas->saveLayer(&bounds, nullptr);
- SkScalar dy = drawCell(canvas, mode,
+ SkScalar dy = drawCell(canvas, SkXfermode::Make(gModes[i].fMode),
gAlphaValue[alpha & 1],
gAlphaValue[alpha & 2]);
canvas->restore();
canvas->translate(0, dy * 5 / 4);
- SkSafeUnref(mode);
}
canvas->restore();
canvas->restore();
diff --git a/gm/aaxfermodes.cpp b/gm/aaxfermodes.cpp
index f1264db964..2ea1844e27 100644
--- a/gm/aaxfermodes.cpp
+++ b/gm/aaxfermodes.cpp
@@ -210,7 +210,7 @@ protected:
if (maxSum > 255) {
SkPaint dimPaint;
dimPaint.setAntiAlias(false);
- dimPaint.setXfermode(SkXfermode::Create(SkXfermode::kDstIn_Mode));
+ dimPaint.setXfermode(SkXfermode::Make(SkXfermode::kDstIn_Mode));
if (255 != paint->getAlpha()) {
// Dim the src and dst colors.
dimPaint.setARGB(255 * 255 / maxSum, 0, 0, 0);
@@ -230,13 +230,13 @@ protected:
SkPaint shapePaint(paint);
shapePaint.setAntiAlias(kSquare_Shape != shape);
- SkAutoTUnref<SkXfermode> xfermode;
+ sk_sp<SkXfermode> xfermode;
if (mode <= SkXfermode::kLastMode) {
- xfermode.reset(SkXfermode::Create(mode));
+ xfermode = SkXfermode::Make(mode);
} else {
- xfermode.reset(SkArithmeticMode::Create(+1.0f, +0.25f, -0.5f, +0.1f));
+ xfermode = SkArithmeticMode::Make(+1.0f, +0.25f, -0.5f, +0.1f);
}
- shapePaint.setXfermode(xfermode);
+ shapePaint.setXfermode(std::move(xfermode));
switch (shape) {
case kSquare_Shape:
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp
index bddd2005f8..cd074d4b12 100644
--- a/gm/arithmode.cpp
+++ b/gm/arithmode.cpp
@@ -110,9 +110,8 @@ protected:
SkRect rect = SkRect::MakeXYWH(x, y, SkIntToScalar(WW), SkIntToScalar(HH));
canvas->saveLayer(&rect, nullptr);
canvas->drawBitmap(dst, x, y, nullptr);
- SkXfermode* xfer = SkArithmeticMode::Create(k[0], k[1], k[2], k[3]);
SkPaint paint;
- paint.setXfermode(xfer)->unref();
+ paint.setXfermode(SkArithmeticMode::Make(k[0], k[1], k[2], k[3]));
canvas->drawBitmap(src, x, y, &paint);
canvas->restore();
x += gap;
@@ -133,13 +132,11 @@ protected:
x += gap;
SkRect rect = SkRect::MakeXYWH(x, y, SkIntToScalar(WW), SkIntToScalar(HH));
canvas->saveLayer(&rect, nullptr);
- SkXfermode* xfer1 = SkArithmeticMode::Create(0, -one / 2, 0, 1, enforcePMColor);
SkPaint paint1;
- paint1.setXfermode(xfer1)->unref();
+ paint1.setXfermode(SkArithmeticMode::Make(0, -one / 2, 0, 1, enforcePMColor));
canvas->drawBitmap(dst, x, y, &paint1);
- SkXfermode* xfer2 = SkArithmeticMode::Create(0, one / 2, -one, 1);
SkPaint paint2;
- paint2.setXfermode(xfer2)->unref();
+ paint2.setXfermode(SkArithmeticMode::Make(0, one / 2, -one, 1));
canvas->drawBitmap(dst, x, y, &paint2);
canvas->restore();
x += gap;
diff --git a/gm/avoidxfermode.cpp b/gm/avoidxfermode.cpp
index d224b4e2d0..8e8dc28553 100644
--- a/gm/avoidxfermode.cpp
+++ b/gm/avoidxfermode.cpp
@@ -37,9 +37,7 @@ protected:
// UL corner: replace white with black with a tight tolerance
SkPaint p1;
p1.setColor(SK_ColorBLACK);
- p1.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
- 5,
- SkAvoidXfermode::kTargetColor_Mode))->unref();
+ p1.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 5, SkAvoidXfermode::kTargetColor_Mode));
canvas->drawRect(r, p1);
@@ -48,9 +46,8 @@ protected:
// UR corner: draw black everywhere except white with a tight tolerance
SkPaint p2;
p2.setColor(SK_ColorBLACK);
- p2.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
- 250,
- SkAvoidXfermode::kAvoidColor_Mode))->unref();
+ p2.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 250,
+ SkAvoidXfermode::kAvoidColor_Mode));
canvas->drawRect(r, p2);
@@ -59,9 +56,7 @@ protected:
// LL corner: replace red with transparent blue with a loose tolerance
SkPaint p3;
p3.setColor(0x7F0000FF);
- p3.setXfermode(SkAvoidXfermode::Create(SK_ColorRED,
- 250,
- SkAvoidXfermode::kTargetColor_Mode))->unref();
+ p3.setXfermode(SkAvoidXfermode::Make(SK_ColorRED, 250, SkAvoidXfermode::kTargetColor_Mode));
canvas->drawRect(r, p3);
@@ -70,9 +65,7 @@ protected:
// LR corner: draw black everywhere except red with a loose tolerance
SkPaint p4;
p4.setColor(SK_ColorBLACK);
- p4.setXfermode(SkAvoidXfermode::Create(SK_ColorRED,
- 5,
- SkAvoidXfermode::kAvoidColor_Mode))->unref();
+ p4.setXfermode(SkAvoidXfermode::Make(SK_ColorRED, 5, SkAvoidXfermode::kAvoidColor_Mode));
canvas->drawRect(r, p4);
}
diff --git a/gm/avoidxfermode2.cpp b/gm/avoidxfermode2.cpp
index 039ed4017b..9fe7d3321b 100644
--- a/gm/avoidxfermode2.cpp
+++ b/gm/avoidxfermode2.cpp
@@ -35,9 +35,8 @@ protected:
// UL corner: replace the green with a tight tolerance
SkPaint p1;
p1.setColor(SK_ColorRED);
- p1.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN,
- 55,
- SkAvoidXfermode::kTargetColor_Mode))->unref();
+ p1.setXfermode(SkAvoidXfermode::Make(SK_ColorGREEN, 55,
+ SkAvoidXfermode::kTargetColor_Mode));
canvas->drawRect(r, p1);
@@ -46,9 +45,8 @@ protected:
// UR corner: avoid the green with a tight tolerance
SkPaint p2;
p2.setColor(SK_ColorRED);
- p2.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN,
- 200,
- SkAvoidXfermode::kAvoidColor_Mode))->unref();
+ p2.setXfermode(SkAvoidXfermode::Make(SK_ColorGREEN, 200,
+ SkAvoidXfermode::kAvoidColor_Mode));
canvas->drawRect(r, p2);
@@ -57,9 +55,8 @@ protected:
// LL corner: replace the green with a loose tolerance
SkPaint p3;
p3.setColor(SK_ColorRED);
- p3.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN,
- 200,
- SkAvoidXfermode::kTargetColor_Mode))->unref();
+ p3.setXfermode(SkAvoidXfermode::Make(SK_ColorGREEN, 200,
+ SkAvoidXfermode::kTargetColor_Mode));
canvas->drawRect(r, p3);
@@ -68,9 +65,7 @@ protected:
// LR corner: avoid the green with a loose tolerance
SkPaint p4;
p4.setColor(SK_ColorRED);
- p4.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN,
- 55,
- SkAvoidXfermode::kAvoidColor_Mode))->unref();
+ p4.setXfermode(SkAvoidXfermode::Make(SK_ColorGREEN, 55, SkAvoidXfermode::kAvoidColor_Mode));
canvas->drawRect(r, p4);
}
diff --git a/gm/avoidxfermode3.cpp b/gm/avoidxfermode3.cpp
index c88b2a2ab1..a635ae47ac 100644
--- a/gm/avoidxfermode3.cpp
+++ b/gm/avoidxfermode3.cpp
@@ -38,9 +38,7 @@ protected:
SkPaint p1;
p1.setColor(SK_ColorGREEN);
p1.setAntiAlias(true);
- p1.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
- 5,
- SkAvoidXfermode::kTargetColor_Mode))->unref();
+ p1.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 5, SkAvoidXfermode::kTargetColor_Mode));
canvas->drawRect(r, p1);
@@ -50,9 +48,8 @@ protected:
SkPaint p2;
p2.setColor(SK_ColorRED);
p2.setAntiAlias(true);
- p2.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
- 250,
- SkAvoidXfermode::kAvoidColor_Mode))->unref();
+ p2.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 250,
+ SkAvoidXfermode::kAvoidColor_Mode));
canvas->drawRect(r, p2);
@@ -62,9 +59,8 @@ protected:
SkPaint p3;
p3.setColor(SK_ColorBLUE);
p3.setAntiAlias(true);
- p3.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
- 250,
- SkAvoidXfermode::kTargetColor_Mode))->unref();
+ p3.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 250,
+ SkAvoidXfermode::kTargetColor_Mode));
canvas->drawRect(r, p3);
@@ -74,9 +70,7 @@ protected:
SkPaint p4;
p4.setColor(SK_ColorYELLOW);
p4.setAntiAlias(true);
- p4.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
- 5,
- SkAvoidXfermode::kAvoidColor_Mode))->unref();
+ p4.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 5, SkAvoidXfermode::kAvoidColor_Mode));
canvas->drawRect(r, p4);
}
diff --git a/gm/bitmaprect.cpp b/gm/bitmaprect.cpp
index 4853d03a52..4db6e2fe95 100644
--- a/gm/bitmaprect.cpp
+++ b/gm/bitmaprect.cpp
@@ -199,12 +199,9 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
-
- SkXfermode* mode = SkXfermode::Create(SkXfermode::kXor_Mode);
-
SkPaint paint;
paint.setAlpha(128);
- paint.setXfermode(mode)->unref();
+ paint.setXfermode(SkXfermode::Make(SkXfermode::kXor_Mode));
SkRect srcR1 = { 0.0f, 0.0f, 4096.0f, 2040.0f };
SkRect dstR1 = { 10.1f, 10.1f, 629.9f, 400.9f };
diff --git a/gm/blurredclippedcircle.cpp b/gm/blurredclippedcircle.cpp
index 3bbff755e9..d162ac1110 100644
--- a/gm/blurredclippedcircle.cpp
+++ b/gm/blurredclippedcircle.cpp
@@ -34,7 +34,7 @@ protected:
void onDraw(SkCanvas* canvas) override {
SkPaint whitePaint;
whitePaint.setColor(SK_ColorWHITE);
- whitePaint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode))->unref();
+ whitePaint.setXfermode(SkXfermode::Make(SkXfermode::kSrc_Mode));
whitePaint.setAntiAlias(true);
// This scale exercises precision limits in the circle blur effect (crbug.com/560651)
diff --git a/gm/colortypexfermode.cpp b/gm/colortypexfermode.cpp
index 3489f36557..36db2aa3f5 100644
--- a/gm/colortypexfermode.cpp
+++ b/gm/colortypexfermode.cpp
@@ -121,8 +121,6 @@ protected:
SkScalar y0 = 0;
SkScalar x = x0, y = y0;
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
- SkXfermode* mode = SkXfermode::Create(gModes[i].fMode);
- SkAutoUnref aur(mode);
SkRect r;
r.set(x, y, x+w, y+h);
@@ -136,7 +134,7 @@ protected:
p.setShader(nullptr);
canvas->drawRect(r, p);
- textP.setXfermode(mode);
+ textP.setXfermode(SkXfermode::Make(gModes[i].fMode));
canvas->drawText("H", 1, x+ w/10.f, y + 7.f*h/8.f, textP);
#if 1
canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel),
diff --git a/gm/composeshader.cpp b/gm/composeshader.cpp
index 421641c356..efcfe79afe 100644
--- a/gm/composeshader.cpp
+++ b/gm/composeshader.cpp
@@ -30,9 +30,8 @@ static sk_sp<SkShader> make_shader(SkXfermode::Mode mode) {
colors[1] = SkColorSetARGB(0x80, 0, 0, 0);
auto shaderB = SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
- SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode));
-
- return SkShader::MakeComposeShader(std::move(shaderA), std::move(shaderB), xfer);
+ return SkShader::MakeComposeShader(std::move(shaderA), std::move(shaderB),
+ SkXfermode::Make(mode));
}
class ComposeShaderGM : public skiagm::GM {
@@ -176,7 +175,7 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
- SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kDstOver_Mode));
+ auto xfer(SkXfermode::Make(SkXfermode::kDstOver_Mode));
sk_sp<SkShader> shaders[] = {
// gradient should appear over color bitmap
diff --git a/gm/drawatlascolor.cpp b/gm/drawatlascolor.cpp
index 0e85055402..3331482538 100644
--- a/gm/drawatlascolor.cpp
+++ b/gm/drawatlascolor.cpp
@@ -26,7 +26,7 @@ static sk_sp<SkImage> make_atlas(SkCanvas* caller, int atlasSize) {
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
- paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode));
+ paint.setXfermode(SkXfermode::Make(SkXfermode::kSrc_Mode));
paint.setColor(SK_ColorWHITE);
SkRect r = SkRect::MakeXYWH(0, 0,
diff --git a/gm/hairmodes.cpp b/gm/hairmodes.cpp
index 15e75fe847..2651d04104 100644
--- a/gm/hairmodes.cpp
+++ b/gm/hairmodes.cpp
@@ -33,7 +33,7 @@ const int gHeight = 64;
const SkScalar W = SkIntToScalar(gWidth);
const SkScalar H = SkIntToScalar(gHeight);
-static SkScalar drawCell(SkCanvas* canvas, SkXfermode* mode, SkAlpha a0, SkAlpha a1) {
+static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, SkAlpha a1) {
SkPaint paint;
paint.setAntiAlias(true);
@@ -47,7 +47,7 @@ static SkScalar drawCell(SkCanvas* canvas, SkXfermode* mode, SkAlpha a0, SkAlpha
paint.setColor(SK_ColorRED);
paint.setAlpha(a1);
- paint.setXfermode(mode);
+ paint.setXfermode(std::move(mode));
for (int angle = 0; angle < 24; ++angle) {
SkScalar x = SkScalarCos(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gWidth;
SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gHeight;
@@ -101,17 +101,15 @@ namespace skiagm {
canvas->translate(W * 5, 0);
canvas->save();
}
- SkXfermode* mode = SkXfermode::Create(gModes[i].fMode);
canvas->drawRect(bounds, fBGPaint);
canvas->saveLayer(&bounds, nullptr);
- SkScalar dy = drawCell(canvas, mode,
+ SkScalar dy = drawCell(canvas, SkXfermode::Make(gModes[i].fMode),
gAlphaValue[alpha & 1],
gAlphaValue[alpha & 2]);
canvas->restore();
canvas->translate(0, dy * 5 / 4);
- SkSafeUnref(mode);
}
canvas->restore();
canvas->restore();
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index 547a3bbbe2..53343bc3d0 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -140,11 +140,10 @@ protected:
auto matrixFilter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
SkAutoTUnref<SkImageFilter> colorMorph(SkColorFilterImageFilter::Create(matrixFilter.get(), morph));
- SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOver_Mode));
- SkAutoTUnref<SkImageFilter> blendColor(SkXfermodeImageFilter::Create(mode, colorMorph));
-
SkPaint paint;
- paint.setImageFilter(blendColor);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(
+ SkXfermode::Make(SkXfermode::kSrcOver_Mode), colorMorph));
+
DrawClippedImage(canvas, fImage.get(), paint);
canvas->translate(SkIntToScalar(100), 0);
}
@@ -158,12 +157,11 @@ protected:
SkAutoTUnref<SkImageFilter> offsetFilter(
SimpleOffsetFilter::Create(10.0f, 10.f, matrixFilter));
- SkAutoTUnref<SkXfermode> arith(SkArithmeticMode::Create(0, SK_Scalar1, SK_Scalar1, 0));
- SkAutoTUnref<SkImageFilter> arithFilter(
- SkXfermodeImageFilter::Create(arith, matrixFilter, offsetFilter));
-
SkPaint paint;
- paint.setImageFilter(arithFilter);
+ paint.setImageFilter(
+ SkXfermodeImageFilter::Make(SkArithmeticMode::Make(0, SK_Scalar1, SK_Scalar1, 0),
+ matrixFilter, offsetFilter, nullptr));
+
DrawClippedImage(canvas, fImage.get(), paint);
canvas->translate(SkIntToScalar(100), 0);
}
@@ -171,13 +169,11 @@ protected:
SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(
SkIntToScalar(10), SkIntToScalar(10)));
- SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_Mode));
SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), SkIntToScalar(100)));
- SkAutoTUnref<SkImageFilter> blend(
- SkXfermodeImageFilter::Create(mode, blur, nullptr, &cropRect));
-
SkPaint paint;
- paint.setImageFilter(blend);
+ paint.setImageFilter(
+ SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kSrcIn_Mode), blur,
+ nullptr, &cropRect));
DrawClippedImage(canvas, fImage.get(), paint);
canvas->translate(SkIntToScalar(100), 0);
}
@@ -188,8 +184,6 @@ protected:
// (supplied by the dilate).
SkAutoTUnref<SkImageFilter> dilate(SkDilateImageFilter::Create(5, 5));
- SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_Mode));
-
SkScalar kernel[9] = {
SkIntToScalar(-1), SkIntToScalar( -1 ), SkIntToScalar(-1),
SkIntToScalar(-1), SkIntToScalar( 7 ), SkIntToScalar(-1),
diff --git a/gm/lcdblendmodes.cpp b/gm/lcdblendmodes.cpp
index 8ac944980a..42359e3aef 100644
--- a/gm/lcdblendmodes.cpp
+++ b/gm/lcdblendmodes.cpp
@@ -76,8 +76,7 @@ protected:
this->drawColumn(surfCanvas, SK_ColorCYAN, SK_ColorMAGENTA, true);
SkPaint surfPaint;
- SkAutoTUnref<SkXfermode> xfermode(SkXfermode::Create(SkXfermode::kSrcOver_Mode));
- surfPaint.setXfermode(xfermode);
+ surfPaint.setXfermode(SkXfermode::Make(SkXfermode::kSrcOver_Mode));
surface->draw(canvas, 0, 0, &surfPaint);
}
@@ -123,14 +122,13 @@ protected:
backgroundPaint);
SkScalar y = fTextHeight;
for (size_t m = 0; m < SK_ARRAY_COUNT(gModes); m++) {
- SkAutoTUnref<SkXfermode> xfermode(SkXfermode::Create(gModes[m].fMode));
SkPaint paint;
paint.setColor(textColor);
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setLCDRenderText(true);
paint.setTextSize(fTextHeight);
- paint.setXfermode(xfermode);
+ paint.setXfermode(SkXfermode::Make(gModes[m].fMode));
sk_tool_utils::set_portable_typeface(&paint);
if (useGrad) {
SkRect r;
diff --git a/gm/lcdoverlap.cpp b/gm/lcdoverlap.cpp
index 17775646a6..aae27d8c1a 100644
--- a/gm/lcdoverlap.cpp
+++ b/gm/lcdoverlap.cpp
@@ -60,8 +60,8 @@ protected:
SK_ColorMAGENTA,
};
- SkAutoTUnref<SkXfermode> xfermode(SkXfermode::Create(mode));
- SkAutoTUnref<SkXfermode> xfermode2(SkXfermode::Create(mode2));
+ sk_sp<SkXfermode> xfermode(SkXfermode::Make(mode));
+ sk_sp<SkXfermode> xfermode2(SkXfermode::Make(mode2));
for (size_t i = 0; i < SK_ARRAY_COUNT(colors); i++) {
canvas->save();
canvas->translate(x, y);
diff --git a/gm/patch.cpp b/gm/patch.cpp
index d27c4e1a85..40eb46f4b6 100644
--- a/gm/patch.cpp
+++ b/gm/patch.cpp
@@ -95,7 +95,7 @@ DEF_SIMPLE_GM(patch_primitive, canvas, 800, 800) {
canvas->save();
for (int y = 0; y < 3; y++) {
- SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(modes[y]));
+ sk_sp<SkXfermode> xfer(SkXfermode::Make(modes[y]));
for (int x = 0; x < 4; x++) {
canvas->save();
diff --git a/gm/pixelxorxfermode.cpp b/gm/pixelxorxfermode.cpp
index daccca8c41..6a490e1767 100644
--- a/gm/pixelxorxfermode.cpp
+++ b/gm/pixelxorxfermode.cpp
@@ -38,7 +38,7 @@ protected:
// the green & blue channels alone
SkPaint p1;
p1.setColor(SK_ColorBLACK); // noop
- p1.setXfermode(SkPixelXorXfermode::Create(0x7FFF0000))->unref();
+ p1.setXfermode(SkPixelXorXfermode::Make(0x7FFF0000));
canvas->drawRect(r, p1);
@@ -47,7 +47,7 @@ protected:
// Negate the dst color via the src color
SkPaint p2;
p2.setColor(SK_ColorWHITE);
- p2.setXfermode(SkPixelXorXfermode::Create(SK_ColorBLACK))->unref(); // noop
+ p2.setXfermode(SkPixelXorXfermode::Make(SK_ColorBLACK)); // noop
canvas->drawRect(r, p2);
@@ -56,7 +56,7 @@ protected:
// Just return the original color
SkPaint p3;
p3.setColor(SK_ColorBLACK); // noop
- p3.setXfermode(SkPixelXorXfermode::Create(SK_ColorBLACK))->unref(); // noop
+ p3.setXfermode(SkPixelXorXfermode::Make(SK_ColorBLACK)); // noop
canvas->drawRect(r, p3);
@@ -66,7 +66,7 @@ protected:
// the blue channel alone
SkPaint p4;
p4.setColor(SK_ColorBLACK); // noop
- p4.setXfermode(SkPixelXorXfermode::Create(SK_ColorYELLOW))->unref();
+ p4.setXfermode(SkPixelXorXfermode::Make(SK_ColorYELLOW));
canvas->drawRect(r, p4);
}
diff --git a/gm/vertices.cpp b/gm/vertices.cpp
index 9c4ccc16bb..978d9e69c5 100644
--- a/gm/vertices.cpp
+++ b/gm/vertices.cpp
@@ -154,7 +154,7 @@ protected:
canvas->translate(4, 4);
int x = 0;
for (size_t j = 0; j < SK_ARRAY_COUNT(modes); ++j) {
- SkXfermode* xfer = SkXfermode::Create(modes[j]);
+ auto xfer = SkXfermode::Make(modes[j]);
canvas->save();
for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
paint.setShader(rec[i].fShader);
@@ -170,7 +170,6 @@ protected:
}
canvas->restore();
canvas->translate(0, 40);
- SkSafeUnref(xfer);
}
}
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index 805e2201ea..90e2dd0c2b 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -87,9 +87,8 @@ protected:
int x = 0, y = 0;
SkAutoTUnref<SkImageFilter> background(SkImageSource::Create(fCheckerboard.get()));
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
- SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(gModes[i].fMode));
- SkAutoTUnref<SkImageFilter> filter(SkXfermodeImageFilter::Create(mode, background));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(gModes[i].fMode),
+ background));
DrawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -98,9 +97,8 @@ protected:
}
}
// Test arithmetic mode as image filter
- SkAutoTUnref<SkXfermode> mode(SkArithmeticMode::Create(0, SK_Scalar1, SK_Scalar1, 0));
- SkAutoTUnref<SkImageFilter> filter(SkXfermodeImageFilter::Create(mode, background));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(
+ SkArithmeticMode::Make(0, SK_Scalar1, SK_Scalar1, 0), background));
DrawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -108,8 +106,7 @@ protected:
y += fBitmap.height() + MARGIN;
}
// Test nullptr mode
- filter.reset(SkXfermodeImageFilter::Create(nullptr, background));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(nullptr, background));
DrawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -125,9 +122,9 @@ protected:
SkIntToScalar(4), SkIntToScalar(-4), foreground));
SkAutoTUnref<SkImageFilter> offsetBackground(SkOffsetImageFilter::Create(
SkIntToScalar(4), SkIntToScalar(4), background));
- mode.reset(SkXfermode::Create(SkXfermode::kSrcOver_Mode));
- filter.reset(SkXfermodeImageFilter::Create(mode, offsetBackground, offsetForeground));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(
+ SkXfermode::Make(SkXfermode::kSrcOver_Mode), offsetBackground,
+ offsetForeground, nullptr));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -135,9 +132,8 @@ protected:
y += fBitmap.height() + MARGIN;
}
// Test offsets on Darken (uses shader blend)
- mode.reset(SkXfermode::Create(SkXfermode::kDarken_Mode));
- filter.reset(SkXfermodeImageFilter::Create(mode, offsetBackground, offsetForeground));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kDarken_Mode),
+ offsetBackground, offsetForeground, nullptr));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -158,10 +154,8 @@ protected:
fBitmap.width() + offsets[i][2],
fBitmap.height() + offsets[i][3]);
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
- mode.reset(SkXfermode::Create(sampledModes[i]));
- filter.reset(SkXfermodeImageFilter::Create(
- mode, offsetBackground, offsetForeground, &rect));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(
+ SkXfermode::Make(sampledModes[i]), offsetBackground, offsetForeground, &rect));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -170,12 +164,11 @@ protected:
}
}
// Test small bg, large fg with Screen (uses shader blend)
- mode.reset(SkXfermode::Create(SkXfermode::kScreen_Mode));
+ auto mode = SkXfermode::Make(SkXfermode::kScreen_Mode);
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(10, 10, 60, 60));
SkAutoTUnref<SkImageFilter> cropped(
SkOffsetImageFilter::Create(0, 0, foreground, &cropRect));
- filter.reset(SkXfermodeImageFilter::Create(mode, cropped, background));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(mode, cropped, background, nullptr));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -183,8 +176,7 @@ protected:
y += fBitmap.height() + MARGIN;
}
// Test small fg, large bg with Screen (uses shader blend)
- filter.reset(SkXfermodeImageFilter::Create(mode, background, cropped));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropped, nullptr));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp
index 821bb8cc75..331c3d156c 100644
--- a/gm/xfermodes.cpp
+++ b/gm/xfermodes.cpp
@@ -24,19 +24,19 @@ enum CustomModes {
kAvoid_CustomMode = 3 << kCustomShift,
};
-static SkXfermode* make_custom(int customMode) {
+static sk_sp<SkXfermode> make_custom(int customMode) {
switch (customMode) {
case kArithmetic_CustomMode: {
const SkScalar k1 = 0.25;
const SkScalar k2 = 0.75;
const SkScalar k3 = 0.75;
const SkScalar k4 = -0.25;
- return SkArithmeticMode::Create(k1, k2, k3, k4);
+ return SkArithmeticMode::Make(k1, k2, k3, k4);
}
case kPixelXor_CustomMode:
- return SkPixelXorXfermode::Create(0xFF88CC44);
+ return SkPixelXorXfermode::Make(0xFF88CC44);
case kAvoid_CustomMode:
- return SkAvoidXfermode::Create(0xFFFF0000, 0x44, SkAvoidXfermode::kAvoidColor_Mode);
+ return SkAvoidXfermode::Make(0xFFFF0000, 0x44, SkAvoidXfermode::kAvoidColor_Mode);
default:
break;
}
@@ -155,7 +155,7 @@ class XfermodesGM : public skiagm::GM {
* uses the implied shape of the drawing command and these modes
* demonstrate that.
*/
- void draw_mode(SkCanvas* canvas, SkXfermode* mode, SrcType srcType,
+ void draw_mode(SkCanvas* canvas, sk_sp<SkXfermode> mode, SrcType srcType,
SkScalar x, SkScalar y) {
SkPaint p;
SkMatrix m;
@@ -163,7 +163,7 @@ class XfermodesGM : public skiagm::GM {
m.setTranslate(x, y);
canvas->drawBitmap(fSrcB, x, y, &p);
- p.setXfermode(mode);
+ p.setXfermode(std::move(mode));
switch (srcType) {
case kSmallTransparentImage_SrcType: {
m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y);
@@ -279,11 +279,11 @@ protected:
if ((gModes[i].fSourceTypeMask & sourceType) == 0) {
continue;
}
- SkAutoTUnref<SkXfermode> mode;
+ sk_sp<SkXfermode> mode;
if (gModes[i].fSourceTypeMask & kCustomMask) {
- mode.reset(make_custom(gModes[i].fSourceTypeMask & kCustomMask));
+ mode = make_custom(gModes[i].fSourceTypeMask & kCustomMask);
} else {
- mode.reset(SkXfermode::Create(gModes[i].fMode));
+ mode = SkXfermode::Make(gModes[i].fMode);
}
SkRect r;
r.set(x, y, x+w, y+h);
@@ -294,7 +294,7 @@ protected:
canvas->drawRect(r, p);
canvas->saveLayer(&r, nullptr);
- draw_mode(canvas, mode, static_cast<SrcType>(sourceType),
+ draw_mode(canvas, std::move(mode), static_cast<SrcType>(sourceType),
r.fLeft, r.fTop);
canvas->restore();
diff --git a/gm/xfermodes2.cpp b/gm/xfermodes2.cpp
index 0956af66df..b0d6ca3def 100644
--- a/gm/xfermodes2.cpp
+++ b/gm/xfermodes2.cpp
@@ -41,8 +41,6 @@ protected:
SkScalar x = 0, y = 0;
for (size_t m = 0; m <= SkXfermode::kLastMode; m++) {
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m);
- SkXfermode* xm = SkXfermode::Create(mode);
- SkAutoUnref aur(xm);
canvas->save();
@@ -59,7 +57,7 @@ protected:
p.setShader(fDst);
canvas->drawRect(r, p);
p.setShader(fSrc);
- p.setXfermode(xm);
+ p.setXfermode(SkXfermode::Make(mode));
canvas->drawRect(r, p);
canvas->restore();