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

alex at webkit.org alex at webkit.org
Wed Dec 22 13:37:27 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 1cb4b6f4d9968a54fc028ac16402cf37dc727829
Author: alex at webkit.org <alex at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 21 20:21:27 2010 +0000

    2010-09-21  Alejandro G. Castro  <alex at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [gtk] Move copyContextProperties outside the GraphicsContextCairo
            https://bugs.webkit.org/show_bug.cgi?id=46179.
    
            Moved the copyContextProperties function to the CairoUtilities so
            we can use it outside GraphicsContextCairo. We moved also the old
            gtk CairoUtilities file to GdkCairoUtilities and added the new
            file in the cairo directory.
    
            * GNUmakefile.am:
            * platform/graphics/cairo/CairoUtilities.cpp: Added.
            (WebCore::copyContextProperties):
            * platform/graphics/cairo/CairoUtilities.h: Added.
            * platform/graphics/cairo/GraphicsContextCairo.cpp:
            * platform/graphics/gtk/CairoUtilities.cpp: Removed.
            * platform/graphics/gtk/CairoUtilities.h: Removed.
            * platform/graphics/gtk/GdkCairoUtilities.cpp: Added.
            (getCairoSurfacePixel):
            (getGdkPixbufPixel):
            (cairoImageSurfaceToGdkPixbuf):
            * platform/graphics/gtk/GdkCairoUtilities.h: Added.
            * platform/graphics/gtk/ImageBufferGtk.cpp:
            * platform/graphics/gtk/ImageGtk.cpp:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67981 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index acdddcb..6e4e825 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2010-09-21  Alejandro G. Castro  <alex at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [gtk] Move copyContextProperties outside the GraphicsContextCairo
+        https://bugs.webkit.org/show_bug.cgi?id=46179.
+
+        Moved the copyContextProperties function to the CairoUtilities so
+        we can use it outside GraphicsContextCairo. We moved also the old
+        gtk CairoUtilities file to GdkCairoUtilities and added the new
+        file in the cairo directory.
+
+        * GNUmakefile.am:
+        * platform/graphics/cairo/CairoUtilities.cpp: Added.
+        (WebCore::copyContextProperties):
+        * platform/graphics/cairo/CairoUtilities.h: Added.
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        * platform/graphics/gtk/CairoUtilities.cpp: Removed.
+        * platform/graphics/gtk/CairoUtilities.h: Removed.
+        * platform/graphics/gtk/GdkCairoUtilities.cpp: Added.
+        (getCairoSurfacePixel):
+        (getGdkPixbufPixel):
+        (cairoImageSurfaceToGdkPixbuf):
+        * platform/graphics/gtk/GdkCairoUtilities.h: Added.
+        * platform/graphics/gtk/ImageBufferGtk.cpp:
+        * platform/graphics/gtk/ImageGtk.cpp:
+
 2010-09-21  Vangelis Kokkevis  <vangelis at chromium.org>
 
         Reviewed by James Robinson.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 62d4c33..28204d0 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -3354,6 +3354,8 @@ webcoregtk_sources += \
 	WebCore/page/gtk/EventHandlerGtk.cpp \
 	WebCore/page/gtk/FrameGtk.cpp \
 	WebCore/platform/graphics/cairo/CairoPath.h \
+	WebCore/platform/graphics/cairo/CairoUtilities.cpp \
+	WebCore/platform/graphics/cairo/CairoUtilities.h \
 	WebCore/platform/graphics/cairo/FontCairo.cpp \
 	WebCore/platform/graphics/cairo/FontCustomPlatformData.h \
 	WebCore/platform/graphics/cairo/FontPlatformData.h \
@@ -3386,10 +3388,10 @@ webcoregtk_sources += \
 	WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.h \
 	WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp \
 	WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.h \
-	WebCore/platform/graphics/gtk/CairoUtilities.cpp \
-	WebCore/platform/graphics/gtk/CairoUtilities.h \
 	WebCore/platform/graphics/gtk/ColorGtk.cpp \
 	WebCore/platform/graphics/gtk/FontGtk.cpp \
+	WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp \
+	WebCore/platform/graphics/gtk/GdkCairoUtilities.h \
 	WebCore/platform/graphics/gtk/IconGtk.cpp \
 	WebCore/platform/graphics/gtk/ImageBufferGtk.cpp \
 	WebCore/platform/graphics/gtk/ImageGtk.cpp \
diff --git a/WebCore/platform/graphics/cairo/CairoUtilities.cpp b/WebCore/platform/graphics/cairo/CairoUtilities.cpp
new file mode 100644
index 0000000..34b4482
--- /dev/null
+++ b/WebCore/platform/graphics/cairo/CairoUtilities.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * 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 "CairoUtilities.h"
+
+#include <cairo.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr)
+{
+    cairo_set_antialias(dstCr, cairo_get_antialias(srcCr));
+
+    size_t dashCount = cairo_get_dash_count(srcCr);
+    Vector<double> dashes(dashCount);
+
+    double offset;
+    cairo_get_dash(srcCr, dashes.data(), &offset);
+    cairo_set_dash(dstCr, dashes.data(), dashCount, offset);
+    cairo_set_line_cap(dstCr, cairo_get_line_cap(srcCr));
+    cairo_set_line_join(dstCr, cairo_get_line_join(srcCr));
+    cairo_set_line_width(dstCr, cairo_get_line_width(srcCr));
+    cairo_set_miter_limit(dstCr, cairo_get_miter_limit(srcCr));
+    cairo_set_fill_rule(dstCr, cairo_get_fill_rule(srcCr));
+}
+
+} // namespace WebCore
+
diff --git a/WebCore/platform/graphics/cairo/CairoUtilities.h b/WebCore/platform/graphics/cairo/CairoUtilities.h
new file mode 100644
index 0000000..2efe9ea
--- /dev/null
+++ b/WebCore/platform/graphics/cairo/CairoUtilities.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * 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 CairoUtilities_h
+#define CairoUtilities_h
+
+typedef struct _cairo cairo_t;
+
+namespace WebCore {
+
+void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr);
+} // namespace WebCore
+
+#endif // CairoUtilities_h
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
index 5de7e1f..4174892 100644
--- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
@@ -35,6 +35,7 @@
 
 #include "AffineTransform.h"
 #include "CairoPath.h"
+#include "CairoUtilities.h"
 #include "FEGaussianBlur.h"
 #include "FloatRect.h"
 #include "Font.h"
@@ -131,23 +132,6 @@ static inline void fillRectSourceOver(cairo_t* cr, const FloatRect& rect, const
     cairo_fill(cr);
 }
 
-static inline void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr)
-{
-    cairo_set_antialias(dstCr, cairo_get_antialias(srcCr));
-
-    size_t dashCount = cairo_get_dash_count(srcCr);
-    Vector<double> dashes(dashCount);
-
-    double offset;
-    cairo_get_dash(srcCr, dashes.data(), &offset);
-    cairo_set_dash(dstCr, dashes.data(), dashCount, offset);
-    cairo_set_line_cap(dstCr, cairo_get_line_cap(srcCr));
-    cairo_set_line_join(dstCr, cairo_get_line_join(srcCr));
-    cairo_set_line_width(dstCr, cairo_get_line_width(srcCr));
-    cairo_set_miter_limit(dstCr, cairo_get_miter_limit(srcCr));
-    cairo_set_fill_rule(dstCr, cairo_get_fill_rule(srcCr));
-}
-
 static void appendPathToCairoContext(cairo_t* to, cairo_t* from)
 {
     cairo_path_t* cairoPath = cairo_copy_path(from);
diff --git a/WebCore/platform/graphics/gtk/CairoUtilities.cpp b/WebCore/platform/graphics/gtk/CairoUtilities.cpp
deleted file mode 100644
index 81e00f0..0000000
--- a/WebCore/platform/graphics/gtk/CairoUtilities.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2010 Igalia S.L.
- *
- * 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 "CairoUtilities.h"
-
-#include <cairo.h>
-#include <gtk/gtk.h>
-
-static inline unsigned char* getCairoSurfacePixel(unsigned char* data, unsigned x, unsigned y, unsigned rowStride)
-{
-    return data + (y * rowStride) + x * 4;
-}
-
-static inline guchar* getGdkPixbufPixel(guchar* data, unsigned x, unsigned y, unsigned rowStride)
-{
-    return data + (y * rowStride) + x * 4;
-}
-
-GdkPixbuf* cairoImageSurfaceToGdkPixbuf(cairo_surface_t* surface)
-{
-    int width = cairo_image_surface_get_width(surface);
-    int height = cairo_image_surface_get_height(surface);
-    unsigned char* surfaceData = cairo_image_surface_get_data(surface);
-    int surfaceRowStride = cairo_image_surface_get_stride(surface);
-
-    GdkPixbuf* dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
-    if (!dest)
-        return 0;
-
-    guchar* pixbufData = gdk_pixbuf_get_pixels(dest);
-    int pixbufRowStride = gdk_pixbuf_get_rowstride(dest);
-
-    /* From: http://cairographics.org/manual/cairo-image-surface.html#cairo-format-t
-     * "CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with alpha in
-     * the upper 8 bits, then red, then green, then blue. The 32-bit
-     * quantities are stored native-endian. Pre-multiplied alpha is used.
-     * (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)"
-     *
-     * See http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf
-     * for information on the structure of GdkPixbufs stored with GDK_COLORSPACE_RGB.
-     *
-     * RGB color channels in CAIRO_FORMAT_ARGB32 are stored based on the
-     * endianness of the machine and are also multiplied by the alpha channel.
-     * To properly transfer the data from the Cairo surface we must divide each
-     * of the RGB channels by the alpha channel and then reorder all channels
-     * if this machine is little-endian.
-     */
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++) {
-            unsigned char* source = getCairoSurfacePixel(surfaceData, x, y, surfaceRowStride);
-            guchar* dest = getGdkPixbufPixel(pixbufData, x, y, pixbufRowStride);
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-            guchar alpha = source[3];
-            dest[0] = alpha ? ((source[2] * 255) / alpha) : 0;
-            dest[1] = alpha ? ((source[1] * 255) / alpha) : 0;
-            dest[2] = alpha ? ((source[0] * 255) / alpha) : 0;
-            dest[3] = alpha;
-#else
-            guchar alpha = source[0];
-            dest[0] = alpha ? ((source[1] * 255) / alpha) : 0;
-            dest[1] = alpha ? ((source[2] * 255) / alpha) : 0;
-            dest[2] = alpha ? ((source[3] * 255) / alpha) : 0;
-            dest[3] = alpha;
-#endif
-        }
-    }
-
-    return dest;
-}
-
diff --git a/WebCore/platform/graphics/gtk/CairoUtilities.h b/WebCore/platform/graphics/gtk/CairoUtilities.h
deleted file mode 100644
index 594abc0..0000000
--- a/WebCore/platform/graphics/gtk/CairoUtilities.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2010 Igalia S.L.
- *
- * 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 CairoUtilities_h
-#define CairoUtilities_h
-
-GdkPixbuf* cairoImageSurfaceToGdkPixbuf(cairo_surface_t* surface);
-
-#endif // CairoUtilities_h
diff --git a/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp b/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp
new file mode 100644
index 0000000..d768ce2
--- /dev/null
+++ b/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * 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 "GdkCairoUtilities.h"
+
+#include <cairo.h>
+#include <gtk/gtk.h>
+
+static inline unsigned char* getCairoSurfacePixel(unsigned char* data, unsigned x, unsigned y, unsigned rowStride)
+{
+    return data + (y * rowStride) + x * 4;
+}
+
+static inline guchar* getGdkPixbufPixel(guchar* data, unsigned x, unsigned y, unsigned rowStride)
+{
+    return data + (y * rowStride) + x * 4;
+}
+
+GdkPixbuf* cairoImageSurfaceToGdkPixbuf(cairo_surface_t* surface)
+{
+    int width = cairo_image_surface_get_width(surface);
+    int height = cairo_image_surface_get_height(surface);
+    unsigned char* surfaceData = cairo_image_surface_get_data(surface);
+    int surfaceRowStride = cairo_image_surface_get_stride(surface);
+
+    GdkPixbuf* dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+    if (!dest)
+        return 0;
+
+    guchar* pixbufData = gdk_pixbuf_get_pixels(dest);
+    int pixbufRowStride = gdk_pixbuf_get_rowstride(dest);
+
+    /* From: http://cairographics.org/manual/cairo-image-surface.html#cairo-format-t
+     * "CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with alpha in
+     * the upper 8 bits, then red, then green, then blue. The 32-bit
+     * quantities are stored native-endian. Pre-multiplied alpha is used.
+     * (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)"
+     *
+     * See http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf
+     * for information on the structure of GdkPixbufs stored with GDK_COLORSPACE_RGB.
+     *
+     * RGB color channels in CAIRO_FORMAT_ARGB32 are stored based on the
+     * endianness of the machine and are also multiplied by the alpha channel.
+     * To properly transfer the data from the Cairo surface we must divide each
+     * of the RGB channels by the alpha channel and then reorder all channels
+     * if this machine is little-endian.
+     */
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++) {
+            unsigned char* source = getCairoSurfacePixel(surfaceData, x, y, surfaceRowStride);
+            guchar* dest = getGdkPixbufPixel(pixbufData, x, y, pixbufRowStride);
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+            guchar alpha = source[3];
+            dest[0] = alpha ? ((source[2] * 255) / alpha) : 0;
+            dest[1] = alpha ? ((source[1] * 255) / alpha) : 0;
+            dest[2] = alpha ? ((source[0] * 255) / alpha) : 0;
+            dest[3] = alpha;
+#else
+            guchar alpha = source[0];
+            dest[0] = alpha ? ((source[1] * 255) / alpha) : 0;
+            dest[1] = alpha ? ((source[2] * 255) / alpha) : 0;
+            dest[2] = alpha ? ((source[3] * 255) / alpha) : 0;
+            dest[3] = alpha;
+#endif
+        }
+    }
+
+    return dest;
+}
+
diff --git a/WebCore/platform/graphics/gtk/GdkCairoUtilities.h b/WebCore/platform/graphics/gtk/GdkCairoUtilities.h
new file mode 100644
index 0000000..ff5b3ed
--- /dev/null
+++ b/WebCore/platform/graphics/gtk/GdkCairoUtilities.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * 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 GdkCairoUtilities_h
+#define GdkCairoUtilities_h
+
+GdkPixbuf* cairoImageSurfaceToGdkPixbuf(cairo_surface_t* surface);
+
+#endif // GdkCairoUtilities_h
diff --git a/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp b/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
index 821cc12..edb26f0 100644
--- a/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
+++ b/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
@@ -21,7 +21,7 @@
 #include "ImageBuffer.h"
 
 #include "Base64.h"
-#include "CairoUtilities.h"
+#include "GdkCairoUtilities.h"
 #include "GOwnPtr.h"
 #include "GRefPtrGtk.h"
 #include "MIMETypeRegistry.h"
diff --git a/WebCore/platform/graphics/gtk/ImageGtk.cpp b/WebCore/platform/graphics/gtk/ImageGtk.cpp
index 5272243..623ace6 100644
--- a/WebCore/platform/graphics/gtk/ImageGtk.cpp
+++ b/WebCore/platform/graphics/gtk/ImageGtk.cpp
@@ -26,7 +26,7 @@
 #include "config.h"
 
 #include "BitmapImage.h"
-#include "CairoUtilities.h"
+#include "GdkCairoUtilities.h"
 #include "GOwnPtrGtk.h"
 #include "SharedBuffer.h"
 #include <wtf/text/CString.h>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list