diff options
author | Mike Reed <reed@google.com> | 2017-09-26 17:46:02 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-27 14:36:07 +0000 |
commit | 88757dacd4f532a0f647c02ae0ee596d31ab5c68 (patch) | |
tree | a07e9df0a581f84287d1a1c08f3f32cde0a3d9a0 /include/core/SkBitmap.h | |
parent | fa7ee2447e6227e7f441d32e570489130c0932bb (diff) |
guard old apis for querying byte-size of a bitmap/imageinfo/pixmap
Now with legacy behavior for allocpixels
This was reverted, so the current CL is a "fix" on top of ...
https://skia-review.googlesource.com/c/skia/+/50980
Related update to Chrome (in preparation for this change)
https://chromium-review.googlesource.com/c/chromium/src/+/685719
Bug: skia:
Change-Id: I4b370ee7e95083ab27421f008132219c9c7b86e9
Reviewed-on: https://skia-review.googlesource.com/51341
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include/core/SkBitmap.h')
-rw-r--r-- | include/core/SkBitmap.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 7425eb03d5..cea50b8886 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -141,10 +141,13 @@ public: */ void* getPixels() const { return fPixels; } - /** Return the byte size of the pixels, based on the height and rowBytes. - Note this truncates the result to 32bits. Call getSize64() to detect - if the real size exceeds 32bits. - */ + /** + * Returns the size (in bytes) of the bitmap's image buffer. + * If the calculation overflows, or if the height is 0, this returns 0. + */ + size_t computeByteSize() const { return fInfo.computeByteSize(fRowBytes); } + +#ifdef SK_SUPPORT_LEGACY_SAFESIZE64 size_t getSize() const { return fInfo.height() * fRowBytes; } /** Return the number of bytes from the pointer returned by getPixels() @@ -168,6 +171,7 @@ public: int64_t computeSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } +#endif /** Returns true if this bitmap is marked as immutable, meaning that the contents of its pixels will not change for the lifetime of the bitmap. |