aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleBigGradient.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-08 18:50:00 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-08 18:50:00 -0800
commit8a21c9fe7f5fef9e87115defef27bd7218419f28 (patch)
tree1dd8b9eda9eae99b33bc88b97bd5f0a7a0769dc3 /samplecode/SampleBigGradient.cpp
parent042f859c19f71ca9feacddd1cb058ff59eed8963 (diff)
use Make instead of Create to return a shared shader
Partially updated call sites. Undefine the flag in SkSHader.h to convert the remaining sites. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1772463002 Review URL: https://codereview.chromium.org/1772463002
Diffstat (limited to 'samplecode/SampleBigGradient.cpp')
-rw-r--r--samplecode/SampleBigGradient.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/samplecode/SampleBigGradient.cpp b/samplecode/SampleBigGradient.cpp
index 0fa7969c7a..8ae099051b 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);
}