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

Unified Diff: bench/GradientBench.cpp

Issue 234603006: Add conical special cases to GradientBench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: A wild zero appeared Created 6 years, 8 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 | « no previous file | no next file » | 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 9c6c48a2356f5691c8e7d813d1c8204bbf2e518a..55e777d8fbe5ba3be58a69d8d928b0842d89b4bd 100644
--- a/bench/GradientBench.cpp
+++ b/bench/GradientBench.cpp
@@ -102,6 +102,50 @@ static SkShader* MakeConical(const SkPoint pts[2], const GradData& data,
data.fColors, data.fPos, data.fCount, tm, mapper);
}
+/// Ignores scale
+static SkShader* MakeConicalZeroRad(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, SkUnitMapper* mapper,
+ float scale) {
+ 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, mapper);
+}
+
+/// Ignores scale
+static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, SkUnitMapper* mapper,
+ float scale) {
+ SkPoint center0, center1;
+ SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
+ SkScalar radius1 = SkScalarDiv(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, mapper);
+}
+
+/// Ignores scale
+static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, SkUnitMapper* mapper,
+ float scale) {
+ SkPoint center0, center1;
+ SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
+ SkScalar radius1 = SkScalarDiv(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, mapper);
+}
+
typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, SkUnitMapper* mapper,
float scale);
@@ -110,11 +154,14 @@ static const struct {
GradMaker fMaker;
const char* fName;
} gGrads[] = {
- { MakeLinear, "linear" },
- { MakeRadial, "radial1" },
- { MakeSweep, "sweep" },
- { Make2Radial, "radial2" },
- { MakeConical, "conical" },
+ { MakeLinear, "linear" },
+ { MakeRadial, "radial1" },
+ { MakeSweep, "sweep" },
+ { Make2Radial, "radial2" },
+ { MakeConical, "conical" },
+ { MakeConicalZeroRad, "conicalZero" },
+ { MakeConicalOutside, "conicalOut" },
+ { MakeConicalOutsideZeroRad, "conicalOutZero" },
};
enum GradType { // these must match the order in gGrads
@@ -122,7 +169,10 @@ enum GradType { // these must match the order in gGrads
kRadial_GradType,
kSweep_GradType,
kRadial2_GradType,
- kConical_GradType
+ kConical_GradType,
+ kConicalZero_GradType,
+ kConicalOut_GradType,
+ kConicalOutZero_GradType
};
enum GeomType {
@@ -255,6 +305,15 @@ DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[0], SkShader::k
DEF_BENCH( return new GradientBench(kConical_GradType); )
DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[1]); )
DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[2]); )
+DEF_BENCH( return new GradientBench(kConicalZero_GradType); )
+DEF_BENCH( return new GradientBench(kConicalZero_GradType, gGradData[1]); )
+DEF_BENCH( return new GradientBench(kConicalZero_GradType, gGradData[2]); )
+DEF_BENCH( return new GradientBench(kConicalOut_GradType); )
+DEF_BENCH( return new GradientBench(kConicalOut_GradType, gGradData[1]); )
+DEF_BENCH( return new GradientBench(kConicalOut_GradType, gGradData[2]); )
+DEF_BENCH( return new GradientBench(kConicalOutZero_GradType); )
+DEF_BENCH( return new GradientBench(kConicalOutZero_GradType, gGradData[1]); )
+DEF_BENCH( return new GradientBench(kConicalOutZero_GradType, gGradData[2]); )
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698