diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-14 22:10:30 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-14 22:10:30 +0000 |
commit | 12310e42f1798ba7caf8038c2088be16727b0355 (patch) | |
tree | 4a424b78bf81de82590a42651e70e072816cfbd7 /bench/RectBench.cpp | |
parent | d4a1567c179311a457283185a65f7a8aeb8fef80 (diff) |
Add new "aarects" bench to establish baseline for aa rect drawing
https://codereview.appspot.com/6941057/
git-svn-id: http://skia.googlecode.com/svn/trunk@6827 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/RectBench.cpp')
-rw-r--r-- | bench/RectBench.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp index a7375334a4..17fccfd3ab 100644 --- a/bench/RectBench.cpp +++ b/bench/RectBench.cpp @@ -23,7 +23,10 @@ public: SkRect fRects[N]; SkColor fColors[N]; - RectBench(void* param, int shift, int stroke = 0) : INHERITED(param), fShift(shift), fStroke(stroke) { + RectBench(void* param, int shift, int stroke = 0) + : INHERITED(param) + , fShift(shift) + , fStroke(stroke) { SkRandom rand; const SkScalar offset = SK_Scalar1/3; for (int i = 0; i < N; i++) { @@ -159,6 +162,40 @@ protected: virtual const char* onGetName() { return fName; } }; +class AARectBench : public SkBenchmark { +public: + enum { + W = 640, + H = 480, + }; + + AARectBench(void* param) : INHERITED(param) {} + +protected: + + virtual const char* onGetName() { return "aarects"; } + + virtual void onDraw(SkCanvas* canvas) { + SkPaint paint; + this->setupPaint(&paint); + paint.setAntiAlias(true); + paint.setColor(SK_ColorBLACK); + SkRect r; + + // Draw small aa rects in a grid across the screen + for (SkScalar y = SK_ScalarHalf; y < H; y += SkIntToScalar(2)) { + for (SkScalar x = SK_ScalarHalf; x < W; x += SkIntToScalar(2)) { + r.set(x, y, + x+SkFloatToScalar(1.5f), y+SkFloatToScalar(1.5f)); + canvas->drawRect(r, paint); + } + } + + } +private: + typedef SkBenchmark INHERITED; +}; + /******************************************************************************* * to bench BlitMask [Opaque, Black, color, shader] *******************************************************************************/ @@ -251,6 +288,7 @@ DEF_BENCH( return SkNEW_ARGS(PointsBench, (p, SkCanvas::kLines_PointMode, "lines DEF_BENCH( return SkNEW_ARGS(PointsBench, (p, SkCanvas::kPolygon_PointMode, "polygon")); ) DEF_BENCH( return SkNEW_ARGS(SrcModeRectBench, (p)); ) +DEF_BENCH( return SkNEW_ARGS(AARectBench, (p)); ) /* init the blitmask bench */ |