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

Unified Diff: bench/GradientBench.cpp

Issue 1803763002: Finish conversion to sk_sp<SkShader> (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 | « bench/GameBench.cpp ('k') | bench/ImageFilterCollapse.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/GradientBench.cpp
diff --git a/bench/GradientBench.cpp b/bench/GradientBench.cpp
index 73014f7bae2ba55ad960097c2bb70167eb644d10..21ebdce7ab12ebc9c757dab6dc4ffac6b3cc8c07 100644
--- a/bench/GradientBench.cpp
+++ b/bench/GradientBench.cpp
@@ -47,89 +47,87 @@ static const GradData gGradData[] = {
};
/// Ignores scale
-static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, float scale, bool force4f) {
+static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, float scale, bool force4f) {
const uint32_t flags = force4f ? SkLinearGradient::kForce4fContext_PrivateFlag : 0;
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, flags, nullptr);
+ return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos,
+ data.fCount, tm, flags, nullptr);
}
-static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, float scale, bool force4f) {
+static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, float scale, bool force4f) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::CreateRadial(center, center.fX * scale,
- data.fColors,
- data.fPos, data.fCount, tm);
+ return SkGradientShader::MakeRadial(center, center.fX * scale, data.fColors,
+ data.fPos, data.fCount, tm);
}
/// Ignores scale
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, float scale, bool force4f) {
+static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, float scale, bool force4f) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors,
- data.fPos, data.fCount);
+ return SkGradientShader::MakeSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
/// Ignores scale
-static SkShader* MakeConical(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, float scale, bool force4f) {
+static sk_sp<SkShader> MakeConical(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, float scale, bool force4f) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7,
- center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm);
+ return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm);
}
/// Ignores scale
-static SkShader* MakeConicalZeroRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, float scale, bool force4f) {
+static sk_sp<SkShader> MakeConicalZeroRad(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, float scale, bool force4f) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::CreateTwoPointConical(center1, 0.0,
- center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm);
+ return SkGradientShader::MakeTwoPointConical(center1, 0.0,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm);
}
/// Ignores scale
-static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, float scale, bool force4f) {
+static sk_sp<SkShader> MakeConicalOutside(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, float scale, bool force4f) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
- return SkGradientShader::CreateTwoPointConical(center0, radius0,
- center1, radius1,
- data.fColors, data.fPos,
- data.fCount, tm);
+ return SkGradientShader::MakeTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm);
}
/// Ignores scale
-static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, float scale, bool force4f) {
+static sk_sp<SkShader> MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, float scale, bool force4f) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
- return SkGradientShader::CreateTwoPointConical(center0, 0.0,
- center1, radius1,
- data.fColors, data.fPos,
- data.fCount, tm);
+ return SkGradientShader::MakeTwoPointConical(center0, 0.0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm);
}
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, float scale, bool force4f);
+typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, float scale, bool force4f);
static const struct {
GradMaker fMaker;
@@ -213,9 +211,8 @@ public:
fName.append("_4f");
}
- SkAutoTUnref<SkShader> shader(MakeShader(gradType, data, tm, scale, force4f));
this->setupPaint(&fPaint);
- fPaint.setShader(shader);
+ fPaint.setShader(MakeShader(gradType, data, tm, scale, force4f));
}
GradientBench(GradType gradType, GradData data, bool dither, bool force4f = false)
@@ -229,10 +226,8 @@ public:
fName.appendf("_dither");
}
- SkAutoTUnref<SkShader> shader(
- MakeShader(gradType, data, SkShader::kClamp_TileMode, 1.0f, force4f));
this->setupPaint(&fPaint);
- fPaint.setShader(shader);
+ fPaint.setShader(MakeShader(gradType, data, SkShader::kClamp_TileMode, 1.0f, force4f));
fPaint.setDither(dither);
}
@@ -263,8 +258,8 @@ protected:
private:
typedef Benchmark INHERITED;
- SkShader* MakeShader(GradType gradType, GradData data,
- SkShader::TileMode tm, float scale, bool force4f) {
+ sk_sp<SkShader> MakeShader(GradType gradType, GradData data,
+ SkShader::TileMode tm, float scale, bool force4f) {
const SkPoint pts[2] = {
{ 0, 0 },
{ SkIntToScalar(kSize), SkIntToScalar(kSize) }
@@ -383,10 +378,9 @@ protected:
SK_ColorBLACK,
SkColorSetARGB(alpha, gray, gray, gray),
SK_ColorWHITE };
- SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr,
+ paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr,
SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
- paint.setShader(s)->unref();
+ SkShader::kClamp_TileMode));
canvas->drawRect(r, paint);
}
}
« no previous file with comments | « bench/GameBench.cpp ('k') | bench/ImageFilterCollapse.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698