Changeset 108685 in webkit


Ignore:
Timestamp:
Feb 23, 2012 3:37:48 PM (12 years ago)
Author:
zoltan@webkit.org
Message:

[Qt] Allow to use WebCore imagedecoders
https://bugs.webkit.org/show_bug.cgi?id=32410

Source/WebCore:

Add ENABLE(QT_IMAGE_DECODER) guards around Qt imagedecoders and set it to default.
By passing ENABLE_QT_IMAGE_DECODER=0 define to the build system WebKit will build
with WebCore's imagedecoders.

I added NO_RETURN attribute to 2 functions of PNG and JPEG decoders to avoid compiler warnings
because in Qt-port we treat warning as errors (-Werror).

I'm continuing the refactoring of this area and try to use Qt imagedecoders only in
cases when WebCore doesn't support the image format.

Reviewed by Simon Hausmann.

No behavior change, no need new tests.

  • Target.pri:
  • WebCore.pri:
  • platform/MIMETypeRegistry.cpp:

(WebCore::initializeSupportedImageMIMETypes):
(WebCore::initializeSupportedImageMIMETypesForEncoding):

  • platform/image-decoders/ImageDecoder.h:

(WebCore::ImageFrame::getAddr):
(ImageFrame):

  • platform/image-decoders/jpeg/JPEGImageDecoder.cpp:

NO_RETURN has been added to a function to avoid warning message.

  • platform/image-decoders/png/PNGImageDecoder.cpp:

NO_RETURN has been added to a function to avoid warning message.
(WebCore):

  • platform/image-decoders/qt/ImageFrameQt.cpp:

(WebCore):
(WebCore::ImageFrame::asNewNativeImage):

Tools:

Add ENABLE_QT_IMAGE_DECODER macro, it's enabled by default.

Reviewed by Simon Hausmann.

  • qmake/mkspecs/features/features.prf:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r108678 r108685  
     12012-02-23  Zoltan Horvath  <zoltan@webkit.org>
     2
     3        [Qt] Allow to use WebCore imagedecoders
     4        https://bugs.webkit.org/show_bug.cgi?id=32410
     5
     6        Add ENABLE(QT_IMAGE_DECODER) guards around Qt imagedecoders and set it to default.
     7        By passing ENABLE_QT_IMAGE_DECODER=0 define to the build system WebKit will build
     8        with WebCore's imagedecoders.
     9
     10        I added NO_RETURN attribute to 2 functions of PNG and JPEG decoders to avoid compiler warnings
     11        because in Qt-port we treat warning as errors (-Werror).
     12
     13        I'm continuing the refactoring of this area and try to use Qt imagedecoders only in
     14        cases when WebCore doesn't support the image format.
     15
     16        Reviewed by Simon Hausmann.
     17
     18        No behavior change, no need new tests.
     19
     20        * Target.pri:
     21        * WebCore.pri:
     22        * platform/MIMETypeRegistry.cpp:
     23        (WebCore::initializeSupportedImageMIMETypes):
     24        (WebCore::initializeSupportedImageMIMETypesForEncoding):
     25        * platform/image-decoders/ImageDecoder.h:
     26        (WebCore::ImageFrame::getAddr):
     27        (ImageFrame):
     28        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
     29        NO_RETURN has been added to a function to avoid warning message.
     30        * platform/image-decoders/png/PNGImageDecoder.cpp:
     31        NO_RETURN has been added to a function to avoid warning message.
     32        (WebCore):
     33        * platform/image-decoders/qt/ImageFrameQt.cpp:
     34        (WebCore):
     35        (WebCore::ImageFrame::asNewNativeImage):
     36
    1372012-02-23  Dana Jansens  <danakj@chromium.org>
    238
  • trunk/Source/WebCore/Target.pri

    r108561 r108685  
    21922192    platform/graphics/RoundedRect.h \
    21932193    platform/graphics/qt/FontCustomPlatformData.h \
    2194     platform/graphics/qt/ImageDecoderQt.h \
    21952194    platform/graphics/qt/StillImageQt.h \
    21962195    platform/graphics/qt/TransparencyLayer.h \
     
    28032802    platform/graphics/qt/IconQt.cpp \
    28042803    platform/graphics/qt/ImageBufferQt.cpp \
    2805     platform/graphics/qt/ImageDecoderQt.cpp \
    28062804    platform/graphics/qt/ImageQt.cpp \
    28072805    platform/graphics/qt/IntPointQt.cpp \
     
    39393937}
    39403938
     3939contains(DEFINES, ENABLE_QT_IMAGE_DECODER=1) {
     3940    HEADERS += platform/graphics/qt/ImageDecoderQt.h
     3941    SOURCES += platform/graphics/qt/ImageDecoderQt.cpp
     3942} else {
     3943    HEADERS += \
     3944        platform/image-decoders/bmp/BMPImageDecoder.h \
     3945        platform/image-decoders/bmp/BMPImageReader.h \
     3946        platform/image-decoders/gif/GIFImageDecoder.h \
     3947        platform/image-decoders/gif/GIFImageReader.h\
     3948        platform/image-decoders/ico/ICOImageDecoder.h \
     3949        platform/image-decoders/jpeg/JPEGImageDecoder.h \
     3950        platform/image-decoders/png/PNGImageDecoder.h
     3951
     3952    SOURCES += \
     3953        platform/image-decoders/ImageDecoder.cpp \
     3954        platform/image-decoders/bmp/BMPImageDecoder.cpp \
     3955        platform/image-decoders/bmp/BMPImageReader.cpp \
     3956        platform/image-decoders/gif/GIFImageDecoder.cpp \
     3957        platform/image-decoders/gif/GIFImageReader.cpp\
     3958        platform/image-decoders/ico/ICOImageDecoder.cpp \
     3959        platform/image-decoders/jpeg/JPEGImageDecoder.cpp \
     3960        platform/image-decoders/png/PNGImageDecoder.cpp
     3961
     3962    contains(DEFINES, WTF_USE_WEBP=1) {
     3963        HEADERS += platform/image-decoders/webp/WEBPImageDecoder.h
     3964        SOURCES += platform/image-decoders/webp/WEBPImageDecoder.cpp
     3965    }
     3966}
     3967
    39413968!system-sqlite:exists( $${SQLITE3SRCDIR}/sqlite3.c ) {
    39423969    # Build sqlite3 into WebCore from source
  • trunk/Source/WebCore/WebCore.pri

    r108428 r108685  
    204204}
    205205
     206contains(DEFINES, ENABLE_QT_IMAGE_DECODER=0) {
     207    INCLUDEPATH += \
     208        $$SOURCE_DIR/platform/image-decoders/bmp \
     209        $$SOURCE_DIR/platform/image-decoders/gif \
     210        $$SOURCE_DIR/platform/image-decoders/ico \
     211        $$SOURCE_DIR/platform/image-decoders/jpeg \
     212        $$SOURCE_DIR/platform/image-decoders/png
     213
     214    LIBS += -ljpeg -lpng12
     215
     216    contains(DEFINES, WTF_USE_WEBP=1) {
     217        INCLUDEPATH += $$SOURCE_DIR/platform/image-decoders/webp
     218        LIBS += -lwebp
     219    }
     220}
     221
    206222win32-*|wince* {
    207223    DLLDESTDIR = $${ROOT_BUILD_DIR}/bin
  • trunk/Source/WebCore/platform/MIMETypeRegistry.cpp

    r105406 r108685  
    4040#include <wtf/RetainPtr.h>
    4141#endif
    42 #if PLATFORM(QT)
     42#if PLATFORM(QT) && ENABLE(QT_IMAGE_DECODER)
    4343#include <qimagereader.h>
    4444#include <qimagewriter.h>
     
    230230    supportedImageMIMETypes->remove("application/postscript");
    231231
    232 #elif PLATFORM(QT)
     232#elif PLATFORM(QT) && ENABLE(QT_IMAGE_DECODER)
    233233    QList<QByteArray> formats = QImageReader::supportedImageFormats();
    234234    for (size_t i = 0; i < static_cast<size_t>(formats.size()); ++i) {
     
    290290    supportedImageMIMETypesForEncoding->add("image/gif");
    291291#endif
    292 #elif PLATFORM(QT)
     292#elif PLATFORM(QT) && ENABLE(QT_IMAGE_DECODER)
    293293    QList<QByteArray> formats = QImageWriter::supportedImageFormats();
    294294    for (int i = 0; i < formats.size(); ++i) {
  • trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h

    r106097 r108685  
    6565                                      // contents
    6666        };
    67 #if USE(SKIA) || PLATFORM(QT)
     67#if USE(SKIA) || (PLATFORM(QT) && ENABLE(QT_IMAGE_DECODER))
    6868        typedef uint32_t PixelData;
    6969#else
     
    141141#if USE(SKIA)
    142142            return m_bitmap.bitmap().getAddr32(x, y);
    143 #elif PLATFORM(QT)
     143#elif PLATFORM(QT) && ENABLE(QT_IMAGE_DECODER)
    144144            m_image = m_pixmap.toImage();
    145145            m_pixmap = QPixmap();
     
    150150        }
    151151
    152 #if PLATFORM(QT)
     152#if PLATFORM(QT) && ENABLE(QT_IMAGE_DECODER)
    153153        void setPixmap(const QPixmap& pixmap);
    154154#endif
     
    191191        ColorProfile m_colorProfile;
    192192#endif
    193 #elif PLATFORM(QT)
     193#elif PLATFORM(QT) && ENABLE(QT_IMAGE_DECODER)
    194194        mutable QPixmap m_pixmap;
    195195        mutable QImage m_image;
  • trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

    r107389 r108685  
    104104void skip_input_data(j_decompress_ptr jd, long num_bytes);
    105105void term_source(j_decompress_ptr jd);
    106 void error_exit(j_common_ptr cinfo);
     106void error_exit(j_common_ptr cinfo) NO_RETURN;
    107107
    108108// Implementation of a JPEG src object that understands our state machine
  • trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp

    r105709 r108685  
    6565
    6666// Called if the decoding of the image fails.
     67static void PNGAPI decodingFailed(png_structp png, png_const_charp) NO_RETURN;
    6768static void PNGAPI decodingFailed(png_structp png, png_const_charp)
    6869{
  • trunk/Source/WebCore/platform/image-decoders/qt/ImageFrameQt.cpp

    r101610 r108685  
    3131#include "NotImplemented.h"
    3232
    33 #include <QPixmap>
    34 #include <stdio.h>
     33namespace WebCore {
    3534
    36 namespace WebCore {
     35#if !ENABLE(QT_IMAGE_DECODER)
     36
     37QPixmap* ImageFrame::asNewNativeImage() const
     38{
     39    QImage::Format fmt;
     40    if (m_hasAlpha)
     41        fmt = m_premultiplyAlpha ?  QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32;
     42    else
     43        fmt = QImage::Format_RGB32;
     44
     45    QImage img(reinterpret_cast<uchar*>(m_bytes), m_size.width(), m_size.height(), sizeof(PixelData) * m_size.width(), fmt);
     46
     47    return new QPixmap(QPixmap::fromImage(img));
     48}
     49
     50#else
    3751
    3852ImageFrame::ImageFrame()
     
    155169}
    156170
     171#endif
     172
    157173}
  • trunk/Tools/ChangeLog

    r108684 r108685  
     12012-02-23  Zoltan Horvath  <zoltan@webkit.org>
     2
     3        [Qt] Allow to use WebCore imagedecoders
     4        https://bugs.webkit.org/show_bug.cgi?id=32410
     5
     6        Add ENABLE_QT_IMAGE_DECODER macro, it's enabled by default.
     7
     8        Reviewed by Simon Hausmann.
     9
     10        * qmake/mkspecs/features/features.prf:
     11
    1122012-02-23  Eric Seidel  <eric@webkit.org>
    213
  • trunk/Tools/qmake/mkspecs/features/features.prf

    r107656 r108685  
    8787!contains(DEFINES, ENABLE_TOUCH_ICON_LOADING=.): DEFINES += ENABLE_TOUCH_ICON_LOADING=0
    8888!contains(DEFINES, ENABLE_ANIMATION_API=.): DEFINES += ENABLE_ANIMATION_API=0
     89!contains(DEFINES, ENABLE_QT_IMAGE_DECODER=.): DEFINES += ENABLE_QT_IMAGE_DECODER=1
    8990
    9091# Enabled in Source/JavaScriptCore/wtf/Platform.h if not set
Note: See TracChangeset for help on using the changeset viewer.