2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
11 #include "SkColorPriv.h"
15 #include "SkRasterClip.h"
17 class DrawPathBench : public Benchmark {
27 DrawPathBench(bool drawCoverage) : fDrawCoverage(drawCoverage) {
28 fPaint.setAntiAlias(true);
29 fName.printf("draw_coverage_%s", drawCoverage ? "true" : "false");
32 fPath.quadTo(500, 0, 500, 500);
33 fPath.quadTo(250, 0, 0, 500);
35 fBitmap.allocPixels(SkImageInfo::MakeA8(500, 500));
37 fIdentity.setIdentity();
38 fRC.setRect(fPath.getBounds().round());
40 fDraw.fBitmap = &fBitmap;
41 fDraw.fMatrix = &fIdentity;
42 fDraw.fClip = &fRC.bwRgn();
47 const char* onGetName() SK_OVERRIDE {
51 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
53 for (int i = 0; i < loops; ++i) {
54 fDraw.drawPathCoverage(fPath, fPaint);
57 for (int i = 0; i < loops; ++i) {
58 fDraw.drawPath(fPath, fPaint);
64 typedef Benchmark INHERITED;
67 ///////////////////////////////////////////////////////////////////////////////
69 DEF_BENCH( return new DrawPathBench(false) )
70 DEF_BENCH( return new DrawPathBench(true) )