[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

pkasting at chromium.org pkasting at chromium.org
Fri Feb 26 22:24:58 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 2c00432b61bec8546c5986aac19c80f2f99368fa
Author: pkasting at chromium.org <pkasting at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 18 19:35:16 2010 +0000

    Rework PNG-in-ICO decoding to copy the decoded framebuffer into the ICO
    decoder, making the logic less crazy and more like the other decoders.
    https://bugs.webkit.org/show_bug.cgi?id=28751
    
    Reviewed by Adam Barth.
    
    * platform/image-decoders/ImageDecoder.cpp:
    (WebCore::RGBA32Buffer::operator=):
    * platform/image-decoders/ImageDecoder.h:
    (WebCore::RGBA32Buffer::RGBA32Buffer):
    * platform/image-decoders/ico/ICOImageDecoder.cpp:
    (WebCore::ICOImageDecoder::frameBufferAtIndex):
    (WebCore::ICOImageDecoder::decodeAtIndex):
    * platform/image-decoders/ico/ICOImageDecoder.h:
    * platform/image-decoders/qt/RGBA32BufferQt.cpp:
    (WebCore::RGBA32Buffer::operator=):
    * platform/image-decoders/skia/ImageDecoderSkia.cpp:
    (WebCore::RGBA32Buffer::operator=):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54978 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ceb53f7..82cbb5c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-02-17  Peter Kasting  <pkasting at google.com>
+
+        Reviewed by Adam Barth.
+
+        Rework PNG-in-ICO decoding to copy the decoded framebuffer into the ICO
+        decoder, making the logic less crazy and more like the other decoders.
+        https://bugs.webkit.org/show_bug.cgi?id=28751
+
+        * platform/image-decoders/ImageDecoder.cpp:
+        (WebCore::RGBA32Buffer::operator=):
+        * platform/image-decoders/ImageDecoder.h:
+        (WebCore::RGBA32Buffer::RGBA32Buffer):
+        * platform/image-decoders/ico/ICOImageDecoder.cpp:
+        (WebCore::ICOImageDecoder::frameBufferAtIndex):
+        (WebCore::ICOImageDecoder::decodeAtIndex):
+        * platform/image-decoders/ico/ICOImageDecoder.h:
+        * platform/image-decoders/qt/RGBA32BufferQt.cpp:
+        (WebCore::RGBA32Buffer::operator=):
+        * platform/image-decoders/skia/ImageDecoderSkia.cpp:
+        (WebCore::RGBA32Buffer::operator=):
+
 2010-02-18  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/platform/image-decoders/ImageDecoder.cpp b/WebCore/platform/image-decoders/ImageDecoder.cpp
index cc62126..172bccf 100644
--- a/WebCore/platform/image-decoders/ImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/ImageDecoder.cpp
@@ -97,6 +97,19 @@ RGBA32Buffer::RGBA32Buffer()
 {
 } 
 
+RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
+{
+    if (this == &other)
+        return *this;
+
+    copyBitmapData(other);
+    setRect(other.rect());
+    setStatus(other.status());
+    setDuration(other.duration());
+    setDisposalMethod(other.disposalMethod());
+    return *this;
+}
+
 void RGBA32Buffer::clear()
 {
     m_bytes.clear();
@@ -151,19 +164,6 @@ void RGBA32Buffer::setStatus(FrameStatus status)
     m_status = status;
 }
 
-RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
-{
-    if (this == &other)
-        return *this;
-
-    copyBitmapData(other);
-    setRect(other.rect());
-    setStatus(other.status());
-    setDuration(other.duration());
-    setDisposalMethod(other.disposalMethod());
-    return *this;
-}
-
 int RGBA32Buffer::width() const
 {
     return m_size.width();
diff --git a/WebCore/platform/image-decoders/ImageDecoder.h b/WebCore/platform/image-decoders/ImageDecoder.h
index 2d1e481..87bb6a9 100644
--- a/WebCore/platform/image-decoders/ImageDecoder.h
+++ b/WebCore/platform/image-decoders/ImageDecoder.h
@@ -69,15 +69,11 @@ namespace WebCore {
 
         RGBA32Buffer();
 
-        // For backends which refcount their data, this constructor doesn't need
-        // to create a new copy of the image data, only increase the ref count.
-        //
-        // This exists because ImageDecoder keeps a Vector<RGBA32Buffer>, and
-        // Vector requires this constructor.
-        RGBA32Buffer(const RGBA32Buffer& other)
-        {
-            operator=(other);
-        }
+        RGBA32Buffer(const RGBA32Buffer& other) { operator=(other); }
+
+        // For backends which refcount their data, this operator doesn't need to
+        // create a new copy of the image data, only increase the ref count.
+        RGBA32Buffer& operator=(const RGBA32Buffer& other);
 
         // Deletes the pixel data entirely; used by ImageDecoder to save memory
         // when we no longer need to display a frame and only need its metadata.
@@ -139,8 +135,6 @@ namespace WebCore {
 #endif
 
     private:
-        RGBA32Buffer& operator=(const RGBA32Buffer& other);
-
         int width() const;
         int height() const;
 
diff --git a/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp b/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
index 9b726c3..1a202bc 100644
--- a/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
@@ -115,26 +115,10 @@ RGBA32Buffer* ICOImageDecoder::frameBufferAtIndex(size_t index)
     if (index >= frameCount())
         return 0;
 
-    // Determine the image type, and if this is a BMP, decode.
-    decode(index, false);
-
-    // PNGs decode into their own framebuffers, so only use our internal cache
-    // for non-PNGs (BMP or unknown).
-    if (!m_pngDecoders[index])
-        return &m_frameBufferCache[index];
-
-    // Fail if the size the PNGImageDecoder calculated does not match the size
-    // in the directory.
-    if (m_pngDecoders[index]->isSizeAvailable()) {
-        const IntSize pngSize(m_pngDecoders[index]->size());
-        const IconDirectoryEntry& dirEntry = m_dirEntries[index];
-        if (pngSize != dirEntry.m_size) {
-            setFailed();
-            m_pngDecoders[index]->setFailed();
-        }
-    }
-
-    return m_pngDecoders[index]->frameBufferAtIndex(0);
+    RGBA32Buffer* buffer = &m_frameBufferCache[index];
+    if (buffer->status() != RGBA32Buffer::FrameComplete)
+        decode(index, false);
+    return buffer;
 }
 
 // static
@@ -184,35 +168,40 @@ bool ICOImageDecoder::decodeAtIndex(size_t index)
 {
     ASSERT(index < m_dirEntries.size());
     const IconDirectoryEntry& dirEntry = m_dirEntries[index];
-    if (!m_bmpReaders[index] && !m_pngDecoders[index]) {
-        // Image type unknown.
-        const ImageType imageType = imageTypeAtIndex(index);
-        if (imageType == BMP) {
+    const ImageType imageType = imageTypeAtIndex(index);
+    if (imageType == Unknown)
+        return false; // Not enough data to determine image type yet.
+
+    if (imageType == BMP) {
+        if (!m_bmpReaders[index]) {
             // We need to have already sized m_frameBufferCache before this, and
             // we must not resize it again later (see caution in frameCount()).
             ASSERT(m_frameBufferCache.size() == m_dirEntries.size());
             m_bmpReaders[index].set(new BMPImageReader(this, dirEntry.m_imageOffset, 0, true));
             m_bmpReaders[index]->setData(m_data.get());
             m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]);
-        } else if (imageType == PNG) {
-            m_pngDecoders[index].set(new PNGImageDecoder());
-            setDataForPNGDecoderAtIndex(index);
-        } else {
-            // Not enough data to determine image type yet.
-            return false;
         }
-    }
-
-    if (m_bmpReaders[index]) {
         m_frameSize = dirEntry.m_size;
         bool result = m_bmpReaders[index]->decodeBMP(false);
         m_frameSize = IntSize();
         return result;
     }
 
-    // For PNGs, we're now done; further decoding will happen when calling
-    // frameBufferAtIndex() on the PNG decoder.
-    return true;
+    if (!m_pngDecoders[index]) {
+        m_pngDecoders[index].set(new PNGImageDecoder());
+        setDataForPNGDecoderAtIndex(index);
+    }
+    // Fail if the size the PNGImageDecoder calculated does not match the size
+    // in the directory.
+    if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size() != dirEntry.m_size)) {
+        setFailed();
+        return false;
+    }
+    m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0);
+    if (!m_pngDecoders[index]->failed())
+      return true;
+    setFailed();
+    return false;
 }
 
 bool ICOImageDecoder::processDirectory()
diff --git a/WebCore/platform/image-decoders/ico/ICOImageDecoder.h b/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
index ee8cd25..c1f29c9 100644
--- a/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
+++ b/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
@@ -86,11 +86,6 @@ namespace WebCore {
         // Decodes the entry at |index|.  If |onlySize| is true, stops decoding
         // after calculating the image size.  If decoding fails but there is no
         // more data coming, sets the "decode failure" flag.
-        //
-        // NOTE: If the desired entry is a PNG, this doesn't actually trigger
-        // decoding, it merely ensures the decoder is created and ready to
-        // decode.  The caller will then call a function on the PNGImageDecoder
-        // that actually triggers decoding.
         void decode(size_t index, bool onlySize);
 
         // Decodes the directory and directory entries at the beginning of the
diff --git a/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp b/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
index a28b5db..b2e5e17 100644
--- a/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
+++ b/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
@@ -42,6 +42,19 @@ RGBA32Buffer::RGBA32Buffer()
 {
 }
 
+RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
+{
+    if (this == &other)
+        return *this;
+
+    copyBitmapData(other);
+    setRect(other.rect());
+    setStatus(other.status());
+    setDuration(other.duration());
+    setDisposalMethod(other.disposalMethod());
+    return *this;
+}
+
 void RGBA32Buffer::clear()
 {
     m_image = QImage();
@@ -115,19 +128,6 @@ void RGBA32Buffer::setDecodedImage(const QImage& image)
     m_hasAlpha = image.hasAlphaChannel();
 }
 
-RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
-{
-    if (this == &other)
-        return *this;
-
-    copyBitmapData(other);
-    setRect(other.rect());
-    setStatus(other.status());
-    setDuration(other.duration());
-    setDisposalMethod(other.disposalMethod());
-    return *this;
-}
-
 int RGBA32Buffer::width() const
 {
     return m_size.width();
diff --git a/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp b/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
index a8fa995..f763a15 100644
--- a/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
+++ b/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
@@ -36,6 +36,22 @@ RGBA32Buffer::RGBA32Buffer()
 {
 }
 
+RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
+{
+    if (this == &other)
+        return *this;
+
+    m_bitmap = other.m_bitmap;
+    // Keep the pixels locked since we will be writing directly into the
+    // bitmap throughout this object's lifetime.
+    m_bitmap.lockPixels();
+    setRect(other.rect());
+    setStatus(other.status());
+    setDuration(other.duration());
+    setDisposalMethod(other.disposalMethod());
+    return *this;
+}
+
 void RGBA32Buffer::clear()
 {
     m_bitmap.reset();
@@ -98,22 +114,6 @@ void RGBA32Buffer::setStatus(FrameStatus status)
         m_bitmap.setDataComplete();  // Tell the bitmap it's done.
 }
 
-RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
-{
-    if (this == &other)
-        return *this;
-
-    m_bitmap = other.m_bitmap;
-    // Keep the pixels locked since we will be writing directly into the
-    // bitmap throughout this object's lifetime.
-    m_bitmap.lockPixels();
-    setRect(other.rect());
-    setStatus(other.status());
-    setDuration(other.duration());
-    setDisposalMethod(other.disposalMethod());
-    return *this;
-}
-
 int RGBA32Buffer::width() const
 {
     return m_bitmap.width();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list