Changeset 39233 in webkit
- Timestamp:
- Dec 12, 2008, 2:54:42 AM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/qt/ImageDecoderQt.cpp (modified) (4 diffs)
-
platform/graphics/qt/ImageDecoderQt.h (modified) (3 diffs)
-
platform/graphics/qt/ImageSourceQt.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r39228 r39233 1 2008-12-12 Tor Arne Vestbø <tavestbo@trolltech.com> 2 3 Reviewed by Simon Hausmann. 4 5 Implement ImageSource::filenameExtension() for the Qt port 6 7 We're using QImageReader::imageFormat().toLower() to check 8 that the image format is supported, and if it is we store 9 the resulting extension when creating the ImageDecoderQt. 10 11 * platform/graphics/qt/ImageDecoderQt.cpp: 12 (WebCore::ImageDecoderQt::create): 13 (WebCore::ImageDecoderQt::ImageDecoderQt): 14 (WebCore::ImageDecoderQt::imageFormat): 15 * platform/graphics/qt/ImageDecoderQt.h: 16 * platform/graphics/qt/ImageSourceQt.cpp: 17 (WebCore::ImageSource::setData): 18 (WebCore::ImageSource::filenameExtension): 19 1 20 2008-12-11 Stephanie Lewis <slewis@apple.com> 2 21 -
trunk/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
r37061 r39233 179 179 } 180 180 181 182 // ImageDecoderQt 183 ImageDecoderQt::ImageDecoderQt( ) 181 ImageDecoderQt* ImageDecoderQt::create(const SharedBuffer& data) 182 { 183 // We need at least 4 bytes to figure out what kind of image we're dealing with. 184 if (data.size() < 4) 185 return 0; 186 187 QByteArray bytes = QByteArray::fromRawData(data.data(), data.size()); 188 QBuffer buffer(&bytes); 189 if (!buffer.open(QBuffer::ReadOnly)) 190 return 0; 191 192 QString imageFormat = QImageReader::imageFormat(&buffer).toLower(); 193 if (imageFormat.isEmpty()) 194 return 0; // Image format not supported 195 196 return new ImageDecoderQt(imageFormat); 197 } 198 199 ImageDecoderQt::ImageDecoderQt(const QString &imageFormat) 200 : m_imageFormat(imageFormat) 184 201 { 185 202 } … … 255 272 } 256 273 257 258 274 int ImageDecoderQt::repetitionCount() const 259 275 { … … 262 278 return m_loopCount; 263 279 } 264 265 280 266 281 bool ImageDecoderQt::supportsAlpha() const … … 275 290 return m_imageList[index].m_duration; 276 291 } 292 293 QString ImageDecoderQt::imageFormat() const 294 { 295 if (debugImageDecoderQt) 296 qDebug() << " ImageDecoderQt::imageFormat() returns" << m_imageFormat; 297 return m_imageFormat; 298 }; 277 299 278 300 RGBA32Buffer* ImageDecoderQt::frameBufferAtIndex(size_t index) -
trunk/WebCore/platform/graphics/qt/ImageDecoderQt.h
r37061 r39233 39 39 class ImageDecoderQt : public ImageDecoder 40 40 { 41 ImageDecoderQt(const ImageDecoderQt&);42 ImageDecoderQt &operator=(const ImageDecoderQt&);43 41 public: 44 ImageDecoderQt();42 static ImageDecoderQt* create(const SharedBuffer& data); 45 43 ~ImageDecoderQt(); 46 44 … … 48 46 49 47 virtual void setData(const IncomingData& data, bool allDataReceived); 50 51 48 virtual bool isSizeAvailable() const; 52 53 49 virtual int frameCount() const; 54 55 56 50 virtual int repetitionCount() const; 57 58 59 51 virtual RGBA32Buffer* frameBufferAtIndex(size_t index); 60 52 61 53 QPixmap* imageAtIndex(size_t index) const; 62 63 54 virtual bool supportsAlpha() const; 64 65 55 int duration(size_t index) const; 56 QString imageFormat() const; 66 57 67 58 void clearFrame(size_t index); 59 68 60 private: 61 ImageDecoderQt(const QString &imageFormat); 62 ImageDecoderQt(const ImageDecoderQt&); 63 ImageDecoderQt &operator=(const ImageDecoderQt&); 64 69 65 class ReadContext; 70 66 void reset(); … … 90 86 mutable QHash<int, QPixmap> m_pixmapCache; 91 87 int m_loopCount; 88 QString m_imageFormat; 92 89 }; 93 90 -
trunk/WebCore/platform/graphics/qt/ImageSourceQt.cpp
r39209 r39233 38 38 39 39 namespace WebCore { 40 static bool canHandleImage(const SharedBuffer& _data)41 {42 // We need at least 4 bytes to figure out what kind of image we're dealing with.43 if (_data.size() < 4)44 return false;45 46 QByteArray data = QByteArray::fromRawData(_data.data(), _data.size());47 QBuffer buffer(&data);48 if (!buffer.open(QBuffer::ReadOnly))49 return false;50 51 return !QImageReader::imageFormat(&buffer).isEmpty();52 }53 54 ImageDecoderQt* createDecoder(const SharedBuffer& data) {55 if (!canHandleImage(data))56 return 0;57 return new ImageDecoderQt();58 }59 40 60 41 ImageSource::ImageSource() … … 80 61 // made. 81 62 if (!m_decoder) 82 m_decoder = createDecoder(*data);63 m_decoder = ImageDecoderQt::create(*data); 83 64 84 65 if (!m_decoder) … … 90 71 String ImageSource::filenameExtension() const 91 72 { 92 notImplemented(); 93 return String(); 73 if (!m_decoder) 74 return String(); 75 76 return m_decoder->imageFormat(); 94 77 } 95 78
Note:
See TracChangeset
for help on using the changeset viewer.