Reviewed by Antti.
authorlars <lars@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2007 13:38:49 +0000 (13:38 +0000)
committerlars <lars@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2007 13:38:49 +0000 (13:38 +0000)
        Fix the Qt build.
        Add a getter to SharedBuffer that returns a reference to the internal
        Vector to avoid an extra copy of the data.

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

WebCore/ChangeLog
WebCore/platform/SharedBuffer.h
WebCore/platform/graphics/qt/ImageQt.cpp
WebCore/platform/graphics/qt/ImageSourceQt.cpp

index 430d7d2cc46a23d612040de97060d286d59abef5..e584b47fc819b1dff2aed1d52051da8be1763982 100644 (file)
@@ -1,3 +1,20 @@
+2007-03-14  Lars Knoll <lars@trolltech.com>
+
+        Reviewed by Antti.
+
+        Fix the Qt build.
+        Add a getter to SharedBuffer that returns a reference to the internal
+        Vector to avoid an extra copy of the data.
+
+        * platform/SharedBuffer.h:
+        (WebCore::SharedBuffer::buffer):
+        * platform/graphics/qt/ImageQt.cpp:
+        (WebCore::Image::loadPlatformResource):
+        * platform/graphics/qt/ImageSourceQt.cpp:
+        (WebCore::detectImageFormat):
+        (WebCore::createDecoder):
+        (WebCore::ImageSource::setData):
+
 2007-03-14  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Mitz.
index 50ce48e519d44b796f35da2670b3f0e1120dae38..0da24c13b43c9f4ac8a5e9d06a41e0415d8c49d4 100644 (file)
@@ -53,6 +53,7 @@ public:
         
     const char* data() const;
     unsigned size() const;
+    const Vector<char> &buffer() { return m_buffer; }
 
     bool isEmpty() const { return size() == 0; }
 
index 30e6a25babe576c230ac5a09bb20162ac273188e..fa7a11e73f3ed0bbd65b0cb7bdd97660650ba12d 100644 (file)
@@ -74,7 +74,8 @@ Image* Image::loadPlatformResource(const char* name)
 {
     Vector<char> arr = loadResourceIntoArray(name);
     Image* img = new BitmapImage();
-    img->setNativeData(&arr, true);
+    RefPtr<SharedBuffer> buffer = new SharedBuffer(arr.data(), arr.size());
+    img->setData(buffer, true);
     return img;
 }
 
index f106019582ccf66e89ee822ac398a1c73de916fd..c737b19855e9cac319a9a0f9eb8d967038746f82 100644 (file)
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "ImageSource.h"
 #include "ImageDecoderQt.h"
-
+#include "SharedBuffer.h"
 
 #include <QImage>
 #include <qdebug.h>
@@ -39,7 +39,7 @@ namespace WebCore {
     enum ImageFormat { ImageFormat_None, ImageFormat_GIF, ImageFormat_PNG, ImageFormat_JPEG,
                        ImageFormat_BMP,  ImageFormat_ICO,  ImageFormat_XBM };
 
-ImageFormat  detectImageFormat(const Vector<char>& data)
+ImageFormat detectImageFormat(const SharedBuffer& data)
 {
     // We need at least 4 bytes to figure out what kind of image we're dealing with.
     int length = data.size();
@@ -84,7 +84,7 @@ ImageFormat  detectImageFormat(const Vector<char>& data)
     return ImageFormat_None;
 }
     
-ImageDecoderQt* createDecoder(const Vector<char>& data) {
+ImageDecoderQt* createDecoder(const SharedBuffer& data) {
     if (detectImageFormat(data) != ImageFormat_None) 
         return new ImageDecoderQt();
     return 0;
@@ -105,7 +105,7 @@ bool ImageSource::initialized() const
     return m_decoder;
 }
 
-void ImageSource::setData(const Vector<char>* data, bool allDataReceived)
+void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
 {
     // Make the decoder by sniffing the bytes.
     // This method will examine the data and instantiate an instance of the appropriate decoder plugin.
@@ -117,7 +117,7 @@ void ImageSource::setData(const Vector<char>* data, bool allDataReceived)
     if (!m_decoder)
         return;
 
-    m_decoder->setData(*data, allDataReceived);
+    m_decoder->setData(data->buffer(), allDataReceived);
 }
 
 bool ImageSource::isSizeAvailable()