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

Unified Diff: gm/shaderbounds.cpp

Issue 1790353002: Revert of more shader-->sp conversions (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 | « gm/samplerstress.cpp ('k') | gm/shadertext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/shaderbounds.cpp
diff --git a/gm/shaderbounds.cpp b/gm/shaderbounds.cpp
index 503f8f5b1eaafa191fc83cab876a7543b0f610d3..fd42973dba6295a049b7e9f07b92ea7b185ac588 100644
--- a/gm/shaderbounds.cpp
+++ b/gm/shaderbounds.cpp
@@ -4,31 +4,30 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
#include "gm.h"
#include "SkGradientShader.h"
namespace skiagm {
-static sk_sp<SkShader> MakeLinear(SkScalar width, SkScalar height, bool alternate,
+static SkShader* MakeLinear(SkScalar width, SkScalar height, bool alternate,
const SkMatrix& localMatrix) {
- SkPoint pts[2] = { {0, 0}, {width, height}};
- SkColor colors[2] = {SK_ColorRED, SK_ColorGREEN};
- if (alternate) {
- pts[1].fY = 0;
- colors[0] = SK_ColorBLUE;
- colors[1] = SK_ColorYELLOW;
- }
- return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode,
- 0, &localMatrix);
+ SkPoint pts[2] = { {0, 0}, {width, height}};
+ SkColor colors[2] = {SK_ColorRED, SK_ColorGREEN};
+ if (alternate) {
+ pts[1].fY = 0;
+ colors[0] = SK_ColorBLUE;
+ colors[1] = SK_ColorYELLOW;
+ }
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, 2,
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
///////////////////////////////////////////////////////////////////////////////
class ShaderBoundsGM : public GM {
public:
- typedef sk_sp<SkShader> (*ShaderGenFunc)(SkScalar width, SkScalar height,
- bool alternate, const SkMatrix& localMatrix);
+ typedef SkShader* (*ShaderGenFunc)(SkScalar width, SkScalar height,
+ bool alternate, const SkMatrix& localMatrix);
ShaderBoundsGM(ShaderGenFunc maker, const SkString& name)
: fShaderMaker(maker),
fName(name) {
@@ -63,20 +62,20 @@
// Background shader.
SkPaint paint;
- paint.setShader(MakeShader(559, 387, false));
+ paint.setShader(MakeShader(559, 387, false))->unref();
SkRect r = SkRect::MakeXYWH(SkIntToScalar(-12), SkIntToScalar(-41),
SkIntToScalar(571), SkIntToScalar(428));
canvas->drawRect(r, paint);
// Constrained shader.
- paint.setShader(MakeShader(101, 151, true));
+ paint.setShader(MakeShader(101, 151, true))->unref();
r = SkRect::MakeXYWH(SkIntToScalar(43), SkIntToScalar(71),
SkIntToScalar(101), SkIntToScalar(151));
canvas->clipRect(r);
canvas->drawRect(r, paint);
}
- sk_sp<SkShader> MakeShader(int width, int height, bool background) {
+ SkShader* MakeShader(int width, int height, bool background) {
SkScalar scale = 0.5f;
if (background) {
scale = 0.6f;
@@ -84,7 +83,8 @@
SkScalar shaderWidth = width / scale;
SkScalar shaderHeight = height / scale;
SkMatrix shaderScale = SkMatrix::MakeScale(scale);
- return fShaderMaker(shaderWidth, shaderHeight, background, shaderScale);
+ SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background, shaderScale);
+ return shader;
}
private:
@@ -93,7 +93,7 @@
ShaderGenFunc fShaderMaker;
SkString fName;
- sk_sp<SkShader> MakeShader(bool background);
+ SkShader* MakeShader(bool background);
};
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « gm/samplerstress.cpp ('k') | gm/shadertext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698