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

Unified Diff: samplecode/SampleBigGradient.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/SampleAll.cpp ('k') | samplecode/SampleBitmapRect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleBigGradient.cpp
diff --git a/samplecode/SampleBigGradient.cpp b/samplecode/SampleBigGradient.cpp
index 0fa7969c7a34be715cb4717c69279f4bdaec824a..8ae099051b4457f11e3301211cb9a03015c0ef26 100644
--- a/samplecode/SampleBigGradient.cpp
+++ b/samplecode/SampleBigGradient.cpp
@@ -1,20 +1,19 @@
-
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
-static SkShader* make_grad(SkScalar w, SkScalar h) {
+static sk_sp<SkShader> make_grad(SkScalar w, SkScalar h) {
SkColor colors[] = { 0xFF000000, 0xFF333333 };
SkPoint pts[] = { { 0, 0 }, { w, h } };
- return SkGradientShader::CreateLinear(pts, colors, nullptr, 2,
- SkShader::kClamp_TileMode);
+ return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
}
class BigGradientView : public SampleView {
@@ -22,8 +21,7 @@ public:
BigGradientView() {}
protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
+ bool onQuery(SkEvent* evt) override {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "BigGradient");
return true;
@@ -31,11 +29,11 @@ protected:
return this->INHERITED::onQuery(evt);
}
- virtual void onDrawContent(SkCanvas* canvas) {
+ void onDrawContent(SkCanvas* canvas) override {
SkRect r;
r.set(0, 0, this->width(), this->height());
SkPaint p;
- p.setShader(make_grad(this->width(), this->height()))->unref();
+ p.setShader(make_grad(this->width(), this->height()));
canvas->drawRect(r, p);
}
« no previous file with comments | « samplecode/SampleAll.cpp ('k') | samplecode/SampleBitmapRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698