OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBenchmark.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkRandom.h" | 13 #include "SkRandom.h" |
14 #include "SkShader.h" | 14 #include "SkShader.h" |
15 #include "SkString.h" | 15 #include "SkString.h" |
16 #include "SkTArray.h" | 16 #include "SkTArray.h" |
17 | 17 |
18 | 18 |
19 class LineBench : public SkBenchmark { | 19 class LineBench : public SkBenchmark { |
20 SkScalar fStrokeWidth; | 20 SkScalar fStrokeWidth; |
21 bool fDoAA; | 21 bool fDoAA; |
22 SkString fName; | 22 SkString fName; |
23 enum { | 23 enum { |
24 PTS = 500, | 24 PTS = 500, |
25 }; | 25 }; |
26 SkPoint fPts[PTS]; | 26 SkPoint fPts[PTS]; |
27 | 27 |
28 public: | 28 public: |
29 LineBench(void* param, SkScalar width, bool doAA) : INHERITED(param) { | 29 LineBench(SkScalar width, bool doAA) { |
30 fStrokeWidth = width; | 30 fStrokeWidth = width; |
31 fDoAA = doAA; | 31 fDoAA = doAA; |
32 fName.printf("lines_%g_%s", width, doAA ? "AA" : "BW"); | 32 fName.printf("lines_%g_%s", width, doAA ? "AA" : "BW"); |
33 | 33 |
34 SkRandom rand; | 34 SkRandom rand; |
35 for (int i = 0; i < PTS; ++i) { | 35 for (int i = 0; i < PTS; ++i) { |
36 fPts[i].set(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480); | 36 fPts[i].set(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
(...skipping 12 matching lines...) Expand all Loading... |
52 | 52 |
53 for (int i = 0; i < this->getLoops(); i++) { | 53 for (int i = 0; i < this->getLoops(); i++) { |
54 canvas->drawPoints(SkCanvas::kLines_PointMode, PTS, fPts, paint); | 54 canvas->drawPoints(SkCanvas::kLines_PointMode, PTS, fPts, paint); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 typedef SkBenchmark INHERITED; | 59 typedef SkBenchmark INHERITED; |
60 }; | 60 }; |
61 | 61 |
62 DEF_BENCH(return new LineBench(p, 0, false);) | 62 DEF_BENCH(return new LineBench(0, false);) |
63 DEF_BENCH(return new LineBench(p, SK_Scalar1, false);) | 63 DEF_BENCH(return new LineBench(SK_Scalar1, false);) |
64 DEF_BENCH(return new LineBench(p, 0, true);) | 64 DEF_BENCH(return new LineBench(0, true);) |
65 DEF_BENCH(return new LineBench(p, SK_Scalar1/2, true);) | 65 DEF_BENCH(return new LineBench(SK_Scalar1/2, true);) |
66 DEF_BENCH(return new LineBench(p, SK_Scalar1, true);) | 66 DEF_BENCH(return new LineBench(SK_Scalar1, true);) |
OLD | NEW |