diff options
author | 2013-10-07 17:18:21 +0000 | |
---|---|---|
committer | 2013-10-07 17:18:21 +0000 | |
commit | b120bd986ec5e5eeaacdbb8aec04cbe352f98434 (patch) | |
tree | 83c0f2a3a58c5c9b44ebe9f940ff95121c5a168a | |
parent | de09af3fd86c430a9ed9741dfd11e79e19eee105 (diff) |
Make all gradient benchs use the same repeat count.
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/25306003
git-svn-id: http://skia.googlecode.com/svn/trunk@11634 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | bench/GradientBench.cpp | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/bench/GradientBench.cpp b/bench/GradientBench.cpp index 5ec9d8784e..e04a8122d1 100644 --- a/bench/GradientBench.cpp +++ b/bench/GradientBench.cpp @@ -109,13 +109,12 @@ typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, static const struct { GradMaker fMaker; const char* fName; - int fRepeat; } gGrads[] = { - { MakeLinear, "linear", 15 }, - { MakeRadial, "radial1", 10 }, - { MakeSweep, "sweep", 1 }, - { Make2Radial, "radial2", 5 }, - { MakeConical, "conical", 5 }, + { MakeLinear, "linear" }, + { MakeRadial, "radial1" }, + { MakeSweep, "sweep" }, + { Make2Radial, "radial2" }, + { MakeConical, "conical" }, }; enum GradType { // these must match the order in gGrads @@ -162,10 +161,10 @@ static const char* geomtypename(GeomType gt) { class GradientBench : public SkBenchmark { SkString fName; SkShader* fShader; - int fRepeat; enum { W = 400, H = 400, + kRepeat = 15, }; public: GradientBench(GradType gradType, @@ -191,7 +190,6 @@ public: { SkIntToScalar(W), SkIntToScalar(H) } }; - fRepeat = gGrads[gradType].fRepeat; fShader = gGrads[gradType].fMaker(pts, data, tm, NULL, scale); fGeomType = geomType; } @@ -212,7 +210,7 @@ protected: paint.setShader(fShader); SkRect r = { 0, 0, SkIntToScalar(W), SkIntToScalar(H) }; - for (int i = 0; i < this->getLoops() * fRepeat; i++) { + for (int i = 0; i < this->getLoops() * kRepeat; i++) { switch (fGeomType) { case kRect_GeomType: canvas->drawRect(r, paint); @@ -230,6 +228,35 @@ private: GeomType fGeomType; }; +DEF_BENCH( return new GradientBench(kLinear_GradType); ) +DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[1]); ) +DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[2]); ) +DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[0], SkShader::kMirror_TileMode); ) + +DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0]); ) +DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[1]); ) +DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[2]); ) +// Draw a radial gradient of radius 1/2 on a rectangle; half the lines should +// be completely pinned, the other half should pe partially pinned +DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kClamp_TileMode, kRect_GeomType, 0.5f); ) + +// Draw a radial gradient on a circle of equal size; all the lines should +// hit the unpinned fast path (so long as GradientBench.W == H) +DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kClamp_TileMode, kOval_GeomType); ) + +DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kMirror_TileMode); ) +DEF_BENCH( return new GradientBench(kSweep_GradType); ) +DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[1]); ) +DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[2]); ) +DEF_BENCH( return new GradientBench(kRadial2_GradType); ) +DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[1]); ) +DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[0], SkShader::kMirror_TileMode); ) +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]); ) + +/////////////////////////////////////////////////////////////////////////////// + class Gradient2Bench : public SkBenchmark { SkString fName; bool fHasAlpha; @@ -274,33 +301,5 @@ private: typedef SkBenchmark INHERITED; }; -DEF_BENCH( return new GradientBench(kLinear_GradType); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[1]); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[2]); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[0], SkShader::kMirror_TileMode); ) - - -DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0]); ) -DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[1]); ) -DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[2]); ) -// Draw a radial gradient of radius 1/2 on a rectangle; half the lines should -// be completely pinned, the other half should pe partially pinned -DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kClamp_TileMode, kRect_GeomType, 0.5f); ) - -// Draw a radial gradient on a circle of equal size; all the lines should -// hit the unpinned fast path (so long as GradientBench.W == H) -DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kClamp_TileMode, kOval_GeomType); ) - -DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kMirror_TileMode); ) -DEF_BENCH( return new GradientBench(kSweep_GradType); ) -DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[1]); ) -DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[2]); ) -DEF_BENCH( return new GradientBench(kRadial2_GradType); ) -DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[1]); ) -DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[0], SkShader::kMirror_TileMode); ) -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 Gradient2Bench(false); ) DEF_BENCH( return new Gradient2Bench(true); ) |