2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
13 static void make_path(SkPath& path) {
14 #include "BigPathBench.inc"
23 const char* gAlignName[] = { "left", "middle", "right" };
25 // Inspired by crbug.com/455429
26 class BigPathBench : public Benchmark {
33 BigPathBench(Align align, bool round) : fAlign(align), fRound(round) {
34 fName.printf("bigpath_%s", gAlignName[fAlign]);
36 fName.append("_round");
41 const char* onGetName() override {
45 SkIPoint onGetSize() override {
46 return SkIPoint::Make(640, 100);
49 void onDelayedSetup() override {
53 void onDraw(const int loops, SkCanvas* canvas) override {
55 paint.setAntiAlias(true);
56 paint.setStyle(SkPaint::kStroke_Style);
57 paint.setStrokeWidth(2);
59 paint.setStrokeJoin(SkPaint::kRound_Join);
61 this->setupPaint(&paint);
63 const SkRect r = fPath.getBounds();
66 canvas->translate(-r.left(), 0);
71 canvas->translate(640 - r.right(), 0);
75 for (int i = 0; i < loops; i++) {
76 canvas->drawPath(fPath, paint);
81 typedef Benchmark INHERITED;
84 DEF_BENCH( return new BigPathBench(kLeft_Align, false); )
85 DEF_BENCH( return new BigPathBench(kMiddle_Align, false); )
86 DEF_BENCH( return new BigPathBench(kRight_Align, false); )
88 DEF_BENCH( return new BigPathBench(kLeft_Align, true); )
89 DEF_BENCH( return new BigPathBench(kMiddle_Align, true); )
90 DEF_BENCH( return new BigPathBench(kRight_Align, true); )