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

Unified Diff: gm/modecolorfilters.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/matrixconvolution.cpp ('k') | gm/ovals.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/modecolorfilters.cpp
diff --git a/gm/modecolorfilters.cpp b/gm/modecolorfilters.cpp
index b5ede710f1cc2fd3293d7d93fcb51277bec548fd..de6a18a41c85e2320773743e82ee0d9fa92728b3 100644
--- a/gm/modecolorfilters.cpp
+++ b/gm/modecolorfilters.cpp
@@ -6,7 +6,6 @@
*/
#include "gm.h"
-#include "SkBitmapProcShader.h"
#include "SkColorFilter.h"
#include "SkGradientShader.h"
@@ -16,27 +15,27 @@
namespace skiagm {
// Using gradients because GPU doesn't currently have an implementation of SkColorShader (duh!)
-static SkShader* make_color_shader(SkColor color) {
+static sk_sp<SkShader> make_color_shader(SkColor color) {
static const SkPoint kPts[] = {{0, 0}, {1, 1}};
SkColor colors[] = {color, color};
- return SkGradientShader::CreateLinear(kPts, colors, nullptr, 2, SkShader::kClamp_TileMode);
+ return SkGradientShader::MakeLinear(kPts, colors, nullptr, 2, SkShader::kClamp_TileMode);
}
-static SkShader* make_solid_shader() {
+static sk_sp<SkShader> make_solid_shader() {
return make_color_shader(SkColorSetARGB(0xFF, 0x42, 0x82, 0x21));
}
-static SkShader* make_transparent_shader() {
+static sk_sp<SkShader> make_transparent_shader() {
return make_color_shader(SkColorSetARGB(0x80, 0x10, 0x70, 0x20));
}
-static SkShader* make_trans_black_shader() {
+static sk_sp<SkShader> make_trans_black_shader() {
return make_color_shader(0x0);
}
// draws a background behind each test rect to see transparency
-static SkShader* make_bg_shader(int checkSize) {
+static sk_sp<SkShader> make_bg_shader(int checkSize) {
SkBitmap bmp;
bmp.allocN32Pixels(2 * checkSize, 2 * checkSize);
SkCanvas canvas(bmp);
@@ -49,7 +48,7 @@ static SkShader* make_bg_shader(int checkSize) {
SkIntToScalar(checkSize), SkIntToScalar(checkSize));
canvas.drawRect(rect1, paint);
canvas.drawRect(rect0, paint);
- return new SkBitmapProcShader(bmp, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
+ return SkShader::MakeBitmapShader(bmp, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
}
class ModeColorFilterGM : public GM {
@@ -59,15 +58,15 @@ public:
}
protected:
- virtual SkString onShortName() {
+ SkString onShortName() override {
return SkString("modecolorfilters");
}
- virtual SkISize onISize() {
+ SkISize onISize() override {
return SkISize::Make(WIDTH, HEIGHT);
}
- virtual void onDraw(SkCanvas* canvas) {
+ void onDraw(SkCanvas* canvas) override {
// size of rect for each test case
static const int kRectWidth = 20;
static const int kRectHeight = 20;
@@ -75,13 +74,13 @@ protected:
static const int kCheckSize = 10;
if (!fBmpShader) {
- fBmpShader.reset(make_bg_shader(kCheckSize));
+ fBmpShader = make_bg_shader(kCheckSize);
}
SkPaint bgPaint;
bgPaint.setShader(fBmpShader);
bgPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
- SkShader* shaders[] = {
+ sk_sp<SkShader> shaders[] = {
nullptr, // use a paint color instead of a shader
make_solid_shader(),
make_transparent_shader(),
@@ -146,14 +145,10 @@ protected:
}
}
}
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(shaders); ++i) {
- SkSafeUnref(shaders[i]);
- }
}
private:
- SkAutoTUnref<SkShader> fBmpShader;
+ sk_sp<SkShader> fBmpShader;
typedef GM INHERITED;
};
« no previous file with comments | « gm/matrixconvolution.cpp ('k') | gm/ovals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698