diff options
author | 2012-11-07 22:06:55 +0000 | |
---|---|---|
committer | 2012-11-07 22:06:55 +0000 | |
commit | 52e91bf56444f3ac4378feac7a42a157b9afaf9c (patch) | |
tree | 94f8d1eaf25e20eaf2330973e8f30d71b2c8b927 /src | |
parent | e8ca6c6e3a55634ac76efe5aceafaf8d669f43ba (diff) |
check to see if CGImage already knows if we're opaque
Review URL: https://codereview.appspot.com/6838043
git-svn-id: http://skia.googlecode.com/svn/trunk@6340 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/ports/SkImageDecoder_CG.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp index ba7a89c91e..c1b63ea7a8 100644 --- a/src/ports/SkImageDecoder_CG.cpp +++ b/src/ports/SkImageDecoder_CG.cpp @@ -87,8 +87,18 @@ bool SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { CGContextDrawImage(cg, CGRectMake(0, 0, width, height), image); CGContextRelease(cg); - // since CGImage won't tell us if it is opaque, we have to compute it. - bm->computeAndSetOpaquePredicate(); + CGImageAlphaInfo info = CGImageGetAlphaInfo(image); + switch (info) { + case kCGImageAlphaNone: + case kCGImageAlphaNoneSkipLast: + case kCGImageAlphaNoneSkipFirst: + SkASSERT(SkBitmap::ComputeIsOpaque(*bm)); + bm->setIsOpaque(true); + break; + default: + // we don't know if we're opaque or not, so compute it. + bm->computeAndSetOpaquePredicate(); + } bm->unlockPixels(); return true; } |