aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkBitmap.h
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-07 18:30:18 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-07 18:30:18 +0000
commit2a7579d11796866b0026755ab52597d09f4509cc (patch)
tree786887dfa086b39139f8b7b37b6f0634d8db9eac /include/core/SkBitmap.h
parent4a26d9d62a6d762a518c0ca08d43189916b75cf2 (diff)
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
Diffstat (limited to 'include/core/SkBitmap.h')
-rw-r--r--include/core/SkBitmap.h18
1 files changed, 18 insertions, 0 deletions
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
@@ -223,6 +223,24 @@ public:
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
*/
void getBounds(SkRect* bounds) const;