| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 120 SkPaint p(paint); | 120 SkPaint p(paint); |
| 121 p.setStyle(SkPaint::kFill_Style); | 121 p.setStyle(SkPaint::kFill_Style); |
| 122 p.setPathEffect(NULL); | 122 p.setPathEffect(nullptr); |
| 123 | 123 |
| 124 int count = SkScalarRoundToInt((pts[1].fX - pts[0].fX) / (2*fWidth))
; | 124 int count = SkScalarRoundToInt((pts[1].fX - pts[0].fX) / (2*fWidth))
; |
| 125 SkScalar dx = SkIntToScalar(2 * fWidth); | 125 SkScalar dx = SkIntToScalar(2 * fWidth); |
| 126 | 126 |
| 127 for (int i = 0; i < N*10; ++i) { | 127 for (int i = 0; i < N*10; ++i) { |
| 128 SkRect r = rect; | 128 SkRect r = rect; |
| 129 for (int j = 0; j < count; ++j) { | 129 for (int j = 0; j < count; ++j) { |
| 130 canvas->drawRect(r, p); | 130 canvas->drawRect(r, p); |
| 131 r.offset(dx, 0); | 131 r.offset(dx, 0); |
| 132 } | 132 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 protected: | 191 protected: |
| 192 const char* onGetName() override { | 192 const char* onGetName() override { |
| 193 return fName.c_str(); | 193 return fName.c_str(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void onDraw(const int loops, SkCanvas*) override { | 196 void onDraw(const int loops, SkCanvas*) override { |
| 197 SkPath dst; | 197 SkPath dst; |
| 198 for (int i = 0; i < loops; ++i) { | 198 for (int i = 0; i < loops; ++i) { |
| 199 SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle); | 199 SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle); |
| 200 | 200 |
| 201 fPE->filterPath(&dst, fPath, &rec, NULL); | 201 fPE->filterPath(&dst, fPath, &rec, nullptr); |
| 202 dst.rewind(); | 202 dst.rewind(); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 private: | 206 private: |
| 207 typedef Benchmark INHERITED; | 207 typedef Benchmark INHERITED; |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 /* | 210 /* |
| 211 * We try to special case square dashes (intervals are equal to strokewidth). | 211 * We try to special case square dashes (intervals are equal to strokewidth). |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 // hori_2 is just too slow to enable at the moment | 479 // hori_2 is just too slow to enable at the moment |
| 480 DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); ) | 480 DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); ) |
| 481 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); ) | 481 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); ) |
| 482 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); ) | 482 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); ) |
| 483 | 483 |
| 484 DEF_BENCH( return new DashGridBench(1, 1, true); ) | 484 DEF_BENCH( return new DashGridBench(1, 1, true); ) |
| 485 DEF_BENCH( return new DashGridBench(1, 1, false); ) | 485 DEF_BENCH( return new DashGridBench(1, 1, false); ) |
| 486 DEF_BENCH( return new DashGridBench(3, 1, true); ) | 486 DEF_BENCH( return new DashGridBench(3, 1, true); ) |
| 487 DEF_BENCH( return new DashGridBench(3, 1, false); ) | 487 DEF_BENCH( return new DashGridBench(3, 1, false); ) |
| 488 #endif | 488 #endif |
| OLD | NEW |