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

mrobinson at webkit.org mrobinson at webkit.org
Wed Dec 22 12:14:40 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit e3cf3060a613ab5ff96a9daec73883617116f3f2
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 17 19:05:02 2010 +0000

    2010-08-17  Martin Robinson  <mrobinson at igalia.com>
    
            Reviewed by David Hyatt.
    
            [Cairo] Remove unnecessary full-surface copies from ImageCairo and GraphicsContextCairo
            https://bugs.webkit.org/show_bug.cgi?id=44076
    
            No new tests as functionality has not changed.
    
            * GNUmakefile.am: Added GRefPtrCairo to the sources list.
            * platform/graphics/cairo/GRefPtrCairo.cpp: Added.
            (WTF::refGPtr): Added specializations for cairo_t and cairo_surface_t.
            (WTF::derefGPtr):
            * platform/graphics/cairo/GRefPtrCairo.h: Added.
            * platform/graphics/cairo/GraphicsContextCairo.cpp:
            (WebCore::GraphicsContext::createPlatformShadow): Access the image surface directly
            from the ImageBuffer instead of wrapping it in an Image.
            * platform/graphics/cairo/ImageCairo.cpp:
            (WebCore::Image::drawPattern): Create the temporary surface using cairo primitives
            instead of through the platform-independent WebCore code.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65530 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index de84981..2481b9f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,5 +1,26 @@
 2010-08-17  Martin Robinson  <mrobinson at igalia.com>
 
+        Reviewed by David Hyatt.
+
+        [Cairo] Remove unnecessary full-surface copies from ImageCairo and GraphicsContextCairo
+        https://bugs.webkit.org/show_bug.cgi?id=44076
+
+        No new tests as functionality has not changed.
+
+        * GNUmakefile.am: Added GRefPtrCairo to the sources list.
+        * platform/graphics/cairo/GRefPtrCairo.cpp: Added.
+        (WTF::refGPtr): Added specializations for cairo_t and cairo_surface_t.
+        (WTF::derefGPtr):
+        * platform/graphics/cairo/GRefPtrCairo.h: Added.
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::createPlatformShadow): Access the image surface directly
+        from the ImageBuffer instead of wrapping it in an Image.
+        * platform/graphics/cairo/ImageCairo.cpp:
+        (WebCore::Image::drawPattern): Create the temporary surface using cairo primitives
+        instead of through the platform-independent WebCore code.
+
+2010-08-17  Martin Robinson  <mrobinson at igalia.com>
+
         [GTK] Clean up WebCore/platform/graphics/gtk/ImageGtk.cpp
         https://bugs.webkit.org/show_bug.cgi?id=44069
 
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 729bee4..80a3cbc 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -2444,6 +2444,8 @@ webcoregtk_sources += \
 	WebCore/platform/graphics/cairo/FontPlatformData.h \
 	WebCore/platform/graphics/cairo/GOwnPtrCairo.cpp \
 	WebCore/platform/graphics/cairo/GOwnPtrCairo.h \
+	WebCore/platform/graphics/cairo/GRefPtrCairo.cpp \
+	WebCore/platform/graphics/cairo/GRefPtrCairo.h \
 	WebCore/platform/graphics/cairo/GradientCairo.cpp \
 	WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp \
 	WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h \
diff --git a/WebCore/platform/graphics/cairo/GRefPtrCairo.cpp b/WebCore/platform/graphics/cairo/GRefPtrCairo.cpp
new file mode 100644
index 0000000..d244954
--- /dev/null
+++ b/WebCore/platform/graphics/cairo/GRefPtrCairo.cpp
@@ -0,0 +1,52 @@
+/*
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "GRefPtrCairo.h"
+
+#include <cairo.h>
+
+namespace WTF {
+
+template <> cairo_t* refGPtr(cairo_t* ptr)
+{
+    if (ptr)
+        cairo_reference(ptr);
+    return ptr;
+}
+
+template <> void derefGPtr(cairo_t* ptr)
+{
+    if (ptr)
+        cairo_destroy(ptr);
+}
+
+template <> cairo_surface_t* refGPtr(cairo_surface_t* ptr)
+{
+    if (ptr)
+        cairo_surface_reference(ptr);
+    return ptr;
+}
+
+template <> void derefGPtr(cairo_surface_t* ptr)
+{
+    if (ptr)
+        cairo_surface_destroy(ptr);
+}
+
+}
diff --git a/WebCore/platform/graphics/cairo/GRefPtrCairo.h b/WebCore/platform/graphics/cairo/GRefPtrCairo.h
new file mode 100644
index 0000000..aef51fe
--- /dev/null
+++ b/WebCore/platform/graphics/cairo/GRefPtrCairo.h
@@ -0,0 +1,38 @@
+/*
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GRefPtrCairo_h
+#define GRefPtrCairo_h
+
+#include "GRefPtr.h"
+
+typedef struct _cairo cairo_t;
+typedef struct _cairo_surface cairo_surface_t;
+
+namespace WTF {
+
+template <> cairo_t* refGPtr(cairo_t* ptr);
+template <> void derefGPtr(cairo_t* ptr);
+
+template <> cairo_surface_t* refGPtr(cairo_surface_t* ptr);
+template <> void derefGPtr(cairo_surface_t* ptr);
+
+}
+
+#endif
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
index 3e62ee2..9b3096e 100644
--- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
@@ -928,8 +928,7 @@ void GraphicsContext::createPlatformShadow(PassOwnPtr<ImageBuffer> buffer, const
     // draw the shadow without blurring, if kernelSize is zero
     if (!kernelSize) {
         setColor(cr, shadowColor);
-        RefPtr<Image> copiedImage = buffer->copyImage(); // FIXME: Copying the image is wasteful.
-        cairo_mask_surface(cr, copiedImage->nativeImageForCurrentFrame(), shadowRect.x(), shadowRect.y());
+        cairo_mask_surface(cr, buffer->m_data.m_surface, shadowRect.x(), shadowRect.y());
         return;
     }
 
@@ -949,8 +948,7 @@ void GraphicsContext::createPlatformShadow(PassOwnPtr<ImageBuffer> buffer, const
     // Mask the filter with the shadow color and draw it to the context.
     // Masking makes it possible to just blur the alpha channel.
     setColor(cr, shadowColor);
-    RefPtr<Image> copiedImage = blur->resultImage()->copyImage(); // FIXME: Copying the image is wasteful.
-    cairo_mask_surface(cr, copiedImage->nativeImageForCurrentFrame(), shadowRect.x(), shadowRect.y());
+    cairo_mask_surface(cr, blur->resultImage()->m_data.m_surface, shadowRect.x(), shadowRect.y());
 #endif
 }
 
diff --git a/WebCore/platform/graphics/cairo/ImageCairo.cpp b/WebCore/platform/graphics/cairo/ImageCairo.cpp
index a8a86b9..1582671 100644
--- a/WebCore/platform/graphics/cairo/ImageCairo.cpp
+++ b/WebCore/platform/graphics/cairo/ImageCairo.cpp
@@ -33,6 +33,7 @@
 #include "AffineTransform.h"
 #include "Color.h"
 #include "FloatRect.h"
+#include "GRefPtrCairo.h"
 #include "GraphicsContext.h"
 #include "ImageBuffer.h"
 #include "ImageObserver.h"
@@ -184,18 +185,14 @@ void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, con
     cairo_t* cr = context->platformContext();
     context->save();
 
-    IntRect imageSize = enclosingIntRect(tileRect);
-    OwnPtr<ImageBuffer> imageSurface = ImageBuffer::create(imageSize.size());
-
-    if (!imageSurface)
-        return;
-
+    GRefPtr<cairo_surface_t> clippedImageSurface = 0;
     if (tileRect.size() != size()) {
-        cairo_t* clippedImageContext = imageSurface->context()->platformContext();
-        cairo_set_source_surface(clippedImageContext, image, -tileRect.x(), -tileRect.y());
-        cairo_paint(clippedImageContext);
-        RefPtr<Image> copiedImage = imageSurface->copyImage(); // FIXME: Copying here is wasteful.
-        image = copiedImage->nativeImageForCurrentFrame();
+        IntRect imageSize = enclosingIntRect(tileRect);
+        clippedImageSurface = adoptGRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, imageSize.width(), imageSize.height()));
+        GRefPtr<cairo_t> clippedImageContext(cairo_create(clippedImageSurface.get()));
+        cairo_set_source_surface(clippedImageContext.get(), image, -tileRect.x(), -tileRect.y());
+        cairo_paint(clippedImageContext.get());
+        image = clippedImageSurface.get();
     }
 
     cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list