From 1a9b9640843a64af8d9d90337ec3b3fea663196a Mon Sep 17 00:00:00 2001 From: reed Date: Sun, 13 Mar 2016 14:13:58 -0700 Subject: Reland of "more shader-->sp conversions (patchset #5 id:80001 of https://codereview.chromium.org/1789633002/ )" This reverts commit 9283d20afc27571f7a871d1bd1100dd5df584941. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1793303002 Review URL: https://codereview.chromium.org/1793303002 --- gm/shallowgradient.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'gm/shallowgradient.cpp') diff --git a/gm/shallowgradient.cpp b/gm/shallowgradient.cpp index 764b1a5034..6990ba7c93 100644 --- a/gm/shallowgradient.cpp +++ b/gm/shallowgradient.cpp @@ -8,31 +8,27 @@ #include "gm.h" #include "SkGradientShader.h" -typedef SkShader* (*MakeShaderProc)(const SkColor[], int count, const SkSize&); +typedef sk_sp (*MakeShaderProc)(const SkColor[], int count, const SkSize&); -static SkShader* shader_linear(const SkColor colors[], int count, const SkSize& size) { +static sk_sp shader_linear(const SkColor colors[], int count, const SkSize& size) { SkPoint pts[] = { { 0, 0 }, { size.width(), size.height() } }; - return SkGradientShader::CreateLinear(pts, colors, nullptr, count, - SkShader::kClamp_TileMode); + return SkGradientShader::MakeLinear(pts, colors, nullptr, count, SkShader::kClamp_TileMode); } -static SkShader* shader_radial(const SkColor colors[], int count, const SkSize& size) { +static sk_sp shader_radial(const SkColor colors[], int count, const SkSize& size) { SkPoint center = { size.width()/2, size.height()/2 }; - return SkGradientShader::CreateRadial(center, size.width()/2, colors, nullptr, count, - SkShader::kClamp_TileMode); + return SkGradientShader::MakeRadial(center, size.width()/2, colors, nullptr, count, + SkShader::kClamp_TileMode); } -static SkShader* shader_conical(const SkColor colors[], int count, const SkSize& size) { +static sk_sp shader_conical(const SkColor colors[], int count, const SkSize& size) { SkPoint center = { size.width()/2, size.height()/2 }; - return SkGradientShader::CreateTwoPointConical(center, size.width()/64, - center, size.width()/2, - colors, nullptr, count, - SkShader::kClamp_TileMode); + return SkGradientShader::MakeTwoPointConical(center, size.width()/64, center, size.width()/2, + colors, nullptr, count, SkShader::kClamp_TileMode); } -static SkShader* shader_sweep(const SkColor colors[], int count, const SkSize& size) { - return SkGradientShader::CreateSweep(size.width()/2, size.height()/2, - colors, nullptr, count); +static sk_sp shader_sweep(const SkColor colors[], int count, const SkSize& size) { + return SkGradientShader::MakeSweep(size.width()/2, size.height()/2, colors, nullptr, count); } class ShallowGradientGM : public skiagm::GM { @@ -62,7 +58,7 @@ protected: SkSize size = SkSize::Make(r.width(), r.height()); SkPaint paint; - paint.setShader(fProc(colors, colorCount, size))->unref(); + paint.setShader(fProc(colors, colorCount, size)); paint.setDither(fDither); canvas->drawRect(r, paint); } -- cgit v1.2.3