[Qt] Change NativeImagePtr from QPixmap* to QImage*
authorzoltan@webkit.org <zoltan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2012 13:50:14 +0000 (13:50 +0000)
committerzoltan@webkit.org <zoltan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2012 13:50:14 +0000 (13:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=88785

Reviewed by Simon Hausmann.

Since we use raster engine there is no difference between QPixmap and QImage, so we are going
to use QImage everywhere where it is possible. This refactoring contains the change of the
NativeImagePtr typedef from QPixmap* to QImage* and covers the related modifications.

Part of the change is similar to Viatcheslav Ostapenko's internal work.

Covered by existing tests.

Source/WebCore:

* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::QtPixmapAssignToElementMethod::invoke):
(JSC::Bindings::QtPixmapInstance::variantFromObject):
* platform/DragImage.h:
(WebCore):
* platform/graphics/GraphicsContext.h:
(GraphicsContext):
* platform/graphics/Image.h:
(Image):
* platform/graphics/ImageSource.h:
(WebCore):
* platform/graphics/gstreamer/ImageGStreamer.h:
* platform/graphics/gstreamer/ImageGStreamerQt.cpp:
(ImageGStreamer::ImageGStreamer):
* platform/graphics/qt/GraphicsContext3DQt.cpp:
(WebCore::GraphicsContext3D::getImageData):
* platform/graphics/qt/GraphicsContextQt.cpp:
(WebCore::GraphicsContext::pushTransparencyLayerInternal):
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
* platform/graphics/qt/ImageBufferDataQt.h:
(ImageBufferData):
* platform/graphics/qt/ImageBufferQt.cpp:
(WebCore::ImageBufferData::ImageBufferData):
(WebCore::ImageBuffer::copyImage):
(WebCore::ImageBuffer::clip):
(WebCore::ImageBuffer::platformTransformColorSpace):
(WebCore::getImageData):
(WebCore::ImageBuffer::putByteArray):
(WebCore::encodeImage):
(WebCore::ImageBuffer::toDataURL):
* platform/graphics/qt/ImageDecoderQt.cpp:
(WebCore::ImageFrame::asNewNativeImage):
* platform/graphics/qt/ImageQt.cpp:
(graphics):
(loadResourceImage):
(WebCore::Image::loadPlatformResource):
(WebCore::Image::setPlatformResource):
(WebCore::Image::drawPattern):
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::checkForSolidColor):
(WebCore::BitmapImage::create):
* platform/graphics/qt/NativeImageQt.h: Added.
(WebCore):
(NativeImageQt):
(WebCore::NativeImageQt::defaultFormatForAlphaEnabledImages):
(WebCore::NativeImageQt::defaultFormatForOpaqueImages):
 * platform/graphics/qt/PatternQt.cpp:
(WebCore::Pattern::createPlatformPattern):
* platform/graphics/qt/StillImageQt.cpp:
(WebCore::StillImage::StillImage):
(WebCore::StillImage::~StillImage):
(WebCore::StillImage::currentFrameHasAlpha):
(WebCore::StillImage::size):
(WebCore::StillImage::nativeImageForCurrentFrame):
(WebCore::StillImage::draw):
* platform/graphics/qt/StillImageQt.h:
(WebCore::StillImage::create):
(WebCore::StillImage::createForRendering):
(StillImage):
* platform/graphics/qt/TransparencyLayer.h:
(WebCore::TransparencyLayer::TransparencyLayer):
(TransparencyLayer):
* platform/graphics/texmap/TextureMapperGL.cpp:
* platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp:
(WebCore::GraphicsSurface::createReadOnlyImage):
 * platform/qt/ClipboardQt.cpp:
(WebCore::ClipboardQt::createDragImage):
(WebCore::ClipboardQt::declareAndWriteDragImage):
* platform/qt/CursorQt.cpp:
(WebCore::createCustomCursor):
* platform/qt/DragImageQt.cpp:
(WebCore::createDragImageFromImage):
* platform/qt/PasteboardQt.cpp:
(WebCore::Pasteboard::writeImage):

Source/WebKit/qt:

* Api/qwebframe.cpp:
(QWebHitTestResultPrivate::QWebHitTestResultPrivate):
* Api/qwebhistory.cpp:
(QWebHistoryItem::icon):
* Api/qwebsettings.cpp:
(QWebSettings::iconForUrl):
(QWebSettings::setWebGraphic):
(QWebSettings::webGraphic):
* WebCoreSupport/DragClientQt.cpp:
(WebCore::DragClientQt::startDrag):
* WebCoreSupport/InitWebCoreQt.cpp:
(WebCore::initializeWebCoreQt):

Source/WebKit2:

* Shared/qt/ShareableBitmapQt.cpp:
(WebKit::ShareableBitmap::createImage):
* UIProcess/qt/QtWebIconDatabaseClient.cpp:
(WebKit::QtWebIconDatabaseClient::iconImageForPageURL):
* WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp:
(WebKit::convertQImageToShareableBitmap):
(WebKit::WebDragClient::startDrag):
* WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp:
(WebKit::LayerTreeCoordinator::adoptImageBackingStore):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@122720 268f45cc-cd09-0410-ab3c-d52691b4dbfc

36 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Target.pri
Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
Source/WebCore/platform/DragImage.h
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/Image.h
Source/WebCore/platform/graphics/ImageSource.h [changed mode: 0644->0755]
Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h
Source/WebCore/platform/graphics/gstreamer/ImageGStreamerQt.cpp
Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp [changed mode: 0644->0755]
Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp [changed mode: 0644->0755]
Source/WebCore/platform/graphics/qt/ImageQt.cpp [changed mode: 0644->0755]
Source/WebCore/platform/graphics/qt/NativeImageQt.h [new file with mode: 0644]
Source/WebCore/platform/graphics/qt/PatternQt.cpp
Source/WebCore/platform/graphics/qt/StillImageQt.cpp
Source/WebCore/platform/graphics/qt/StillImageQt.h [changed mode: 0644->0755]
Source/WebCore/platform/graphics/qt/TransparencyLayer.h [changed mode: 0644->0755]
Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp
Source/WebCore/platform/qt/ClipboardQt.cpp
Source/WebCore/platform/qt/CursorQt.cpp
Source/WebCore/platform/qt/DragImageQt.cpp
Source/WebCore/platform/qt/PasteboardQt.cpp
Source/WebKit/qt/Api/qwebframe.cpp
Source/WebKit/qt/Api/qwebhistory.cpp
Source/WebKit/qt/Api/qwebsettings.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DragClientQt.cpp
Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp
Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp
Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp

index b1d4f8e..b81a439 100644 (file)
@@ -1,3 +1,95 @@
+2012-07-16  Zoltan Horvath  <zoltan@webkit.org>
+
+        [Qt] Change NativeImagePtr from QPixmap* to QImage*
+        https://bugs.webkit.org/show_bug.cgi?id=88785
+
+        Reviewed by Simon Hausmann.
+
+        Since we use raster engine there is no difference between QPixmap and QImage, so we are going
+        to use QImage everywhere where it is possible. This refactoring contains the change of the
+        NativeImagePtr typedef from QPixmap* to QImage* and covers the related modifications.
+
+        Part of the change is similar to Viatcheslav Ostapenko's internal work.
+
+        Covered by existing tests.
+
+        * bridge/qt/qt_pixmapruntime.cpp:
+        (JSC::Bindings::QtPixmapAssignToElementMethod::invoke):
+        (JSC::Bindings::QtPixmapInstance::variantFromObject):
+        * platform/DragImage.h:
+        (WebCore):
+        * platform/graphics/GraphicsContext.h:
+        (GraphicsContext):
+        * platform/graphics/Image.h:
+        (Image):
+        * platform/graphics/ImageSource.h:
+        (WebCore):
+        * platform/graphics/gstreamer/ImageGStreamer.h:
+        * platform/graphics/gstreamer/ImageGStreamerQt.cpp:
+        (ImageGStreamer::ImageGStreamer):
+        * platform/graphics/qt/GraphicsContext3DQt.cpp:
+        (WebCore::GraphicsContext3D::getImageData):
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::GraphicsContext::pushTransparencyLayerInternal):
+        (WebCore::GraphicsContext::beginPlatformTransparencyLayer):
+        (WebCore::GraphicsContext::endPlatformTransparencyLayer):
+        * platform/graphics/qt/ImageBufferDataQt.h:
+        (ImageBufferData):
+        * platform/graphics/qt/ImageBufferQt.cpp:
+        (WebCore::ImageBufferData::ImageBufferData):
+        (WebCore::ImageBuffer::copyImage):
+        (WebCore::ImageBuffer::clip):
+        (WebCore::ImageBuffer::platformTransformColorSpace):
+        (WebCore::getImageData):
+        (WebCore::ImageBuffer::putByteArray):
+        (WebCore::encodeImage):
+        (WebCore::ImageBuffer::toDataURL):
+        * platform/graphics/qt/ImageDecoderQt.cpp:
+        (WebCore::ImageFrame::asNewNativeImage):
+        * platform/graphics/qt/ImageQt.cpp:
+        (graphics):
+        (loadResourceImage):
+        (WebCore::Image::loadPlatformResource):
+        (WebCore::Image::setPlatformResource):
+        (WebCore::Image::drawPattern):
+        (WebCore::BitmapImage::BitmapImage):
+        (WebCore::BitmapImage::draw):
+        (WebCore::BitmapImage::checkForSolidColor):
+        (WebCore::BitmapImage::create):
+        * platform/graphics/qt/NativeImageQt.h: Added.
+        (WebCore):
+        (NativeImageQt):
+        (WebCore::NativeImageQt::defaultFormatForAlphaEnabledImages):
+        (WebCore::NativeImageQt::defaultFormatForOpaqueImages):
+         * platform/graphics/qt/PatternQt.cpp:
+        (WebCore::Pattern::createPlatformPattern):
+        * platform/graphics/qt/StillImageQt.cpp:
+        (WebCore::StillImage::StillImage):
+        (WebCore::StillImage::~StillImage):
+        (WebCore::StillImage::currentFrameHasAlpha):
+        (WebCore::StillImage::size):
+        (WebCore::StillImage::nativeImageForCurrentFrame):
+        (WebCore::StillImage::draw):
+        * platform/graphics/qt/StillImageQt.h:
+        (WebCore::StillImage::create):
+        (WebCore::StillImage::createForRendering):
+        (StillImage):
+        * platform/graphics/qt/TransparencyLayer.h:
+        (WebCore::TransparencyLayer::TransparencyLayer):
+        (TransparencyLayer):
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        * platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp:
+        (WebCore::GraphicsSurface::createReadOnlyImage):
+         * platform/qt/ClipboardQt.cpp:
+        (WebCore::ClipboardQt::createDragImage):
+        (WebCore::ClipboardQt::declareAndWriteDragImage):
+        * platform/qt/CursorQt.cpp:
+        (WebCore::createCustomCursor):
+        * platform/qt/DragImageQt.cpp:
+        (WebCore::createDragImageFromImage):
+        * platform/qt/PasteboardQt.cpp:
+        (WebCore::Pasteboard::writeImage):
+
 2012-07-16  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: moving forward to the better memory instrumentation API
index 5dac2b0..3d68088 100644 (file)
@@ -2321,6 +2321,7 @@ HEADERS += \
     platform/graphics/Region.h \
     platform/graphics/RoundedRect.h \
     platform/graphics/qt/FontCustomPlatformData.h \
+    platform/graphics/qt/NativeImageQt.h \
     platform/graphics/qt/StillImageQt.h \
     platform/graphics/qt/TransparencyLayer.h \
     platform/graphics/SegmentedFontData.h \
index b0e5f62..a2daada 100644 (file)
@@ -146,8 +146,8 @@ public:
         if (!objectArg->inherits(&JSHTMLImageElement::s_info))
             return jsUndefined();
 
-        // we now know that we have a valid <img> element as the argument, we can attach the pixmap to it.
-        PassRefPtr<StillImage> stillImage = WebCore::StillImage::create(instance->toPixmap());
+        // we now know that we have a valid <img> element as the argument, we can attach the image to it.
+        RefPtr<StillImage> stillImage = WebCore::StillImage::create(instance->toImage());
         HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(static_cast<JSHTMLImageElement*>(objectArg)->impl());
         imageElement->setCachedImage(new CachedImage(stillImage.get()));
         JSDOMGlobalObject* global = static_cast<JSDOMGlobalObject*>(instance->rootObject()->globalObject());
@@ -383,13 +383,13 @@ QVariant QtPixmapInstance::variantFromObject(JSObject* object, QMetaType::Type h
         if (!image)
             goto returnEmptyVariant;
 
-        QPixmap* pixmap = image->nativeImageForCurrentFrame();
-        if (!pixmap)
+        QImage* nativeImage = image->nativeImageForCurrentFrame();
+        if (!nativeImage)
             goto returnEmptyVariant;
 
         return (hint == static_cast<QMetaType::Type>(qMetaTypeId<QPixmap>()))
-                  ? QVariant::fromValue<QPixmap>(*pixmap)
-                  : QVariant::fromValue<QImage>(pixmap->toImage());
+                  ? QVariant::fromValue<QPixmap>(QPixmap::fromImage(*nativeImage))
+                  : QVariant::fromValue<QImage>(*nativeImage);
     }
 
     if (object->inherits(&QtPixmapRuntimeObject::s_info)) {
index dd970d2..e78a9d3 100644 (file)
@@ -36,7 +36,7 @@
 OBJC_CLASS NSImage;
 #elif PLATFORM(QT)
 QT_BEGIN_NAMESPACE
-class QPixmap;
+class QImage;
 QT_END_NAMESPACE
 #elif PLATFORM(WIN)
 typedef struct HBITMAP__* HBITMAP;
@@ -62,7 +62,7 @@ namespace WebCore {
 #if PLATFORM(MAC)
     typedef RetainPtr<NSImage> DragImageRef;
 #elif PLATFORM(QT)
-    typedef QPixmap* DragImageRef;
+    typedef QImage* DragImageRef;
 #elif PLATFORM(WIN)
     typedef HBITMAP DragImageRef;
 #elif PLATFORM(WX)
index f27bec7..a2e0839 100644 (file)
@@ -501,7 +501,7 @@ namespace WebCore {
 #endif
 
 #if PLATFORM(QT)
-        void pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask);
+        void pushTransparencyLayerInternal(const QRect&, qreal, QImage&);
         void takeOwnershipOfPlatformContext();
 #endif
 
index a6b9490..ba953f5 100644 (file)
@@ -52,10 +52,6 @@ typedef SIZE* LPSIZE;
 typedef struct HBITMAP__ *HBITMAP;
 #endif
 
-#if PLATFORM(QT)
-#include <QPixmap>
-#endif
-
 #if PLATFORM(GTK)
 typedef struct _GdkPixbuf GdkPixbuf;
 #endif
@@ -157,7 +153,7 @@ public:
 #endif
 
 #if PLATFORM(QT)
-    static void setPlatformResource(const char* name, const QPixmap&);
+    static void setPlatformResource(const char* name, const QImage&);
 #endif
 
     virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
old mode 100644 (file)
new mode 100755 (executable)
index ed625bc..913a3e7
@@ -43,7 +43,7 @@ typedef const struct __CFData* CFDataRef;
 #elif PLATFORM(QT)
 #include <qglobal.h>
 QT_BEGIN_NAMESPACE
-class QPixmap;
+class QImage;
 QT_END_NAMESPACE
 #elif USE(CAIRO)
 #include "NativeImageCairo.h"
@@ -90,7 +90,7 @@ class ImageDecoder;
 typedef ImageDecoder* NativeImageSourcePtr;
 typedef void* NativeImagePtr;
 #elif PLATFORM(QT)
-typedef QPixmap* NativeImagePtr;
+typedef QImage* NativeImagePtr;
 #endif
 #endif
 
index 83bdfe2..7a0e5ee 100644 (file)
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
+#if PLATFORM(QT)
+#include <QImage>
+#endif
+
 namespace WebCore {
 class IntSize;
 
index 503c13d..d6e6e2a 100644 (file)
@@ -36,7 +36,6 @@ using namespace WebCore;
 ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
     : m_image(0)
 {
-    QPixmap* surface = new QPixmap;
     GstVideoFormat format;
     IntSize size;
     int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
@@ -69,8 +68,7 @@ ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
     image.invertPixels(invertMode);
 #endif
 
-    surface->convertFromImage(image);
-    m_image = BitmapImage::create(surface);
+    m_image = BitmapImage::create(new QImage(image));
 
 #ifdef GST_API_VERSION_1
     if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer))
index 84729d9..1136fb8 100644 (file)
@@ -495,23 +495,16 @@ bool GraphicsContext3D::getImageData(Image* image,
     if (!image)
         return false;
 
-    QImage qtImage;
+    QImage nativeImage;
     // Is image already loaded? If not, load it.
     if (image->data())
-        qtImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size());
-    else {
-        QPixmap* nativePixmap = image->nativeImageForCurrentFrame();
-#if HAVE(QT5)
-        // With QPA, we can avoid a deep copy.
-        qtImage = *nativePixmap->handle()->buffer();
-#else
-        // This might be a deep copy, depending on other references to the pixmap.
-        qtImage = nativePixmap->toImage();
-#endif
-    }
+        nativeImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size());
+    else
+        nativeImage = *image->nativeImageForCurrentFrame();
+
 
     AlphaOp alphaOp = AlphaDoNothing;
-    switch (qtImage.format()) {
+    switch (nativeImage.format()) {
     case QImage::Format_RGB32:
         // For opaque images, we should not premultiply or unmultiply alpha.
         break;
@@ -525,7 +518,7 @@ bool GraphicsContext3D::getImageData(Image* image,
         break;
     default:
         // The image has a format that is not supported in packPixels. We have to convert it here.
-        qtImage = qtImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32);
+        nativeImage = nativeImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32);
         break;
     }
 
@@ -536,7 +529,7 @@ bool GraphicsContext3D::getImageData(Image* image,
 
     outputVector.resize(packedSize);
 
-    return packPixels(qtImage.constBits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, alphaOp, outputVector.data());
+    return packPixels(nativeImage.constBits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, alphaOp, outputVector.data());
 }
 
 void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>)
index c034f64..611efc6 100644 (file)
@@ -1022,7 +1022,7 @@ void GraphicsContext::clearPlatformShadow()
     m_data->shadow->clear();
 }
 
-void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask)
+void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QImage& alphaMask)
 {
     QPainter* p = m_data->p();
 
@@ -1057,7 +1057,7 @@ void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
         h = int(qBound(qreal(0), deviceClip.height(), (qreal)h) + 2);
     }
 
-    QPixmap emptyAlphaMask;
+    QImage emptyAlphaMask;
     m_data->layers.push(new TransparencyLayer(p, QRect(x, y, w, h), opacity, emptyAlphaMask));
     ++m_data->layerCount;
 }
@@ -1071,7 +1071,7 @@ void GraphicsContext::endPlatformTransparencyLayer()
     if (!layer->alphaMask.isNull()) {
         layer->painter.resetTransform();
         layer->painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
-        layer->painter.drawPixmap(QPoint(), layer->alphaMask);
+        layer->painter.drawImage(QPoint(), layer->alphaMask);
     } else
         --m_data->layerCount; // see the comment for layerCount
     layer->painter.end();
@@ -1080,7 +1080,7 @@ void GraphicsContext::endPlatformTransparencyLayer()
     p->save();
     p->resetTransform();
     p->setOpacity(layer->opacity);
-    p->drawPixmap(layer->offset, layer->pixmap);
+    p->drawImage(layer->offset, layer->image);
     p->restore();
 
     delete layer;
index 9cf782b..94065d3 100644 (file)
@@ -25,8 +25,8 @@
 
 #include "Image.h"
 
+#include <QImage>
 #include <QPainter>
-#include <QPixmap>
 
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
@@ -39,9 +39,7 @@ class ImageBufferData {
 public:
     ImageBufferData(const IntSize&);
 
-    QImage toQImage() const;
-
-    QPixmap m_pixmap;
+    QImage m_nativeImage;
     OwnPtr<QPainter> m_painter;
     RefPtr<Image> m_image;
 };
old mode 100644 (file)
new mode 100755 (executable)
index b9b9ebf..eacdc7e
@@ -32,6 +32,7 @@
 #include "GraphicsContext.h"
 #include "ImageData.h"
 #include "MIMETypeRegistry.h"
+#include "NativeImageQt.h"
 #include "StillImageQt.h"
 #include "TransparencyLayer.h"
 #include <wtf/text/CString.h>
 #include <QImage>
 #include <QImageWriter>
 #include <QPainter>
-#include <QPixmap>
 #include <math.h>
 
 namespace WebCore {
 
 ImageBufferData::ImageBufferData(const IntSize& size)
-    : m_pixmap(size)
+    : m_nativeImage(size, NativeImageQt::defaultFormatForAlphaEnabledImages())
 {
-    if (m_pixmap.isNull())
+    if (m_nativeImage.isNull())
         return;
 
-    m_pixmap.fill(QColor(Qt::transparent));
+    m_nativeImage.fill(QColor(Qt::transparent));
 
     QPainter* painter = new QPainter;
     m_painter = adoptPtr(painter);
 
-    if (!painter->begin(&m_pixmap))
+    if (!painter->begin(&m_nativeImage))
         return;
 
     // Since ImageBuffer is used mainly for Canvas, explicitly initialize
@@ -76,22 +76,7 @@ ImageBufferData::ImageBufferData(const IntSize& size)
     painter->setBrush(brush);
     painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
     
-    m_image = StillImage::createForRendering(&m_pixmap);
-}
-
-QImage ImageBufferData::toQImage() const
-{
-    QPaintEngine* paintEngine = m_pixmap.paintEngine();
-    if (!paintEngine || paintEngine->type() != QPaintEngine::Raster)
-        return m_pixmap.toImage();
-
-    // QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it.
-    // For performance reasons, we don't want that here, so we temporarily redirect the paint engine.
-    QPaintDevice* currentPaintDevice = paintEngine->paintDevice();
-    paintEngine->setPaintDevice(0);
-    QImage image = m_pixmap.toImage();
-    paintEngine->setPaintDevice(currentPaintDevice);
-    return image;
+    m_image = StillImage::createForRendering(&m_nativeImage);
 }
 
 ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success)
@@ -120,9 +105,9 @@ GraphicsContext* ImageBuffer::context() const
 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior) const
 {
     if (copyBehavior == CopyBackingStore)
-        return StillImage::create(m_data.m_pixmap);
+        return StillImage::create(m_data.m_nativeImage);
 
-    return StillImage::createForRendering(&m_data.m_pixmap);
+    return StillImage::createForRendering(&m_data.m_nativeImage);
 }
 
 void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
@@ -149,12 +134,12 @@ void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& src
 
 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& floatRect) const
 {
-    QPixmap* nativeImage = m_data.m_image->nativeImageForCurrentFrame();
+    QImage* nativeImage = m_data.m_image->nativeImageForCurrentFrame();
     if (!nativeImage)
         return;
 
     IntRect rect = enclosingIntRect(floatRect);
-    QPixmap alphaMask = *nativeImage;
+    QImage alphaMask = *nativeImage;
 
     context->pushTransparencyLayerInternal(rect, 1.0, alphaMask);
 }
@@ -165,7 +150,7 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
     if (isPainting)
         m_data.m_painter->end();
 
-    QImage image = m_data.toQImage().convertToFormat(QImage::Format_ARGB32);
+    QImage image = m_data.m_nativeImage;
     ASSERT(!image.isNull());
 
     uchar* bits = image.bits();
@@ -182,10 +167,10 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
         }
     }
 
-    m_data.m_pixmap = QPixmap::fromImage(image);
+    m_data.m_nativeImage = image;
 
     if (isPainting)
-        m_data.m_painter->begin(&m_data.m_pixmap);
+        m_data.m_painter->begin(&m_data.m_nativeImage);
 }
 
 template <Multiply multiplied>
@@ -224,7 +209,7 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBuffe
     int numRows = endy - originy;
 
     // NOTE: For unmultiplied data, we undo the premultiplication below.
-    QImage image = imageData.toQImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
+    QImage image = imageData.m_nativeImage.convertToFormat(NativeImageQt::defaultFormatForAlphaEnabledImages());
 
     ASSERT(!image.isNull());
 
@@ -358,7 +343,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
 
     bool isPainting = m_data.m_painter->isActive();
     if (!isPainting)
-        m_data.m_painter->begin(&m_data.m_pixmap);
+        m_data.m_painter->begin(&m_data.m_nativeImage);
     else {
         m_data.m_painter->save();
 
@@ -377,7 +362,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
         m_data.m_painter->restore();
 }
 
-static bool encodeImage(const QPixmap& pixmap, const String& format, const double* quality, QByteArray& data)
+static bool encodeImage(const QImage& image, const String& format, const double* quality, QByteArray& data)
 {
     int compressionQuality = 100;
     if (quality && *quality >= 0.0 && *quality <= 1.0)
@@ -385,7 +370,7 @@ static bool encodeImage(const QPixmap& pixmap, const String& format, const doubl
 
     QBuffer buffer(&data);
     buffer.open(QBuffer::WriteOnly);
-    bool success = pixmap.save(&buffer, format.utf8().data(), compressionQuality);
+    bool success = image.save(&buffer, format.utf8().data(), compressionQuality);
     buffer.close();
 
     return success;
@@ -397,10 +382,10 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality, Coo
 
     // QImageWriter does not support mimetypes. It does support Qt image formats (png,
     // gif, jpeg..., xpm) so skip the image/ to get the Qt image format used to encode
-    // the m_pixmap image.
+    // the m_nativeImage image.
 
     QByteArray data;
-    if (!encodeImage(m_data.m_pixmap, mimeType.substring(sizeof "image"), quality, data))
+    if (!encodeImage(m_data.m_nativeImage, mimeType.substring(sizeof "image"), quality, data))
         return "data:,";
 
     return "data:" + mimeType + ";base64," + data.toBase64().data();
old mode 100644 (file)
new mode 100755 (executable)
index e03636f..f039e43
@@ -272,9 +272,7 @@ NativeImagePtr ImageFrame::asNewNativeImage() const
     else
         format = QImage::Format_RGB32;
 
-    QImage img(reinterpret_cast<uchar*>(m_bytes), m_size.width(), m_size.height(), sizeof(PixelData) * m_size.width(), format);
-
-    return new QPixmap(QPixmap::fromImage(img));
+    return new QImage(reinterpret_cast<uchar*>(m_bytes), m_size.width(), m_size.height(), sizeof(PixelData) * m_size.width(), format);
 }
 
 }
old mode 100644 (file)
new mode 100755 (executable)
index e098e09..10fe1fe
@@ -37,6 +37,7 @@
 #include "FloatRect.h"
 #include "GraphicsContext.h"
 #include "ImageObserver.h"
+#include "NativeImageQt.h"
 #include "PlatformString.h"
 #include "ShadowBlur.h"
 #include "StillImageQt.h"
@@ -55,7 +56,7 @@
 Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP, int hbitmapFormat = 0);
 #endif
 
-typedef QHash<QByteArray, QPixmap> WebGraphicHash;
+typedef QHash<QByteArray, QImage> WebGraphicHash;
 Q_GLOBAL_STATIC(WebGraphicHash, _graphics)
 
 static void earlyClearGraphics()
@@ -69,28 +70,28 @@ static WebGraphicHash* graphics()
 
     if (hash->isEmpty()) {
 
-        // prevent ~QPixmap running after ~QApplication (leaks native pixmaps)
+        // prevent ~QImage running after ~QApplication (leaks native images)
         qAddPostRoutine(earlyClearGraphics);
 
         // QWebSettings::MissingImageGraphic
-        hash->insert("missingImage", QPixmap(QLatin1String(":webkit/resources/missingImage.png")));
+        hash->insert("missingImage", QImage(QLatin1String(":webkit/resources/missingImage.png")));
         // QWebSettings::MissingPluginGraphic
-        hash->insert("nullPlugin", QPixmap(QLatin1String(":webkit/resources/nullPlugin.png")));
+        hash->insert("nullPlugin", QImage(QLatin1String(":webkit/resources/nullPlugin.png")));
         // QWebSettings::DefaultFrameIconGraphic
-        hash->insert("urlIcon", QPixmap(QLatin1String(":webkit/resources/urlIcon.png")));
+        hash->insert("urlIcon", QImage(QLatin1String(":webkit/resources/urlIcon.png")));
         // QWebSettings::TextAreaSizeGripCornerGraphic
-        hash->insert("textAreaResizeCorner", QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
+        hash->insert("textAreaResizeCorner", QImage(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
         // QWebSettings::DeleteButtonGraphic
-        hash->insert("deleteButton", QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
+        hash->insert("deleteButton", QImage(QLatin1String(":webkit/resources/deleteButton.png")));
         // QWebSettings::InputSpeechButtonGraphic
-        hash->insert("inputSpeech", QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));
+        hash->insert("inputSpeech", QImage(QLatin1String(":webkit/resources/inputSpeech.png")));
     }
 
     return hash;
 }
 
 // This function loads resources into WebKit
-static QPixmap loadResourcePixmap(const char *name)
+static QImage loadResourceImage(const char *name)
 {
     return graphics()->value(name);
 }
@@ -117,23 +118,23 @@ bool FrameData::clear(bool clearMetadata)
 
 PassRefPtr<Image> Image::loadPlatformResource(const char* name)
 {
-    return StillImage::create(loadResourcePixmap(name));
+    return StillImage::create(loadResourceImage(name));
 }
 
-void Image::setPlatformResource(const char* name, const QPixmap& pixmap)
+void Image::setPlatformResource(const char* name, const QImage& image)
 {
     WebGraphicHash* h = graphics();
-    if (pixmap.isNull())
+    if (image.isNull())
         h->remove(name);
     else
-        h->insert(name, pixmap);
+        h->insert(name, image);
 }
 
 void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
                         const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect)
 {
-    QPixmap* framePixmap = nativeImageForCurrentFrame();
-    if (!framePixmap) // If it's too early we won't have an image yet.
+    QImage* frameImage = nativeImageForCurrentFrame();
+    if (!frameImage) // If it's too early we won't have an image yet.
         return;
 
 #if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
@@ -148,34 +149,38 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
     if (!dr.width() || !dr.height() || !tr.width() || !tr.height())
         return;
 
-    QPixmap pixmap = *framePixmap;
-    if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height())
-        pixmap = pixmap.copy(tr);
+    QImage image = *frameImage;
+    if (tr.x() || tr.y() || tr.width() != image.width() || tr.height() != image.height())
+        image = image.copy(tr);
 
     CompositeOperator previousOperator = ctxt->compositeOperation();
 
-    ctxt->setCompositeOperation(!pixmap.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
+    ctxt->setCompositeOperation(!image.hasAlphaChannel() && op == CompositeSourceOver ? CompositeCopy : op);
 
     QPainter* p = ctxt->platformContext();
     QTransform transform(patternTransform);
 
-    // If this would draw more than one scaled tile, we scale the pixmap first and then use the result to draw.
+    // If this would draw more than one scaled tile, we scale the image first and then use the result to draw.
     if (transform.type() == QTransform::TxScale) {
         QRectF tileRectInTargetCoords = (transform * QTransform().translate(phase.x(), phase.y())).mapRect(tr);
 
         bool tileWillBePaintedOnlyOnce = tileRectInTargetCoords.contains(dr);
         if (!tileWillBePaintedOnlyOnce) {
-            QSizeF scaledSize(float(pixmap.width()) * transform.m11(), float(pixmap.height()) * transform.m22());
-            QPixmap scaledPixmap(scaledSize.toSize());
-            if (pixmap.hasAlpha())
-                scaledPixmap.fill(Qt::transparent);
+            QSizeF scaledSize(float(image.width()) * transform.m11(), float(image.height()) * transform.m22());
+            QImage scaledImage;
+            if (image.hasAlphaChannel()) {
+                scaledImage = QImage(scaledSize.toSize(), NativeImageQt::defaultFormatForAlphaEnabledImages());
+                scaledImage.fill(Qt::transparent);
+            } else
+                scaledImage = QImage(scaledSize.toSize(), NativeImageQt::defaultFormatForOpaqueImages());
+
             {
-                QPainter painter(&scaledPixmap);
+                QPainter painter(&scaledImage);
                 painter.setCompositionMode(QPainter::CompositionMode_Source);
                 painter.setRenderHints(p->renderHints());
-                painter.drawPixmap(QRect(0, 0, scaledPixmap.width(), scaledPixmap.height()), pixmap);
+                painter.drawImage(QRect(0, 0, scaledImage.width(), scaledImage.height()), image);
             }
-            pixmap = scaledPixmap;
+            image = scaledImage;
             transform = QTransform::fromTranslate(transform.dx(), transform.dy());
         }
     }
@@ -184,7 +189,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
     transform *= QTransform().translate(phase.x(), phase.y());
     transform.translate(tr.x(), tr.y());
 
-    QBrush b(pixmap);
+    QBrush b(image);
     b.setTransform(transform);
     p->fillRect(dr, b);
 
@@ -194,7 +199,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
         imageObserver()->didDraw(this);
 }
 
-BitmapImage::BitmapImage(QPixmap* pixmap, ImageObserver* observer)
+BitmapImage::BitmapImage(QImage* image, ImageObserver* observer)
     : Image(observer)
     , m_currentFrame(0)
     , m_frames(0)
@@ -212,14 +217,14 @@ BitmapImage::BitmapImage(QPixmap* pixmap, ImageObserver* observer)
     , m_sizeAvailable(true)
     , m_haveFrameCount(true)
 {
-    int width = pixmap->width();
-    int height = pixmap->height();
+    int width = image->width();
+    int height = image->height();
     m_decodedSize = width * height * 4;
     m_size = IntSize(width, height);
 
     m_frames.grow(1);
-    m_frames[0].m_frame = pixmap;
-    m_frames[0].m_hasAlpha = pixmap->hasAlpha();
+    m_frames[0].m_frame = image;
+    m_frames[0].m_hasAlpha = image->hasAlphaChannel();
     m_frames[0].m_haveMetadata = true;
     checkForSolidColor();
 }
@@ -240,7 +245,8 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
     if (normalizedSrc.isEmpty() || normalizedDst.isEmpty())
         return;
 
-    QPixmap* image = nativeImageForCurrentFrame();
+    QImage* image = nativeImageForCurrentFrame();
+
     if (!image)
         return;
 
@@ -254,19 +260,19 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
 #endif
 
     CompositeOperator previousOperator = ctxt->compositeOperation();
-    ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
+    ctxt->setCompositeOperation(!image->hasAlphaChannel() && op == CompositeSourceOver ? CompositeCopy : op);
 
     if (ctxt->hasShadow()) {
         ShadowBlur* shadow = ctxt->shadowBlur();
         GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
         if (shadowContext) {
             QPainter* shadowPainter = shadowContext->platformContext();
-            shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
+            shadowPainter->drawImage(normalizedDst, *image, normalizedSrc);
             shadow->endShadowLayer(ctxt);
         }
     }
 
-    ctxt->platformContext()->drawPixmap(normalizedDst, *image, normalizedSrc);
+    ctxt->platformContext()->drawImage(normalizedDst, *image, normalizedSrc);
 
     ctxt->setCompositeOperation(previousOperator);
 
@@ -282,24 +288,24 @@ void BitmapImage::checkForSolidColor()
     if (frameCount() > 1)
         return;
 
-    QPixmap* framePixmap = frameAtIndex(0);
-    if (!framePixmap || framePixmap->width() != 1 || framePixmap->height() != 1)
+    QImage* frameImage = frameAtIndex(0);
+    if (!frameImage || frameImage->width() != 1 || frameImage->height() != 1)
         return;
 
     m_isSolidColor = true;
-    m_solidColor = QColor::fromRgba(framePixmap->toImage().pixel(0, 0));
+    m_solidColor = QColor::fromRgba(frameImage->pixel(0, 0));
 }
 
 #if OS(WINDOWS)
 PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
 {
 #if HAVE(QT5)
-    QPixmap* qPixmap = new QPixmap(qt_pixmapFromWinHBITMAP(hBitmap));
+    QImage* nativeImage = new QImage(qt_pixmapFromWinHBITMAP(hBitmap).toImage());
 #else
-    QPixmap* qPixmap = new QPixmap(QPixmap::fromWinHBITMAP(hBitmap));
+    QImage* nativeImage = new QImage(QPixmap::fromWinHBITMAP(hBitmap).toImage());
 #endif
 
-    return BitmapImage::create(qPixmap);
+    return BitmapImage::create(nativeImage);
 }
 #endif
 
diff --git a/Source/WebCore/platform/graphics/qt/NativeImageQt.h b/Source/WebCore/platform/graphics/qt/NativeImageQt.h
new file mode 100644 (file)
index 0000000..0fd1d2c
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2012 Zoltan Horvath (zoltan@webkit.org) 2012 University of Szeged.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NativeImageQt_h
+#define NativeImageQt_h
+
+#include <QImage>
+
+namespace WebCore {
+
+class NativeImageQt {
+public:
+    static QImage::Format defaultFormatForAlphaEnabledImages()
+    {
+        return QImage::Format_ARGB32_Premultiplied;
+    }
+
+    static QImage::Format defaultFormatForOpaqueImages()
+    {
+        return QImage::Format_RGB32;
+    }
+};
+
+}
+
+#endif // NativeImageQt_h
index 7aae625..5c94122 100644 (file)
@@ -33,12 +33,12 @@ namespace WebCore {
 
 QBrush Pattern::createPlatformPattern() const
 {
-    QPixmap* pixmap = tileImage()->nativeImageForCurrentFrame();
-    if (!pixmap)
+    QImage* image = tileImage()->nativeImageForCurrentFrame();
+    if (!image)
         return QBrush();
 
     // Qt merges patter space and user space itself
-    QBrush brush(*pixmap);
+    QBrush brush(*image);
     brush.setTransform(m_patternSpaceTransformation);
 
     return brush;
index 80666ba..0412520 100644 (file)
 
 namespace WebCore {
 
-StillImage::StillImage(const QPixmap& pixmap)
-    : m_pixmap(new QPixmap(pixmap))
-    , m_ownsPixmap(true)
+StillImage::StillImage(const QImage& image)
+    : m_image(new QImage(image))
+    , m_ownsImage(true)
 {}
 
-StillImage::StillImage(const QPixmap* pixmap)
-    : m_pixmap(pixmap)
-    , m_ownsPixmap(false)
+StillImage::StillImage(const QImage* image)
+    : m_image(image)
+    , m_ownsImage(false)
 {}
 
 StillImage::~StillImage()
 {
-    if (m_ownsPixmap)
-        delete m_pixmap;
+    if (m_ownsImage)
+        delete m_image;
 }
 
 bool StillImage::currentFrameHasAlpha()
 {
-    return m_pixmap->hasAlpha();
+    return m_image->hasAlphaChannel();
 }
 
 IntSize StillImage::size() const
 {
-    return IntSize(m_pixmap->width(), m_pixmap->height());
+    return IntSize(m_image->width(), m_image->height());
 }
 
 NativeImagePtr StillImage::nativeImageForCurrentFrame()
 {
-    return const_cast<NativeImagePtr>(m_pixmap);
+    return const_cast<NativeImagePtr>(m_image);
 }
 
 void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
                       const FloatRect& src, ColorSpace, CompositeOperator op)
 {
-    if (m_pixmap->isNull())
+    if (m_image->isNull())
         return;
 
     FloatRect normalizedSrc = src.normalized();
@@ -84,12 +84,12 @@ void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
         GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
         if (shadowContext) {
             QPainter* shadowPainter = shadowContext->platformContext();
-            shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
+            shadowPainter->drawImage(normalizedDst, *m_image, normalizedSrc);
             shadow->endShadowLayer(ctxt);
         }
     }
 
-    ctxt->platformContext()->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
+    ctxt->platformContext()->drawImage(normalizedDst, *m_image, normalizedSrc);
     ctxt->setCompositeOperation(previousOperator);
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 26df471..8c9ec0d
@@ -34,14 +34,14 @@ namespace WebCore {
 
     class StillImage : public Image {
     public:
-        static PassRefPtr<StillImage> create(const QPixmap& pixmap)
+        static PassRefPtr<StillImage> create(const QImage& image)
         {
-            return adoptRef(new StillImage(pixmap));
+            return adoptRef(new StillImage(image));
         }
 
-        static PassRefPtr<StillImage> createForRendering(const QPixmap* pixmap)
+        static PassRefPtr<StillImage> createForRendering(const QImage* image)
         {
-            return adoptRef(new StillImage(pixmap));
+            return adoptRef(new StillImage(image));
         }
 
         virtual bool currentFrameHasAlpha();
@@ -56,12 +56,12 @@ namespace WebCore {
         virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
 
     private:
-        StillImage(const QPixmap& pixmap);
-        StillImage(const QPixmap* pixmap);
+        StillImage(const QImage&);
+        StillImage(const QImage*);
         virtual ~StillImage();
         
-        const QPixmap* m_pixmap;
-        bool m_ownsPixmap;
+        const QImage* m_image;
+        bool m_ownsImage;
     };
 
 }
old mode 100644 (file)
new mode 100755 (executable)
index f13deb0..5974017
 #ifndef TransparencyLayer_h
 #define TransparencyLayer_h
 
+#include <NativeImageQt.h>
 #include <QPaintEngine>
 #include <QPainter>
-#include <QPixmap>
 
 namespace WebCore {
 
 struct TransparencyLayer {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    TransparencyLayer(const QPainter* p, const QRect &rect, qreal opacity, QPixmap& alphaMask)
-        : pixmap(rect.width(), rect.height())
+    TransparencyLayer(const QPainter* p, const QRect &rect, qreal opacity, QImage& alphaMask)
+        : image(rect.width(), rect.height(), NativeImageQt::defaultFormatForAlphaEnabledImages())
         , opacity(opacity)
         , alphaMask(alphaMask)
         , saveCounter(1) // see the comment for saveCounter
     {
         offset = rect.topLeft();
-        pixmap.fill(Qt::transparent);
-        painter.begin(&pixmap);
+        image.fill(Qt::transparent);
+        painter.begin(&image);
         painter.setRenderHints(p->renderHints());
         painter.translate(-offset);
         painter.setPen(p->pen());
@@ -67,12 +67,12 @@ public:
     {
     }
 
-    QPixmap pixmap;
+    QImage image;
     QPoint offset;
     QPainter painter;
     qreal opacity;
     // for clipToImageBuffer
-    QPixmap alphaMask;
+    QImage alphaMask;
     // saveCounter is only used in combination with alphaMask
     // otherwise, its value is unspecified
     int saveCounter;
index 734a093..e1b2758 100644 (file)
@@ -52,8 +52,7 @@ PassRefPtr<Image> GraphicsSurface::createReadOnlyImage(const IntRect& rect)
     int stride;
     QImage::Format format = (flags() & SupportsAlpha) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
     char* data = platformLock(rect, &stride, RetainPixels | ReadOnly);
-    QImage image(reinterpret_cast<uchar*>(data), rect.width(), rect.height(), stride, format, didReleaseImage, this);
-    return BitmapImage::create(new QPixmap(QPixmap::fromImage(image)));
+    return BitmapImage::create(new QImage(reinterpret_cast<uchar*>(data), rect.width(), rect.height(), stride, format, didReleaseImage, this));
 }
 
 }
index 6d2ab72..8e4c580 100644 (file)
@@ -50,6 +50,7 @@
 
 #include <QGuiApplication>
 #include <QClipboard>
+#include <QImage>
 #include <QList>
 #include <QMimeData>
 #include <QStringList>
@@ -243,7 +244,7 @@ DragImageRef ClipboardQt::createDragImage(IntPoint& dragLoc) const
     if (!m_dragImage)
         return 0;
     dragLoc = m_dragLoc;
-    return m_dragImage->image()->nativeImageForCurrentFrame();
+    return new QImage(*m_dragImage->image()->nativeImageForCurrentFrame());
 }
 
 
@@ -273,9 +274,9 @@ void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, co
     CachedImage* cachedImage = getCachedImage(element);
     if (!cachedImage || !cachedImage->imageForRenderer(element->renderer()) || !cachedImage->isLoaded())
         return;
-    QPixmap* pixmap = cachedImage->imageForRenderer(element->renderer())->nativeImageForCurrentFrame();
-    if (pixmap)
-        m_writableData->setImageData(*pixmap);
+    QImage* image = cachedImage->imageForRenderer(element->renderer())->nativeImageForCurrentFrame();
+    if (image)
+        m_writableData->setImageData(*image);
 
     QList<QUrl> urls;
     urls.append(url);
index e7854dd..168a2f5 100644 (file)
@@ -37,6 +37,8 @@
 
 #include "NotImplemented.h"
 
+#include <QImage>
+#include <QPixmap>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -75,10 +77,11 @@ Cursor& Cursor::operator=(const Cursor& other)
 #ifndef QT_NO_CURSOR
 static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot)
 {
-    if (!image->nativeImageForCurrentFrame())
+    QImage* nativeImage = image->nativeImageForCurrentFrame();
+    if (!nativeImage)
         return 0;
     IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
-    return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y());
+    return new QCursor(QPixmap::fromImage(*nativeImage), effectiveHotSpot.x(), effectiveHotSpot.y());
 }
 #endif
 
index 0e7ce04..e93ac70 100644 (file)
@@ -29,6 +29,8 @@
 #include "CachedImage.h"
 #include "Image.h"
 
+#include <QImage>
+
 namespace WebCore {
 
 IntSize dragImageSize(DragImageRef image)
@@ -66,7 +68,7 @@ DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum)
     if (!image || !image->nativeImageForCurrentFrame())
         return 0;
 
-    return new QPixmap(*image->nativeImageForCurrentFrame());
+    return new QImage(*image->nativeImageForCurrentFrame());
 }
 
 DragImageRef createDragImageIconForCachedImage(CachedImage*)
index d6f4e1d..c6e3d01 100644 (file)
@@ -166,10 +166,10 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
     Image* image = cachedImage->imageForRenderer(node->renderer());
     ASSERT(image);
 
-    QPixmap* pixmap = image->nativeImageForCurrentFrame();
-    if (!pixmap)
+    QImage* nativeImage = image->nativeImageForCurrentFrame();
+    if (!image)
         return;
-    QGuiApplication::clipboard()->setPixmap(*pixmap, QClipboard::Clipboard);
+    QGuiApplication::clipboard()->setImage(*nativeImage, QClipboard::Clipboard);
 #endif
 }
 
index ed1806f..6d2c404 100644 (file)
@@ -1773,9 +1773,9 @@ QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult
     boundingRect = innerNonSharedNode ? innerNonSharedNode->renderer()->absoluteBoundingBoxRect() : IntRect();
     WebCore::Image *img = hitTest.image();
     if (img) {
-        QPixmap *pix = img->nativeImageForCurrentFrame();
+        QImage *pix = img->nativeImageForCurrentFrame();
         if (pix)
-            pixmap = *pix;
+            pixmap = QPixmap::fromImage(*pix);
     }
     WebCore::Frame *wframe = hitTest.targetFrame();
     if (wframe)
index 15d4ad8..712c28f 100644 (file)
@@ -158,7 +158,7 @@ QDateTime QWebHistoryItem::lastVisited() const
 QIcon QWebHistoryItem::icon() const
 {
     if (d->item)
-        return *WebCore::iconDatabase().synchronousNativeIconForPageURL(d->item->url(), WebCore::IntSize(16, 16));
+        return QPixmap::fromImage(*WebCore::iconDatabase().synchronousNativeIconForPageURL(d->item->url(), WebCore::IntSize(16, 16)));
 
     return QIcon();
 }
index 5358dd2..caf9505 100644 (file)
@@ -717,12 +717,12 @@ void QWebSettings::clearIconDatabase()
 QIcon QWebSettings::iconForUrl(const QUrl& url)
 {
     WebCore::initializeWebCoreQt();
-    QPixmap* icon = WebCore::iconDatabase().synchronousNativeIconForPageURL(WebCore::KURL(url).string(),
+    QImage* icon = WebCore::iconDatabase().synchronousNativeIconForPageURL(WebCore::KURL(url).string(),
                                 WebCore::IntSize(16, 16));
     if (!icon)
-        return QPixmap();
+        return QIcon();
 
-    return* icon;
+    return QPixmap::fromImage(*icon);
 }
 
 /*
@@ -765,7 +765,7 @@ static const char* resourceNameForWebGraphic(QWebSettings::WebGraphic type)
 void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap& graphic)
 {
     WebCore::initializeWebCoreQt();
-    WebCore::Image::setPlatformResource(resourceNameForWebGraphic(type), graphic);
+    WebCore::Image::setPlatformResource(resourceNameForWebGraphic(type), graphic.toImage());
 }
 
 /*!
@@ -780,10 +780,10 @@ QPixmap QWebSettings::webGraphic(WebGraphic type)
     RefPtr<WebCore::Image> img = WebCore::Image::loadPlatformResource(resourceNameForWebGraphic(type));
     if (!img)
         return QPixmap();
-    QPixmap* pixmap = img->nativeImageForCurrentFrame();
-    if (!pixmap)
+    QImage* image = img->nativeImageForCurrentFrame();
+    if (!image)
         return QPixmap();
-    return *pixmap;
+    return QPixmap::fromImage(*image);
 }
 
 /*!
index 98b2b6b..1d5f718 100644 (file)
@@ -1,3 +1,31 @@
+2012-07-16  Zoltan Horvath  <zoltan@webkit.org>
+
+        [Qt] Change NativeImagePtr from QPixmap* to QImage*
+        https://bugs.webkit.org/show_bug.cgi?id=88785
+
+        Reviewed by Simon Hausmann.
+
+        Since we use raster engine there is no difference between QPixmap and QImage, so we are going
+        to use QImage everywhere where it is possible. This refactoring contains the change of the
+        NativeImagePtr typedef from QPixmap* to QImage* and covers the related modifications.
+
+        Part of the change is similar to Viatcheslav Ostapenko's internal work.
+
+        Covered by existing tests.
+
+        * Api/qwebframe.cpp:
+        (QWebHitTestResultPrivate::QWebHitTestResultPrivate):
+        * Api/qwebhistory.cpp:
+        (QWebHistoryItem::icon):
+        * Api/qwebsettings.cpp:
+        (QWebSettings::iconForUrl):
+        (QWebSettings::setWebGraphic):
+        (QWebSettings::webGraphic):
+        * WebCoreSupport/DragClientQt.cpp:
+        (WebCore::DragClientQt::startDrag):
+        * WebCoreSupport/InitWebCoreQt.cpp:
+        (WebCore::initializeWebCoreQt):
+
 2012-07-16  Frederik Gladhorn  <frederik.gladhorn@nokia.com>
 
         Accessible Widget for QWebView
index cb63283..8b648c1 100644 (file)
@@ -97,9 +97,9 @@ void DragClientQt::startDrag(DragImageRef dragImage, const IntPoint&, const IntP
     if (view) {
         QDrag* drag = new QDrag(view);
         if (dragImage)
-            drag->setPixmap(*dragImage);
+            drag->setPixmap(QPixmap::fromImage(*dragImage));
         else if (clipboardData && clipboardData->hasImage())
-            drag->setPixmap(qvariant_cast<QPixmap>(clipboardData->imageData()));
+            drag->setPixmap(QPixmap::fromImage(qvariant_cast<QImage>(clipboardData->imageData())));
         DragOperation dragOperationMask = clipboard->sourceOperation();
         drag->setMimeData(clipboardData);
         Qt::DropAction actualDropAction = drag->exec(dragOperationsToDropActions(dragOperationMask));
index 5ac449d..c63ccb0 100644 (file)
@@ -83,9 +83,9 @@ void initializeWebCoreQt()
 #endif
 
     // QWebSettings::SearchCancelButtonGraphic
-    Image::setPlatformResource("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
+    Image::setPlatformResource("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton).toImage());
     // QWebSettings::SearchCancelButtonPressedGraphic
-    Image::setPlatformResource("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
+    Image::setPlatformResource("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton).toImage());
 
     initialized = true;
 }
index 741f7e8..11bd9fe 100644 (file)
@@ -1,3 +1,28 @@
+2012-07-16  Zoltan Horvath  <zoltan@webkit.org>
+
+        [Qt] Change NativeImagePtr from QPixmap* to QImage*
+        https://bugs.webkit.org/show_bug.cgi?id=88785
+
+        Reviewed by Simon Hausmann.
+
+        Since we use raster engine there is no difference between QPixmap and QImage, so we are going
+        to use QImage everywhere where it is possible. This refactoring contains the change of the
+        NativeImagePtr typedef from QPixmap* to QImage* and covers the related modifications.
+
+        Part of the change is similar to Viatcheslav Ostapenko's internal work.
+
+        Covered by existing tests.
+
+        * Shared/qt/ShareableBitmapQt.cpp:
+        (WebKit::ShareableBitmap::createImage):
+        * UIProcess/qt/QtWebIconDatabaseClient.cpp:
+        (WebKit::QtWebIconDatabaseClient::iconImageForPageURL):
+        * WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp:
+        (WebKit::convertQImageToShareableBitmap):
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp:
+        (WebKit::LayerTreeCoordinator::adoptImageBackingStore):
+
 2012-07-16  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix make distcheck.
index a7ab8d4..b6ceb3e 100644 (file)
@@ -52,8 +52,8 @@ void ShareableBitmap::releaseSharedMemoryData(void* typelessBitmap)
 
 PassRefPtr<Image> ShareableBitmap::createImage()
 {
-    QPixmap* pixmap = new QPixmap(QPixmap::fromImage(createQImage()));
-    return BitmapImage::create(pixmap);
+    QImage* image = new QImage(createQImage());
+    return BitmapImage::create(image);
 }
 
 PassOwnPtr<GraphicsContext> ShareableBitmap::createGraphicsContext()
index 592bb37..afdfa6f 100644 (file)
@@ -90,11 +90,11 @@ QImage QtWebIconDatabaseClient::iconImageForPageURL(const WTF::String& pageURL,
 
     WebCore::IntSize size(iconSize.width(), iconSize.height());
 
-    QPixmap* nativeImage = m_iconDatabase->nativeImageForPageURL(pageURL, size);
+    QImage* nativeImage = m_iconDatabase->nativeImageForPageURL(pageURL, size);
     if (!nativeImage)
         return QImage();
 
-    return nativeImage->toImage();
+    return *nativeImage;
 }
 
 void QtWebIconDatabaseClient::retainIconForPageURL(const String& pageURL)
index bbdb635..d9e6d1d 100644 (file)
@@ -38,15 +38,15 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static PassRefPtr<ShareableBitmap> convertQPixmapToShareableBitmap(QPixmap* pixmap)
+static PassRefPtr<ShareableBitmap> convertQImageToShareableBitmap(QImage* image)
 {
-    if (!pixmap)
+    if (!image)
         return 0;
 
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(pixmap->size()), ShareableBitmap::SupportsAlpha);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha);
     OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext();
 
-    graphicsContext->platformContext()->drawPixmap(0, 0, *pixmap);
+    graphicsContext->platformContext()->drawImage(0, 0, *image);
     return bitmap.release();
 }
 
@@ -57,7 +57,7 @@ void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosi
     static_cast<ClipboardQt*>(clipboard)->invalidateWritableData();
     DragData dragData(clipboardData, clientPosition, globalPosition, dragOperationMask);
 
-    RefPtr<ShareableBitmap> bitmap = convertQPixmapToShareableBitmap(dragImage);
+    RefPtr<ShareableBitmap> bitmap = convertQImageToShareableBitmap(dragImage);
     ShareableBitmap::Handle handle;
     if (bitmap && !bitmap->createHandle(handle))
         return;
index ae099d1..a3b9a13 100644 (file)
@@ -409,12 +409,12 @@ int64_t LayerTreeCoordinator::adoptImageBackingStore(Image* image)
     int64_t key = 0;
 
 #if PLATFORM(QT)
-    QPixmap* pixmap = image->nativeImageForCurrentFrame();
+    QImage* nativeImage = image->nativeImageForCurrentFrame();
 
-    if (!pixmap)
+    if (!nativeImage)
         return InvalidWebLayerID;
 
-    key = pixmap->cacheKey();
+    key = nativeImage->cacheKey();
 #endif
 
     HashMap<int64_t, int>::iterator it = m_directlyCompositedImageRefCounts.find(key);