2008-05-08 Holger Hans Peter Freyther <zecke@selfish.org>
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 May 2008 14:58:01 +0000 (14:58 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 May 2008 14:58:01 +0000 (14:58 +0000)
        Reviewed by Simon.

        Simple ImageBuffer::image implementation.

        In contrast to cg and cairo we do not use a special BitmapImage because
        the ownership of the FrameData inside the BitmapImage is a bit backward
        (actually owned by the ImageDecoderQt...). Further work is needed for image
        and pixmap handling in the qt port...

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

WebCore/ChangeLog
WebCore/WebCore.pro
WebCore/platform/graphics/ImageBuffer.h
WebCore/platform/graphics/qt/ImageBufferQt.cpp
WebCore/platform/graphics/qt/ImageQt.cpp
WebCore/platform/graphics/qt/StillImageQt.cpp [new file with mode: 0644]
WebCore/platform/graphics/qt/StillImageQt.h [new file with mode: 0644]

index 9656235..e73469c 100644 (file)
@@ -2,6 +2,29 @@
 
         Reviewed by Simon.
 
+        Simple ImageBuffer::image implementation.
+
+        In contrast to cg and cairo we do not use a special BitmapImage because
+        the ownership of the FrameData inside the BitmapImage is a bit backward
+        (actually owned by the ImageDecoderQt...). Further work is needed for image
+        and pixmap handling in the qt port...
+
+        * WebCore.pro:
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/qt/ImageBufferQt.cpp:
+        (WebCore::ImageBuffer::image):
+        * platform/graphics/qt/ImageQt.cpp:
+        * platform/graphics/qt/StillImageQt.cpp: Added.
+        (WebCore::StillImage::StillImage):
+        (WebCore::StillImage::size):
+        (WebCore::StillImage::getPixmap):
+        (WebCore::StillImage::draw):
+        * platform/graphics/qt/StillImageQt.h: Added.
+
+2008-05-08  Holger Hans Peter Freyther  <zecke@selfish.org>
+
+        Reviewed by Simon.
+
         Update the WebKit.qrc of the inspector to be functional again
 
         * page/inspector/WebKit.qrc:
index d5781a4..f057a90 100644 (file)
@@ -966,6 +966,7 @@ gtk-port {
 qt-port {
 
     HEADERS += \
+    $$PWD/platform/graphics/qt/StillImageQt.h \
     $$PWD/platform/qt/QWebPopup.h \
     $$PWD/platform/qt/MenuEventProxy.h \
     $$PWD/platform/qt/SharedTimerQt.h \
@@ -999,6 +1000,7 @@ qt-port {
     platform/graphics/qt/IntRectQt.cpp \
     platform/graphics/qt/IntSizeQt.cpp \
     platform/graphics/qt/PathQt.cpp \
+    platform/graphics/qt/StillImageQt.cpp \
     platform/network/qt/ResourceHandleQt.cpp \
     platform/network/qt/ResourceRequestQt.cpp \
     platform/network/qt/QNetworkReplyHandler.cpp \
index 1058a5f..e652e2a 100644 (file)
@@ -77,7 +77,7 @@ namespace WebCore {
         cairo_surface_t* surface() const;
 #endif
 
-#if PLATFORM(CG) || PLATFORM(CAIRO)
+#if PLATFORM(CG) || PLATFORM(CAIRO) || PLATFORM(QT)
         Image* image() const;
 #else
         Image* image() const { notImplemented(); return 0; }
index 93a9ecb..b190d36 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2008 Holger Hans Peter Freyther
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,6 +30,7 @@
 #include "GraphicsContext.h"
 #include "ImageData.h"
 #include "NotImplemented.h"
+#include "StillImageQt.h"
 
 #include <QPainter>
 #include <QPixmap>
@@ -71,6 +73,18 @@ QPixmap* ImageBuffer::pixmap() const
     return &m_pixmap;
 }
 
+Image* ImageBuffer::image() const
+{
+    if (!m_image) {
+        // It's assumed that if image() is called, the actual rendering to the
+        // GraphicsContext must be done.
+        ASSERT(context());
+        m_image.set(new StillImage(m_pixmap));
+    }
+
+    return m_image.get();
+}
+
 PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect&) const
 {
     notImplemented();
index efd0f52..6e9843b 100644 (file)
@@ -36,6 +36,7 @@
 #include "GraphicsContext.h"
 #include "AffineTransform.h"
 #include "NotImplemented.h"
+#include "StillImageQt.h"
 #include "qwebsettings.h"
 
 #include <QPixmap>
 
 #include <math.h>
 
-namespace WebCore {
-class StillImage : public Image {
-public:
-    StillImage(const QPixmap& pixmap);
-
-    virtual IntSize size() const;
-    virtual QPixmap* getPixmap() const;
-    virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator);
-
-private:
-    QPixmap m_pixmap;
-};
-}
-
 // This function loads resources into WebKit
 static QPixmap loadResourcePixmap(const char *name)
 {
@@ -182,33 +169,6 @@ QPixmap* BitmapImage::getPixmap() const
     return const_cast<BitmapImage*>(this)->frameAtIndex(0);
 }
 
-StillImage::StillImage(const QPixmap& pixmap)
-    : m_pixmap(pixmap)
-{}
-
-IntSize StillImage::size() const
-{
-    return IntSize(m_pixmap.width(), m_pixmap.height());
-}
-
-QPixmap* StillImage::getPixmap() const
-{
-    return const_cast<QPixmap*>(&m_pixmap);
-}
-
-void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
-                      const FloatRect& src, CompositeOperator op)
-{
-    if (m_pixmap.isNull())
-        return;
-
-    ctxt->save();
-    ctxt->setCompositeOperation(op);
-    QPainter* painter(ctxt->platformContext());
-    painter->drawPixmap(dst, m_pixmap, src);
-    ctxt->restore();
-}
-
 }
 
 
diff --git a/WebCore/platform/graphics/qt/StillImageQt.cpp b/WebCore/platform/graphics/qt/StillImageQt.cpp
new file mode 100644 (file)
index 0000000..2f667c9
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 Holger Hans Peter Freyther
+ *
+ * All rights reserved.
+ *
+ * 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+ */
+
+#include "config.h"
+#include "StillImageQt.h"
+
+#include "GraphicsContext.h"
+#include "IntSize.h"
+
+#include <QPainter>
+
+namespace WebCore {
+
+StillImage::StillImage(const QPixmap& pixmap)
+    : m_pixmap(pixmap)
+{}
+
+IntSize StillImage::size() const
+{
+    return IntSize(m_pixmap.width(), m_pixmap.height());
+}
+
+QPixmap* StillImage::getPixmap() const
+{
+    return const_cast<QPixmap*>(&m_pixmap);
+}
+
+void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
+                      const FloatRect& src, CompositeOperator op)
+{
+    if (m_pixmap.isNull())
+        return;
+
+    ctxt->save();
+    ctxt->setCompositeOperation(op);
+    QPainter* painter(ctxt->platformContext());
+    painter->drawPixmap(dst, m_pixmap, src);
+    ctxt->restore();
+}
+
+}
diff --git a/WebCore/platform/graphics/qt/StillImageQt.h b/WebCore/platform/graphics/qt/StillImageQt.h
new file mode 100644 (file)
index 0000000..fc926e8
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2008 Holger Hans Peter Freyther
+ *
+ * All rights reserved.
+ *
+ * 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 StillImageQt_h
+#define StillImageQt_h
+
+#include "Image.h"
+
+namespace WebCore {
+
+    class StillImage : public Image {
+    public:
+        StillImage(const QPixmap& pixmap);
+
+        virtual IntSize size() const;
+        virtual QPixmap* getPixmap() const;
+        virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator);
+
+    private:
+        QPixmap m_pixmap;
+    };
+
+}
+
+#endif