diff options
author | Mike Reed <reed@google.com> | 2017-10-06 15:04:23 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-06 19:36:17 +0000 |
commit | 24295462722fd5a298d108a80b0aacbb0964da53 (patch) | |
tree | d98efb1e32f860294629ddb154199382136b60c1 /include | |
parent | 9cb2cae63584d0bfb8c98a90062d06ff59659e72 (diff) |
change computeByteSize to return max_size_t on overflow
Bug: skia:7132
Change-Id: I41045640ee62b2c988a84370ead5034bbccc6daf
Reviewed-on: https://skia-review.googlesource.com/56620
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkImageInfo.h | 8 | ||||
-rw-r--r-- | include/core/SkTypes.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index 50d068a09c..cab84b9fe0 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -317,11 +317,19 @@ public: } #endif +#ifdef SK_SUPPORT_LEGACY_COMPUTEBYTESIZE_RET_0 /** * Returns the size (in bytes) of the image buffer that this info needs, given the specified * rowBytes. The rowBytes must be >= this->minRowBytes(). * If the calculation overflows, or if the height is 0, this returns 0. */ +#else + /** + * Returns the size (in bytes) of the image buffer that this info needs, given the specified + * rowBytes. The rowBytes must be >= this->minRowBytes(). + * If the calculation overflows this returns SK_MaxSizeT + */ +#endif size_t computeByteSize(size_t rowBytes) const; /** diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index 63a2b40591..59bdaaa90c 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -233,6 +233,7 @@ template <typename D, typename S> D SkTo(S s) { #define SK_MaxU32 0xFFFFFFFF #define SK_MinU32 0 #define SK_NaN32 ((int) (1U << 31)) +#define SK_MaxSizeT SIZE_MAX static inline int32_t SkLeftShift(int32_t value, int32_t shift) { return (int32_t) ((uint32_t) value << shift); |