Index: bench/RectBench.cpp |
=================================================================== |
--- bench/RectBench.cpp (revision 8933) |
+++ bench/RectBench.cpp (working copy) |
@@ -169,30 +169,48 @@ |
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,8 +308,10 @@ |
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 |
*/ |
DEF_BENCH( return SkNEW_ARGS(BlitMaskBench, |