[Qt] r122720 causes performance regression with DirectFB on ARMv7
authorzoltan@webkit.org <zoltan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2012 13:44:14 +0000 (13:44 +0000)
committerzoltan@webkit.org <zoltan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2012 13:44:14 +0000 (13:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97548

Reviewed by Jocelyn Turcotte.

Revert the rest of r122720. This change modifies the NativeImagePtr from QImage* to QPixmap*.

Covered by existing tests.

Source/WebCore:

* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::assignToHTMLImageElement):
(JSC::Bindings::QtPixmapRuntime::toQt):
* platform/DragImage.h:
(WebCore):
* platform/graphics/GraphicsContext.h:
(GraphicsContext):
* platform/graphics/Image.h:
(Image):
* platform/graphics/NativeImagePtr.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):
(WebCore::ImageBufferData::toQImage):
(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):
(loadResourcePixmap):
(WebCore::Image::loadPlatformResource):
(WebCore::Image::setPlatformResource):
(WebCore::Image::drawPattern):
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::checkForSolidColor):
(WebCore::BitmapImage::create):
* 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/surfaces/qt/GraphicsSurfaceQt.cpp:
(WebCore::GraphicsSurface::createReadOnlyImage):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::BitmapTextureGL::updateContents):
* 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::convertQPixmapToShareableBitmap):
(WebKit::WebDragClient::startDrag):
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
(WebKit::LayerTreeCoordinator::adoptImageBackingStore):

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

35 files changed:
Source/WebCore/ChangeLog
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/NativeImagePtr.h
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
Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
Source/WebCore/platform/graphics/qt/ImageQt.cpp
Source/WebCore/platform/graphics/qt/PatternQt.cpp
Source/WebCore/platform/graphics/qt/StillImageQt.cpp
Source/WebCore/platform/graphics/qt/StillImageQt.h
Source/WebCore/platform/graphics/qt/TransparencyLayer.h
Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperGL.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/CoordinatedGraphics/LayerTreeCoordinator.cpp

index 25117eb..6141019 100644 (file)
@@ -1,3 +1,89 @@
+2012-10-08  Zoltan Horvath  <zoltan@webkit.org>
+
+        [Qt] r122720 causes performance regression with DirectFB on ARMv7
+        https://bugs.webkit.org/show_bug.cgi?id=97548
+
+        Reviewed by Jocelyn Turcotte.
+
+        Revert the rest of r122720. This change modifies the NativeImagePtr from QImage* to QPixmap*.
+
+        Covered by existing tests.
+
+        * bridge/qt/qt_pixmapruntime.cpp:
+        (JSC::Bindings::assignToHTMLImageElement):
+        (JSC::Bindings::QtPixmapRuntime::toQt):
+        * platform/DragImage.h:
+        (WebCore):
+        * platform/graphics/GraphicsContext.h:
+        (GraphicsContext):
+        * platform/graphics/Image.h:
+        (Image):
+        * platform/graphics/NativeImagePtr.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):
+        (WebCore::ImageBufferData::toQImage):
+        (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):
+        (loadResourcePixmap):
+        (WebCore::Image::loadPlatformResource):
+        (WebCore::Image::setPlatformResource):
+        (WebCore::Image::drawPattern):
+        (WebCore::BitmapImage::BitmapImage):
+        (WebCore::BitmapImage::draw):
+        (WebCore::BitmapImage::checkForSolidColor):
+        (WebCore::BitmapImage::create):
+        * 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/surfaces/qt/GraphicsSurfaceQt.cpp:
+        (WebCore::GraphicsSurface::createReadOnlyImage):
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::BitmapTextureGL::updateContents):
+        * 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-10-08  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix make distcheck.
index 150724b..2bc5c2c 100644 (file)
@@ -135,8 +135,8 @@ static JSValueRef assignToHTMLImageElement(JSContextRef context, JSObjectRef fun
 
     QVariant& data = *static_cast<QVariant*>(JSObjectGetPrivate(object));
 
-    // 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(toImage(data));
+    // We now know that we have a valid <img> element as the argument, we can attach the pixmap to it.
+    RefPtr<StillImage> stillImage = WebCore::StillImage::create(toPixmap(data));
     HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(static_cast<JSHTMLImageElement*>(jsObject)->impl());
     imageElement->setCachedImage(new CachedImage(stillImage.get()));
     return JSValueMakeUndefined(context);
@@ -231,13 +231,13 @@ QVariant QtPixmapRuntime::toQt(JSContextRef context, JSObjectRef obj, QMetaType:
     if (!image)
         return emptyVariantForHint(hint);
 
-    QImage* nativeImage = image->nativeImageForCurrentFrame();
-    if (!nativeImage)
+    QPixmap* pixmap = image->nativeImageForCurrentFrame();
+    if (!pixmap)
         return emptyVariantForHint(hint);
 
     return (hint == static_cast<QMetaType::Type>(qMetaTypeId<QPixmap>()))
-              ? QVariant::fromValue<QPixmap>(QPixmap::fromImage(*nativeImage))
-              : QVariant::fromValue<QImage>(*nativeImage);
+        ? QVariant::fromValue<QPixmap>(*pixmap)
+        : QVariant::fromValue<QImage>(pixmap->toImage());
 }
 
 bool QtPixmapRuntime::canHandle(QMetaType::Type hint)
index e78a9d3..dd970d2 100644 (file)
@@ -36,7 +36,7 @@
 OBJC_CLASS NSImage;
 #elif PLATFORM(QT)
 QT_BEGIN_NAMESPACE
-class QImage;
+class QPixmap;
 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 QImage* DragImageRef;
+    typedef QPixmap* DragImageRef;
 #elif PLATFORM(WIN)
     typedef HBITMAP DragImageRef;
 #elif PLATFORM(WX)
index 16947fb..d4a8c1f 100644 (file)
@@ -499,7 +499,7 @@ namespace WebCore {
 #endif
 
 #if PLATFORM(QT)
-        void pushTransparencyLayerInternal(const QRect&, qreal, QImage&);
+        void pushTransparencyLayerInternal(const QRect&, qreal, QPixmap&);
         void takeOwnershipOfPlatformContext();
 #endif
 
index feb6e2b..5e700c1 100644 (file)
@@ -53,6 +53,10 @@ typedef SIZE* LPSIZE;
 typedef struct HBITMAP__ *HBITMAP;
 #endif
 
+#if PLATFORM(QT)
+#include <QPixmap>
+#endif
+
 #if PLATFORM(GTK)
 typedef struct _GdkPixbuf GdkPixbuf;
 #endif
@@ -154,7 +158,7 @@ public:
 #endif
 
 #if PLATFORM(QT)
-    static void setPlatformResource(const char* name, const QImage&);
+    static void setPlatformResource(const char* name, const QPixmap&);
 #endif
 
     virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
index 50cde5d..c98f8c2 100644 (file)
@@ -36,7 +36,7 @@ typedef struct CGImage* CGImageRef;
 #elif PLATFORM(QT)
 #include <qglobal.h>
 QT_BEGIN_NAMESPACE
-class QImage;
+class QPixmap;
 QT_END_NAMESPACE
 #elif USE(CAIRO)
 #include "NativeImageCairo.h"
@@ -57,7 +57,7 @@ namespace WebCore {
 #if USE(CG)
 typedef CGImageRef NativeImagePtr;
 #elif PLATFORM(QT)
-typedef QImage* NativeImagePtr;
+typedef QPixmap* NativeImagePtr;
 #elif PLATFORM(OPENVG)
 class TiledImageOpenVG;
 typedef TiledImageOpenVG* NativeImagePtr;
index 7a0e5ee..83bdfe2 100644 (file)
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
-#if PLATFORM(QT)
-#include <QImage>
-#endif
-
 namespace WebCore {
 class IntSize;
 
index d6e6e2a..375026d 100644 (file)
@@ -67,8 +67,9 @@ ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
     image.invertPixels(invertMode);
 #endif
-
-    m_image = BitmapImage::create(new QImage(image));
+    QPixmap* surface = new QPixmap;
+    surface->convertFromImage(image);
+    m_image = BitmapImage::create(surface);
 
 #ifdef GST_API_VERSION_1
     if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer))
index cbd5192..8ac1231 100644 (file)
@@ -485,16 +485,18 @@ bool GraphicsContext3D::getImageData(Image* image,
     if (!image)
         return false;
 
-    QImage nativeImage;
+    QImage qtImage;
     // Is image already loaded? If not, load it.
     if (image->data())
-        nativeImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size());
-    else
-        nativeImage = *image->nativeImageForCurrentFrame();
-
+        qtImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size());
+    else {
+        QPixmap* nativePixmap = image->nativeImageForCurrentFrame();
+        // With QPA, we can avoid a deep copy.
+        qtImage = *nativePixmap->handle()->buffer();
+    }
 
     AlphaOp alphaOp = AlphaDoNothing;
-    switch (nativeImage.format()) {
+    switch (qtImage.format()) {
     case QImage::Format_RGB32:
         // For opaque images, we should not premultiply or unmultiply alpha.
         break;
@@ -508,7 +510,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.
-        nativeImage = nativeImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32);
+        qtImage = qtImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32);
         break;
     }
 
@@ -519,7 +521,7 @@ bool GraphicsContext3D::getImageData(Image* image,
 
     outputVector.resize(packedSize);
 
-    return packPixels(nativeImage.constBits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, alphaOp, outputVector.data());
+    return packPixels(qtImage.constBits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, alphaOp, outputVector.data());
 }
 
 void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>)
index 5c8a3ae..c8b35a9 100644 (file)
@@ -1066,7 +1066,7 @@ void GraphicsContext::clearPlatformShadow()
     m_data->shadow->clear();
 }
 
-void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QImage& alphaMask)
+void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask)
 {
     QPainter* p = m_data->p();
 
@@ -1101,7 +1101,7 @@ void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
         h = int(qBound(qreal(0), deviceClip.height(), (qreal)h) + 2);
     }
 
-    QImage emptyAlphaMask;
+    QPixmap emptyAlphaMask;
     m_data->layers.push(new TransparencyLayer(p, QRect(x, y, w, h), opacity, emptyAlphaMask));
     ++m_data->layerCount;
 }
@@ -1115,7 +1115,7 @@ void GraphicsContext::endPlatformTransparencyLayer()
     if (!layer->alphaMask.isNull()) {
         layer->painter.resetTransform();
         layer->painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
-        layer->painter.drawImage(QPoint(), layer->alphaMask);
+        layer->painter.drawPixmap(QPoint(), layer->alphaMask);
     } else
         --m_data->layerCount; // see the comment for layerCount
     layer->painter.end();
@@ -1124,7 +1124,7 @@ void GraphicsContext::endPlatformTransparencyLayer()
     p->save();
     p->resetTransform();
     p->setOpacity(layer->opacity);
-    p->drawImage(layer->offset, layer->image);
+    p->drawPixmap(layer->offset, layer->pixmap);
     p->restore();
 
     delete layer;
index 94065d3..9cf782b 100644 (file)
@@ -25,8 +25,8 @@
 
 #include "Image.h"
 
-#include <QImage>
 #include <QPainter>
+#include <QPixmap>
 
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
@@ -39,7 +39,9 @@ class ImageBufferData {
 public:
     ImageBufferData(const IntSize&);
 
-    QImage m_nativeImage;
+    QImage toQImage() const;
+
+    QPixmap m_pixmap;
     OwnPtr<QPainter> m_painter;
     RefPtr<Image> m_image;
 };
index 32dd39a..b9b9ebf 100644 (file)
@@ -32,7 +32,6 @@
 #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_nativeImage(size, NativeImageQt::defaultFormatForAlphaEnabledImages())
+    : m_pixmap(size)
 {
-    if (m_nativeImage.isNull())
+    if (m_pixmap.isNull())
         return;
 
-    m_nativeImage.fill(QColor(Qt::transparent));
+    m_pixmap.fill(QColor(Qt::transparent));
 
     QPainter* painter = new QPainter;
     m_painter = adoptPtr(painter);
 
-    if (!painter->begin(&m_nativeImage))
+    if (!painter->begin(&m_pixmap))
         return;
 
     // Since ImageBuffer is used mainly for Canvas, explicitly initialize
@@ -76,7 +76,22 @@ ImageBufferData::ImageBufferData(const IntSize& size)
     painter->setBrush(brush);
     painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
     
-    m_image = StillImage::createForRendering(&m_nativeImage);
+    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;
 }
 
 ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success)
@@ -105,9 +120,9 @@ GraphicsContext* ImageBuffer::context() const
 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior) const
 {
     if (copyBehavior == CopyBackingStore)
-        return StillImage::create(m_data.m_nativeImage);
+        return StillImage::create(m_data.m_pixmap);
 
-    return StillImage::createForRendering(&m_data.m_nativeImage);
+    return StillImage::createForRendering(&m_data.m_pixmap);
 }
 
 void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
@@ -134,12 +149,12 @@ void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& src
 
 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& floatRect) const
 {
-    QImage* nativeImage = m_data.m_image->nativeImageForCurrentFrame();
+    QPixmap* nativeImage = m_data.m_image->nativeImageForCurrentFrame();
     if (!nativeImage)
         return;
 
     IntRect rect = enclosingIntRect(floatRect);
-    QImage alphaMask = *nativeImage;
+    QPixmap alphaMask = *nativeImage;
 
     context->pushTransparencyLayerInternal(rect, 1.0, alphaMask);
 }
@@ -150,7 +165,7 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
     if (isPainting)
         m_data.m_painter->end();
 
-    QImage image = m_data.m_nativeImage.convertToFormat(QImage::Format_ARGB32);
+    QImage image = m_data.toQImage().convertToFormat(QImage::Format_ARGB32);
     ASSERT(!image.isNull());
 
     uchar* bits = image.bits();
@@ -167,10 +182,10 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
         }
     }
 
-    m_data.m_nativeImage = image;
+    m_data.m_pixmap = QPixmap::fromImage(image);
 
     if (isPainting)
-        m_data.m_painter->begin(&m_data.m_nativeImage);
+        m_data.m_painter->begin(&m_data.m_pixmap);
 }
 
 template <Multiply multiplied>
@@ -209,7 +224,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.m_nativeImage.convertToFormat(NativeImageQt::defaultFormatForAlphaEnabledImages());
+    QImage image = imageData.toQImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
 
     ASSERT(!image.isNull());
 
@@ -343,7 +358,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_nativeImage);
+        m_data.m_painter->begin(&m_data.m_pixmap);
     else {
         m_data.m_painter->save();
 
@@ -362,7 +377,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
         m_data.m_painter->restore();
 }
 
-static bool encodeImage(const QImage& image, const String& format, const double* quality, QByteArray& data)
+static bool encodeImage(const QPixmap& pixmap, const String& format, const double* quality, QByteArray& data)
 {
     int compressionQuality = 100;
     if (quality && *quality >= 0.0 && *quality <= 1.0)
@@ -370,7 +385,7 @@ static bool encodeImage(const QImage& image, const String& format, const double*
 
     QBuffer buffer(&data);
     buffer.open(QBuffer::WriteOnly);
-    bool success = image.save(&buffer, format.utf8().data(), compressionQuality);
+    bool success = pixmap.save(&buffer, format.utf8().data(), compressionQuality);
     buffer.close();
 
     return success;
@@ -382,10 +397,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_nativeImage image.
+    // the m_pixmap image.
 
     QByteArray data;
-    if (!encodeImage(m_data.m_nativeImage, mimeType.substring(sizeof "image"), quality, data))
+    if (!encodeImage(m_data.m_pixmap, mimeType.substring(sizeof "image"), quality, data))
         return "data:,";
 
     return "data:" + mimeType + ";base64," + data.toBase64().data();
index d45e61c..a7d9f75 100644 (file)
@@ -272,7 +272,9 @@ NativeImagePtr ImageFrame::asNewNativeImage() const
     else
         format = QImage::Format_RGB32;
 
-    return new QImage(reinterpret_cast<uchar*>(m_bytes), m_size.width(), m_size.height(), sizeof(PixelData) * m_size.width(), format);
+    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));
 }
 
 }
index 5be31ce..fc01c40 100644 (file)
@@ -37,7 +37,6 @@
 #include "FloatRect.h"
 #include "GraphicsContext.h"
 #include "ImageObserver.h"
-#include "NativeImageQt.h"
 #include "ShadowBlur.h"
 #include "StillImageQt.h"
 #include <wtf/text/WTFString.h>
@@ -56,7 +55,7 @@
 Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP, int hbitmapFormat = 0);
 #endif
 
-typedef QHash<QByteArray, QImage> WebGraphicHash;
+typedef QHash<QByteArray, QPixmap> WebGraphicHash;
 Q_GLOBAL_STATIC(WebGraphicHash, _graphics)
 
 static void earlyClearGraphics()
@@ -70,28 +69,28 @@ static WebGraphicHash* graphics()
 
     if (hash->isEmpty()) {
 
-        // prevent ~QImage running after ~QApplication (leaks native images)
+        // prevent ~QPixmap running after ~QApplication (leaks native pixmaps)
         qAddPostRoutine(earlyClearGraphics);
 
         // QWebSettings::MissingImageGraphic
-        hash->insert("missingImage", QImage(QLatin1String(":webkit/resources/missingImage.png")));
+        hash->insert("missingImage", QPixmap(QLatin1String(":webkit/resources/missingImage.png")));
         // QWebSettings::MissingPluginGraphic
-        hash->insert("nullPlugin", QImage(QLatin1String(":webkit/resources/nullPlugin.png")));
+        hash->insert("nullPlugin", QPixmap(QLatin1String(":webkit/resources/nullPlugin.png")));
         // QWebSettings::DefaultFrameIconGraphic
-        hash->insert("urlIcon", QImage(QLatin1String(":webkit/resources/urlIcon.png")));
+        hash->insert("urlIcon", QPixmap(QLatin1String(":webkit/resources/urlIcon.png")));
         // QWebSettings::TextAreaSizeGripCornerGraphic
-        hash->insert("textAreaResizeCorner", QImage(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
+        hash->insert("textAreaResizeCorner", QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
         // QWebSettings::DeleteButtonGraphic
-        hash->insert("deleteButton", QImage(QLatin1String(":webkit/resources/deleteButton.png")));
+        hash->insert("deleteButton", QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
         // QWebSettings::InputSpeechButtonGraphic
-        hash->insert("inputSpeech", QImage(QLatin1String(":webkit/resources/inputSpeech.png")));
+        hash->insert("inputSpeech", QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));
     }
 
     return hash;
 }
 
 // This function loads resources into WebKit
-static QImage loadResourceImage(const char *name)
+static QPixmap loadResourcePixmap(const char *name)
 {
     return graphics()->value(name);
 }
@@ -118,23 +117,23 @@ bool FrameData::clear(bool clearMetadata)
 
 PassRefPtr<Image> Image::loadPlatformResource(const char* name)
 {
-    return StillImage::create(loadResourceImage(name));
+    return StillImage::create(loadResourcePixmap(name));
 }
 
-void Image::setPlatformResource(const char* name, const QImage& image)
+void Image::setPlatformResource(const char* name, const QPixmap& pixmap)
 {
     WebGraphicHash* h = graphics();
-    if (image.isNull())
+    if (pixmap.isNull())
         h->remove(name);
     else
-        h->insert(name, image);
+        h->insert(name, pixmap);
 }
 
 void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
                         const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect)
 {
-    QImage* frameImage = nativeImageForCurrentFrame();
-    if (!frameImage) // If it's too early we won't have an image yet.
+    QPixmap* framePixmap = nativeImageForCurrentFrame();
+    if (!framePixmap) // If it's too early we won't have an image yet.
         return;
 
 #if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
@@ -149,38 +148,34 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
     if (!dr.width() || !dr.height() || !tr.width() || !tr.height())
         return;
 
-    QImage image = *frameImage;
-    if (tr.x() || tr.y() || tr.width() != image.width() || tr.height() != image.height())
-        image = image.copy(tr);
+    QPixmap pixmap = *framePixmap;
+    if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height())
+        pixmap = pixmap.copy(tr);
 
     CompositeOperator previousOperator = ctxt->compositeOperation();
 
-    ctxt->setCompositeOperation(!image.hasAlphaChannel() && op == CompositeSourceOver ? CompositeCopy : op);
+    ctxt->setCompositeOperation(!pixmap.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
 
     QPainter* p = ctxt->platformContext();
     QTransform transform(patternTransform);
 
-    // If this would draw more than one scaled tile, we scale the image first and then use the result to draw.
+    // If this would draw more than one scaled tile, we scale the pixmap 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(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());
-
+            QSizeF scaledSize(float(pixmap.width()) * transform.m11(), float(pixmap.height()) * transform.m22());
+            QPixmap scaledPixmap(scaledSize.toSize());
+            if (pixmap.hasAlpha())
+                scaledPixmap.fill(Qt::transparent);
             {
-                QPainter painter(&scaledImage);
+                QPainter painter(&scaledPixmap);
                 painter.setCompositionMode(QPainter::CompositionMode_Source);
                 painter.setRenderHints(p->renderHints());
-                painter.drawImage(QRect(0, 0, scaledImage.width(), scaledImage.height()), image);
+                painter.drawPixmap(QRect(0, 0, scaledPixmap.width(), scaledPixmap.height()), pixmap);
             }
-            image = scaledImage;
+            pixmap = scaledPixmap;
             transform = QTransform::fromTranslate(transform.dx(), transform.dy());
         }
     }
@@ -189,7 +184,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(image);
+    QBrush b(pixmap);
     b.setTransform(transform);
     p->fillRect(dr, b);
 
@@ -199,7 +194,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
         imageObserver()->didDraw(this);
 }
 
-BitmapImage::BitmapImage(QImage* image, ImageObserver* observer)
+BitmapImage::BitmapImage(QPixmap* pixmap, ImageObserver* observer)
     : Image(observer)
     , m_currentFrame(0)
     , m_frames(0)
@@ -217,14 +212,14 @@ BitmapImage::BitmapImage(QImage* image, ImageObserver* observer)
     , m_sizeAvailable(true)
     , m_haveFrameCount(true)
 {
-    int width = image->width();
-    int height = image->height();
+    int width = pixmap->width();
+    int height = pixmap->height();
     m_decodedSize = width * height * 4;
     m_size = IntSize(width, height);
 
     m_frames.grow(1);
-    m_frames[0].m_frame = image;
-    m_frames[0].m_hasAlpha = image->hasAlphaChannel();
+    m_frames[0].m_frame = pixmap;
+    m_frames[0].m_hasAlpha = pixmap->hasAlpha();
     m_frames[0].m_haveMetadata = true;
     checkForSolidColor();
 }
@@ -245,8 +240,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
     if (normalizedSrc.isEmpty() || normalizedDst.isEmpty())
         return;
 
-    QImage* image = nativeImageForCurrentFrame();
-
+    QPixmap* image = nativeImageForCurrentFrame();
     if (!image)
         return;
 
@@ -260,19 +254,19 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
 #endif
 
     CompositeOperator previousOperator = ctxt->compositeOperation();
-    ctxt->setCompositeOperation(!image->hasAlphaChannel() && op == CompositeSourceOver ? CompositeCopy : op);
+    ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
 
     if (ctxt->hasShadow()) {
         ShadowBlur* shadow = ctxt->shadowBlur();
         GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
         if (shadowContext) {
             QPainter* shadowPainter = shadowContext->platformContext();
-            shadowPainter->drawImage(normalizedDst, *image, normalizedSrc);
+            shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
             shadow->endShadowLayer(ctxt);
         }
     }
 
-    ctxt->platformContext()->drawImage(normalizedDst, *image, normalizedSrc);
+    ctxt->platformContext()->drawPixmap(normalizedDst, *image, normalizedSrc);
 
     ctxt->setCompositeOperation(previousOperator);
 
@@ -288,20 +282,20 @@ void BitmapImage::checkForSolidColor()
     if (frameCount() > 1)
         return;
 
-    QImage* frameImage = frameAtIndex(0);
-    if (!frameImage || frameImage->width() != 1 || frameImage->height() != 1)
+    QPixmap* framePixmap = frameAtIndex(0);
+    if (!framePixmap || framePixmap->width() != 1 || framePixmap->height() != 1)
         return;
 
     m_isSolidColor = true;
-    m_solidColor = QColor::fromRgba(frameImage->pixel(0, 0));
+    m_solidColor = QColor::fromRgba(framePixmap->toImage().pixel(0, 0));
 }
 
 #if OS(WINDOWS)
 PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
 {
-    QImage* nativeImage = new QImage(qt_pixmapFromWinHBITMAP(hBitmap).toImage());
+    QPixmap* qPixmap = new QPixmap(qt_pixmapFromWinHBITMAP(hBitmap));
 
-    return BitmapImage::create(nativeImage);
+    return BitmapImage::create(qPixmap);
 }
 #endif
 
index 5c94122..7aae625 100644 (file)
@@ -33,12 +33,12 @@ namespace WebCore {
 
 QBrush Pattern::createPlatformPattern() const
 {
-    QImage* image = tileImage()->nativeImageForCurrentFrame();
-    if (!image)
+    QPixmap* pixmap = tileImage()->nativeImageForCurrentFrame();
+    if (!pixmap)
         return QBrush();
 
     // Qt merges patter space and user space itself
-    QBrush brush(*image);
+    QBrush brush(*pixmap);
     brush.setTransform(m_patternSpaceTransformation);
 
     return brush;
index 0412520..80666ba 100644 (file)
 
 namespace WebCore {
 
-StillImage::StillImage(const QImage& image)
-    : m_image(new QImage(image))
-    , m_ownsImage(true)
+StillImage::StillImage(const QPixmap& pixmap)
+    : m_pixmap(new QPixmap(pixmap))
+    , m_ownsPixmap(true)
 {}
 
-StillImage::StillImage(const QImage* image)
-    : m_image(image)
-    , m_ownsImage(false)
+StillImage::StillImage(const QPixmap* pixmap)
+    : m_pixmap(pixmap)
+    , m_ownsPixmap(false)
 {}
 
 StillImage::~StillImage()
 {
-    if (m_ownsImage)
-        delete m_image;
+    if (m_ownsPixmap)
+        delete m_pixmap;
 }
 
 bool StillImage::currentFrameHasAlpha()
 {
-    return m_image->hasAlphaChannel();
+    return m_pixmap->hasAlpha();
 }
 
 IntSize StillImage::size() const
 {
-    return IntSize(m_image->width(), m_image->height());
+    return IntSize(m_pixmap->width(), m_pixmap->height());
 }
 
 NativeImagePtr StillImage::nativeImageForCurrentFrame()
 {
-    return const_cast<NativeImagePtr>(m_image);
+    return const_cast<NativeImagePtr>(m_pixmap);
 }
 
 void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
                       const FloatRect& src, ColorSpace, CompositeOperator op)
 {
-    if (m_image->isNull())
+    if (m_pixmap->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->drawImage(normalizedDst, *m_image, normalizedSrc);
+            shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
             shadow->endShadowLayer(ctxt);
         }
     }
 
-    ctxt->platformContext()->drawImage(normalizedDst, *m_image, normalizedSrc);
+    ctxt->platformContext()->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
     ctxt->setCompositeOperation(previousOperator);
 }
 
index 8c9ec0d..0609b54 100644 (file)
@@ -34,14 +34,14 @@ namespace WebCore {
 
     class StillImage : public Image {
     public:
-        static PassRefPtr<StillImage> create(const QImage& image)
+        static PassRefPtr<StillImage> create(const QPixmap& pixmap)
         {
-            return adoptRef(new StillImage(image));
+            return adoptRef(new StillImage(pixmap));
         }
 
-        static PassRefPtr<StillImage> createForRendering(const QImage* image)
+        static PassRefPtr<StillImage> createForRendering(const QPixmap* pixmap)
         {
-            return adoptRef(new StillImage(image));
+            return adoptRef(new StillImage(pixmap));
         }
 
         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 QImage&);
-        StillImage(const QImage*);
+        StillImage(const QPixmap&);
+        StillImage(const QPixmap*);
         virtual ~StillImage();
         
-        const QImage* m_image;
-        bool m_ownsImage;
+        const QPixmap* m_pixmap;
+        bool m_ownsPixmap;
     };
 
 }
index 5974017..f13deb0 100644 (file)
 #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, QImage& alphaMask)
-        : image(rect.width(), rect.height(), NativeImageQt::defaultFormatForAlphaEnabledImages())
+    TransparencyLayer(const QPainter* p, const QRect &rect, qreal opacity, QPixmap& alphaMask)
+        : pixmap(rect.width(), rect.height())
         , opacity(opacity)
         , alphaMask(alphaMask)
         , saveCounter(1) // see the comment for saveCounter
     {
         offset = rect.topLeft();
-        image.fill(Qt::transparent);
-        painter.begin(&image);
+        pixmap.fill(Qt::transparent);
+        painter.begin(&pixmap);
         painter.setRenderHints(p->renderHints());
         painter.translate(-offset);
         painter.setPen(p->pen());
@@ -67,12 +67,12 @@ public:
     {
     }
 
-    QImage image;
+    QPixmap pixmap;
     QPoint offset;
     QPainter painter;
     qreal opacity;
     // for clipToImageBuffer
-    QImage alphaMask;
+    QPixmap alphaMask;
     // saveCounter is only used in combination with alphaMask
     // otherwise, its value is unspecified
     int saveCounter;
index e1b2758..734a093 100644 (file)
@@ -52,7 +52,8 @@ 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);
-    return BitmapImage::create(new QImage(reinterpret_cast<uchar*>(data), rect.width(), rect.height(), stride, format, didReleaseImage, this));
+    QImage image(reinterpret_cast<uchar*>(data), rect.width(), rect.height(), stride, format, didReleaseImage, this);
+    return BitmapImage::create(new QPixmap(QPixmap::fromImage(image)));
 }
 
 }
index 873f904..9169bfb 100644 (file)
@@ -697,8 +697,9 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
     const char* imageData;
 
 #if PLATFORM(QT)
-    imageData = reinterpret_cast<const char*>(frameImage->constBits());
-    bytesPerLine = frameImage->bytesPerLine();
+    QImage qImage = frameImage->toImage();
+    imageData = reinterpret_cast<const char*>(qImage.constBits());
+    bytesPerLine = qImage.bytesPerLine();
 #elif USE(CAIRO)
     cairo_surface_t* surface = frameImage->surface();
     imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
index 8d84d72..6212f58 100644 (file)
@@ -50,7 +50,6 @@
 
 #include <QClipboard>
 #include <QGuiApplication>
-#include <QImage>
 #include <QList>
 #include <QMimeData>
 #include <QStringList>
@@ -244,7 +243,7 @@ DragImageRef ClipboardQt::createDragImage(IntPoint& dragLoc) const
     if (!m_dragImage)
         return 0;
     dragLoc = m_dragLoc;
-    return new QImage(*m_dragImage->image()->nativeImageForCurrentFrame());
+    return m_dragImage->image()->nativeImageForCurrentFrame();
 }
 
 
@@ -274,9 +273,9 @@ void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, co
     CachedImage* cachedImage = getCachedImage(element);
     if (!cachedImage || !cachedImage->imageForRenderer(element->renderer()) || !cachedImage->isLoaded())
         return;
-    QImage* image = cachedImage->imageForRenderer(element->renderer())->nativeImageForCurrentFrame();
-    if (image)
-        m_writableData->setImageData(*image);
+    QPixmap* pixmap = cachedImage->imageForRenderer(element->renderer())->nativeImageForCurrentFrame();
+    if (pixmap)
+        m_writableData->setImageData(*pixmap);
 
     QList<QUrl> urls;
     urls.append(url);
index 168a2f5..e7854dd 100644 (file)
@@ -37,8 +37,6 @@
 
 #include "NotImplemented.h"
 
-#include <QImage>
-#include <QPixmap>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -77,11 +75,10 @@ Cursor& Cursor::operator=(const Cursor& other)
 #ifndef QT_NO_CURSOR
 static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot)
 {
-    QImage* nativeImage = image->nativeImageForCurrentFrame();
-    if (!nativeImage)
+    if (!image->nativeImageForCurrentFrame())
         return 0;
     IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
-    return new QCursor(QPixmap::fromImage(*nativeImage), effectiveHotSpot.x(), effectiveHotSpot.y());
+    return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y());
 }
 #endif
 
index e93ac70..0e7ce04 100644 (file)
@@ -29,8 +29,6 @@
 #include "CachedImage.h"
 #include "Image.h"
 
-#include <QImage>
-
 namespace WebCore {
 
 IntSize dragImageSize(DragImageRef image)
@@ -68,7 +66,7 @@ DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum)
     if (!image || !image->nativeImageForCurrentFrame())
         return 0;
 
-    return new QImage(*image->nativeImageForCurrentFrame());
+    return new QPixmap(*image->nativeImageForCurrentFrame());
 }
 
 DragImageRef createDragImageIconForCachedImage(CachedImage*)
index a0beb48..96deac4 100644 (file)
@@ -168,10 +168,10 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
     Image* image = cachedImage->imageForRenderer(node->renderer());
     ASSERT(image);
 
-    QImage* nativeImage = image->nativeImageForCurrentFrame();
-    if (!image)
+    QPixmap* pixmap = image->nativeImageForCurrentFrame();
+    if (!pixmap)
         return;
-    QGuiApplication::clipboard()->setImage(*nativeImage, QClipboard::Clipboard);
+    QGuiApplication::clipboard()->setPixmap(*pixmap, QClipboard::Clipboard);
 #endif
 }
 
index 0e6e0e3..0accd33 100644 (file)
@@ -1611,9 +1611,9 @@ QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult
     boundingRect = innerNonSharedNode ? innerNonSharedNode->renderer()->absoluteBoundingBoxRect() : IntRect();
     WebCore::Image *img = hitTest.image();
     if (img) {
-        QImage *pix = img->nativeImageForCurrentFrame();
+        QPixmap *pix = img->nativeImageForCurrentFrame();
         if (pix)
-            pixmap = QPixmap::fromImage(*pix);
+            pixmap = *pix;
     }
     WebCore::Frame *wframe = hitTest.targetFrame();
     if (wframe)
index 4bf6358..f784966 100644 (file)
@@ -158,7 +158,7 @@ QDateTime QWebHistoryItem::lastVisited() const
 QIcon QWebHistoryItem::icon() const
 {
     if (d->item)
-        return QPixmap::fromImage(*WebCore::iconDatabase().synchronousNativeIconForPageURL(d->item->url(), WebCore::IntSize(16, 16)));
+        return *WebCore::iconDatabase().synchronousNativeIconForPageURL(d->item->url(), WebCore::IntSize(16, 16));
 
     return QIcon();
 }
index ebecc7f..ba7187d 100644 (file)
@@ -723,12 +723,12 @@ void QWebSettings::clearIconDatabase()
 QIcon QWebSettings::iconForUrl(const QUrl& url)
 {
     WebCore::initializeWebCoreQt();
-    QImage* icon = WebCore::iconDatabase().synchronousNativeIconForPageURL(WebCore::KURL(url).string(),
+    QPixmap* icon = WebCore::iconDatabase().synchronousNativeIconForPageURL(WebCore::KURL(url).string(),
                                 WebCore::IntSize(16, 16));
     if (!icon)
         return QIcon();
 
-    return QPixmap::fromImage(*icon);
+    return* icon;
 }
 
 /*
@@ -771,7 +771,7 @@ static const char* resourceNameForWebGraphic(QWebSettings::WebGraphic type)
 void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap& graphic)
 {
     WebCore::initializeWebCoreQt();
-    WebCore::Image::setPlatformResource(resourceNameForWebGraphic(type), graphic.toImage());
+    WebCore::Image::setPlatformResource(resourceNameForWebGraphic(type), graphic);
 }
 
 /*!
@@ -786,10 +786,10 @@ QPixmap QWebSettings::webGraphic(WebGraphic type)
     RefPtr<WebCore::Image> img = WebCore::Image::loadPlatformResource(resourceNameForWebGraphic(type));
     if (!img)
         return QPixmap();
-    QImage* image = img->nativeImageForCurrentFrame();
-    if (!image)
+    QPixmap* pixmap = img->nativeImageForCurrentFrame();
+    if (!pixmap)
         return QPixmap();
-    return QPixmap::fromImage(*image);
+    return *pixmap;
 }
 
 /*!
index 2955d78..b099760 100644 (file)
@@ -1,3 +1,27 @@
+2012-10-08  Zoltan Horvath  <zoltan@webkit.org>
+
+        [Qt] r122720 causes performance regression with DirectFB on ARMv7
+        https://bugs.webkit.org/show_bug.cgi?id=97548
+
+        Reviewed by Jocelyn Turcotte.
+
+        Revert the rest of r122720. This change modifies the NativeImagePtr from QImage* to QPixmap*.
+
+        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-10-07  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
 
         Rename first/second to key/value in HashMap iterators
index 8b648c1..cb63283 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(QPixmap::fromImage(*dragImage));
+            drag->setPixmap(*dragImage);
         else if (clipboardData && clipboardData->hasImage())
-            drag->setPixmap(QPixmap::fromImage(qvariant_cast<QImage>(clipboardData->imageData())));
+            drag->setPixmap(qvariant_cast<QPixmap>(clipboardData->imageData()));
         DragOperation dragOperationMask = clipboard->sourceOperation();
         drag->setMimeData(clipboardData);
         Qt::DropAction actualDropAction = drag->exec(dragOperationsToDropActions(dragOperationMask));
index c63ccb0..5ac449d 100644 (file)
@@ -83,9 +83,9 @@ void initializeWebCoreQt()
 #endif
 
     // QWebSettings::SearchCancelButtonGraphic
-    Image::setPlatformResource("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton).toImage());
+    Image::setPlatformResource("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
     // QWebSettings::SearchCancelButtonPressedGraphic
-    Image::setPlatformResource("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton).toImage());
+    Image::setPlatformResource("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
 
     initialized = true;
 }
index 2f1ef3b..31641f6 100644 (file)
@@ -1,3 +1,24 @@
+2012-10-08  Zoltan Horvath  <zoltan@webkit.org>
+
+        [Qt] r122720 causes performance regression with DirectFB on ARMv7
+        https://bugs.webkit.org/show_bug.cgi?id=97548
+
+        Reviewed by Jocelyn Turcotte.
+
+        Revert the rest of r122720. This change modifies the NativeImagePtr from QImage* to QPixmap*.
+
+        Covered by existing tests.
+
+        * Shared/qt/ShareableBitmapQt.cpp:
+        (WebKit::ShareableBitmap::createImage):
+        * UIProcess/qt/QtWebIconDatabaseClient.cpp:
+        (WebKit::QtWebIconDatabaseClient::iconImageForPageURL):
+        * WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp:
+        (WebKit::convertQPixmapToShareableBitmap):
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
+        (WebKit::LayerTreeCoordinator::adoptImageBackingStore):
+
 2012-10-08  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
 
         Unreviewed build fix after r130630
index 6cadb08..874e1c3 100644 (file)
@@ -53,8 +53,8 @@ void ShareableBitmap::releaseSharedMemoryData(void* typelessBitmap)
 
 PassRefPtr<Image> ShareableBitmap::createImage()
 {
-    QImage* image = new QImage(createQImage());
-    return BitmapImage::create(image);
+    QPixmap* pixmap = new QPixmap(QPixmap::fromImage(createQImage()));
+    return BitmapImage::create(pixmap);
 }
 
 PassOwnPtr<GraphicsContext> ShareableBitmap::createGraphicsContext()
index afdfa6f..592bb37 100644 (file)
@@ -90,11 +90,11 @@ QImage QtWebIconDatabaseClient::iconImageForPageURL(const WTF::String& pageURL,
 
     WebCore::IntSize size(iconSize.width(), iconSize.height());
 
-    QImage* nativeImage = m_iconDatabase->nativeImageForPageURL(pageURL, size);
+    QPixmap* nativeImage = m_iconDatabase->nativeImageForPageURL(pageURL, size);
     if (!nativeImage)
         return QImage();
 
-    return *nativeImage;
+    return nativeImage->toImage();
 }
 
 void QtWebIconDatabaseClient::retainIconForPageURL(const String& pageURL)
index d9e6d1d..bbdb635 100644 (file)
@@ -38,15 +38,15 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static PassRefPtr<ShareableBitmap> convertQImageToShareableBitmap(QImage* image)
+static PassRefPtr<ShareableBitmap> convertQPixmapToShareableBitmap(QPixmap* pixmap)
 {
-    if (!image)
+    if (!pixmap)
         return 0;
 
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(pixmap->size()), ShareableBitmap::SupportsAlpha);
     OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext();
 
-    graphicsContext->platformContext()->drawImage(0, 0, *image);
+    graphicsContext->platformContext()->drawPixmap(0, 0, *pixmap);
     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 = convertQImageToShareableBitmap(dragImage);
+    RefPtr<ShareableBitmap> bitmap = convertQPixmapToShareableBitmap(dragImage);
     ShareableBitmap::Handle handle;
     if (bitmap && !bitmap->createHandle(handle))
         return;
index ba5b469..123e29c 100644 (file)
@@ -451,7 +451,7 @@ int64_t LayerTreeCoordinator::adoptImageBackingStore(Image* image)
     int64_t key = 0;
 
 #if PLATFORM(QT)
-    QImage* nativeImage = image->nativeImageForCurrentFrame();
+    QPixmap* nativeImage = image->nativeImageForCurrentFrame();
 
     if (!nativeImage)
         return InvalidWebLayerID;