2 * Copyright 2012 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"
19 class LineBench : public Benchmark {
20 SkScalar fStrokeWidth;
29 LineBench(SkScalar width, bool doAA) {
32 fName.printf("lines_%g_%s", width, doAA ? "AA" : "BW");
35 for (int i = 0; i < PTS; ++i) {
36 fPts[i].set(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
41 const char* onGetName() SK_OVERRIDE {
45 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
47 this->setupPaint(&paint);
49 paint.setStyle(SkPaint::kStroke_Style);
50 paint.setAntiAlias(fDoAA);
51 paint.setStrokeWidth(fStrokeWidth);
53 for (int i = 0; i < loops; i++) {
54 canvas->drawPoints(SkCanvas::kLines_PointMode, PTS, fPts, paint);
59 typedef Benchmark INHERITED;
62 DEF_BENCH(return new LineBench(0, false);)
63 DEF_BENCH(return new LineBench(SK_Scalar1, false);)
64 DEF_BENCH(return new LineBench(0, true);)
65 DEF_BENCH(return new LineBench(SK_Scalar1/2, true);)
66 DEF_BENCH(return new LineBench(SK_Scalar1, true);)