Treat a GIF with no color table as transparent
authorscroggo <scroggo@chromium.org>
Mon, 31 Oct 2016 11:45:10 +0000 (04:45 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 31 Oct 2016 11:45:11 +0000 (04:45 -0700)
When checking to see whether a GIF has transparency to determine its
alpha type, treat an empty color table as having alpha, since we
will draw it as a transparent image.

(This is a separate bug from skbug.com/5883, but the image I used to
verify that bug was drawn to 565 as black. The fix is to not support
565 in that case, by changing its recommended alpha type.)

BUG=skia:5883
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2461813002

Review-Url: https://codereview.chromium.org/2461813002

third_party/gif/SkGifImageReader.cpp

index eeaee68..bbf5f9a 100644 (file)
@@ -737,8 +737,10 @@ bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query)
                 bool hasTransparentPixel;
                 if (m_frames.size() == 0) {
                     // We did not see a Graphics Control Extension, so no transparent
-                    // pixel was specified.
-                    hasTransparentPixel = false;
+                    // pixel was specified. But if there is no color table, this frame is
+                    // still transparent.
+                    hasTransparentPixel = !isLocalColormapDefined
+                                          && m_globalColorMap.numColors() == 0;
                 } else {
                     // This means we did see a Graphics Control Extension, which specifies
                     // the transparent pixel