From 2a7579d11796866b0026755ab52597d09f4509cc Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Wed, 7 Nov 2012 18:30:18 +0000 Subject: CG imagedecoder never sets isOpaque, so add method to SkBitmap to compute that, and call it from CG imagedecoder. Review URL: https://codereview.appspot.com/6816101 git-svn-id: http://skia.googlecode.com/svn/trunk@6334 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkBitmap.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/core') diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 9c81e836f2..ef4cdd9c9a 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -222,6 +222,24 @@ public: static Sk64 ComputeSize64(Config, int width, int height); static size_t ComputeSize(Config, int width, int height); + /** + * This will brute-force return true if all of the pixels in the bitmap + * are opaque. If it fails to read the pixels, or encounters an error, + * it will return false. + * + * Since this can be an expensive operation, the bitmap stores a flag for + * this (isOpaque, setIsOpaque). Only call this if you need to compute this + * value from "unknown" pixels. + */ + static bool ComputeIsOpaque(const SkBitmap&); + + /** + * Calls ComputeIsOpaque, and passes its result to setIsOpaque(). + */ + void computeAndSetOpaquePredicate() { + this->setIsOpaque(ComputeIsOpaque(*this)); + } + /** * Return the bitmap's bounds [0, 0, width, height] as an SkRect */ -- cgit v1.2.3