Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Unified Diff: gm/shadertext.cpp

Issue 1793303002: Reland of "more shader-->sp conversions (patchset #5 id:80001 of https://codereview.chromium… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: make pictureRef a value, so its clearer what's going on Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/shaderbounds.cpp ('k') | gm/shadertext2.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/shadertext.cpp
diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp
index e68ee98df04c1a419fd8c2569d3b6c145174b3da..13fa28325bb3b80cd9e492cc05cf50cb334fd6db 100644
--- a/gm/shadertext.cpp
+++ b/gm/shadertext.cpp
@@ -24,8 +24,8 @@ 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);
}
@@ -46,38 +46,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) {
+static sk_sp<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);
+ 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
@@ -123,7 +123,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) {
@@ -138,7 +138,7 @@ protected:
makebm(&bm, w/16, h/4);
for (size_t tx = 0; tx < SK_ARRAY_COUNT(tileModes); ++tx) {
for (size_t ty = 0; ty < SK_ARRAY_COUNT(tileModes); ++ty) {
- shaders[shdIdx++] = SkShader::CreateBitmapShader(bm, tileModes[tx], tileModes[ty]);
+ shaders[shdIdx++] = SkShader::MakeBitmapShader(bm, tileModes[tx], tileModes[ty]);
}
}
@@ -167,7 +167,7 @@ protected:
int 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();
« no previous file with comments | « gm/shaderbounds.cpp ('k') | gm/shadertext2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698