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

Unified Diff: gm/transparency.cpp

Issue 1790353002: Revert of more shader-->sp conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 5e057617d4349828e346359af0b51a6dbbd1a53a..73bd8b20235f3add7320fdfd8575bb267d89d8be 100644
--- a/gm/transparency.cpp
+++ b/gm/transparency.cpp
@@ -9,7 +9,9 @@
#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);
@@ -29,27 +31,30 @@
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(SkGradientShader::MakeLinear(pts, shaderColors, nullptr, 2,
- SkShader::kClamp_TileMode));
- canvas->drawRect(SkRect::MakeXYWH(0, i * kRowHeight, width, kRowHeight), p);
+ p.setShader(shader);
+ canvas->drawRect(r, p);
}
}
// http://crrev.com/834303005
-static sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size) {
+static 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::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
+ return SkShader::CreateBitmapShader(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));
+ paint.setShader(create_checkerboard_shader(c1, c2, size))->unref();
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