Changeset 61534 in webkit
- Timestamp:
- Jun 21, 2010 1:30:42 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r61531 r61534 1 2010-06-21 Benjamin Poulain <benjamin.poulain@nokia.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Decode images directly to QPixmap 6 https://bugs.webkit.org/show_bug.cgi?id=40797 7 8 Decode images to QPixmap directly instead of QImage when possible. 9 RGBA32Buffer transforms the pixmap back to image if 10 necessary. 11 12 This improve the performance with certain graphic system, and 13 can reduce memory usage. 14 15 * platform/graphics/qt/ImageDecoderQt.cpp: 16 (WebCore::ImageDecoderQt::setData): 17 (WebCore::ImageDecoderQt::internalHandleCurrentImage): 18 * platform/image-decoders/ImageDecoder.h: 19 (WebCore::RGBA32Buffer::getAddr): 20 * platform/image-decoders/qt/RGBA32BufferQt.cpp: 21 (WebCore::RGBA32Buffer::clear): 22 (WebCore::RGBA32Buffer::zeroFill): 23 (WebCore::RGBA32Buffer::copyBitmapData): 24 (WebCore::RGBA32Buffer::setSize): 25 (WebCore::RGBA32Buffer::asNewNativeImage): 26 (WebCore::RGBA32Buffer::setPixmap): 27 1 28 2010-06-20 Dumitru Daniliuc <dumi@chromium.org> 2 29 -
trunk/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
r61364 r61534 79 79 m_reader.set(new QImageReader(m_buffer.get(), m_format)); 80 80 81 // This will force the JPEG decoder to use JDCT_IFAST82 m_reader->setQuality(49);83 84 81 // QImageReader only allows retrieving the format before reading the image 85 82 m_format = m_reader->format(); … … 189 186 bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex) 190 187 { 191 // Now get the QImage from Qt and place it in the RGBA32Buffer 192 QImage img; 193 if (!m_reader->read(&img)) { 188 QPixmap pixmap; 189 bool pixmapLoaded; 190 const int imageCount = m_reader->imageCount(); 191 if (imageCount == 0 || imageCount == 1) 192 pixmapLoaded = pixmap.loadFromData((const uchar*)(m_data->data()), m_data->size(), m_format); 193 else { 194 QImage img; 195 const bool imageLoaded = m_reader->read(&img); 196 if (imageLoaded) { 197 pixmap = QPixmap::fromImage(img); 198 pixmapLoaded = true; 199 } 200 } 201 202 if (!pixmapLoaded) { 194 203 frameCount(); 195 204 repetitionCount(); … … 203 212 buffer->setStatus(RGBA32Buffer::FrameComplete); 204 213 buffer->setDuration(m_reader->nextImageDelay()); 205 buffer->set DecodedImage(img);214 buffer->setPixmap(pixmap); 206 215 return true; 207 216 } -
trunk/WebCore/platform/image-decoders/ImageDecoder.h
r56007 r61534 41 41 #include "NativeImageSkia.h" 42 42 #elif PLATFORM(QT) 43 #include <QPixmap> 43 44 #include <QImage> 44 45 #endif … … 131 132 132 133 #if PLATFORM(QT) 133 void setDecodedImage(const QImage& image); 134 QImage decodedImage() const { return m_image; } 134 void setPixmap(const QPixmap& pixmap); 135 135 #endif 136 136 … … 144 144 return m_bitmap.getAddr32(x, y); 145 145 #elif PLATFORM(QT) 146 m_image = m_pixmap.toImage(); 147 m_pixmap = QPixmap(); 146 148 return reinterpret_cast<QRgb*>(m_image.scanLine(y)) + x; 147 149 #else … … 169 171 NativeImageSkia m_bitmap; 170 172 #elif PLATFORM(QT) 173 mutable QPixmap m_pixmap; 171 174 mutable QImage m_image; 172 175 bool m_hasAlpha; -
trunk/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
r54978 r61534 58 58 void RGBA32Buffer::clear() 59 59 { 60 m_pixmap = QPixmap(); 60 61 m_image = QImage(); 61 62 m_status = FrameEmpty; … … 68 69 void RGBA32Buffer::zeroFill() 69 70 { 70 m_image.fill(0); 71 if (m_pixmap.isNull() && !m_image.isNull()) { 72 m_pixmap = QPixmap::fromImage(m_image); 73 m_image = QImage(); 74 } 75 m_pixmap.fill(QColor(0, 0, 0, 0)); 71 76 } 72 77 … … 77 82 78 83 m_image = other.m_image; 84 m_pixmap = other.m_pixmap; 79 85 m_size = other.m_size; 80 86 m_hasAlpha = other.m_hasAlpha; … … 88 94 89 95 m_size = IntSize(newWidth, newHeight); 90 m_image = QImage(newWidth, newHeight, QImage::Format_ARGB32_Premultiplied); 91 if (m_image.isNull()) 96 m_image = QImage(); 97 m_pixmap = QPixmap(newWidth, newHeight); 98 if (m_pixmap.isNull()) 92 99 return false; 93 100 … … 100 107 QPixmap* RGBA32Buffer::asNewNativeImage() const 101 108 { 102 QPixmap pix = QPixmap::fromImage(m_image); 103 m_image = QImage(); 104 105 return new QPixmap(pix); 109 if (m_pixmap.isNull() && !m_image.isNull()) { 110 m_pixmap = QPixmap::fromImage(m_image); 111 m_image = QImage(); 112 } 113 return new QPixmap(m_pixmap); 106 114 } 107 115 … … 122 130 123 131 // The image must not have format 8888 pre multiplied... 124 void RGBA32Buffer::set DecodedImage(const QImage& image)132 void RGBA32Buffer::setPixmap(const QPixmap& pixmap) 125 133 { 126 m_image = image; 127 m_size = image.size(); 128 m_hasAlpha = image.hasAlphaChannel(); 134 m_pixmap = pixmap; 135 m_image = QImage(); 136 m_size = pixmap.size(); 137 m_hasAlpha = pixmap.hasAlphaChannel(); 129 138 } 130 139
Note: See TracChangeset
for help on using the changeset viewer.