| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 const double piOverTwoDouble = M_PI_2; | 53 const double piOverTwoDouble = M_PI_2; |
| 54 const float piOverTwoFloat = static_cast<float>(M_PI_2); | 54 const float piOverTwoFloat = static_cast<float>(M_PI_2); |
| 55 | 55 |
| 56 const double piOverFourDouble = M_PI_4; | 56 const double piOverFourDouble = M_PI_4; |
| 57 const float piOverFourFloat = static_cast<float>(M_PI_4); | 57 const float piOverFourFloat = static_cast<float>(M_PI_4); |
| 58 | 58 |
| 59 const double twoPiDouble = piDouble * 2.0; | 59 const double twoPiDouble = piDouble * 2.0; |
| 60 const float twoPiFloat = piFloat * 2.0f; | 60 const float twoPiFloat = piFloat * 2.0f; |
| 61 | 61 |
| 62 #if OS(ANDROID) | |
| 63 // ANDROID's math.h does not currently supply log2 or log2f. | |
| 64 inline double log2(double num) { | |
| 65 // This constant is roughly M_LN2, which is not provided by default on Windows | |
| 66 // and Android. | |
| 67 return log(num) / 0.693147180559945309417232121458176568; | |
| 68 } | |
| 69 | |
| 70 inline float log2f(float num) { | |
| 71 // This constant is roughly M_LN2, which is not provided by default on Windows | |
| 72 // and Android. | |
| 73 return logf(num) / 0.693147180559945309417232121458176568f; | |
| 74 } | |
| 75 #endif | |
| 76 | |
| 77 #if COMPILER(MSVC) | 62 #if COMPILER(MSVC) |
| 78 | 63 |
| 79 // VS2013 has most of the math functions now, but we still need to work | 64 // VS2013 has most of the math functions now, but we still need to work |
| 80 // around various differences in behavior of Inf. | 65 // around various differences in behavior of Inf. |
| 81 | 66 |
| 82 // Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN | 67 // Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN |
| 83 // instead of specific values. | 68 // instead of specific values. |
| 84 inline double wtf_atan2(double x, double y) { | 69 inline double wtf_atan2(double x, double y) { |
| 85 double posInf = std::numeric_limits<double>::infinity(); | 70 double posInf = std::numeric_limits<double>::infinity(); |
| 86 double negInf = -std::numeric_limits<double>::infinity(); | 71 double negInf = -std::numeric_limits<double>::infinity(); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 if (i >> 2) | 426 if (i >> 2) |
| 442 log2 += 2, i >>= 2; | 427 log2 += 2, i >>= 2; |
| 443 if (i >> 1) | 428 if (i >> 1) |
| 444 log2 += 1; | 429 log2 += 1; |
| 445 return log2; | 430 return log2; |
| 446 } | 431 } |
| 447 | 432 |
| 448 } // namespace WTF | 433 } // namespace WTF |
| 449 | 434 |
| 450 #endif // #ifndef WTF_MathExtras_h | 435 #endif // #ifndef WTF_MathExtras_h |
| OLD | NEW |