aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/gradientDirtyLaundry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gm/gradientDirtyLaundry.cpp')
-rw-r--r--gm/gradientDirtyLaundry.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/gm/gradientDirtyLaundry.cpp b/gm/gradientDirtyLaundry.cpp
index 8ef5fc9229..3fca7f276c 100644
--- a/gm/gradientDirtyLaundry.cpp
+++ b/gm/gradientDirtyLaundry.cpp
@@ -35,27 +35,22 @@ static const GradData gGradData[] = {
// { 2, gCol2, nullptr },
};
-static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCount, tm);
+static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+ return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCount, tm);
}
-static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
- SkPoint center;
- center.set(SkScalarAve(pts[0].fX, pts[1].fX),
- SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::CreateRadial(center, center.fX, data.fColors,
- data.fPos, data.fCount, tm);
+static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+ const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) };
+ return SkGradientShader::MakeRadial(pt, pt.fX, data.fColors, data.fPos, data.fCount, tm);
}
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode) {
- SkPoint center;
- center.set(SkScalarAve(pts[0].fX, pts[1].fX),
- SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
+static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode) {
+ const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) };
+ return SkGradientShader::MakeSweep(pt.fX, pt.fY, data.fColors, data.fPos, data.fCount);
}
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
+typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData&, SkShader::TileMode);
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep,
@@ -86,8 +81,7 @@ protected:
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
- SkShader* shader = gGradMakers[j](pts, gGradData[i], tm);
- paint.setShader(shader)->unref();
+ paint.setShader(gGradMakers[j](pts, gGradData[i], tm));
canvas->drawRect(r, paint);
canvas->translate(0, SkIntToScalar(120));
}