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

Unified Diff: gm/gradient_matrix.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/gradientDirtyLaundry.cpp ('k') | gm/gradients.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gradient_matrix.cpp
diff --git a/gm/gradient_matrix.cpp b/gm/gradient_matrix.cpp
index 8f665a1b945eb0db671f44840a92d6b27734a0b7..816891847ddf4a521898028a27b89c9349bc74a3 100644
--- a/gm/gradient_matrix.cpp
+++ b/gm/gradient_matrix.cpp
@@ -61,22 +61,22 @@ static const SkScalar TESTGRID_Y = SkIntToScalar(200);
static const int IMAGES_X = 4; // number of images per row
-static SkShader* make_linear_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
- return SkGradientShader::CreateLinear(pts, gColors, nullptr, SK_ARRAY_COUNT(gColors),
- SkShader::kClamp_TileMode, 0, &localMatrix);
+static sk_sp<SkShader> make_linear_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
+ return SkGradientShader::MakeLinear(pts, gColors, nullptr, SK_ARRAY_COUNT(gColors),
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
-static SkShader* make_radial_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
+static sk_sp<SkShader> make_radial_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
float radius = (center - pts[0]).length();
- return SkGradientShader::CreateRadial(center, radius, gColors, nullptr, SK_ARRAY_COUNT(gColors),
- SkShader::kClamp_TileMode, 0, &localMatrix);
+ return SkGradientShader::MakeRadial(center, radius, gColors, nullptr, SK_ARRAY_COUNT(gColors),
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
static void draw_gradients(SkCanvas* canvas,
- SkShader* (*makeShader)(const SkPoint[2], const SkMatrix&),
+ sk_sp<SkShader> (*makeShader)(const SkPoint[2], const SkMatrix&),
const SkPoint ptsArray[][2], int numImages) {
// Use some nice prime numbers for the rectangle and matrix with
// different scaling along the x and y axes (which is the bug this
@@ -97,11 +97,8 @@ static void draw_gradients(SkCanvas* canvas,
canvas->save();
}
- // Setup shader and draw.
- SkAutoTUnref<SkShader> shader(makeShader(*ptsArray, shaderMat));
-
SkPaint paint;
- paint.setShader(shader);
+ paint.setShader(makeShader(*ptsArray, shaderMat));
canvas->drawRect(rectGrad, paint);
// Advance to next position.
« no previous file with comments | « gm/gradientDirtyLaundry.cpp ('k') | gm/gradients.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698