Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1086)

Side by Side Diff: bench/BigPathBench.cpp

Issue 909563002: add bench for very big paths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move giant path data into sep file Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | bench/BigPathBench.inc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Benchmark.h"
9 #include "SkCanvas.h"
10 #include "SkPath.h"
11 #include "SkString.h"
12
13 static void make_path(SkPath& path) {
14 #include "BigPathBench.inc"
15 }
16
17 enum Align {
18 kLeft_Align,
19 kMiddle_Align,
20 kRight_Align
21 };
22
23 const char* gAlignName[] = { "left", "middle", "right" };
24
25 // Inspired by crbug.com/455429
26 class BigPathBench : public Benchmark {
27 SkPath fPath;
28 SkString fName;
29 Align fAlign;
30
31 public:
32 BigPathBench(Align align) : fAlign(align) {
33 fName.printf("bigpath_%s", gAlignName[fAlign]);
34 }
35
36 protected:
37 const char* onGetName() SK_OVERRIDE {
38 return fName.c_str();
39 }
40
41 SkIPoint onGetSize() SK_OVERRIDE {
42 return SkIPoint::Make(640, 100);
43 }
44
45 void onPreDraw() SK_OVERRIDE {
46 make_path(fPath);
47 }
48
49 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
50 SkPaint paint;
51 paint.setAntiAlias(true);
52 paint.setStyle(SkPaint::kStroke_Style);
53 paint.setStrokeWidth(2);
54 this->setupPaint(&paint);
55
56 const SkRect r = fPath.getBounds();
57 switch (fAlign) {
58 case kLeft_Align:
59 canvas->translate(-r.left(), 0);
60 break;
61 case kMiddle_Align:
62 break;
63 case kRight_Align:
64 canvas->translate(640 - r.right(), 0);
65 break;
66 }
67
68 for (int i = 0; i < loops; i++) {
69 canvas->drawPath(fPath, paint);
70 }
71 }
72
73 private:
74 typedef Benchmark INHERITED;
75 };
76
77 DEF_BENCH( return new BigPathBench(kLeft_Align); )
78 DEF_BENCH( return new BigPathBench(kMiddle_Align); )
79 DEF_BENCH( return new BigPathBench(kRight_Align); )
80
OLDNEW
« no previous file with comments | « no previous file | bench/BigPathBench.inc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698