diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkBitmap.h | 5 | ||||
-rw-r--r-- | include/core/SkPixmap.h | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 061f0e5c95..7c3cd7f9b7 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -215,7 +215,10 @@ public: * this (isOpaque). Only call this if you need to compute this value from * "unknown" pixels. */ - static bool ComputeIsOpaque(const SkBitmap&); + static bool ComputeIsOpaque(const SkBitmap& bm) { + SkAutoPixmapUnlock result; + return bm.requestLock(&result) && result.pixmap().computeIsOpaque(); + } /** * Return the bitmap's bounds [0, 0, width, height] as an SkRect diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h index ce13297fb9..6cf948e601 100644 --- a/include/core/SkPixmap.h +++ b/include/core/SkPixmap.h @@ -91,6 +91,12 @@ public: size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } /** + * This will brute-force return true if all of the pixels in the pixmap + * are opaque. If there are no pixels, or encounters an error, returns false. + */ + bool computeIsOpaque() const; + + /** * Converts the pixel at the specified coordinate to an unpremultiplied * SkColor. Note: this ignores any SkColorSpace information, and may return * lower precision data than is actually in the pixel. Alpha only |