| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
| 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 "SkMathPriv.h" | 8 #include "SkMathPriv.h" |
| 9 #include "SkCordic.h" | 9 #include "SkCordic.h" |
| 10 #include "SkFloatBits.h" | 10 #include "SkFloatBits.h" |
| 11 #include "SkFloatingPoint.h" | 11 #include "SkFloatingPoint.h" |
| 12 #include "Sk64.h" | 12 #include "Sk64.h" |
| 13 #include "SkScalar.h" | 13 #include "SkScalar.h" |
| 14 | 14 |
| 15 #ifdef SK_SCALAR_IS_FLOAT | 15 const uint32_t gIEEENotANumber = 0x7FFFFFFF; |
| 16 const uint32_t gIEEENotANumber = 0x7FFFFFFF; | 16 const uint32_t gIEEEInfinity = 0x7F800000; |
| 17 const uint32_t gIEEEInfinity = 0x7F800000; | 17 const uint32_t gIEEENegativeInfinity = 0xFF800000; |
| 18 const uint32_t gIEEENegativeInfinity = 0xFF800000; | |
| 19 #endif | |
| 20 | 18 |
| 21 #define sub_shift(zeros, x, n) \ | 19 #define sub_shift(zeros, x, n) \ |
| 22 zeros -= n; \ | 20 zeros -= n; \ |
| 23 x >>= n | 21 x >>= n |
| 24 | 22 |
| 25 int SkCLZ_portable(uint32_t x) { | 23 int SkCLZ_portable(uint32_t x) { |
| 26 if (x == 0) { | 24 if (x == 0) { |
| 27 return 32; | 25 return 32; |
| 28 } | 26 } |
| 29 | 27 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 367 |
| 370 SkFixed SkFixedMean(SkFixed a, SkFixed b) { | 368 SkFixed SkFixedMean(SkFixed a, SkFixed b) { |
| 371 Sk64 tmp; | 369 Sk64 tmp; |
| 372 | 370 |
| 373 tmp.setMul(a, b); | 371 tmp.setMul(a, b); |
| 374 return tmp.getSqrt(); | 372 return tmp.getSqrt(); |
| 375 } | 373 } |
| 376 | 374 |
| 377 /////////////////////////////////////////////////////////////////////////////// | 375 /////////////////////////////////////////////////////////////////////////////// |
| 378 | 376 |
| 379 #ifdef SK_SCALAR_IS_FLOAT | |
| 380 float SkScalarSinCos(float radians, float* cosValue) { | 377 float SkScalarSinCos(float radians, float* cosValue) { |
| 381 float sinValue = sk_float_sin(radians); | 378 float sinValue = sk_float_sin(radians); |
| 382 | 379 |
| 383 if (cosValue) { | 380 if (cosValue) { |
| 384 *cosValue = sk_float_cos(radians); | 381 *cosValue = sk_float_cos(radians); |
| 385 if (SkScalarNearlyZero(*cosValue)) { | 382 if (SkScalarNearlyZero(*cosValue)) { |
| 386 *cosValue = 0; | 383 *cosValue = 0; |
| 387 } | 384 } |
| 388 } | 385 } |
| 389 | 386 |
| 390 if (SkScalarNearlyZero(sinValue)) { | 387 if (SkScalarNearlyZero(sinValue)) { |
| 391 sinValue = 0; | 388 sinValue = 0; |
| 392 } | 389 } |
| 393 return sinValue; | 390 return sinValue; |
| 394 } | 391 } |
| 395 #endif | |
| 396 | 392 |
| 397 #define INTERP_SINTABLE | 393 #define INTERP_SINTABLE |
| 398 #define BUILD_TABLE_AT_RUNTIMEx | 394 #define BUILD_TABLE_AT_RUNTIMEx |
| 399 | 395 |
| 400 #define kTableSize 256 | 396 #define kTableSize 256 |
| 401 | 397 |
| 402 #ifdef BUILD_TABLE_AT_RUNTIME | 398 #ifdef BUILD_TABLE_AT_RUNTIME |
| 403 static uint16_t gSkSinTable[kTableSize]; | 399 static uint16_t gSkSinTable[kTableSize]; |
| 404 | 400 |
| 405 static void build_sintable(uint16_t table[]) { | 401 static void build_sintable(uint16_t table[]) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 } | 504 } |
| 509 | 505 |
| 510 /////////////////////////////////////////////////////////////////////////////// | 506 /////////////////////////////////////////////////////////////////////////////// |
| 511 | 507 |
| 512 SkFixed SkFixedTan(SkFixed radians) { return SkCordicTan(radians); } | 508 SkFixed SkFixedTan(SkFixed radians) { return SkCordicTan(radians); } |
| 513 SkFixed SkFixedASin(SkFixed x) { return SkCordicASin(x); } | 509 SkFixed SkFixedASin(SkFixed x) { return SkCordicASin(x); } |
| 514 SkFixed SkFixedACos(SkFixed x) { return SkCordicACos(x); } | 510 SkFixed SkFixedACos(SkFixed x) { return SkCordicACos(x); } |
| 515 SkFixed SkFixedATan2(SkFixed y, SkFixed x) { return SkCordicATan2(y, x); } | 511 SkFixed SkFixedATan2(SkFixed y, SkFixed x) { return SkCordicATan2(y, x); } |
| 516 SkFixed SkFixedExp(SkFixed x) { return SkCordicExp(x); } | 512 SkFixed SkFixedExp(SkFixed x) { return SkCordicExp(x); } |
| 517 SkFixed SkFixedLog(SkFixed x) { return SkCordicLog(x); } | 513 SkFixed SkFixedLog(SkFixed x) { return SkCordicLog(x); } |
| OLD | NEW |