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

Unified Diff: gm/tilemodes.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/tiledscaledbitmap.cpp ('k') | gm/tilemodes_scaled.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/tilemodes.cpp
diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp
index 26b83486e86c7e197524ee643f82df4908b95bcb..d774939648d3ea7fa6b1f9e8ccc87f2d242056e8 100644
--- a/gm/tilemodes.cpp
+++ b/gm/tilemodes.cpp
@@ -27,15 +27,14 @@ static void makebm(SkBitmap* bm, SkColorType ct, 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 void setup(SkPaint* paint, const SkBitmap& bm, bool filter,
SkShader::TileMode tmx, SkShader::TileMode tmy) {
- SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy);
- paint->setShader(shader)->unref();
+ paint->setShader(SkShader::MakeBitmapShader(bm, tmx, tmy));
paint->setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
}
@@ -156,13 +155,13 @@ private:
static const int gWidth = 32;
static const int gHeight = 32;
-static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
+static sk_sp<SkShader> make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
SkBitmap bm;
makebm(&bm, kN32_SkColorType, gWidth, gHeight);
- return SkShader::CreateBitmapShader(bm, tx, ty);
+ return SkShader::MakeBitmapShader(bm, tx, ty);
}
-static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) {
+static sk_sp<SkShader> make_grad(SkShader::TileMode tx, SkShader::TileMode ty) {
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)} };
SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 };
SkScalar rad = SkIntToScalar(gWidth)/2;
@@ -171,17 +170,16 @@ static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) {
int index = (int)ty;
switch (index % 3) {
case 0:
- return SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
+ return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
case 1:
- return SkGradientShader::CreateRadial(center, rad, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
+ return SkGradientShader::MakeRadial(center, rad, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
case 2:
- return SkGradientShader::CreateSweep(center.fX, center.fY, colors, nullptr, SK_ARRAY_COUNT(colors));
+ return SkGradientShader::MakeSweep(center.fX, center.fY, colors, nullptr, SK_ARRAY_COUNT(colors));
}
-
return nullptr;
}
-typedef SkShader* (*ShaderProc)(SkShader::TileMode, SkShader::TileMode);
+typedef sk_sp<SkShader> (*ShaderProc)(SkShader::TileMode, SkShader::TileMode);
class Tiling2GM : public skiagm::GM {
ShaderProc fProc;
@@ -239,7 +237,7 @@ protected:
x += SkIntToScalar(50);
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
SkPaint paint;
- paint.setShader(fProc(gModes[kx], gModes[ky]))->unref();
+ paint.setShader(fProc(gModes[kx], gModes[ky]));
canvas->save();
canvas->translate(x, y);
« no previous file with comments | « gm/tiledscaledbitmap.cpp ('k') | gm/tilemodes_scaled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698