Revert "Revert "change computeByteSize to return max_size_t on overflow""
This reverts commit 384f0a7d66
.
Bug: skia:
Change-Id: I392ef5c1a5172181caf81ae270befeba6e778241
Reviewed-on: https://skia-review.googlesource.com/57084
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
16e92cdd91
commit
7281801849
@ -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;
|
||||
|
||||
/**
|
||||
@ -334,7 +342,11 @@ public:
|
||||
|
||||
// Returns true if the result of computeByteSize (or computeMinByteSize) overflowed
|
||||
static bool ByteSizeOverflowed(size_t byteSize) {
|
||||
#ifdef SK_SUPPORT_LEGACY_COMPUTEBYTESIZE_RET_0
|
||||
return 0 == byteSize;
|
||||
#else
|
||||
return SK_MaxSizeT == byteSize;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool validRowBytes(size_t rowBytes) const {
|
||||
|
@ -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);
|
||||
|
@ -656,6 +656,7 @@ DEFINES_ALL = [
|
||||
# Required for building dm.
|
||||
"GR_TEST_UTILS",
|
||||
# Staging flags for API changes
|
||||
"SK_SUPPORT_LEGACY_COMPUTEBYTESIZE_RET_0",
|
||||
# Should remove after we update golden images
|
||||
"SK_WEBP_ENCODER_USE_DEFAULT_METHOD",
|
||||
# Experiment to diagnose image diffs in Google3
|
||||
|
@ -78,7 +78,11 @@ size_t SkImageInfo::computeByteSize(size_t rowBytes) const {
|
||||
SkSafeMath safe;
|
||||
size_t bytes = safe.add(safe.mul(fHeight - 1, rowBytes),
|
||||
safe.mul(fWidth, this->bytesPerPixel()));
|
||||
#ifdef SK_SUPPORT_LEGACY_COMPUTEBYTESIZE_RET_0
|
||||
return safe ? bytes : 0;
|
||||
#else
|
||||
return safe ? bytes : SK_MaxSizeT;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool alpha_type_is_valid(SkAlphaType alphaType) {
|
||||
|
Loading…
Reference in New Issue
Block a user