diff options
author | 2013-02-04 18:09:58 +0000 | |
---|---|---|
committer | 2013-02-04 18:09:58 +0000 | |
commit | 73349aa33277889d79e3e8bd8cef89cdf0310288 (patch) | |
tree | 39413f9ea60d51872737438d867124469fa2aa4b | |
parent | 58ba41034eed12ddd5d1c0b8fe158078746dd629 (diff) |
extend gradient_create bench to test opaque and alpha gradient ramps
git-svn-id: http://skia.googlecode.com/svn/trunk@7548 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | bench/GradientBench.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/bench/GradientBench.cpp b/bench/GradientBench.cpp index 93637e4f88..2787edbf0b 100644 --- a/bench/GradientBench.cpp +++ b/bench/GradientBench.cpp @@ -221,12 +221,18 @@ private: }; class Gradient2Bench : public SkBenchmark { + SkString fName; + bool fHasAlpha; + public: - Gradient2Bench(void* param) : INHERITED(param) {} + Gradient2Bench(void* param, bool hasAlpha) : INHERITED(param) { + fName.printf("gradient_create_%s", hasAlpha ? "alpha" : "opaque"); + fHasAlpha = hasAlpha; + } protected: virtual const char* onGetName() { - return "gradient_create"; + return fName.c_str(); } virtual void onDraw(SkCanvas* canvas) { @@ -240,10 +246,11 @@ protected: }; for (int i = 0; i < SkBENCHLOOP(1000); i++) { - const int a = i % 256; + const int gray = i % 256; + const int alpha = fHasAlpha ? gray : 0xFF; SkColor colors[] = { SK_ColorBLACK, - SkColorSetARGB(a, a, a, a), + SkColorSetARGB(alpha, gray, gray, gray), SK_ColorWHITE }; SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, SK_ARRAY_COUNT(colors), @@ -274,4 +281,5 @@ DEF_BENCH( return new GradientBench(p, kRadial2_GradType); ) DEF_BENCH( return new GradientBench(p, kRadial2_GradType, SkShader::kMirror_TileMode); ) DEF_BENCH( return new GradientBench(p, kConical_GradType); ) -DEF_BENCH( return new Gradient2Bench(p); ) +DEF_BENCH( return new Gradient2Bench(p, false); ) +DEF_BENCH( return new Gradient2Bench(p, true); ) |