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 | |
59 struct Sk4fGradientBench : public Benchmark { | 43 struct Sk4fGradientBench : public Benchmark { |
60 const char* onGetName() override { return "Sk4f_gradient"; } | 44 const char* onGetName() override { return "Sk4f_gradient"; } |
61 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } | 45 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } |
62 | 46 |
63 SkPMColor fDevice[100]; | 47 SkPMColor fDevice[100]; |
64 void onDraw(int loops, SkCanvas*) override { | 48 void onDraw(int loops, SkCanvas*) override { |
65 Sk4f c0(0,0,255,255), | 49 Sk4f c0(0,0,255,255), |
66 c1(255,0,0,255), | 50 c1(255,0,0,255), |
67 dc = c1 - c0, | 51 dc = c1 - c0, |
68 fx(0.1f), | 52 fx(0.1f), |
(...skipping 10 matching lines...) Expand all Loading... |
79 Sk4f_ToBytes((uint8_t*)(fDevice+i), a, b, c, d); | 63 Sk4f_ToBytes((uint8_t*)(fDevice+i), a, b, c, d); |
80 a = a + dcdx4; | 64 a = a + dcdx4; |
81 b = b + dcdx4; | 65 b = b + dcdx4; |
82 c = c + dcdx4; | 66 c = c + dcdx4; |
83 d = d + dcdx4; | 67 d = d + dcdx4; |
84 } | 68 } |
85 } | 69 } |
86 } | 70 } |
87 }; | 71 }; |
88 DEF_BENCH(return new Sk4fGradientBench;) | 72 DEF_BENCH(return new Sk4fGradientBench;) |
OLD | NEW |