2007-12-20 Peter Kasting <zerodpx@gmail.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2007 03:56:09 +0000 (03:56 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2007 03:56:09 +0000 (03:56 +0000)
        Reviewed by Alp Toker.

        http://bugs.webkit.org/show_bug.cgi?id=16508
        Fix regression in GIFImageDecoder.cpp: "Haeberli hack" led to wrongly
        decoded transparent areas.

        * platform/image-decoders/gif/GIFImageDecoder.cpp:
        (WebCore::GIFImageDecoder::haveDecodedRow):
        * platform/image-decoders/gif/GIFImageDecoder.h:
        * platform/image-decoders/gif/GIFImageReader.cpp:
        (GIFImageReader::output_row):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28925 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
WebCore/platform/image-decoders/gif/GIFImageDecoder.h
WebCore/platform/image-decoders/gif/GIFImageReader.cpp

index 83b48570f540c17db27f8e23d7ee2cd02027d656..423e20491e5b03cff3d82e996eca6456b0ce8409 100644 (file)
@@ -1,3 +1,17 @@
+2007-12-20  Peter Kasting  <zerodpx@gmail.com>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16508
+        Fix regression in GIFImageDecoder.cpp: "Haeberli hack" led to wrongly
+        decoded transparent areas.
+
+        * platform/image-decoders/gif/GIFImageDecoder.cpp:
+        (WebCore::GIFImageDecoder::haveDecodedRow):
+        * platform/image-decoders/gif/GIFImageDecoder.h:
+        * platform/image-decoders/gif/GIFImageReader.cpp:
+        (GIFImageReader::output_row):
+
 2007-12-20  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by Oliver Hunt.
index fa8d46d978d1258ab44e5e37fdccb3914fd75840..1b70cd4b6ca98de84b80f728bc14c23e67abf6f7 100644 (file)
@@ -278,7 +278,8 @@ void GIFImageDecoder::haveDecodedRow(unsigned frameIndex,
                                      unsigned char* rowBuffer,   // Pointer to single scanline temporary buffer
                                      unsigned char* rowEnd,
                                      unsigned rowNumber,  // The row index
-                                     unsigned repeatCount) // How many times to repeat the row
+                                     unsigned repeatCount,  // How many times to repeat the row
+                                     bool writeTransparentPixels)
 {
     // Initialize the frame if necessary.
     RGBA32Buffer& buffer = m_frameBufferCache[frameIndex];
@@ -317,6 +318,15 @@ void GIFImageDecoder::haveDecodedRow(unsigned frameIndex,
             RGBA32Buffer::setRGBA(*currDst, red, green, blue, 255);
         } else {
             m_currentBufferSawAlpha = true;
+            // We may or may not need to write transparent pixels to the buffer.
+            // If we're compositing against a previous image, it's wrong, and if
+            // we're writing atop a cleared, fully transparent buffer, it's
+            // unnecessary; but if we're decoding an interlaced gif and
+            // displaying it "Haeberli"-style, we must write these for passes
+            // beyond the first, or the initial passes will "show through" the
+            // later ones.
+            if (writeTransparentPixels)
+                RGBA32Buffer::setRGBA(*currDst, 0, 0, 0, 0);
         }
         currDst++;
         currentRowByte++;
index e2fc76717fa802895dbc6fdb8af5877cbe0b22cc..7d22325ed022d05bf1d8f1040aa0d8b0a7925651 100644 (file)
@@ -64,7 +64,7 @@ public:
     void sizeNowAvailable(unsigned width, unsigned height);
     void decodingHalted(unsigned bytesLeft);
     void haveDecodedRow(unsigned frameIndex, unsigned char* rowBuffer, unsigned char* rowEnd, unsigned rowNumber, 
-                        unsigned repeatCount);
+                        unsigned repeatCount, bool writeTransparentPixels);
     void frameComplete(unsigned frameIndex, unsigned frameDuration, RGBA32Buffer::FrameDisposalMethod disposalMethod);
     void gifComplete();
 
index 0f9b2e9bb0080a310706a367800e5580b00bf7d2..04347af10f163027191fdaea341a4b216fae00ed 100644 (file)
@@ -161,7 +161,8 @@ void GIFImageReader::output_row()
   // CALLBACK: Let the client know we have decoded a row.
   if (clientptr && frame_reader)
     clientptr->haveDecodedRow(images_count - 1, frame_reader->rowbuf, frame_reader->rowend,
-                              drow_start, drow_end - drow_start + 1);
+                              drow_start, drow_end - drow_start + 1,
+                              gs->progressive_display && gs->interlaced && gs->ipass > 1);
 
   gs->rowp = gs->rowbuf;