| Index: cc/resources/resource_util.h
|
| diff --git a/cc/resources/resource_util.h b/cc/resources/resource_util.h
|
| index 0953fbbdb1b33919e7d78c44dc57cc138ca6f84d..9d9905b47d5d8644a20472fd08eab8da2913ca21 100644
|
| --- a/cc/resources/resource_util.h
|
| +++ b/cc/resources/resource_util.h
|
| @@ -68,9 +68,6 @@ class CC_EXPORT ResourceUtil {
|
| static inline void VerifyType();
|
|
|
| template <typename T>
|
| - static bool VerifyRoundUp(T value, T round_up);
|
| -
|
| - template <typename T>
|
| static bool VerifyFitsInBytesInternal(int width,
|
| int height,
|
| ResourceFormat format,
|
| @@ -107,10 +104,7 @@ T ResourceUtil::CheckedWidthInBytes(int width, ResourceFormat format) {
|
| DCHECK(VerifyFitsInBytesInternal<T>(width, 0, format, false, false));
|
| base::CheckedNumeric<T> checked_value = BitsPerPixel(format);
|
| checked_value *= width;
|
| - // TODO(prashant.n): Move the value roundup overflow to MathUtil class.
|
| - // http://crbug.com/515566
|
| - CHECK(VerifyRoundUp(checked_value.ValueOrDie(), static_cast<T>(8)));
|
| - checked_value = MathUtil::RoundUp<T>(checked_value.ValueOrDie(), 8);
|
| + checked_value = MathUtil::CheckedRoundUp<T>(checked_value.ValueOrDie(), 8);
|
| checked_value /= 8;
|
| return checked_value.ValueOrDie();
|
| }
|
| @@ -123,8 +117,7 @@ T ResourceUtil::CheckedSizeInBytes(const gfx::Size& size,
|
| false));
|
| base::CheckedNumeric<T> checked_value = BitsPerPixel(format);
|
| checked_value *= size.width();
|
| - CHECK(VerifyRoundUp(checked_value.ValueOrDie(), static_cast<T>(8)));
|
| - checked_value = MathUtil::RoundUp<T>(checked_value.ValueOrDie(), 8);
|
| + checked_value = MathUtil::CheckedRoundUp<T>(checked_value.ValueOrDie(), 8);
|
| checked_value /= 8;
|
| checked_value *= size.height();
|
| return checked_value.ValueOrDie();
|
| @@ -170,18 +163,6 @@ void ResourceUtil::VerifyType() {
|
| }
|
|
|
| template <typename T>
|
| -bool ResourceUtil::VerifyRoundUp(T value, T round_up) {
|
| - if (round_up == 0)
|
| - return false;
|
| - if (value == round_up)
|
| - return true;
|
| - if ((std::numeric_limits<T>::max() - (value - (value % round_up))) >=
|
| - round_up)
|
| - return true;
|
| - return false;
|
| -}
|
| -
|
| -template <typename T>
|
| bool ResourceUtil::VerifyFitsInBytesInternal(int width,
|
| int height,
|
| ResourceFormat format,
|
| @@ -194,8 +175,7 @@ bool ResourceUtil::VerifyFitsInBytesInternal(int width,
|
|
|
| // Roundup bits to byte (8 bits) boundary. If width is 3 and BitsPerPixel is
|
| // 4, then it should return 16, so that row pixels do not get truncated.
|
| - DCHECK(VerifyRoundUp(checked_value.ValueOrDie(), static_cast<T>(8)));
|
| - checked_value = MathUtil::RoundUp<T>(checked_value.ValueOrDie(), 8);
|
| + checked_value = MathUtil::UncheckedRoundUp<T>(checked_value.ValueOrDie(), 8);
|
|
|
| // If aligned is true, bytes are aligned on 4-bytes boundaries for upload
|
| // performance, assuming that GL_PACK_ALIGNMENT or GL_UNPACK_ALIGNMENT have
|
| @@ -204,7 +184,8 @@ bool ResourceUtil::VerifyFitsInBytesInternal(int width,
|
| checked_value /= 8;
|
| if (!checked_value.IsValid())
|
| return false;
|
| - checked_value = MathUtil::RoundUp<T>(checked_value.ValueOrDie(), 4);
|
| + checked_value =
|
| + MathUtil::UncheckedRoundUp<T>(checked_value.ValueOrDie(), 4);
|
| checked_value *= 8;
|
| }
|
|
|
| @@ -226,11 +207,10 @@ T ResourceUtil::BytesInternal(int width,
|
| bool aligned) {
|
| T bytes = BitsPerPixel(format);
|
| bytes *= width;
|
| - DCHECK(VerifyRoundUp(bytes, static_cast<T>(8)));
|
| - bytes = MathUtil::RoundUp<T>(bytes, 8);
|
| + bytes = MathUtil::UncheckedRoundUp<T>(bytes, 8);
|
| bytes /= 8;
|
| if (aligned)
|
| - bytes = MathUtil::RoundUp<T>(bytes, 4);
|
| + bytes = MathUtil::UncheckedRoundUp<T>(bytes, 4);
|
| if (verify_size)
|
| bytes *= height;
|
|
|
|
|