OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkArithmeticMode.h" | 8 #include "SkArithmeticMode.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (i < 3) { | 177 if (i < 3) { |
178 str->append(" "); | 178 str->append(" "); |
179 } | 179 } |
180 } | 180 } |
181 } | 181 } |
182 #endif | 182 #endif |
183 | 183 |
184 /////////////////////////////////////////////////////////////////////////////// | 184 /////////////////////////////////////////////////////////////////////////////// |
185 | 185 |
186 static bool fitsInBits(SkScalar x, int bits) { | 186 static bool fitsInBits(SkScalar x, int bits) { |
187 #ifdef SK_SCALAR_IS_FIXED | |
188 x = SkAbs32(x); | |
189 x += 1 << 7; | |
190 x >>= 8; | |
191 return x < (1 << (bits - 1)); | |
192 #else | |
193 return SkScalarAbs(x) < (1 << (bits - 1)); | 187 return SkScalarAbs(x) < (1 << (bits - 1)); |
194 #endif | |
195 } | 188 } |
196 | 189 |
197 #if 0 // UNUSED | 190 #if 0 // UNUSED |
198 static int32_t toDot8(SkScalar x) { | 191 static int32_t toDot8(SkScalar x) { |
199 #ifdef SK_SCALAR_IS_FIXED | |
200 x += 1 << 7; | |
201 x >>= 8; | |
202 return x; | |
203 #else | |
204 return (int32_t)(x * 256); | 192 return (int32_t)(x * 256); |
205 #endif | |
206 } | 193 } |
207 #endif | 194 #endif |
208 | 195 |
209 SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2, | 196 SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2, |
210 SkScalar k3, SkScalar k4) { | 197 SkScalar k3, SkScalar k4) { |
211 if (fitsInBits(k1, 8) && fitsInBits(k2, 16) && | 198 if (fitsInBits(k1, 8) && fitsInBits(k2, 16) && |
212 fitsInBits(k2, 16) && fitsInBits(k2, 24)) { | 199 fitsInBits(k2, 16) && fitsInBits(k2, 24)) { |
213 | 200 |
214 #if 0 // UNUSED | 201 #if 0 // UNUSED |
215 int32_t i1 = toDot8(k1); | 202 int32_t i1 = toDot8(k1); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 background); | 404 background); |
418 } | 405 } |
419 return true; | 406 return true; |
420 } | 407 } |
421 | 408 |
422 #endif | 409 #endif |
423 | 410 |
424 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 411 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
425 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 412 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
426 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 413 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |