Changeset 118909 in webkit
- Timestamp:
- May 30, 2012 2:37:01 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r118907 r118909 1 2012-05-30 Zoltan Horvath <zoltan@webkit.org> 2 3 [Qt] Set WebCore imagedecoders as default and add fallback to QImageDecoder 4 https://bugs.webkit.org/show_bug.cgi?id=80400 5 6 This change modifies the default ImageDecoder for Qt-port from QImageDecoder to WebCore ImageDecoder. 7 The new behavior is to use QImageDecoder only if WebCoreImageDecoder - and the platform - doesn't support 8 the requested image type. 9 The WTF_USE_QT_IMAGE_DECODER macro has been removed, since it is no longer needed. 10 11 This change adds build depedency (except Qt-MAC and Qt-WIN platform) for libpng-dev and libjpeg-dev packages, 12 because PNG and JPEG imagedecoders need not only these libraries, but their headers also. Qmake-config 13 tests for these libraries were introduced in r110045. 14 15 Notice: with using libjpeg-turbo as a system library I measured 10% performance improvement on Methanol benchmark 16 (collection of popular sites, page-loading benchmark) with this patch. 17 18 Reviewed by Simon Hausmann. 19 20 No new tests needed. 21 22 * Target.pri: Move WebCore ImageDecoder files out of guards. Remove ImageFrameQt.cpp from sources. 23 * WebCore.pri: Move WebCore ImageDecoder include paths out of guards. 24 * platform/MIMETypeRegistry.cpp: 25 (WebCore::initializeSupportedImageMIMETypes): Add WebCore supported and Qt supported MIME types. 26 (WebCore::initializeSupportedImageMIMETypesForEncoding): Use Qt supported MIME types. 27 * platform/graphics/ImageSource.cpp: Remove unnecessary includes. 28 * platform/graphics/ImageSource.h: Remove unnecessary typedefs. 29 (WebCore): 30 * platform/graphics/qt/ImageDecoderQt.cpp: Remove ImageDecoder::create, since it is no longer needed. 31 (WebCore::ImageDecoderQt::filenameExtension): Remove unnecessary semicolon. 32 (WebCore::ImageDecoderQt::internalHandleCurrentImage): Use QImage and ImageFrame instead of QPixmap. 33 (WebCore): 34 (WebCore::ImageFrame::asNewNativeImage): Moved here from removed ImageFrameQt.cpp. 35 * platform/image-decoders/ImageDecoder.cpp: Reorganize the includes of the header. 36 (WebCore::ImageDecoder::create): Add platform macro guarded fallback case for QImageDecoder. Add guards 37 for JPEG, PNG, ICO decoder for Qt-MAC and Qt-WIN platform. 38 * platform/image-decoders/ImageDecoder.h: Remove Qt-specific codes. 39 (WebCore::ImageFrame::getAddr): Remove Qt-specific case, since it is no longer needed. 40 (ImageFrame): 41 * platform/image-decoders/qt/ImageFrameQt.cpp: Removed. Dead code, other code has been moved to 42 ImageDecoderQt.cpp. 43 1 44 2012-05-23 Kinuko Yasuda <kinuko@chromium.org> 2 45 -
trunk/Source/WebCore/Target.pri
r118735 r118909 1092 1092 platform/FileSystem.cpp \ 1093 1093 platform/HistogramSupport.cpp \ 1094 platform/image-decoders/qt/ImageFrameQt.cpp \1095 1094 platform/graphics/FontDescription.cpp \ 1096 1095 platform/graphics/FontFallbackList.cpp \ … … 1145 1144 platform/graphics/transforms/TransformState.cpp \ 1146 1145 platform/graphics/transforms/TranslateTransformOperation.cpp \ 1146 platform/image-decoders/ImageDecoder.cpp \ 1147 platform/image-decoders/bmp/BMPImageDecoder.cpp \ 1148 platform/image-decoders/bmp/BMPImageReader.cpp \ 1149 platform/image-decoders/gif/GIFImageDecoder.cpp \ 1150 platform/image-decoders/gif/GIFImageReader.cpp\ 1147 1151 platform/KillRingNone.cpp \ 1148 1152 platform/KURL.cpp \ … … 2301 2305 platform/graphics/transforms/TransformState.h \ 2302 2306 platform/graphics/transforms/TranslateTransformOperation.h \ 2307 platform/image-decoders/bmp/BMPImageDecoder.h \ 2308 platform/image-decoders/bmp/BMPImageReader.h \ 2309 platform/image-decoders/ico/ICOImageDecoder.h \ 2310 platform/image-decoders/gif/GIFImageDecoder.h \ 2311 platform/image-decoders/gif/GIFImageReader.h \ 2312 platform/image-decoders/jpeg/JPEGImageDecoder.h \ 2313 platform/image-decoders/png/PNGImageDecoder.h \ 2303 2314 platform/KillRing.h \ 2304 2315 platform/KURL.h \ … … 2878 2889 platform/graphics/qt/IconQt.cpp \ 2879 2890 platform/graphics/qt/ImageBufferQt.cpp \ 2891 platform/graphics/qt/ImageDecoderQt.cpp \ 2880 2892 platform/graphics/qt/ImageQt.cpp \ 2881 2893 platform/graphics/qt/IntPointQt.cpp \ … … 4053 4065 } 4054 4066 4055 contains(DEFINES, WTF_USE_QT_IMAGE_DECODER=1) { 4056 HEADERS += platform/graphics/qt/ImageDecoderQt.h 4057 SOURCES += platform/graphics/qt/ImageDecoderQt.cpp 4058 } else { 4059 HEADERS += \ 4060 platform/image-decoders/bmp/BMPImageDecoder.h \ 4061 platform/image-decoders/bmp/BMPImageReader.h \ 4062 platform/image-decoders/gif/GIFImageDecoder.h \ 4063 platform/image-decoders/gif/GIFImageReader.h\ 4064 platform/image-decoders/ico/ICOImageDecoder.h \ 4065 platform/image-decoders/jpeg/JPEGImageDecoder.h \ 4066 platform/image-decoders/png/PNGImageDecoder.h 4067 4068 SOURCES += \ 4069 platform/image-decoders/ImageDecoder.cpp \ 4070 platform/image-decoders/bmp/BMPImageDecoder.cpp \ 4071 platform/image-decoders/bmp/BMPImageReader.cpp \ 4072 platform/image-decoders/gif/GIFImageDecoder.cpp \ 4073 platform/image-decoders/gif/GIFImageReader.cpp\ 4074 platform/image-decoders/ico/ICOImageDecoder.cpp \ 4075 platform/image-decoders/jpeg/JPEGImageDecoder.cpp \ 4076 platform/image-decoders/png/PNGImageDecoder.cpp 4077 4078 contains(DEFINES, WTF_USE_WEBP=1) { 4079 HEADERS += platform/image-decoders/webp/WEBPImageDecoder.h 4080 SOURCES += platform/image-decoders/webp/WEBPImageDecoder.cpp 4081 } 4067 contains(DEFINES, HAVE_LIBPNG=1) { 4068 SOURCES += platform/image-decoders/ico/ICOImageDecoder.cpp \ 4069 platform/image-decoders/png/PNGImageDecoder.cpp 4070 } 4071 4072 contains(DEFINES, HAVE_LIBJPEG=1) { 4073 SOURCES += platform/image-decoders/jpeg/JPEGImageDecoder.cpp 4074 } 4075 4076 contains(DEFINES, WTF_USE_WEBP=1) { 4077 INCLUDEPATH += platform/image-decoders/webp 4078 HEADERS += platform/image-decoders/webp/WEBPImageDecoder.h 4079 SOURCES += platform/image-decoders/webp/WEBPImageDecoder.cpp 4082 4080 } 4083 4081 -
trunk/Source/WebCore/WebCore.pri
r118377 r118909 66 66 $$SOURCE_DIR/platform/graphics/transforms \ 67 67 $$SOURCE_DIR/platform/image-decoders \ 68 $$SOURCE_DIR/platform/image-decoders/bmp \ 69 $$SOURCE_DIR/platform/image-decoders/ico \ 70 $$SOURCE_DIR/platform/image-decoders/gif \ 71 $$SOURCE_DIR/platform/image-decoders/jpeg \ 72 $$SOURCE_DIR/platform/image-decoders/png \ 68 73 $$SOURCE_DIR/platform/leveldb \ 69 74 $$SOURCE_DIR/platform/mock \ … … 224 229 } 225 230 226 contains(DEFINES, WTF_USE_QT_IMAGE_DECODER=0) { 227 INCLUDEPATH += \ 228 $$SOURCE_DIR/platform/image-decoders/bmp \ 229 $$SOURCE_DIR/platform/image-decoders/gif \ 230 $$SOURCE_DIR/platform/image-decoders/ico \ 231 $$SOURCE_DIR/platform/image-decoders/jpeg \ 232 $$SOURCE_DIR/platform/image-decoders/png 233 234 haveQt(5) { 235 # Qt5 allows us to use config tests to check for the presence of these libraries 236 !contains(config_test_libjpeg, yes): error("JPEG library not found!") 237 !contains(config_test_libpng, yes): error("PNG library not found!") 238 } 239 240 LIBS += -ljpeg -lpng 241 242 contains(DEFINES, WTF_USE_WEBP=1) { 243 INCLUDEPATH += $$SOURCE_DIR/platform/image-decoders/webp 244 LIBS += -lwebp 231 contains(DEFINES, WTF_USE_WEBP=1) { 232 INCLUDEPATH += $$SOURCE_DIR/platform/image-decoders/webp 233 LIBS += -lwebp 234 } 235 236 haveQt(5) { 237 # Qt5 allows us to use config tests to check for the presence of these libraries 238 contains(config_test_libjpeg, yes) { 239 DEFINES += HAVE_LIBJPEG=1 240 LIBS += -ljpeg 241 } else { 242 warning("JPEG library not found! QImageDecoder will decode JPEG images.") 243 } 244 contains(config_test_libpng, yes) { 245 DEFINES += HAVE_LIBPNG=1 246 LIBS += -lpng 247 } else { 248 warning("PNG library not found! QImageDecoder will decode PNG images.") 249 } 250 } else { 251 !win32-*:!mac { 252 DEFINES += HAVE_LIBJPEG=1 HAVE_LIBPNG=1 253 LIBS += -ljpeg -lpng 245 254 } 246 255 } -
trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
r116145 r118909 40 40 #include <wtf/RetainPtr.h> 41 41 #endif 42 #if PLATFORM(QT) && USE(QT_IMAGE_DECODER)43 #include < qimagereader.h>44 #include < qimagewriter.h>42 #if PLATFORM(QT) 43 #include <QImageReader> 44 #include <QImageWriter> 45 45 #endif 46 46 … … 228 228 supportedImageMIMETypes->remove("application/postscript"); 229 229 230 #elif PLATFORM(QT) && USE(QT_IMAGE_DECODER)231 QList<QByteArray> formats = QImageReader::supportedImageFormats();232 for (size_t i = 0; i < static_cast<size_t>(formats.size()); ++i) {233 #if ENABLE(SVG)234 /*235 * Qt has support for SVG, but we want to use KSVG2236 */237 if (formats.at(i).toLower().startsWith("svg"))238 continue;239 #endif240 String mimeType = MIMETypeRegistry::getMIMETypeForExtension(formats.at(i).constData());241 if (!mimeType.isEmpty()) {242 supportedImageMIMETypes->add(mimeType);243 supportedImageResourceMIMETypes->add(mimeType);244 }245 }246 230 #else 247 231 // assume that all implementations at least support the following standard … … 260 244 supportedImageResourceMIMETypes->add(types[i]); 261 245 } 246 247 #if PLATFORM(QT) 248 QList<QByteArray> formats = QImageReader::supportedImageFormats(); 249 for (size_t i = 0; i < static_cast<size_t>(formats.size()); ++i) { 250 #if ENABLE(SVG) 251 // Qt has support for SVG, but we want to use KSVG2 252 if (formats.at(i).toLower().startsWith("svg")) 253 continue; 254 #endif // ENABLE(SVG) 255 String mimeType = MIMETypeRegistry::getMIMETypeForExtension(formats.at(i).constData()); 256 if (!mimeType.isEmpty()) { 257 supportedImageMIMETypes->add(mimeType); 258 supportedImageResourceMIMETypes->add(mimeType); 259 } 260 } 261 #endif // PLATFORM(QT) 262 262 #endif 263 263 } … … 284 284 supportedImageMIMETypesForEncoding->add("image/gif"); 285 285 #endif 286 #elif PLATFORM(QT) && USE(QT_IMAGE_DECODER)286 #elif PLATFORM(QT) 287 287 QList<QByteArray> formats = QImageWriter::supportedImageFormats(); 288 288 for (int i = 0; i < formats.size(); ++i) { … … 291 291 supportedImageMIMETypesForEncoding->add(mimeType); 292 292 } 293 #elif PLATFORM(GTK) || (PLATFORM(QT) && !USE(QT_IMAGE_DECODER))293 #elif PLATFORM(GTK) 294 294 supportedImageMIMETypesForEncoding->add("image/png"); 295 295 supportedImageMIMETypesForEncoding->add("image/jpeg"); -
trunk/Source/WebCore/platform/graphics/ImageSource.cpp
r116105 r118909 30 30 #include "ImageSource.h" 31 31 32 #if PLATFORM(QT)33 #include "ImageDecoderQt.h"34 #else35 32 #include "ImageDecoder.h" 36 #endif37 33 38 34 #include "ImageOrientation.h" -
trunk/Source/WebCore/platform/graphics/ImageSource.h
r117355 r118909 71 71 typedef ImageDecoder* NativeImageSourcePtr; 72 72 typedef TiledImageOpenVG* NativeImagePtr; 73 #elif PLATFORM(QT)74 class ImageDecoderQt;75 typedef ImageDecoderQt* NativeImageSourcePtr;76 typedef QPixmap* NativeImagePtr;77 73 #else 78 74 class ImageDecoder; … … 94 90 typedef ImageDecoder* NativeImageSourcePtr; 95 91 typedef void* NativeImagePtr; 92 #elif PLATFORM(QT) 93 typedef QPixmap* NativeImagePtr; 96 94 #endif 97 95 #endif -
trunk/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
r116105 r118909 32 32 #include <QtCore/QByteArray> 33 33 #include <QtCore/QBuffer> 34 35 34 #include <QtGui/QImageReader> 36 #include <qdebug.h>37 35 38 36 namespace WebCore { 39 40 ImageDecoder* ImageDecoder::create(const SharedBuffer& data, ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)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 0;45 46 return new ImageDecoderQt(alphaOption, gammaAndColorProfileOption);47 }48 37 49 38 ImageDecoderQt::ImageDecoderQt(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) … … 130 119 { 131 120 return String(m_format.constData(), m_format.length()); 132 } ;121 } 133 122 134 123 ImageFrame* ImageDecoderQt::frameBufferAtIndex(size_t index) … … 195 184 bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex) 196 185 { 197 QPixmap pixmap = QPixmap::fromImageReader(m_reader.get()); 198 199 if (pixmap.isNull()) { 186 ImageFrame* const buffer = &m_frameBufferCache[frameIndex]; 187 QSize imageSize = m_reader->size(); 188 189 if (!buffer->setSize(imageSize.width(), imageSize.height())) 190 return false; 191 192 QImage image(reinterpret_cast<uchar*>(buffer->getAddr(0, 0)), imageSize.width(), imageSize.height(), sizeof(ImageFrame::PixelData) * imageSize.width(), m_reader->imageFormat()); 193 194 buffer->setDuration(m_reader->nextImageDelay()); 195 m_reader->read(&image); 196 197 if (image.isNull()) { 200 198 frameCount(); 201 199 repetitionCount(); … … 204 202 } 205 203 206 // now into the ImageFrame - even if the image is not 207 ImageFrame* const buffer = &m_frameBufferCache[frameIndex]; 208 buffer->setOriginalFrameRect(m_reader->currentImageRect()); 204 buffer->setOriginalFrameRect(image.rect()); 205 buffer->setHasAlpha(image.hasAlphaChannel()); 209 206 buffer->setStatus(ImageFrame::FrameComplete); 210 buffer->setDuration(m_reader->nextImageDelay()); 211 buffer->setPixmap(pixmap); 207 212 208 return true; 213 209 } … … 246 242 m_buffer.clear(); 247 243 } 244 245 NativeImagePtr ImageFrame::asNewNativeImage() const 246 { 247 QImage::Format format; 248 if (m_hasAlpha) 249 format = m_premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32; 250 else 251 format = QImage::Format_RGB32; 252 253 QImage img(reinterpret_cast<uchar*>(m_bytes), m_size.width(), m_size.height(), sizeof(PixelData) * m_size.width(), format); 254 255 return new QPixmap(QPixmap::fromImage(img)); 256 } 257 248 258 } 249 259 -
trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp
r117355 r118909 21 21 22 22 #include "config.h" 23 24 23 #include "ImageDecoder.h" 25 26 #include <algorithm>27 #include <cmath>28 24 29 25 #include "BMPImageDecoder.h" 30 26 #include "GIFImageDecoder.h" 31 27 #include "ICOImageDecoder.h" 28 #if PLATFORM(QT) 29 #include "ImageDecoderQt.h" 30 #endif 32 31 #include "JPEGImageDecoder.h" 33 32 #include "PNGImageDecoder.h" 33 #include "SharedBuffer.h" 34 34 #if USE(WEBP) 35 35 #include "WEBPImageDecoder.h" 36 36 #endif 37 #include "SharedBuffer.h" 37 38 #include <algorithm> 39 #include <cmath> 38 40 39 41 using namespace std; … … 108 110 return new GIFImageDecoder(alphaOption, gammaAndColorProfileOption); 109 111 112 #if !PLATFORM(QT) || (PLATFORM(QT) && HAVE(LIBPNG)) 110 113 if (matchesPNGSignature(contents)) 111 114 return new PNGImageDecoder(alphaOption, gammaAndColorProfileOption); 112 115 116 if (matchesICOSignature(contents) || matchesCURSignature(contents)) 117 return new ICOImageDecoder(alphaOption, gammaAndColorProfileOption); 118 #endif 119 120 #if !PLATFORM(QT) || (PLATFORM(QT) && HAVE(LIBJPEG)) 113 121 if (matchesJPEGSignature(contents)) 114 122 return new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption); 123 #endif 115 124 116 125 #if USE(WEBP) … … 122 131 return new BMPImageDecoder(alphaOption, gammaAndColorProfileOption); 123 132 124 if (matchesICOSignature(contents) || matchesCURSignature(contents))125 return new ICOImageDecoder(alphaOption, gammaAndColorProfileOption);126 133 #if PLATFORM(QT) 134 return new ImageDecoderQt(alphaOption, gammaAndColorProfileOption); 135 #endif 127 136 return 0; 128 137 } -
trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h
r117355 r118909 41 41 #include "NativeImageSkia.h" 42 42 #include "SkColorPriv.h" 43 #elif PLATFORM(QT)44 #include <QPixmap>45 #include <QImage>46 43 #endif 47 44 … … 65 62 // contents 66 63 }; 67 #if USE(SKIA) || (PLATFORM(QT) && USE(QT_IMAGE_DECODER))64 #if USE(SKIA) 68 65 typedef uint32_t PixelData; 69 66 #else … … 137 134 #if USE(SKIA) 138 135 return m_bitmap.bitmap().getAddr32(x, y); 139 #elif PLATFORM(QT) && USE(QT_IMAGE_DECODER)140 m_image = m_pixmap.toImage();141 m_pixmap = QPixmap();142 return reinterpret_cast_ptr<QRgb*>(m_image.scanLine(y)) + x;143 136 #else 144 137 return m_bytes + (y * width()) + x; 145 138 #endif 146 139 } 147 148 #if PLATFORM(QT) && USE(QT_IMAGE_DECODER)149 void setPixmap(const QPixmap& pixmap);150 #endif151 152 140 private: 153 141 int width() const; … … 181 169 ColorProfile m_colorProfile; 182 170 #endif 183 #elif PLATFORM(QT) && USE(QT_IMAGE_DECODER)184 mutable QPixmap m_pixmap;185 mutable QImage m_image;186 bool m_hasAlpha;187 IntSize m_size;188 171 #else 189 172 Vector<PixelData> m_backingStore; -
trunk/Source/WebKit/blackberry/ChangeLog
r118895 r118909 1 2012-05-30 Zoltan Horvath <zoltan@webkit.org> 2 3 [Qt] Set WebCore imagedecoders as default and add fallback to QImageDecoder 4 https://bugs.webkit.org/show_bug.cgi?id=80400 5 6 Get rid of QT_IMAGE_DECODER flag. 7 8 Reviewed by Simon Hausmann. 9 10 * WebCoreSupport/AboutDataEnableFeatures.in: 11 1 12 2012-05-29 Max Feil <mfeil@rim.com> 2 13 -
trunk/Source/WebKit/blackberry/WebCoreSupport/AboutDataEnableFeatures.in
r116105 r118909 108 108 PROGRESS_TAG 109 109 PURGEABLE_MEMORY 110 QT_IMAGE_DECODER111 110 QUOTA 112 111 REGEXP_TRACING
Note: See TracChangeset
for help on using the changeset viewer.