OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkNx.h" | 10 #include "SkNx.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 while (loops --> 0) { | 33 while (loops --> 0) { |
34 fs = SkNx_cast<float>(SkNx_cast<T>(fs)); | 34 fs = SkNx_cast<float>(SkNx_cast<T>(fs)); |
35 } | 35 } |
36 fs.store((float*)blackhole); | 36 fs.store((float*)blackhole); |
37 } | 37 } |
38 }; | 38 }; |
39 DEF_BENCH(return new Sk4fRoundtripBench<uint8_t>;) | 39 DEF_BENCH(return new Sk4fRoundtripBench<uint8_t>;) |
40 DEF_BENCH(return new Sk4fRoundtripBench<uint16_t>;) | 40 DEF_BENCH(return new Sk4fRoundtripBench<uint16_t>;) |
41 DEF_BENCH(return new Sk4fRoundtripBench<int>;) | 41 DEF_BENCH(return new Sk4fRoundtripBench<int>;) |
42 | 42 |
| 43 struct Sk4fFloorBench : public Benchmark { |
| 44 Sk4fFloorBench() {} |
| 45 |
| 46 const char* onGetName() override { return "Sk4f_floor"; } |
| 47 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } |
| 48 |
| 49 void onDraw(int loops, SkCanvas* canvas) override { |
| 50 Sk4f fs(1,2,3,4); |
| 51 while (loops --> 0) { |
| 52 fs = fs.floor(); |
| 53 } |
| 54 fs.store((float*)blackhole); |
| 55 } |
| 56 }; |
| 57 DEF_BENCH(return new Sk4fFloorBench;) |
| 58 |
43 struct Sk4fGradientBench : public Benchmark { | 59 struct Sk4fGradientBench : public Benchmark { |
44 const char* onGetName() override { return "Sk4f_gradient"; } | 60 const char* onGetName() override { return "Sk4f_gradient"; } |
45 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } | 61 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } |
46 | 62 |
47 SkPMColor fDevice[100]; | 63 SkPMColor fDevice[100]; |
48 void onDraw(int loops, SkCanvas*) override { | 64 void onDraw(int loops, SkCanvas*) override { |
49 Sk4f c0(0,0,255,255), | 65 Sk4f c0(0,0,255,255), |
50 c1(255,0,0,255), | 66 c1(255,0,0,255), |
51 dc = c1 - c0, | 67 dc = c1 - c0, |
52 fx(0.1f), | 68 fx(0.1f), |
(...skipping 10 matching lines...) Expand all Loading... |
63 Sk4f_ToBytes((uint8_t*)(fDevice+i), a, b, c, d); | 79 Sk4f_ToBytes((uint8_t*)(fDevice+i), a, b, c, d); |
64 a = a + dcdx4; | 80 a = a + dcdx4; |
65 b = b + dcdx4; | 81 b = b + dcdx4; |
66 c = c + dcdx4; | 82 c = c + dcdx4; |
67 d = d + dcdx4; | 83 d = d + dcdx4; |
68 } | 84 } |
69 } | 85 } |
70 } | 86 } |
71 }; | 87 }; |
72 DEF_BENCH(return new Sk4fGradientBench;) | 88 DEF_BENCH(return new Sk4fGradientBench;) |
OLD | NEW |