diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
commit | 635860845790a19bf50bbc51ba8fb66a96dde068 (patch) | |
tree | ef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/platform/graphics/qt/ImageSourceQt.cpp | |
parent | 8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff) | |
download | external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2 |
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/platform/graphics/qt/ImageSourceQt.cpp')
-rw-r--r-- | WebCore/platform/graphics/qt/ImageSourceQt.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/WebCore/platform/graphics/qt/ImageSourceQt.cpp b/WebCore/platform/graphics/qt/ImageSourceQt.cpp index 1d14f9d..d62acc3 100644 --- a/WebCore/platform/graphics/qt/ImageSourceQt.cpp +++ b/WebCore/platform/graphics/qt/ImageSourceQt.cpp @@ -29,6 +29,7 @@ #include "config.h" #include "ImageSource.h" #include "ImageDecoderQt.h" +#include "NotImplemented.h" #include "SharedBuffer.h" #include <QBuffer> @@ -36,25 +37,6 @@ #include <QImageReader> namespace WebCore { -static bool canHandleImage(const SharedBuffer& _data) -{ - // We need at least 4 bytes to figure out what kind of image we're dealing with. - if (_data.size() < 4) - return false; - - QByteArray data = QByteArray::fromRawData(_data.data(), _data.size()); - QBuffer buffer(&data); - if (!buffer.open(QBuffer::ReadOnly)) - return false; - - return !QImageReader::imageFormat(&buffer).isEmpty(); -} - -ImageDecoderQt* createDecoder(const SharedBuffer& data) { - if (!canHandleImage(data)) - return 0; - return new ImageDecoderQt(); -} ImageSource::ImageSource() : m_decoder(0) @@ -63,7 +45,7 @@ ImageSource::ImageSource() ImageSource::~ImageSource() { - delete m_decoder; + clear(true); } bool ImageSource::initialized() const @@ -78,7 +60,7 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived) // If insufficient bytes are available to determine the image type, no decoder plugin will be // made. if (!m_decoder) - m_decoder = createDecoder(*data); + m_decoder = ImageDecoderQt::create(*data); if (!m_decoder) return; @@ -86,6 +68,14 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived) m_decoder->setData(data->buffer(), allDataReceived); } +String ImageSource::filenameExtension() const +{ + if (!m_decoder) + return String(); + + return m_decoder->filenameExtension(); +} + bool ImageSource::isSizeAvailable() { if (!m_decoder) @@ -162,13 +152,20 @@ bool ImageSource::frameIsCompleteAtIndex(size_t index) return (m_decoder && m_decoder->imageAtIndex(index) != 0); } -void ImageSource::clear() +void ImageSource::clear(bool destroyAll, size_t clearBeforeFrame, SharedBuffer* data, bool allDataReceived) { - delete m_decoder; + if (!destroyAll) { + if (m_decoder) + m_decoder->clearFrameBufferCache(clearBeforeFrame); + return; + } + + delete m_decoder; m_decoder = 0; + if (data) + setData(data, allDataReceived); } - } // vim: ts=4 sw=4 et |