[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

zecke at webkit.org zecke at webkit.org
Thu Oct 29 20:44:21 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit b58c76ffbaea82ec2a2e927f574028a3afb1e7a0
Author: zecke at webkit.org <zecke at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 14 14:10:52 2009 +0000

    ImageDecoderQt: Minor tweaks to the decoder
    
    - Only cache the data when we start to use it.
    - Start with a repetition count of none for normal images.
    - Do not use canRead as this will trigger parsing of the full image
    - Cope with a GIF failing to decode the first frame, do not
      set m_failed to true if decoding the first frame failed
    - Inform the QImageReader about the format that was detected
    - Always create a ImageDecoderQt when when we have more
      than four byte.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49559 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 02c12c4..b14effa 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2009-10-13  Holger Hans Peter Freyther  <zecke at selfish.org>
+
+        Reviewed by Simon Hausmann.
+
+        ImageDecoderQt: Minor tweaks to the decoder
+
+        - Only cache the data when we start to use it.
+        - Start with a repetition count of none for normal images.
+        - Do not use canRead as this will trigger parsing of the full image
+        - Cope with a GIF failing to decode the first frame, do not
+          set m_failed to true if decoding the first frame failed
+        - Inform the QImageReader about the format that was detected
+        - Always create a ImageDecoderQt when when we have more
+        than four byte.
+
+
+        * platform/graphics/qt/ImageDecoderQt.cpp:
+        (WebCore::ImageDecoder::create): Always create QImageReader for a significant speed up
+        (WebCore::ImageDecoderQt::ImageDecoderQt): Initialize m_repetitionCount to cAnimationNone
+        (WebCore::ImageDecoderQt::setData): Only call ImageDecoder::setData when everything has been received
+        (WebCore::ImageDecoderQt::isSizeAvailable): Do not check m_failed twice.
+        (WebCore::ImageDecoderQt::filenameExtension): Convert from QByteArray to String
+        (WebCore::ImageDecoderQt::frameBufferAtIndex): Check for m_failed before trying to decode
+        (WebCore::ImageDecoderQt::internalDecodeSize): Fail if the size is QSize()
+        (WebCore::ImageDecoderQt::forceLoadEverything): Handle the case were decoding the first frame fails
+        * platform/graphics/qt/ImageDecoderQt.h: Change the m_format type
+
 2009-10-14  Mikhail Naganov  <mnaganov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index 3a27fe3..f8403b7 100644
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -43,22 +43,13 @@ ImageDecoder* ImageDecoder::create(const SharedBuffer& data)
     if (data.size() < 4)
         return 0;
 
-    QByteArray bytes = QByteArray::fromRawData(data.data(), data.size());
-    QBuffer buffer(&bytes);
-    if (!buffer.open(QBuffer::ReadOnly))
-        return 0;
-
-    QByteArray imageFormat = QImageReader::imageFormat(&buffer);
-    if (imageFormat.isEmpty())
-        return 0; // Image format not supported
-
-    return new ImageDecoderQt(imageFormat);
+    return new ImageDecoderQt;
 }
 
-ImageDecoderQt::ImageDecoderQt(const QByteArray& imageFormat)
-    : m_buffer(0)
+ImageDecoderQt::ImageDecoderQt()
+    :  m_buffer(0)
     , m_reader(0)
-    , m_repetitionCount(-1)
+    , m_repetitionCount(cAnimationNone)
 {
 }
 
@@ -73,13 +64,13 @@ void ImageDecoderQt::setData(SharedBuffer* data, bool allDataReceived)
     if (m_failed)
         return;
 
-    // Cache our own new data.
-    ImageDecoder::setData(data, allDataReceived);
-
     // No progressive loading possible
     if (!allDataReceived)
         return;
 
+    // Cache our own new data.
+    ImageDecoder::setData(data, allDataReceived);
+
     // We expect to be only called once with allDataReceived
     ASSERT(!m_buffer);
     ASSERT(!m_reader);
@@ -89,15 +80,12 @@ void ImageDecoderQt::setData(SharedBuffer* data, bool allDataReceived)
     m_buffer = new QBuffer;
     m_buffer->setData(imageData);
     m_buffer->open(QBuffer::ReadOnly);
-    m_reader = new QImageReader(m_buffer);
-
-    if (!m_reader->canRead())
-        failRead();
+    m_reader = new QImageReader(m_buffer, m_format);
 }
 
 bool ImageDecoderQt::isSizeAvailable()
 {
-    if (!m_failed && !ImageDecoder::isSizeAvailable() && m_reader)
+    if (!ImageDecoder::isSizeAvailable() && m_reader)
         internalDecodeSize();
 
     return ImageDecoder::isSizeAvailable();
@@ -134,14 +122,16 @@ int ImageDecoderQt::repetitionCount() const
 
 String ImageDecoderQt::filenameExtension() const
 {
-    return m_format;
+    return String(m_format.constData(), m_format.length());
 };
 
 RGBA32Buffer* ImageDecoderQt::frameBufferAtIndex(size_t index)
 {
-    // this information might not have been set
+    // In case the ImageDecoderQt got recreated we don't know
+    // yet how many images we are going to have and need to
+    // find that out now.
     int count = m_frameBufferCache.size();
-    if (count == 0) {
+    if (!m_failed && count == 0) {
         internalDecodeSize();
         count = frameCount();
     }
@@ -171,7 +161,12 @@ void ImageDecoderQt::internalDecodeSize()
 {
     ASSERT(m_reader);
 
+    // If we have a QSize() something failed
     QSize size = m_reader->size();
+    if (size.isEmpty())
+        return failRead();
+
+    m_format = m_reader->format();
     setSize(size.width(), size.height());
 }
 
@@ -213,9 +208,15 @@ void ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex)
     buffer->setDecodedImage(img);
 }
 
-// We will parse everything and we have no idea how
-// many images we have... We will have to find out the
-// hard way.
+// The QImageIOHandler is not able to tell us how many frames
+// we have and we need to parse every image. We do this by
+// increasing the m_frameBufferCache by one and try to parse
+// the image. We stop when QImage::read fails and then need
+// to resize the m_frameBufferCache to the final size and update
+// the m_failed. In case we failed to decode the first image
+// we want to keep m_failed set to true.
+
+// TODO: Do not increment the m_frameBufferCache.size() by one but more than one
 void ImageDecoderQt::forceLoadEverything()
 {
     int imageCount = 0;
@@ -225,9 +226,12 @@ void ImageDecoderQt::forceLoadEverything()
         internalHandleCurrentImage(imageCount - 1);
     } while(!m_failed);
 
-    // reset the failed state and resize the vector...
+    // If we failed decoding the first image we actually
+    // have no images and need to keep m_failed set to
+    // true otherwise we want to reset it and forget about
+    // the last attempt to decode a image.
     m_frameBufferCache.resize(imageCount - 1);
-    m_failed = false;
+    m_failed = imageCount == 1;
 }
 
 void ImageDecoderQt::failRead()
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.h b/WebCore/platform/graphics/qt/ImageDecoderQt.h
index 7b3b686..d11b938 100644
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.h
+++ b/WebCore/platform/graphics/qt/ImageDecoderQt.h
@@ -40,7 +40,7 @@ namespace WebCore {
 class ImageDecoderQt : public ImageDecoder
 {
 public:
-    ImageDecoderQt(const QByteArray& imageFormat);
+    ImageDecoderQt();
     ~ImageDecoderQt();
 
     virtual void setData(SharedBuffer* data, bool allDataReceived);
@@ -65,7 +65,7 @@ private:
     void failRead();
 
 private:
-    String m_format;
+    QByteArray m_format;
     QBuffer* m_buffer;
     QImageReader* m_reader;
     mutable int m_repetitionCount;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list