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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 template <> | 351 template <> |
352 inline double defaultMinimumForClamp<double>() { | 352 inline double defaultMinimumForClamp<double>() { |
353 return -std::numeric_limits<double>::max(); | 353 return -std::numeric_limits<double>::max(); |
354 } | 354 } |
355 | 355 |
356 // And, finally, the actual function for people to call. | 356 // And, finally, the actual function for people to call. |
357 template <typename LimitType, typename ValueType> | 357 template <typename LimitType, typename ValueType> |
358 inline LimitType clampTo(ValueType value, | 358 inline LimitType clampTo(ValueType value, |
359 LimitType min = defaultMinimumForClamp<LimitType>(), | 359 LimitType min = defaultMinimumForClamp<LimitType>(), |
360 LimitType max = defaultMaximumForClamp<LimitType>()) { | 360 LimitType max = defaultMaximumForClamp<LimitType>()) { |
361 ASSERT(!std::isnan(static_cast<double>(value))); | 361 DCHECK(!std::isnan(static_cast<double>(value))); |
362 ASSERT(min <= max); // This also ensures |min| and |max| aren't NaN. | 362 DCHECK_LE(min, max); // This also ensures |min| and |max| aren't NaN. |
363 return ClampToHelper<LimitType, ValueType>::clampTo(value, min, max); | 363 return ClampToHelper<LimitType, ValueType>::clampTo(value, min, max); |
364 } | 364 } |
365 | 365 |
366 inline bool isWithinIntRange(float x) { | 366 inline bool isWithinIntRange(float x) { |
367 return x > static_cast<float>(std::numeric_limits<int>::min()) && | 367 return x > static_cast<float>(std::numeric_limits<int>::min()) && |
368 x < static_cast<float>(std::numeric_limits<int>::max()); | 368 x < static_cast<float>(std::numeric_limits<int>::max()); |
369 } | 369 } |
370 | 370 |
371 static size_t greatestCommonDivisor(size_t a, size_t b) { | 371 static size_t greatestCommonDivisor(size_t a, size_t b) { |
372 return b ? greatestCommonDivisor(b, a % b) : a; | 372 return b ? greatestCommonDivisor(b, a % b) : a; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 if (i >> 2) | 426 if (i >> 2) |
427 log2 += 2, i >>= 2; | 427 log2 += 2, i >>= 2; |
428 if (i >> 1) | 428 if (i >> 1) |
429 log2 += 1; | 429 log2 += 1; |
430 return log2; | 430 return log2; |
431 } | 431 } |
432 | 432 |
433 } // namespace WTF | 433 } // namespace WTF |
434 | 434 |
435 #endif // #ifndef WTF_MathExtras_h | 435 #endif // #ifndef WTF_MathExtras_h |
OLD | NEW |