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 "SkBenchmark.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 64 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
65 SkPaint paint; | 65 SkPaint paint; |
66 this->setupPaint(&paint); | 66 this->setupPaint(&paint); |
67 paint.setStyle(SkPaint::kStroke_Style); | 67 paint.setStyle(SkPaint::kStroke_Style); |
68 paint.setStrokeWidth(SkIntToScalar(fWidth)); | 68 paint.setStrokeWidth(SkIntToScalar(fWidth)); |
69 paint.setAntiAlias(false); | 69 paint.setAntiAlias(false); |
70 | 70 |
71 SkPath path; | 71 SkPath path; |
72 this->makePath(&path); | 72 this->makePath(&path); |
73 | 73 |
74 paint.setPathEffect(new SkDashPathEffect(fIntervals.begin(), | 74 paint.setPathEffect(SkDashPathEffect::Create(fIntervals.begin(), |
75 fIntervals.count(), 0))->unref(
); | 75 fIntervals.count(), 0))->un
ref(); |
76 | 76 |
77 if (fDoClip) { | 77 if (fDoClip) { |
78 SkRect r = path.getBounds(); | 78 SkRect r = path.getBounds(); |
79 r.inset(-SkIntToScalar(20), -SkIntToScalar(20)); | 79 r.inset(-SkIntToScalar(20), -SkIntToScalar(20)); |
80 // now move it so we don't intersect | 80 // now move it so we don't intersect |
81 r.offset(0, r.height() * 3 / 2); | 81 r.offset(0, r.height() * 3 / 2); |
82 canvas->clipRect(r); | 82 canvas->clipRect(r); |
83 } | 83 } |
84 | 84 |
85 this->handlePath(canvas, path, paint, loops); | 85 this->handlePath(canvas, path, paint, loops); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 SkString fName; | 179 SkString fName; |
180 SkPath fPath; | 180 SkPath fPath; |
181 SkAutoTUnref<SkPathEffect> fPE; | 181 SkAutoTUnref<SkPathEffect> fPE; |
182 | 182 |
183 public: | 183 public: |
184 MakeDashBench(void (*proc)(SkPath*), const char name[]) { | 184 MakeDashBench(void (*proc)(SkPath*), const char name[]) { |
185 fName.printf("makedash_%s", name); | 185 fName.printf("makedash_%s", name); |
186 proc(&fPath); | 186 proc(&fPath); |
187 | 187 |
188 SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) }; | 188 SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) }; |
189 fPE.reset(new SkDashPathEffect(vals, 2, 0)); | 189 fPE.reset(SkDashPathEffect::Create(vals, 2, 0)); |
190 } | 190 } |
191 | 191 |
192 protected: | 192 protected: |
193 virtual const char* onGetName() SK_OVERRIDE { | 193 virtual const char* onGetName() SK_OVERRIDE { |
194 return fName.c_str(); | 194 return fName.c_str(); |
195 } | 195 } |
196 | 196 |
197 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { | 197 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { |
198 SkPath dst; | 198 SkPath dst; |
199 for (int i = 0; i < loops; ++i) { | 199 for (int i = 0; i < loops; ++i) { |
(...skipping 17 matching lines...) Expand all Loading... |
217 bool fIsRound; | 217 bool fIsRound; |
218 SkAutoTUnref<SkPathEffect> fPE; | 218 SkAutoTUnref<SkPathEffect> fPE; |
219 | 219 |
220 public: | 220 public: |
221 DashLineBench(SkScalar width, bool isRound) { | 221 DashLineBench(SkScalar width, bool isRound) { |
222 fName.printf("dashline_%g_%s", SkScalarToFloat(width), isRound ? "circle
" : "square"); | 222 fName.printf("dashline_%g_%s", SkScalarToFloat(width), isRound ? "circle
" : "square"); |
223 fStrokeWidth = width; | 223 fStrokeWidth = width; |
224 fIsRound = isRound; | 224 fIsRound = isRound; |
225 | 225 |
226 SkScalar vals[] = { SK_Scalar1, SK_Scalar1 }; | 226 SkScalar vals[] = { SK_Scalar1, SK_Scalar1 }; |
227 fPE.reset(new SkDashPathEffect(vals, 2, 0)); | 227 fPE.reset(SkDashPathEffect::Create(vals, 2, 0)); |
228 } | 228 } |
229 | 229 |
230 protected: | 230 protected: |
231 virtual const char* onGetName() SK_OVERRIDE { | 231 virtual const char* onGetName() SK_OVERRIDE { |
232 return fName.c_str(); | 232 return fName.c_str(); |
233 } | 233 } |
234 | 234 |
235 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 235 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
236 SkPaint paint; | 236 SkPaint paint; |
237 this->setupPaint(&paint); | 237 this->setupPaint(&paint); |
(...skipping 18 matching lines...) Expand all Loading... |
256 SkAutoTUnref<SkPathEffect> fPathEffect; | 256 SkAutoTUnref<SkPathEffect> fPathEffect; |
257 | 257 |
258 public: | 258 public: |
259 DrawPointsDashingBench(int dashLength, int strokeWidth, bool doAA) | 259 DrawPointsDashingBench(int dashLength, int strokeWidth, bool doAA) |
260 { | 260 { |
261 fName.printf("drawpointsdash_%d_%d%s", dashLength, strokeWidth, doAA ? "
_aa" : "_bw"); | 261 fName.printf("drawpointsdash_%d_%d%s", dashLength, strokeWidth, doAA ? "
_aa" : "_bw"); |
262 fStrokeWidth = strokeWidth; | 262 fStrokeWidth = strokeWidth; |
263 fDoAA = doAA; | 263 fDoAA = doAA; |
264 | 264 |
265 SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength)
}; | 265 SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength)
}; |
266 fPathEffect.reset(new SkDashPathEffect(vals, 2, SK_Scalar1, false)); | 266 fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1, false)); |
267 } | 267 } |
268 | 268 |
269 protected: | 269 protected: |
270 virtual const char* onGetName() SK_OVERRIDE { | 270 virtual const char* onGetName() SK_OVERRIDE { |
271 return fName.c_str(); | 271 return fName.c_str(); |
272 } | 272 } |
273 | 273 |
274 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 274 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
275 SkPaint p; | 275 SkPaint p; |
276 this->setupPaint(&p); | 276 this->setupPaint(&p); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 return gNames[lt]; | 316 return gNames[lt]; |
317 } | 317 } |
318 | 318 |
319 GiantDashBench(LineType lt, SkScalar width) { | 319 GiantDashBench(LineType lt, SkScalar width) { |
320 fName.printf("giantdashline_%s_%g", LineTypeName(lt), width); | 320 fName.printf("giantdashline_%s_%g", LineTypeName(lt), width); |
321 fStrokeWidth = width; | 321 fStrokeWidth = width; |
322 | 322 |
323 // deliberately pick intervals that won't be caught by asPoints(), so | 323 // deliberately pick intervals that won't be caught by asPoints(), so |
324 // we can test the filterPath code-path. | 324 // we can test the filterPath code-path. |
325 const SkScalar intervals[] = { 2, 1, 1, 1 }; | 325 const SkScalar intervals[] = { 2, 1, 1, 1 }; |
326 fPathEffect.reset(new SkDashPathEffect(intervals, | 326 fPathEffect.reset(SkDashPathEffect::Create(intervals, |
327 SK_ARRAY_COUNT(intervals), 0)); | 327 SK_ARRAY_COUNT(intervals), 0)
); |
328 | 328 |
329 SkScalar cx = 640 / 2; // center X | 329 SkScalar cx = 640 / 2; // center X |
330 SkScalar cy = 480 / 2; // center Y | 330 SkScalar cy = 480 / 2; // center Y |
331 SkMatrix matrix; | 331 SkMatrix matrix; |
332 | 332 |
333 switch (lt) { | 333 switch (lt) { |
334 case kHori_LineType: | 334 case kHori_LineType: |
335 matrix.setIdentity(); | 335 matrix.setIdentity(); |
336 break; | 336 break; |
337 case kVert_LineType: | 337 case kVert_LineType: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 0); ) | 409 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 0); ) |
410 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 0); ) | 410 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 0); ) |
411 | 411 |
412 // pass 2 to explicitly avoid any 1-is-the-same-as-hairline special casing | 412 // pass 2 to explicitly avoid any 1-is-the-same-as-hairline special casing |
413 | 413 |
414 // hori_2 is just too slow to enable at the moment | 414 // hori_2 is just too slow to enable at the moment |
415 DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); ) | 415 DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); ) |
416 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); ) | 416 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); ) |
417 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); ) | 417 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); ) |
418 #endif | 418 #endif |
OLD | NEW |