aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-08 18:50:00 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-08 18:50:00 -0800
commit8a21c9fe7f5fef9e87115defef27bd7218419f28 (patch)
tree1dd8b9eda9eae99b33bc88b97bd5f0a7a0769dc3 /gm
parent042f859c19f71ca9feacddd1cb058ff59eed8963 (diff)
use Make instead of Create to return a shared shader
Partially updated call sites. Undefine the flag in SkSHader.h to convert the remaining sites. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1772463002 Review URL: https://codereview.chromium.org/1772463002
Diffstat (limited to 'gm')
-rw-r--r--gm/alphagradients.cpp5
-rw-r--r--gm/arithmode.cpp10
-rw-r--r--gm/badpaint.cpp9
-rw-r--r--gm/bitmapshader.cpp13
-rw-r--r--gm/gm.cpp7
-rw-r--r--gm/lcdblendmodes.cpp6
-rw-r--r--gm/pixelsnap.cpp2
7 files changed, 20 insertions, 32 deletions
diff --git a/gm/alphagradients.cpp b/gm/alphagradients.cpp
index 71ec27c975..65fa0c4082 100644
--- a/gm/alphagradients.cpp
+++ b/gm/alphagradients.cpp
@@ -28,9 +28,8 @@ protected:
SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fBottom } };
SkPaint paint;
uint32_t flags = doPreMul ? SkGradientShader::kInterpolateColorsInPremul_Flag : 0;
- SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, 2,
- SkShader::kClamp_TileMode, flags, nullptr);
- paint.setShader(s)->unref();
+ paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
+ SkShader::kClamp_TileMode, flags, nullptr));
canvas->drawRect(r, paint);
paint.setShader(nullptr);
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp
index eb2ecb8abd..bddd2005f8 100644
--- a/gm/arithmode.cpp
+++ b/gm/arithmode.cpp
@@ -31,9 +31,8 @@ static SkBitmap make_src() {
SK_ColorTRANSPARENT, SK_ColorGREEN, SK_ColorCYAN,
SK_ColorRED, SK_ColorMAGENTA, SK_ColorWHITE,
};
- SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
- paint.setShader(s)->unref();
+ paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode));
canvas.drawPaint(paint);
return bm;
}
@@ -47,9 +46,8 @@ static SkBitmap make_dst() {
SK_ColorBLUE, SK_ColorYELLOW, SK_ColorBLACK, SK_ColorGREEN,
sk_tool_utils::color_to_565(SK_ColorGRAY)
};
- SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
- paint.setShader(s)->unref();
+ paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode));
canvas.drawPaint(paint);
return bm;
}
diff --git a/gm/badpaint.cpp b/gm/badpaint.cpp
index 7c51c749ee..85eaa1ed10 100644
--- a/gm/badpaint.cpp
+++ b/gm/badpaint.cpp
@@ -32,14 +32,13 @@ protected:
// Empty bitmap.
fPaints.push_back().setColor(SK_ColorGREEN);
- fPaints.back().setShader(SkShader::CreateBitmapShader(emptyBmp, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode))->unref();
+ fPaints.back().setShader(SkShader::MakeBitmapShader(emptyBmp, SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode));
// Non-invertible local matrix.
fPaints.push_back().setColor(SK_ColorGREEN);
- fPaints.back().setShader(SkShader::CreateBitmapShader(blueBmp, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode,
- &badMatrix))->unref();
+ fPaints.back().setShader(SkShader::MakeBitmapShader(blueBmp, SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode, &badMatrix));
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/bitmapshader.cpp b/gm/bitmapshader.cpp
index 5d7b35c2cd..491905afb3 100644
--- a/gm/bitmapshader.cpp
+++ b/gm/bitmapshader.cpp
@@ -35,11 +35,6 @@ static void draw_mask(SkBitmap* bm) {
canvas.drawCircle(10, 10, 10, circlePaint);
}
-static void adopt_shader(SkPaint* paint, SkShader* shader) {
- paint->setShader(shader);
- SkSafeUnref(shader);
-}
-
class BitmapShaderGM : public GM {
protected:
@@ -69,8 +64,8 @@ protected:
}
canvas->save();
- adopt_shader(&paint, SkShader::CreateBitmapShader(fBitmap, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode, &s));
+ paint.setShader(SkShader::MakeBitmapShader(fBitmap, SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode, &s));
// draw the shader with a bitmap mask
canvas->drawBitmap(fMask, 0, 0, &paint);
@@ -91,8 +86,8 @@ protected:
canvas->translate(0, 25);
- adopt_shader(&paint, SkShader::CreateBitmapShader(fMask, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &s));
+ paint.setShader(SkShader::MakeBitmapShader(fMask, SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode, &s));
paint.setColor(SK_ColorRED);
// draw the mask using the shader and a color
diff --git a/gm/gm.cpp b/gm/gm.cpp
index dc882fd646..ebdc4f183c 100644
--- a/gm/gm.cpp
+++ b/gm/gm.cpp
@@ -85,10 +85,9 @@ void GM::DrawGpuOnlyMessage(SkCanvas* canvas) {
SkMatrix localM;
localM.setRotate(35.f);
localM.postTranslate(10.f, 0.f);
- SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(bmp, SkShader::kMirror_TileMode,
- SkShader::kMirror_TileMode,
- &localM));
- paint.setShader(shader);
+ paint.setShader(SkShader::MakeBitmapShader(bmp, SkShader::kMirror_TileMode,
+ SkShader::kMirror_TileMode,
+ &localM));
paint.setFilterQuality(kMedium_SkFilterQuality);
canvas->drawPaint(paint);
return;
diff --git a/gm/lcdblendmodes.cpp b/gm/lcdblendmodes.cpp
index a2405349eb..d7a9024204 100644
--- a/gm/lcdblendmodes.cpp
+++ b/gm/lcdblendmodes.cpp
@@ -48,9 +48,7 @@ protected:
}
void onOnceBeforeDraw() override {
- fCheckerboard.reset(sk_tool_utils::create_checkerboard_shader(SK_ColorBLACK,
- SK_ColorWHITE,
- 4));
+ fCheckerboard = sk_tool_utils::create_checkerboard_shader(SK_ColorBLACK, SK_ColorWHITE, 4);
}
SkISize onISize() override { return SkISize::Make(kWidth, kHeight); }
@@ -148,7 +146,7 @@ protected:
private:
SkScalar fTextHeight;
- SkAutoTUnref<SkShader> fCheckerboard;
+ sk_sp<SkShader> fCheckerboard;
typedef skiagm::GM INHERITED;
};
diff --git a/gm/pixelsnap.cpp b/gm/pixelsnap.cpp
index 5f1a745b14..7791acb0d0 100644
--- a/gm/pixelsnap.cpp
+++ b/gm/pixelsnap.cpp
@@ -37,7 +37,7 @@ protected:
bgPaint.setShader(
sk_tool_utils::create_checkerboard_shader(
sk_tool_utils::color_to_565(0xFFAAAAAA),
- sk_tool_utils::color_to_565(0xFF777777), 1))->unref();
+ sk_tool_utils::color_to_565(0xFF777777), 1));
canvas->drawPaint(bgPaint);
SkString offset;