diff options
author | Hal Canary <halcanary@google.com> | 2017-12-14 15:33:23 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-15 01:23:57 +0000 |
commit | a088365e2faca3f28469c0fc568169e095b5b1a0 (patch) | |
tree | fcad288bcdd54f3a59349aed7fbc5c326ae3cb31 /include/core/SkBitmap.h | |
parent | f6e6be2da12add94770db4ecaa9d365f3bcad453 (diff) |
SkBitmap::pixmap
Change-Id: I6d062b9ae1d242970be140d5a1885639c8c45f77
Reviewed-on: https://skia-review.googlesource.com/85320
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'include/core/SkBitmap.h')
-rw-r--r-- | include/core/SkBitmap.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 5727f6056f..d2fb7da376 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -99,6 +99,17 @@ public: */ void swap(SkBitmap& other); + + /** Returns a SkPixmap with the SkBitmap pixel address, row bytes, and + SkImageInfo to pixmap, if address is available. If pixel address + is not available, return an empty SkPixmap. + + The SkPixmap contents become invalid on any future change to SkBitmap. + + @return new SkPixmap describing this SkBitmap. + */ + SkPixmap pixmap() const { return fPixels ? SkPixmap(fInfo, fPixels, fRowBytes) : SkPixmap(); } + /** Returns width, height, SkAlphaType, SkColorType, and SkColorSpace. @return reference to SkImageInfo @@ -337,8 +348,7 @@ public: @return true if all pixels have opaque values or SkColorType is opaque */ static bool ComputeIsOpaque(const SkBitmap& bm) { - SkPixmap pmap; - return bm.peekPixels(&pmap) && pmap.computeIsOpaque(); + return bm.pixmap().computeIsOpaque(); } /** Returns SkRect { 0, 0, width(), height() }. @@ -840,9 +850,7 @@ public: @return pixel converted to unpremultiplied color */ SkColor getColor(int x, int y) const { - SkPixmap pixmap; - SkAssertResult(this->peekPixels(&pixmap)); - return pixmap.getColor(x, y); + return this->pixmap().getColor(x, y); } /** Returns pixel address at (x, y). |