Index: samplecode/SampleShaderText.cpp |
diff --git a/samplecode/SampleShaderText.cpp b/samplecode/SampleShaderText.cpp |
index f13fd4edc7927fb430c92ed6043e5033be6a473b..cf0cb0fe75e7c0c453491325c19b9b392f22c5a1 100644 |
--- a/samplecode/SampleShaderText.cpp |
+++ b/samplecode/SampleShaderText.cpp |
@@ -23,18 +23,18 @@ static void makebm(SkBitmap* bm, int w, int h) { |
SkPaint paint; |
paint.setDither(true); |
- paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos, |
- SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref(); |
+ paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos, |
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode)); |
canvas.drawPaint(paint); |
} |
-static SkShader* MakeBitmapShader(SkShader::TileMode tx, SkShader::TileMode ty, |
- int w, int h) { |
+static sk_sp<SkShader> MakeBitmapShader(SkShader::TileMode tx, SkShader::TileMode ty, |
+ int w, int h) { |
static SkBitmap bmp; |
if (bmp.isNull()) { |
makebm(&bmp, w/2, h/4); |
} |
- return SkShader::CreateBitmapShader(bmp, tx, ty); |
+ return SkShader::MakeBitmapShader(bmp, tx, ty); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -54,38 +54,38 @@ static const GradData gGradData[] = { |
{ 5, gColors, 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) { |
+static sk_sp<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); |
+ return SkGradientShader::MakeRadial(center, center.fX, data.fColors, |
+ data.fPos, data.fCount, tm); |
} |
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) { |
+static sk_sp<SkShader> MakeSweep(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::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount); |
+ return SkGradientShader::MakeSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount); |
} |
-static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) { |
+static sk_sp<SkShader> Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) { |
SkPoint center0, center1; |
center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
SkScalarAve(pts[0].fY, pts[1].fY)); |
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), |
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
- return SkGradientShader::CreateTwoPointConical( |
+ return SkGradientShader::MakeTwoPointConical( |
center1, (pts[1].fX - pts[0].fX) / 7, |
center0, (pts[1].fX - pts[0].fX) / 2, |
data.fColors, data.fPos, data.fCount, tm); |
} |
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm); |
+typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm); |
static const GradMaker gGradMakers[] = { |
MakeLinear, MakeRadial, MakeSweep, Make2Conical |
@@ -133,7 +133,7 @@ protected: |
SK_ARRAY_COUNT(gGradMakers); |
static const int bmpCount = SK_ARRAY_COUNT(tileModes) * |
SK_ARRAY_COUNT(tileModes); |
- SkShader* shaders[gradCount + bmpCount]; |
+ sk_sp<SkShader> shaders[gradCount + bmpCount]; |
int shdIdx = 0; |
for (size_t d = 0; d < SK_ARRAY_COUNT(gGradData); ++d) { |
@@ -175,7 +175,7 @@ protected: |
size_t i = 2*s; |
canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
SkIntToScalar((i % testsPerCol) * rowHeight)); |
- paint.setShader(shaders[s])->unref(); |
+ paint.setShader(shaders[s]); |
canvas->drawText(text, textLen, 0, textBase, paint); |
canvas->restore(); |
canvas->save(); |