diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-02 13:57:52 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-02 13:57:52 +0000 |
commit | 370d835c1cf293b46b34477ec99b84ba82ff9c49 (patch) | |
tree | 3c10a06af0550b943e540fee02852afe8569eb74 /bench | |
parent | c1c5695f8f0cda7cbabb490d274d742ca0e26eed (diff) |
Add new bench for rotated rects (aarects_rotated)
https://codereview.chromium.org/14688007/
git-svn-id: http://skia.googlecode.com/svn/trunk@8957 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r-- | bench/RectBench.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp index 2595bd5718..92abee65ed 100644 --- a/bench/RectBench.cpp +++ b/bench/RectBench.cpp @@ -169,30 +169,48 @@ public: H = 480, }; - AARectBench(void* param) : INHERITED(param) {} + AARectBench(void* param, bool rotate) : INHERITED(param), fRotate(rotate) {} protected: - virtual const char* onGetName() { return "aarects"; } + virtual const char* onGetName() { + if (fRotate) { + return "aarects_rotated"; + } + return "aarects"; + } virtual void onDraw(SkCanvas* canvas) { + static const SkScalar kHalfRectSize = SkFloatToScalar(0.75f); + SkPaint paint; this->setupPaint(&paint); paint.setAntiAlias(true); paint.setColor(SK_ColorBLACK); - SkRect r; + SkRect r = { -kHalfRectSize, -kHalfRectSize, kHalfRectSize, kHalfRectSize }; + int rot = 0; // 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)); + for (SkScalar y = kHalfRectSize+SK_Scalar1; y < H; y += 2*kHalfRectSize+2) { + for (SkScalar x = kHalfRectSize+SK_Scalar1; x < W; x += 2*kHalfRectSize+2) { + canvas->save(); + canvas->translate(x, y); + + if (fRotate) { + SkMatrix rotate; + rotate.setRotate(SkIntToScalar(rot)); + canvas->concat(rotate); + rot += 10; + } + canvas->drawRect(r, paint); + canvas->restore(); } } } private: + bool fRotate; typedef SkBenchmark INHERITED; }; @@ -290,7 +308,9 @@ 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)); ) + +DEF_BENCH( return SkNEW_ARGS(AARectBench, (p, false)); ) +DEF_BENCH( return SkNEW_ARGS(AARectBench, (p, true)); ) /* init the blitmask bench */ |