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); |
} |