OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkBenchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCommandLineFlags.h" | 10 #include "SkCommandLineFlags.h" |
11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
13 #include "SkShader.h" | 13 #include "SkShader.h" |
14 #include "SkString.h" | 14 #include "SkString.h" |
15 | 15 |
16 DEFINE_double(strokeWidth, -1.0, "If set, use this stroke width in RectBench."); | 16 DEFINE_double(strokeWidth, -1.0, "If set, use this stroke width in RectBench."); |
17 | 17 |
18 class RectBench : public SkBenchmark { | 18 class RectBench : public Benchmark { |
19 public: | 19 public: |
20 int fShift, fStroke; | 20 int fShift, fStroke; |
21 enum { | 21 enum { |
22 W = 640, | 22 W = 640, |
23 H = 480, | 23 H = 480, |
24 N = 300, | 24 N = 300, |
25 }; | 25 }; |
26 SkRect fRects[N]; | 26 SkRect fRects[N]; |
27 SkColor fColors[N]; | 27 SkColor fColors[N]; |
28 | 28 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 paint.setStyle(SkPaint::kStroke_Style); | 71 paint.setStyle(SkPaint::kStroke_Style); |
72 paint.setStrokeWidth(SkIntToScalar(fStroke)); | 72 paint.setStrokeWidth(SkIntToScalar(fStroke)); |
73 } | 73 } |
74 for (int i = 0; i < loops; i++) { | 74 for (int i = 0; i < loops; i++) { |
75 paint.setColor(fColors[i % N]); | 75 paint.setColor(fColors[i % N]); |
76 this->setupPaint(&paint); | 76 this->setupPaint(&paint); |
77 this->drawThisRect(canvas, fRects[i % N], paint); | 77 this->drawThisRect(canvas, fRects[i % N], paint); |
78 } | 78 } |
79 } | 79 } |
80 private: | 80 private: |
81 typedef SkBenchmark INHERITED; | 81 typedef Benchmark INHERITED; |
82 }; | 82 }; |
83 | 83 |
84 class SrcModeRectBench : public RectBench { | 84 class SrcModeRectBench : public RectBench { |
85 public: | 85 public: |
86 SrcModeRectBench() : INHERITED(1, 0) { | 86 SrcModeRectBench() : INHERITED(1, 0) { |
87 fMode = SkXfermode::Create(SkXfermode::kSrc_Mode); | 87 fMode = SkXfermode::Create(SkXfermode::kSrc_Mode); |
88 } | 88 } |
89 | 89 |
90 virtual ~SrcModeRectBench() { | 90 virtual ~SrcModeRectBench() { |
91 SkSafeUnref(fMode); | 91 SkSafeUnref(fMode); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 paint.setStrokeWidth(gSizes[i]); | 163 paint.setStrokeWidth(gSizes[i]); |
164 this->setupPaint(&paint); | 164 this->setupPaint(&paint); |
165 canvas->drawPoints(fMode, N * 2, SkTCast<SkPoint*>(fRects), pain
t); | 165 canvas->drawPoints(fMode, N * 2, SkTCast<SkPoint*>(fRects), pain
t); |
166 paint.setColor(fColors[i % N]); | 166 paint.setColor(fColors[i % N]); |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
170 virtual const char* onGetName() { return fName; } | 170 virtual const char* onGetName() { return fName; } |
171 }; | 171 }; |
172 | 172 |
173 class AARectBench : public SkBenchmark { | 173 class AARectBench : public Benchmark { |
174 public: | 174 public: |
175 enum { | 175 enum { |
176 W = 640, | 176 W = 640, |
177 H = 480, | 177 H = 480, |
178 }; | 178 }; |
179 | 179 |
180 AARectBench(bool rotate) : fRotate(rotate) {} | 180 AARectBench(bool rotate) : fRotate(rotate) {} |
181 | 181 |
182 protected: | 182 protected: |
183 | 183 |
(...skipping 30 matching lines...) Expand all Loading... |
214 | 214 |
215 canvas->drawRect(r, paint); | 215 canvas->drawRect(r, paint); |
216 canvas->restore(); | 216 canvas->restore(); |
217 } | 217 } |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 } | 221 } |
222 private: | 222 private: |
223 bool fRotate; | 223 bool fRotate; |
224 typedef SkBenchmark INHERITED; | 224 typedef Benchmark INHERITED; |
225 }; | 225 }; |
226 | 226 |
227 /******************************************************************************* | 227 /******************************************************************************* |
228 * to bench BlitMask [Opaque, Black, color, shader] | 228 * to bench BlitMask [Opaque, Black, color, shader] |
229 *******************************************************************************
/ | 229 *******************************************************************************
/ |
230 | 230 |
231 class BlitMaskBench : public RectBench { | 231 class BlitMaskBench : public RectBench { |
232 public: | 232 public: |
233 enum kMaskType { | 233 enum kMaskType { |
234 kMaskOpaque = 0, | 234 kMaskOpaque = 0, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 BlitMaskBench::kMaskBlack, "maskblack") | 336 BlitMaskBench::kMaskBlack, "maskblack") |
337 ); ) | 337 ); ) |
338 DEF_BENCH( return SkNEW_ARGS(BlitMaskBench, | 338 DEF_BENCH( return SkNEW_ARGS(BlitMaskBench, |
339 (SkCanvas::kPoints_PointMode, | 339 (SkCanvas::kPoints_PointMode, |
340 BlitMaskBench::kMaskColor, "maskcolor") | 340 BlitMaskBench::kMaskColor, "maskcolor") |
341 ); ) | 341 ); ) |
342 DEF_BENCH( return SkNEW_ARGS(BlitMaskBench, | 342 DEF_BENCH( return SkNEW_ARGS(BlitMaskBench, |
343 (SkCanvas::kPoints_PointMode, | 343 (SkCanvas::kPoints_PointMode, |
344 BlitMaskBench::KMaskShader, "maskshader") | 344 BlitMaskBench::KMaskShader, "maskshader") |
345 ); ) | 345 ); ) |
OLD | NEW |