3 * Copyright 2011 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
11 #include "SkColorPriv.h"
17 static int rand_pts(SkRandom& rand, SkPoint pts[4]) {
18 int n = rand.nextU() & 3;
21 for (int i = 0; i < n; ++i) {
22 pts[i].fX = rand.nextSScalar1();
23 pts[i].fY = rand.nextSScalar1();
28 class PathIterBench : public Benchmark {
34 PathIterBench(bool raw) {
35 fName.printf("pathiter_%s", raw ? "raw" : "consume");
39 for (int i = 0; i < 1000; ++i) {
41 int n = rand_pts(rand, pts);
50 fPath.quadTo(pts[1], pts[2]);
53 fPath.cubicTo(pts[1], pts[2], pts[3]);
59 bool isSuitableFor(Backend backend) SK_OVERRIDE {
60 return backend == kNonRendering_Backend;
64 const char* onGetName() SK_OVERRIDE {
68 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
70 for (int i = 0; i < loops; ++i) {
71 SkPath::RawIter iter(fPath);
75 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { }
78 for (int i = 0; i < loops; ++i) {
79 SkPath::Iter iter(fPath, false);
83 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { }
89 typedef Benchmark INHERITED;
92 ///////////////////////////////////////////////////////////////////////////////
94 DEF_BENCH( return new PathIterBench(false); )
95 DEF_BENCH( return new PathIterBench(true); )