[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andreas.kling at nokia.com andreas.kling at nokia.com
Wed Dec 22 11:18:09 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7fb296a5fd5b9385a49b0d66edbf7ca89f8fa782
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jul 17 03:23:11 2010 +0000

    2010-07-16  Andreas Kling  <andreas.kling at nokia.com>
    
            Reviewed by Oliver Hunt.
    
            QtWebkit creates an unnecessary deep copy of images when canvas drawing is done
            A https://bugs.webkit.org/show_bug.cgi?id=32530
    
            Solve this by adding ImageBuffer::imageForRendering() which returns an image
            that can be used for rendering now, but isn't a copy to be kept around.
    
            * platform/graphics/ImageBuffer.h:
            (WebCore::ImageBuffer::imageForRendering):
            * platform/graphics/qt/ImageBufferQt.cpp:
            (WebCore::ImageBuffer::imageForRendering): Added to provide an image that can
            be used for rendering now, but may change in the future.
            * platform/graphics/qt/StillImageQt.cpp:
            (WebCore::StillImage::StillImage):
            (WebCore::StillImage::~StillImage):
            (WebCore::StillImage::size):
            (WebCore::StillImage::nativeImageForCurrentFrame):
            (WebCore::StillImage::draw):
            * platform/graphics/qt/StillImageQt.h:
            (WebCore::StillImage::createForRendering): Added for use in
            ImageBuffer::imageForRendering(), provides a thin wrapper around a QPixmap*.
            * html/HTMLCanvasElement.cpp:
            (WebCore::HTMLCanvasElement::paint): Paint with ImageBuffer::imageForRendering()
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63606 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1dfa273..55667eb 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,33 @@
 
         Reviewed by Oliver Hunt.
 
+        QtWebkit creates an unnecessary deep copy of images when canvas drawing is done
+        A https://bugs.webkit.org/show_bug.cgi?id=32530
+
+        Solve this by adding ImageBuffer::imageForRendering() which returns an image
+        that can be used for rendering now, but isn't a copy to be kept around.
+
+        * platform/graphics/ImageBuffer.h:
+        (WebCore::ImageBuffer::imageForRendering):
+        * platform/graphics/qt/ImageBufferQt.cpp:
+        (WebCore::ImageBuffer::imageForRendering): Added to provide an image that can
+        be used for rendering now, but may change in the future.
+        * platform/graphics/qt/StillImageQt.cpp:
+        (WebCore::StillImage::StillImage):
+        (WebCore::StillImage::~StillImage):
+        (WebCore::StillImage::size):
+        (WebCore::StillImage::nativeImageForCurrentFrame):
+        (WebCore::StillImage::draw):
+        * platform/graphics/qt/StillImageQt.h:
+        (WebCore::StillImage::createForRendering): Added for use in
+        ImageBuffer::imageForRendering(), provides a thin wrapper around a QPixmap*.
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::paint): Paint with ImageBuffer::imageForRendering()
+
+2010-07-16  Andreas Kling  <andreas.kling at nokia.com>
+
+        Reviewed by Oliver Hunt.
+
         [Qt] Remove redundant logic in Path::addArcTo()
         https://bugs.webkit.org/show_bug.cgi?id=42494
 
diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp
index 6174f51..6b5a3a3 100644
--- a/WebCore/html/HTMLCanvasElement.cpp
+++ b/WebCore/html/HTMLCanvasElement.cpp
@@ -278,7 +278,7 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
     if (hasCreatedImageBuffer()) {
         ImageBuffer* imageBuffer = buffer();
         if (imageBuffer) {
-            Image* image = imageBuffer->image();
+            Image* image = imageBuffer->imageForRendering();
             if (image)
                 context->drawImage(image, DeviceColorSpace, r);
         }
diff --git a/WebCore/platform/graphics/ImageBuffer.h b/WebCore/platform/graphics/ImageBuffer.h
index 9f9ba7e..cb5d63f 100644
--- a/WebCore/platform/graphics/ImageBuffer.h
+++ b/WebCore/platform/graphics/ImageBuffer.h
@@ -74,6 +74,11 @@ namespace WebCore {
         GraphicsContext* context() const;
 
         Image* image() const;
+#if PLATFORM(QT)
+        Image* imageForRendering() const;
+#else
+        Image* imageForRendering() const { return image(); }
+#endif
 
         void clearImage() { m_image.clear(); }
 
diff --git a/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index a546def..043a8c5 100644
--- a/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -98,6 +98,14 @@ GraphicsContext* ImageBuffer::context() const
     return m_context.get();
 }
 
+Image* ImageBuffer::imageForRendering() const
+{
+    if (!m_image)
+        m_image = StillImage::createForRendering(&m_data.m_pixmap);
+
+    return m_image.get();
+}
+
 Image* ImageBuffer::image() const
 {
     if (!m_image) {
diff --git a/WebCore/platform/graphics/qt/StillImageQt.cpp b/WebCore/platform/graphics/qt/StillImageQt.cpp
index 4653c58..034234d 100644
--- a/WebCore/platform/graphics/qt/StillImageQt.cpp
+++ b/WebCore/platform/graphics/qt/StillImageQt.cpp
@@ -36,23 +36,35 @@
 namespace WebCore {
 
 StillImage::StillImage(const QPixmap& pixmap)
+    : m_pixmap(new QPixmap(pixmap))
+    , m_ownsPixmap(true)
+{}
+
+StillImage::StillImage(const QPixmap* pixmap)
     : m_pixmap(pixmap)
+    , m_ownsPixmap(false)
 {}
 
+StillImage::~StillImage()
+{
+    if (m_ownsPixmap)
+        delete m_pixmap;
+}
+
 IntSize StillImage::size() const
 {
-    return IntSize(m_pixmap.width(), m_pixmap.height());
+    return IntSize(m_pixmap->width(), m_pixmap->height());
 }
 
 NativeImagePtr StillImage::nativeImageForCurrentFrame()
 {
-    return const_cast<NativeImagePtr>(&m_pixmap);
+    return const_cast<NativeImagePtr>(m_pixmap);
 }
 
 void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
                       const FloatRect& src, ColorSpace, CompositeOperator op)
 {
-    if (m_pixmap.isNull())
+    if (m_pixmap->isNull())
         return;
 
     ctxt->save();
@@ -93,7 +105,7 @@ void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
     FloatRect dstM(dx, dy, dw, dh);
     QPainter* painter(ctxt->platformContext());
 
-    painter->drawPixmap(dstM, m_pixmap, srcM);
+    painter->drawPixmap(dstM, *m_pixmap, srcM);
     ctxt->restore();
 }
 
diff --git a/WebCore/platform/graphics/qt/StillImageQt.h b/WebCore/platform/graphics/qt/StillImageQt.h
index 7be9136..58071d9 100644
--- a/WebCore/platform/graphics/qt/StillImageQt.h
+++ b/WebCore/platform/graphics/qt/StillImageQt.h
@@ -39,6 +39,11 @@ namespace WebCore {
             return adoptRef(new StillImage(pixmap));
         }
 
+        static PassRefPtr<StillImage> createForRendering(const QPixmap* pixmap)
+        {
+            return adoptRef(new StillImage(pixmap));
+        }
+
         // FIXME: StillImages are underreporting decoded sizes and will be unable
         // to prune because these functions are not implemented yet.
         virtual void destroyDecodedData(bool destroyAll = true) { Q_UNUSED(destroyAll); }
@@ -50,8 +55,11 @@ namespace WebCore {
 
     private:
         StillImage(const QPixmap& pixmap);
+        StillImage(const QPixmap* pixmap);
+        ~StillImage();
         
-        QPixmap m_pixmap;
+        const QPixmap* m_pixmap;
+        bool m_ownsPixmap;
     };
 
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list