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 "Sk4px.h" | 8 #include "Sk4px.h" |
9 #include "SkNx.h" | 9 #include "SkNx.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 DEF_TEST(SkNi, r) { | 126 DEF_TEST(SkNi, r) { |
127 test_Ni<2, uint16_t>(r); | 127 test_Ni<2, uint16_t>(r); |
128 test_Ni<4, uint16_t>(r); | 128 test_Ni<4, uint16_t>(r); |
129 test_Ni<8, uint16_t>(r); | 129 test_Ni<8, uint16_t>(r); |
130 | 130 |
131 test_Ni<2, int>(r); | 131 test_Ni<2, int>(r); |
132 test_Ni<4, int>(r); | 132 test_Ni<4, int>(r); |
133 test_Ni<8, int>(r); | 133 test_Ni<8, int>(r); |
134 } | 134 } |
135 | 135 |
136 DEF_TEST(SkNi_min, r) { | 136 DEF_TEST(SkNi_min_lt, r) { |
137 // Exhaustively check the 8x8 bit space. | 137 // Exhaustively check the 8x8 bit space. |
138 for (int a = 0; a < (1<<8); a++) { | 138 for (int a = 0; a < (1<<8); a++) { |
139 for (int b = 0; b < (1<<8); b++) { | 139 for (int b = 0; b < (1<<8); b++) { |
140 REPORTER_ASSERT(r, Sk16b::Min(Sk16b(a), Sk16b(b)).kth<0>() == SkTMin(a,
b)); | 140 Sk16b aw(a), bw(b); |
| 141 REPORTER_ASSERT(r, Sk16b::Min(aw, bw).kth<0>() == SkTMin(a, b)); |
| 142 REPORTER_ASSERT(r, !(aw < bw).kth<0>() == !(a < b)); |
141 }} | 143 }} |
142 | 144 |
143 // Exhausting the 16x16 bit space is kind of slow, so only do that in releas
e builds. | 145 // Exhausting the 16x16 bit space is kind of slow, so only do that in releas
e builds. |
144 #ifdef SK_DEBUG | 146 #ifdef SK_DEBUG |
145 SkRandom rand; | 147 SkRandom rand; |
146 for (int i = 0; i < (1<<16); i++) { | 148 for (int i = 0; i < (1<<16); i++) { |
147 uint16_t a = rand.nextU() >> 16, | 149 uint16_t a = rand.nextU() >> 16, |
148 b = rand.nextU() >> 16; | 150 b = rand.nextU() >> 16; |
149 REPORTER_ASSERT(r, Sk8h::Min(Sk8h(a), Sk8h(b)).kth<0>() == SkTMin(a, b))
; | 151 REPORTER_ASSERT(r, Sk8h::Min(Sk8h(a), Sk8h(b)).kth<0>() == SkTMin(a, b))
; |
150 } | 152 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 185 |
184 // We're a bit more flexible on this method: correct for 0 or 255, other
wise off by <=1. | 186 // We're a bit more flexible on this method: correct for 0 or 255, other
wise off by <=1. |
185 int fast = av.approxMulDiv255(bv).kth<0>(); | 187 int fast = av.approxMulDiv255(bv).kth<0>(); |
186 REPORTER_ASSERT(r, fast-exact >= -1 && fast-exact <= 1); | 188 REPORTER_ASSERT(r, fast-exact >= -1 && fast-exact <= 1); |
187 if (a == 0 || a == 255 || b == 0 || b == 255) { | 189 if (a == 0 || a == 255 || b == 0 || b == 255) { |
188 REPORTER_ASSERT(r, fast == exact); | 190 REPORTER_ASSERT(r, fast == exact); |
189 } | 191 } |
190 } | 192 } |
191 } | 193 } |
192 } | 194 } |
OLD | NEW |