diff options
author | 2017-09-29 13:41:58 -0400 | |
---|---|---|
committer | 2017-09-29 18:20:14 +0000 | |
commit | e74dafc74d8d87f10d9be7889349990d11c245f9 (patch) | |
tree | a4da76b310f4aa8c06355e275681bbf402c4c1a3 /src/core/SkImageInfo.cpp | |
parent | c739b7260a36ed4f9ea803991909a438629ca1d2 (diff) |
Just add new safe size apis
Update skia (and then hide the older versions) to come later
Inspired by https://skia-review.googlesource.com/c/skia/+/52665
Bug: skia:
Change-Id: I15c7395557fb49c4163cb3b323b5428abd2c752d
Reviewed-on: https://skia-review.googlesource.com/53520
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkImageInfo.cpp')
-rw-r--r-- | src/core/SkImageInfo.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp index 1baf0b77de..c610b82bdc 100644 --- a/src/core/SkImageInfo.cpp +++ b/src/core/SkImageInfo.cpp @@ -6,6 +6,7 @@ */ #include "SkImageInfo.h" +#include "SkSafeMath.h" #include "SkReadBuffer.h" #include "SkWriteBuffer.h" @@ -70,6 +71,16 @@ static SkColorType stored_to_live(unsigned stored) { /////////////////////////////////////////////////////////////////////////////////////////////////// +size_t SkImageInfo::computeByteSize(size_t rowBytes) const { + if (0 == fHeight) { + return 0; + } + SkSafeMath safe; + size_t bytes = safe.add(safe.mul(fHeight - 1, rowBytes), + safe.mul(fWidth, this->bytesPerPixel())); + return safe ? bytes : 0; +} + static bool alpha_type_is_valid(SkAlphaType alphaType) { return (alphaType >= kUnknown_SkAlphaType) && (alphaType <= kLastEnum_SkAlphaType); } |