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

Unified Diff: gm/transparency.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/tinybitmap.cpp ('k') | gm/vertices.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/transparency.cpp
diff --git a/gm/transparency.cpp b/gm/transparency.cpp
index 73bd8b20235f3add7320fdfd8575bb267d89d8be..5e057617d4349828e346359af0b51a6dbbd1a53a 100644
--- a/gm/transparency.cpp
+++ b/gm/transparency.cpp
@@ -9,9 +9,7 @@
#include "SkSurface.h"
#include "gm.h"
-static void make_transparency(SkCanvas* canvas,
- SkScalar width,
- SkScalar height) {
+static void make_transparency(SkCanvas* canvas, SkScalar width, SkScalar height) {
SkPoint pts[2];
pts[0] = SkPoint::Make(0, 0);
pts[1] = SkPoint::Make(width, 0);
@@ -31,30 +29,27 @@ static void make_transparency(SkCanvas* canvas,
SkColor shaderColors[2];
shaderColors[0] = SK_AlphaTRANSPARENT;
shaderColors[1] = kColors[i];
- SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(
- pts, shaderColors, nullptr, 2, SkShader::kClamp_TileMode));
- SkRect r = SkRect::MakeXYWH(0, i * kRowHeight, width, kRowHeight);
SkPaint p;
- p.setShader(shader);
- canvas->drawRect(r, p);
+ p.setShader(SkGradientShader::MakeLinear(pts, shaderColors, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ canvas->drawRect(SkRect::MakeXYWH(0, i * kRowHeight, width, kRowHeight), p);
}
}
// http://crrev.com/834303005
-static SkShader* create_checkerboard_shader(SkColor c1, SkColor c2, int size) {
+static sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size) {
SkBitmap bm;
bm.allocN32Pixels(2 * size, 2 * size);
bm.eraseColor(c1);
bm.eraseArea(SkIRect::MakeLTRB(0, 0, size, size), c2);
bm.eraseArea(SkIRect::MakeLTRB(size, size, 2 * size, 2 * size), c2);
- return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
+ return SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
}
// http://crrev.com/834303005
static void checkerboard(SkCanvas* canvas, SkColor c1, SkColor c2, int size) {
SkPaint paint;
- paint.setShader(create_checkerboard_shader(c1, c2, size))->unref();
+ paint.setShader(create_checkerboard_shader(c1, c2, size));
canvas->drawPaint(paint);
}
« no previous file with comments | « gm/tinybitmap.cpp ('k') | gm/vertices.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698