| 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 "Benchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 fPts[0].set(SkIntToScalar(10), SkIntToScalar(10)); | 51 fPts[0].set(SkIntToScalar(10), SkIntToScalar(10)); |
| 52 fPts[1].set(SkIntToScalar(600), SkIntToScalar(10)); | 52 fPts[1].set(SkIntToScalar(600), SkIntToScalar(10)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual void makePath(SkPath* path) { | 55 virtual void makePath(SkPath* path) { |
| 56 path_hline(path); | 56 path_hline(path); |
| 57 } | 57 } |
| 58 | 58 |
| 59 protected: | 59 protected: |
| 60 const char* onGetName() SK_OVERRIDE { | 60 const char* onGetName() override { |
| 61 return fName.c_str(); | 61 return fName.c_str(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 64 void onDraw(const int loops, SkCanvas* canvas) 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(SkDashPathEffect::Create(fIntervals.begin(), | 74 paint.setPathEffect(SkDashPathEffect::Create(fIntervals.begin(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 99 | 99 |
| 100 class RectDashBench : public DashBench { | 100 class RectDashBench : public DashBench { |
| 101 public: | 101 public: |
| 102 RectDashBench(const SkScalar intervals[], int count, int width) | 102 RectDashBench(const SkScalar intervals[], int count, int width) |
| 103 : INHERITED(intervals, count, width) { | 103 : INHERITED(intervals, count, width) { |
| 104 fName.append("_rect"); | 104 fName.append("_rect"); |
| 105 } | 105 } |
| 106 | 106 |
| 107 protected: | 107 protected: |
| 108 virtual void handlePath(SkCanvas* canvas, const SkPath& path, | 108 virtual void handlePath(SkCanvas* canvas, const SkPath& path, |
| 109 const SkPaint& paint, int N) SK_OVERRIDE { | 109 const SkPaint& paint, int N) override { |
| 110 SkPoint pts[2]; | 110 SkPoint pts[2]; |
| 111 if (!path.isLine(pts) || pts[0].fY != pts[1].fY) { | 111 if (!path.isLine(pts) || pts[0].fY != pts[1].fY) { |
| 112 this->INHERITED::handlePath(canvas, path, paint, N); | 112 this->INHERITED::handlePath(canvas, path, paint, N); |
| 113 } else { | 113 } else { |
| 114 SkRect rect; | 114 SkRect rect; |
| 115 rect.fLeft = pts[0].fX; | 115 rect.fLeft = pts[0].fX; |
| 116 rect.fTop = pts[0].fY - paint.getStrokeWidth() / 2; | 116 rect.fTop = pts[0].fY - paint.getStrokeWidth() / 2; |
| 117 rect.fRight = rect.fLeft + SkIntToScalar(fWidth); | 117 rect.fRight = rect.fLeft + SkIntToScalar(fWidth); |
| 118 rect.fBottom = rect.fTop + paint.getStrokeWidth(); | 118 rect.fBottom = rect.fTop + paint.getStrokeWidth(); |
| 119 | 119 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(SkDashPathEffect::Create(vals, 2, 0)); | 189 fPE.reset(SkDashPathEffect::Create(vals, 2, 0)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 protected: | 192 protected: |
| 193 const char* onGetName() SK_OVERRIDE { | 193 const char* onGetName() override { |
| 194 return fName.c_str(); | 194 return fName.c_str(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { | 197 void onDraw(const int loops, SkCanvas*) override { |
| 198 SkPath dst; | 198 SkPath dst; |
| 199 for (int i = 0; i < loops; ++i) { | 199 for (int i = 0; i < loops; ++i) { |
| 200 SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle); | 200 SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle); |
| 201 | 201 |
| 202 fPE->filterPath(&dst, fPath, &rec, NULL); | 202 fPE->filterPath(&dst, fPath, &rec, NULL); |
| 203 dst.rewind(); | 203 dst.rewind(); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 private: | 207 private: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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(SkDashPathEffect::Create(vals, 2, 0)); | 227 fPE.reset(SkDashPathEffect::Create(vals, 2, 0)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 protected: | 230 protected: |
| 231 const char* onGetName() SK_OVERRIDE { | 231 const char* onGetName() override { |
| 232 return fName.c_str(); | 232 return fName.c_str(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 235 void onDraw(const int loops, SkCanvas* canvas) override { |
| 236 SkPaint paint; | 236 SkPaint paint; |
| 237 this->setupPaint(&paint); | 237 this->setupPaint(&paint); |
| 238 paint.setStrokeWidth(fStrokeWidth); | 238 paint.setStrokeWidth(fStrokeWidth); |
| 239 paint.setStrokeCap(fIsRound ? SkPaint::kRound_Cap : SkPaint::kSquare_Cap
); | 239 paint.setStrokeCap(fIsRound ? SkPaint::kRound_Cap : SkPaint::kSquare_Cap
); |
| 240 paint.setPathEffect(fPE); | 240 paint.setPathEffect(fPE); |
| 241 for (int i = 0; i < loops; ++i) { | 241 for (int i = 0; i < loops; ++i) { |
| 242 canvas->drawLine(10 * SK_Scalar1, 10 * SK_Scalar1, | 242 canvas->drawLine(10 * SK_Scalar1, 10 * SK_Scalar1, |
| 243 640 * SK_Scalar1, 10 * SK_Scalar1, paint); | 243 640 * SK_Scalar1, 10 * SK_Scalar1, paint); |
| 244 } | 244 } |
| 245 } | 245 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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(SkDashPathEffect::Create(vals, 2, SK_Scalar1)); | 266 fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1)); |
| 267 } | 267 } |
| 268 | 268 |
| 269 protected: | 269 protected: |
| 270 const char* onGetName() SK_OVERRIDE { | 270 const char* onGetName() override { |
| 271 return fName.c_str(); | 271 return fName.c_str(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 274 void onDraw(const int loops, SkCanvas* canvas) override { |
| 275 SkPaint p; | 275 SkPaint p; |
| 276 this->setupPaint(&p); | 276 this->setupPaint(&p); |
| 277 p.setColor(SK_ColorBLACK); | 277 p.setColor(SK_ColorBLACK); |
| 278 p.setStyle(SkPaint::kStroke_Style); | 278 p.setStyle(SkPaint::kStroke_Style); |
| 279 p.setStrokeWidth(SkIntToScalar(fStrokeWidth)); | 279 p.setStrokeWidth(SkIntToScalar(fStrokeWidth)); |
| 280 p.setPathEffect(fPathEffect); | 280 p.setPathEffect(fPathEffect); |
| 281 p.setAntiAlias(fDoAA); | 281 p.setAntiAlias(fDoAA); |
| 282 | 282 |
| 283 SkPoint pts[2] = { | 283 SkPoint pts[2] = { |
| 284 { SkIntToScalar(10), 0 }, | 284 { SkIntToScalar(10), 0 }, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 346 } |
| 347 | 347 |
| 348 const SkScalar overshoot = 100*1000; | 348 const SkScalar overshoot = 100*1000; |
| 349 const SkPoint pts[2] = { | 349 const SkPoint pts[2] = { |
| 350 { -overshoot, cy }, { 640 + overshoot, cy } | 350 { -overshoot, cy }, { 640 + overshoot, cy } |
| 351 }; | 351 }; |
| 352 matrix.mapPoints(fPts, pts, 2); | 352 matrix.mapPoints(fPts, pts, 2); |
| 353 } | 353 } |
| 354 | 354 |
| 355 protected: | 355 protected: |
| 356 const char* onGetName() SK_OVERRIDE { | 356 const char* onGetName() override { |
| 357 return fName.c_str(); | 357 return fName.c_str(); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 360 void onDraw(const int loops, SkCanvas* canvas) override { |
| 361 SkPaint p; | 361 SkPaint p; |
| 362 this->setupPaint(&p); | 362 this->setupPaint(&p); |
| 363 p.setStyle(SkPaint::kStroke_Style); | 363 p.setStyle(SkPaint::kStroke_Style); |
| 364 p.setStrokeWidth(fStrokeWidth); | 364 p.setStrokeWidth(fStrokeWidth); |
| 365 p.setPathEffect(fPathEffect); | 365 p.setPathEffect(fPathEffect); |
| 366 | 366 |
| 367 for (int i = 0; i < loops; i++) { | 367 for (int i = 0; i < loops; i++) { |
| 368 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p); | 368 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p); |
| 369 } | 369 } |
| 370 } | 370 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 386 DashGridBench(int dashLength, int strokeWidth, bool doAA) { | 386 DashGridBench(int dashLength, int strokeWidth, bool doAA) { |
| 387 fName.printf("dashgrid_%d_%d%s", dashLength, strokeWidth, doAA ? "_aa" :
"_bw"); | 387 fName.printf("dashgrid_%d_%d%s", dashLength, strokeWidth, doAA ? "_aa" :
"_bw"); |
| 388 fStrokeWidth = strokeWidth; | 388 fStrokeWidth = strokeWidth; |
| 389 fDoAA = doAA; | 389 fDoAA = doAA; |
| 390 | 390 |
| 391 SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength)
}; | 391 SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength)
}; |
| 392 fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1)); | 392 fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1)); |
| 393 } | 393 } |
| 394 | 394 |
| 395 protected: | 395 protected: |
| 396 const char* onGetName() SK_OVERRIDE { | 396 const char* onGetName() override { |
| 397 return fName.c_str(); | 397 return fName.c_str(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 400 void onDraw(const int loops, SkCanvas* canvas) override { |
| 401 SkPaint p; | 401 SkPaint p; |
| 402 this->setupPaint(&p); | 402 this->setupPaint(&p); |
| 403 p.setColor(SK_ColorBLACK); | 403 p.setColor(SK_ColorBLACK); |
| 404 p.setStyle(SkPaint::kStroke_Style); | 404 p.setStyle(SkPaint::kStroke_Style); |
| 405 p.setStrokeWidth(SkIntToScalar(fStrokeWidth)); | 405 p.setStrokeWidth(SkIntToScalar(fStrokeWidth)); |
| 406 p.setPathEffect(fPathEffect); | 406 p.setPathEffect(fPathEffect); |
| 407 p.setAntiAlias(fDoAA); | 407 p.setAntiAlias(fDoAA); |
| 408 | 408 |
| 409 SkPoint pts[4] = { | 409 SkPoint pts[4] = { |
| 410 { SkIntToScalar(0), 20.5f }, | 410 { SkIntToScalar(0), 20.5f }, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 // hori_2 is just too slow to enable at the moment | 480 // hori_2 is just too slow to enable at the moment |
| 481 DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); ) | 481 DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); ) |
| 482 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); ) | 482 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); ) |
| 483 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); ) | 483 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); ) |
| 484 | 484 |
| 485 DEF_BENCH( return new DashGridBench(1, 1, true); ) | 485 DEF_BENCH( return new DashGridBench(1, 1, true); ) |
| 486 DEF_BENCH( return new DashGridBench(1, 1, false); ) | 486 DEF_BENCH( return new DashGridBench(1, 1, false); ) |
| 487 DEF_BENCH( return new DashGridBench(3, 1, true); ) | 487 DEF_BENCH( return new DashGridBench(3, 1, true); ) |
| 488 DEF_BENCH( return new DashGridBench(3, 1, false); ) | 488 DEF_BENCH( return new DashGridBench(3, 1, false); ) |
| 489 #endif | 489 #endif |
| OLD | NEW |