virtual void onDraw(SkCanvas* canvas) { SkPaint paint; this->setupPaint(&paint); paint.setAntiAlias(true); SkMWCRandom rand; for (int i = 0; i < SkBENCHLOOP(3); i++) { SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400, rand.nextUScalar1() * 400); paint.setImageFilter(fFilter); canvas->drawOval(r, paint); } }
static void rand_op(SkCanvas* canvas, SkMWCRandom& rand) { SkPaint paint; SkRect rect = SkRect::MakeWH(50, 50); SkScalar unit = rand.nextUScalar1(); if (unit <= 0.3) { // SkDebugf("save\n"); canvas->save(); } else if (unit <= 0.6) { // SkDebugf("restore\n"); canvas->restore(); } else if (unit <= 0.9) { // SkDebugf("clip\n"); canvas->clipRect(rect); } else { // SkDebugf("draw\n"); canvas->drawPaint(paint); } }