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

Unified Diff: samplecode/SampleVertices.cpp

Issue 1772463002: use Make instead of Create to return a shared shader (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 | « samplecode/SampleTinyBitmap.cpp ('k') | samplecode/SampleXfer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleVertices.cpp
diff --git a/samplecode/SampleVertices.cpp b/samplecode/SampleVertices.cpp
index 2f2dc024d0eea04e74467203ca4c15f9dc4358e6..a8dcd22bb3c06a9d6648abba6cf8cd5748a5c29b 100644
--- a/samplecode/SampleVertices.cpp
+++ b/samplecode/SampleVertices.cpp
@@ -25,7 +25,7 @@
#include "SkOSFile.h"
#include "SkStream.h"
-static SkShader* make_shader0(SkIPoint* size) {
+static sk_sp<SkShader> make_shader0(SkIPoint* size) {
SkBitmap bm;
size->set(2, 2);
SkPMColor color0 = SkPreMultiplyARGB(0x80, 0x80, 0xff, 0x80);
@@ -38,21 +38,20 @@ static SkShader* make_shader0(SkIPoint* size) {
pixels[1] = pixels[3] = color1;
bm.unlockPixels();
- return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
+ return SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
}
-static SkShader* make_shader1(const SkIPoint& size) {
+static sk_sp<SkShader> make_shader1(const SkIPoint& size) {
SkPoint pts[] = { { 0, 0 },
{ SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
- return SkGradientShader::CreateLinear(pts, colors, nullptr,
+ return SkGradientShader::MakeLinear(pts, colors, nullptr,
SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode);
}
class VerticesView : public SampleView {
- SkShader* fShader0;
- SkShader* fShader1;
+ sk_sp<SkShader> fShader0;
+ sk_sp<SkShader> fShader1;
public:
VerticesView() {
@@ -70,11 +69,6 @@ public:
this->setBGColor(SK_ColorGRAY);
}
- virtual ~VerticesView() {
- SkSafeUnref(fShader0);
- SkSafeUnref(fShader1);
- }
-
protected:
// overrides from SkEventSink
bool onQuery(SkEvent* evt) override {
« no previous file with comments | « samplecode/SampleTinyBitmap.cpp ('k') | samplecode/SampleXfer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698