Commit 5fe38f17 authored by lars's avatar lars
Browse files

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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e3543b8f
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.
......
......@@ -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; }
......
......@@ -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;
}
......
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment