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

Unified Diff: samplecode/SamplePatch.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/SampleLayers.cpp ('k') | samplecode/SampleQuadStroker.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SamplePatch.cpp
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index 5347b0182a706f52895c8c760a68b0d1c254e2f3..c9ecb709900da8fa6293d947843763264099420f 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -28,21 +28,21 @@
#include "SkGeometry.h" // private include :(
-static SkShader* make_shader0(SkIPoint* size) {
+static sk_sp<SkShader> make_shader0(SkIPoint* size) {
SkBitmap bm;
// SkImageDecoder::DecodeFile("/skimages/progressivejpg.jpg", &bm);
SkImageDecoder::DecodeFile("/skimages/logo.png", &bm);
size->set(bm.width(), bm.height());
- return SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode);
+ return SkShader::MakeBitmapShader(bm, SkShader::kClamp_TileMode,
+ SkShader::kClamp_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);
}
@@ -211,8 +211,8 @@ const SkScalar DY = 0;
class PatchView : public SampleView {
SkScalar fAngle;
- SkShader* fShader0;
- SkShader* fShader1;
+ sk_sp<SkShader> fShader0;
+ sk_sp<SkShader> fShader1;
SkIPoint fSize0, fSize1;
SkPoint fPts[12];
@@ -243,11 +243,6 @@ public:
this->setBGColor(SK_ColorGRAY);
}
- virtual ~PatchView() {
- SkSafeUnref(fShader0);
- SkSafeUnref(fShader1);
- }
-
protected:
// overrides from SkEventSink
bool onQuery(SkEvent* evt) override {
« no previous file with comments | « samplecode/SampleLayers.cpp ('k') | samplecode/SampleQuadStroker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698