virtual const char* onGetName() { return fName; }
};
-class AARectBench : public Benchmark {
-public:
- enum {
- W = 640,
- H = 480,
- };
-
- AARectBench(bool rotate) : fRotate(rotate) {}
-
-protected:
-
- virtual const char* onGetName() {
- if (fRotate) {
- return "aarects_rotated";
- }
- return "aarects";
- }
-
- virtual void onDraw(const int loops, SkCanvas* canvas) {
- static const SkScalar kHalfRectSize = 0.75f;
-
- SkPaint paint;
- this->setupPaint(&paint);
- paint.setAntiAlias(true);
- paint.setColor(SK_ColorBLACK);
- SkRect r = { -kHalfRectSize, -kHalfRectSize, kHalfRectSize, kHalfRectSize };
- int rot = 0;
-
- for (int i = 0; i < loops; i++) {
- // Draw small aa rects in a grid across the screen
- 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 Benchmark INHERITED;
-};
-
/*******************************************************************************
* to bench BlitMask [Opaque, Black, color, shader]
*******************************************************************************/
DEF_BENCH( return SkNEW_ARGS(SrcModeRectBench, ()); )
-DEF_BENCH( return SkNEW_ARGS(AARectBench, (false)); )
-DEF_BENCH( return SkNEW_ARGS(AARectBench, (true)); )
-
/* init the blitmask bench
*/
DEF_BENCH( return SkNEW_ARGS(BlitMaskBench,