OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 | 8 |
9 #include "Benchmark.h" | 9 #include "Benchmark.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 fName.printf("Xfermode_%s", SkXfermode::ModeName(mode)); | 22 fName.printf("Xfermode_%s", SkXfermode::ModeName(mode)); |
23 } | 23 } |
24 | 24 |
25 XfermodeBench(SkXfermode* xferMode, const char* name) { | 25 XfermodeBench(SkXfermode* xferMode, const char* name) { |
26 SkASSERT(xferMode); | 26 SkASSERT(xferMode); |
27 fXfermode.reset(xferMode); | 27 fXfermode.reset(xferMode); |
28 fName.printf("Xfermode_%s", name); | 28 fName.printf("Xfermode_%s", name); |
29 } | 29 } |
30 | 30 |
31 protected: | 31 protected: |
32 const char* onGetName() SK_OVERRIDE { return fName.c_str(); } | 32 const char* onGetName() override { return fName.c_str(); } |
33 | 33 |
34 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 34 void onDraw(const int loops, SkCanvas* canvas) override { |
35 SkISize size = canvas->getDeviceSize(); | 35 SkISize size = canvas->getDeviceSize(); |
36 SkRandom random; | 36 SkRandom random; |
37 for (int i = 0; i < loops; ++i) { | 37 for (int i = 0; i < loops; ++i) { |
38 SkPaint paint; | 38 SkPaint paint; |
39 paint.setXfermode(fXfermode.get()); | 39 paint.setXfermode(fXfermode.get()); |
40 paint.setColor(random.nextU()); | 40 paint.setColor(random.nextU()); |
41 SkScalar w = random.nextRangeScalar(SkIntToScalar(kMinSize), SkIntTo
Scalar(kMaxSize)); | 41 SkScalar w = random.nextRangeScalar(SkIntToScalar(kMinSize), SkIntTo
Scalar(kMaxSize)); |
42 SkScalar h = random.nextRangeScalar(SkIntToScalar(kMinSize), SkIntTo
Scalar(kMaxSize)); | 42 SkScalar h = random.nextRangeScalar(SkIntToScalar(kMinSize), SkIntTo
Scalar(kMaxSize)); |
43 SkRect rect = SkRect::MakeXYWH( | 43 SkRect rect = SkRect::MakeXYWH( |
44 random.nextUScalar1() * (size.fWidth - w), | 44 random.nextUScalar1() * (size.fWidth - w), |
(...skipping 11 matching lines...) Expand all Loading... |
56 kMaxSize = 100, | 56 kMaxSize = 100, |
57 }; | 57 }; |
58 SkAutoTUnref<SkXfermode> fXfermode; | 58 SkAutoTUnref<SkXfermode> fXfermode; |
59 SkString fName; | 59 SkString fName; |
60 | 60 |
61 typedef Benchmark INHERITED; | 61 typedef Benchmark INHERITED; |
62 }; | 62 }; |
63 | 63 |
64 class XferCreateBench : public Benchmark { | 64 class XferCreateBench : public Benchmark { |
65 public: | 65 public: |
66 bool isSuitableFor(Backend backend) SK_OVERRIDE { | 66 bool isSuitableFor(Backend backend) override { |
67 return backend == kNonRendering_Backend; | 67 return backend == kNonRendering_Backend; |
68 } | 68 } |
69 | 69 |
70 protected: | 70 protected: |
71 const char* onGetName() SK_OVERRIDE { return "xfermode_create"; } | 71 const char* onGetName() override { return "xfermode_create"; } |
72 | 72 |
73 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 73 void onDraw(const int loops, SkCanvas* canvas) override { |
74 for (int outer = 0; outer < loops * 10; ++outer) { | 74 for (int outer = 0; outer < loops * 10; ++outer) { |
75 for (int i = 0; i <= SkXfermode::kLastMode; ++i) { | 75 for (int i = 0; i <= SkXfermode::kLastMode; ++i) { |
76 SkXfermode* xfer = SkXfermode::Create(SkXfermode::Mode(i)); | 76 SkXfermode* xfer = SkXfermode::Create(SkXfermode::Mode(i)); |
77 SkSafeUnref(xfer); | 77 SkSafeUnref(xfer); |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
83 typedef Benchmark INHERITED; | 83 typedef Benchmark INHERITED; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 BENCH(SkXfermode::kDifference_Mode) | 118 BENCH(SkXfermode::kDifference_Mode) |
119 BENCH(SkXfermode::kExclusion_Mode) | 119 BENCH(SkXfermode::kExclusion_Mode) |
120 BENCH(SkXfermode::kMultiply_Mode) | 120 BENCH(SkXfermode::kMultiply_Mode) |
121 | 121 |
122 BENCH(SkXfermode::kHue_Mode) | 122 BENCH(SkXfermode::kHue_Mode) |
123 BENCH(SkXfermode::kSaturation_Mode) | 123 BENCH(SkXfermode::kSaturation_Mode) |
124 BENCH(SkXfermode::kColor_Mode) | 124 BENCH(SkXfermode::kColor_Mode) |
125 BENCH(SkXfermode::kLuminosity_Mode) | 125 BENCH(SkXfermode::kLuminosity_Mode) |
126 | 126 |
127 DEF_BENCH(return new XferCreateBench;) | 127 DEF_BENCH(return new XferCreateBench;) |
OLD | NEW |