OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBenchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
11 #include "SkRRect.h" | 11 #include "SkRRect.h" |
12 #include "SkString.h" | 12 #include "SkString.h" |
13 | 13 |
14 struct RRectRec { | 14 struct RRectRec { |
15 SkCanvas* fCanvas; | 15 SkCanvas* fCanvas; |
16 SkRRect fRRect; | 16 SkRRect fRRect; |
17 SkPaint fPaint; | 17 SkPaint fPaint; |
18 }; | 18 }; |
(...skipping 27 matching lines...) Expand all Loading... |
46 } | 46 } |
47 } | 47 } |
48 return "oval"; | 48 return "oval"; |
49 } | 49 } |
50 | 50 |
51 // Handles rect, rrect, and oval | 51 // Handles rect, rrect, and oval |
52 // | 52 // |
53 // Test drawing a small stroked version to see the effect of special-casing | 53 // Test drawing a small stroked version to see the effect of special-casing |
54 // our stroke code for these convex single-contour shapes. | 54 // our stroke code for these convex single-contour shapes. |
55 // | 55 // |
56 class StrokeRRectBench : public SkBenchmark { | 56 class StrokeRRectBench : public Benchmark { |
57 SkString fName; | 57 SkString fName; |
58 SkPaint::Join fJoin; | 58 SkPaint::Join fJoin; |
59 RRectRec fRec; | 59 RRectRec fRec; |
60 DrawProc fProc; | 60 DrawProc fProc; |
61 public: | 61 public: |
62 StrokeRRectBench(SkPaint::Join j, DrawProc proc) { | 62 StrokeRRectBench(SkPaint::Join j, DrawProc proc) { |
63 static const char* gJoinName[] = { | 63 static const char* gJoinName[] = { |
64 "miter", "round", "bevel" | 64 "miter", "round", "bevel" |
65 }; | 65 }; |
66 | 66 |
(...skipping 14 matching lines...) Expand all Loading... |
81 virtual void onDraw(const int loops, SkCanvas* canvas) { | 81 virtual void onDraw(const int loops, SkCanvas* canvas) { |
82 fRec.fCanvas = canvas; | 82 fRec.fCanvas = canvas; |
83 this->setupPaint(&fRec.fPaint); | 83 this->setupPaint(&fRec.fPaint); |
84 fRec.fPaint.setStyle(SkPaint::kStroke_Style); | 84 fRec.fPaint.setStyle(SkPaint::kStroke_Style); |
85 fRec.fPaint.setStrokeJoin(fJoin); | 85 fRec.fPaint.setStrokeJoin(fJoin); |
86 fRec.fPaint.setStrokeWidth(5); | 86 fRec.fPaint.setStrokeWidth(5); |
87 fProc(&fRec, loops); | 87 fProc(&fRec, loops); |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
91 typedef SkBenchmark INHERITED; | 91 typedef Benchmark INHERITED; |
92 }; | 92 }; |
93 | 93 |
94 DEF_BENCH( return new StrokeRRectBench(SkPaint::kRound_Join, draw_rect); ) | 94 DEF_BENCH( return new StrokeRRectBench(SkPaint::kRound_Join, draw_rect); ) |
95 DEF_BENCH( return new StrokeRRectBench(SkPaint::kBevel_Join, draw_rect); ) | 95 DEF_BENCH( return new StrokeRRectBench(SkPaint::kBevel_Join, draw_rect); ) |
96 DEF_BENCH( return new StrokeRRectBench(SkPaint::kMiter_Join, draw_rect); ) | 96 DEF_BENCH( return new StrokeRRectBench(SkPaint::kMiter_Join, draw_rect); ) |
97 | 97 |
98 DEF_BENCH( return new StrokeRRectBench(SkPaint::kRound_Join, draw_rrect); ) | 98 DEF_BENCH( return new StrokeRRectBench(SkPaint::kRound_Join, draw_rrect); ) |
99 DEF_BENCH( return new StrokeRRectBench(SkPaint::kBevel_Join, draw_rrect); ) | 99 DEF_BENCH( return new StrokeRRectBench(SkPaint::kBevel_Join, draw_rrect); ) |
100 DEF_BENCH( return new StrokeRRectBench(SkPaint::kMiter_Join, draw_rrect); ) | 100 DEF_BENCH( return new StrokeRRectBench(SkPaint::kMiter_Join, draw_rrect); ) |
101 | 101 |
102 DEF_BENCH( return new StrokeRRectBench(SkPaint::kRound_Join, draw_oval); ) | 102 DEF_BENCH( return new StrokeRRectBench(SkPaint::kRound_Join, draw_oval); ) |
103 DEF_BENCH( return new StrokeRRectBench(SkPaint::kBevel_Join, draw_oval); ) | 103 DEF_BENCH( return new StrokeRRectBench(SkPaint::kBevel_Join, draw_oval); ) |
104 DEF_BENCH( return new StrokeRRectBench(SkPaint::kMiter_Join, draw_oval); ) | 104 DEF_BENCH( return new StrokeRRectBench(SkPaint::kMiter_Join, draw_oval); ) |
OLD | NEW |