<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160080] releases/WebKitGTK/webkit-2.2/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160080">160080</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-04 01:47:51 -0800 (Wed, 04 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/154819">r154819</a> - [cairo] canvas drawing on itself doesn't work with accelerated canvas
https://bugs.webkit.org/show_bug.cgi?id=118808

Reviewed by Martin Robinson.

Source/WebCore:

When copying an accelerated image, we try to get its dimensions with
cairo_image_surface_get_width/cairo_image_surface_get_height. As
surface is not an image, this returns width and height of 0.

Many other places use cairo_image_surface_get although the surface may
be a gl surface.

This patch fixes those issues by implementing a cairoSurfaceSize
helper that returns the surface size whatever type it is.

It use cairo_surface_create_similar instead of
cairo_image_surface_create in copyCairoImageSurface. It also calls
cairo_paint in encodeImage when a drawing over a black background is
needed.

It copies the surface to an image surface if needed in extractImage.

No new tests. Covered by existing tests.

* platform/graphics/cairo/BitmapImageCairo.cpp:
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::checkForSolidColor):
* platform/graphics/cairo/CairoUtilities.cpp:
(WebCore::copyCairoImageSurface):
(WebCore::cairoSurfaceSize):
* platform/graphics/cairo/CairoUtilities.h:
* platform/graphics/cairo/GraphicsContext3DCairo.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage):
* platform/graphics/gtk/GdkCairoUtilities.cpp:
(cairoSurfaceToGdkPixbuf):
* platform/graphics/gtk/GdkCairoUtilities.h:
* platform/graphics/gtk/ImageBufferGtk.cpp:
(WebCore::encodeImage):
* platform/graphics/gtk/ImageGtk.cpp:
(WebCore::BitmapImage::getGdkPixbuf):
* platform/gtk/DragIcon.cpp:
(WebCore::DragIcon::setImage):

Source/WebKit/gtk:

Change cairoImageSurfaceToGdkPixbuf to cairoSurfaceToGdkPixbuf.

* webkit/webkitfavicondatabase.cpp:
(getIconPixbufSynchronously):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.2/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicscairoBitmapImageCairocpp">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicscairoCairoUtilitiescpp">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicscairoCairoUtilitiesh">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/CairoUtilities.h</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicscairoGraphicsContext3DCairocpp">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicsgtkGdkCairoUtilitiescpp">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicsgtkGdkCairoUtilitiesh">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.h</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicsgtkImageBufferGtkcpp">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicsgtkImageGtkcpp">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebCoreplatformgtkDragIconcpp">releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/gtk/DragIcon.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebKitgtkChangeLog">releases/WebKitGTK/webkit-2.2/Source/WebKit/gtk/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebKitgtkwebkitwebkitfavicondatabasecpp">releases/WebKitGTK/webkit-2.2/Source/WebKit/gtk/webkit/webkitfavicondatabase.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit22SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/ChangeLog (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/ChangeLog        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/ChangeLog        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2013-08-29  Arnaud Renevier  &lt;a.renevier@samsung.com&gt;
+
+        [cairo] canvas drawing on itself doesn't work with accelerated canvas
+        https://bugs.webkit.org/show_bug.cgi?id=118808
+
+        Reviewed by Martin Robinson.
+
+        When copying an accelerated image, we try to get its dimensions with
+        cairo_image_surface_get_width/cairo_image_surface_get_height. As
+        surface is not an image, this returns width and height of 0.
+
+        Many other places use cairo_image_surface_get although the surface may
+        be a gl surface. 
+        
+        This patch fixes those issues by implementing a cairoSurfaceSize
+        helper that returns the surface size whatever type it is.
+
+        It use cairo_surface_create_similar instead of
+        cairo_image_surface_create in copyCairoImageSurface. It also calls
+        cairo_paint in encodeImage when a drawing over a black background is
+        needed.
+
+        It copies the surface to an image surface if needed in extractImage.
+
+        No new tests. Covered by existing tests.
+
+        * platform/graphics/cairo/BitmapImageCairo.cpp:
+        (WebCore::BitmapImage::BitmapImage):
+        (WebCore::BitmapImage::draw):
+        (WebCore::BitmapImage::checkForSolidColor):
+        * platform/graphics/cairo/CairoUtilities.cpp:
+        (WebCore::copyCairoImageSurface):
+        (WebCore::cairoSurfaceSize):
+        * platform/graphics/cairo/CairoUtilities.h:
+        * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
+        (WebCore::GraphicsContext3D::ImageExtractor::extractImage):
+        * platform/graphics/gtk/GdkCairoUtilities.cpp:
+        (cairoSurfaceToGdkPixbuf):
+        * platform/graphics/gtk/GdkCairoUtilities.h:
+        * platform/graphics/gtk/ImageBufferGtk.cpp:
+        (WebCore::encodeImage):
+        * platform/graphics/gtk/ImageGtk.cpp:
+        (WebCore::BitmapImage::getGdkPixbuf):
+        * platform/gtk/DragIcon.cpp:
+        (WebCore::DragIcon::setImage):
+
</ins><span class="cx"> 2013-12-02  Andres Gomez  &lt;agomez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Fails to build with freetype 2.5.1
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicscairoBitmapImageCairocpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;BitmapImage.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CairoUtilities.h&quot;
</ins><span class="cx"> #include &quot;ImageObserver.h&quot;
</span><span class="cx"> #include &quot;PlatformContextCairo.h&quot;
</span><span class="cx"> #include &lt;cairo.h&gt;
</span><span class="lines">@@ -36,6 +37,7 @@
</span><span class="cx"> 
</span><span class="cx"> BitmapImage::BitmapImage(PassRefPtr&lt;cairo_surface_t&gt; nativeImage, ImageObserver* observer)
</span><span class="cx">     : Image(observer)
</span><ins>+    , m_size(cairoSurfaceSize(nativeImage.get()))
</ins><span class="cx">     , m_currentFrame(0)
</span><span class="cx">     , m_frames(0)
</span><span class="cx">     , m_frameTimer(0)
</span><span class="lines">@@ -52,10 +54,7 @@
</span><span class="cx">     , m_sizeAvailable(true)
</span><span class="cx">     , m_haveFrameCount(true)
</span><span class="cx"> {
</span><del>-    int width = cairo_image_surface_get_width(nativeImage.get());
-    int height = cairo_image_surface_get_height(nativeImage.get());
-    m_decodedSize = width * height * 4;
-    m_size = IntSize(width, height);
</del><ins>+    m_decodedSize = m_size.width() * m_size.height() * 4;
</ins><span class="cx"> 
</span><span class="cx">     m_frames.grow(1);
</span><span class="cx">     m_frames[0].m_hasAlpha = cairo_surface_get_content(nativeImage.get()) != CAIRO_CONTENT_COLOR;
</span><span class="lines">@@ -95,7 +94,7 @@
</span><span class="cx">         context-&gt;setCompositeOperation(op, blendMode);
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
</span><del>-    IntSize scaledSize(cairo_image_surface_get_width(surface.get()), cairo_image_surface_get_height(surface.get()));
</del><ins>+    IntSize scaledSize = cairoSurfaceSize(surface.get());
</ins><span class="cx">     FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(src, scaledSize);
</span><span class="cx"> #else
</span><span class="cx">     FloatRect adjustedSrcRect(src);
</span><span class="lines">@@ -139,12 +138,12 @@
</span><span class="cx">     if (!surface) // If it's too early we won't have an image yet.
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ASSERT(cairo_surface_get_type(surface.get()) == CAIRO_SURFACE_TYPE_IMAGE);
</del><ins>+    if (cairo_surface_get_type(surface.get()) != CAIRO_SURFACE_TYPE_IMAGE)
+        return;
</ins><span class="cx"> 
</span><del>-    int width = cairo_image_surface_get_width(surface.get());
-    int height = cairo_image_surface_get_height(surface.get());
</del><ins>+    IntSize size = cairoSurfaceSize(surface.get());
</ins><span class="cx"> 
</span><del>-    if (width != 1 || height != 1)
</del><ins>+    if (size.width() != 1 || size.height() != 1)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     unsigned* pixelColor = reinterpret_cast_ptr&lt;unsigned*&gt;(cairo_image_surface_get_data(surface.get()));
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicscairoCairoUtilitiescpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -38,6 +38,10 @@
</span><span class="cx"> #include &quot;RefPtrCairo.h&quot;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><ins>+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include &lt;cairo-gl.h&gt;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr)
</span><span class="lines">@@ -214,9 +218,9 @@
</span><span class="cx">     // Cairo doesn't provide a way to copy a cairo_surface_t.
</span><span class="cx">     // See http://lists.cairographics.org/archives/cairo/2007-June/010877.html
</span><span class="cx">     // Once cairo provides the way, use the function instead of this.
</span><del>-    RefPtr&lt;cairo_surface_t&gt; newSurface = adoptRef(cairo_image_surface_create(cairo_image_surface_get_format(originalSurface), 
-                                                                             cairo_image_surface_get_width(originalSurface),
-                                                                             cairo_image_surface_get_height(originalSurface)));
</del><ins>+    IntSize size = cairoSurfaceSize(originalSurface);
+    RefPtr&lt;cairo_surface_t&gt; newSurface = adoptRef(cairo_surface_create_similar(originalSurface,
+        cairo_surface_get_content(originalSurface), size.width(), size.height()));
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;cairo_t&gt; cr = adoptRef(cairo_create(newSurface.get()));
</span><span class="cx">     cairo_set_source_surface(cr.get(), originalSurface, 0, 0);
</span><span class="lines">@@ -240,4 +244,19 @@
</span><span class="cx">     copyRectFromCairoSurfaceToContext(from, context.get(), sourceOffset, rect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+IntSize cairoSurfaceSize(cairo_surface_t* surface)
+{
+    switch (cairo_surface_get_type(surface)) {
+    case CAIRO_SURFACE_TYPE_IMAGE:
+        return IntSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    case CAIRO_SURFACE_TYPE_GL:
+        return IntSize(cairo_gl_surface_get_width(surface), cairo_gl_surface_get_height(surface));
+#endif
+    default:
+        ASSERT_NOT_REACHED();
+        return IntSize();
+    }
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicscairoCairoUtilitiesh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/CairoUtilities.h (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/CairoUtilities.h        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/CairoUtilities.h        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx"> void copyRectFromCairoSurfaceToContext(cairo_surface_t* from, cairo_t* to, const IntSize&amp; offset, const IntRect&amp;);
</span><span class="cx"> void copyRectFromOneSurfaceToAnother(cairo_surface_t* from, cairo_surface_t* to, const IntSize&amp; offset, const IntRect&amp;, const IntSize&amp; = IntSize(), cairo_operator_t = CAIRO_OPERATOR_OVER);
</span><span class="cx"> 
</span><ins>+IntSize cairoSurfaceSize(cairo_surface_t*);
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // CairoUtilities_h
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicscairoGraphicsContext3DCairocpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(3D_GRAPHICS)
</span><span class="cx"> 
</span><ins>+#include &quot;CairoUtilities.h&quot;
</ins><span class="cx"> #include &quot;GraphicsContext3DPrivate.h&quot;
</span><span class="cx"> #include &quot;Image.h&quot;
</span><span class="cx"> #include &quot;ImageSource.h&quot;
</span><span class="lines">@@ -201,13 +202,23 @@
</span><span class="cx">         // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to false.
</span><span class="cx">         if (!premultiplyAlpha &amp;&amp; m_imageHtmlDomSource != HtmlDomVideo)
</span><span class="cx">             m_alphaOp = AlphaDoUnmultiply;
</span><ins>+
+        // if m_imageSurface is not an image, extract a copy of the surface
+        if (m_imageSurface &amp;&amp; cairo_surface_get_type(m_imageSurface.get()) != CAIRO_SURFACE_TYPE_IMAGE) {
+            RefPtr&lt;cairo_surface_t&gt; tmpSurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, m_imageWidth, m_imageHeight));
+            copyRectFromOneSurfaceToAnother(m_imageSurface.get(), tmpSurface.get(), IntSize(), IntRect(0, 0, m_imageWidth, m_imageHeight), IntSize(), CAIRO_OPERATOR_SOURCE);
+            m_imageSurface = tmpSurface.release();
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!m_imageSurface)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    m_imageWidth = cairo_image_surface_get_width(m_imageSurface.get());
-    m_imageHeight = cairo_image_surface_get_height(m_imageSurface.get());
</del><ins>+    ASSERT(cairo_surface_get_type(m_imageSurface.get()) == CAIRO_SURFACE_TYPE_IMAGE);
+
+    IntSize imageSize = cairoSurfaceSize(m_imageSurface.get());
+    m_imageWidth = imageSize.width();
+    m_imageHeight = imageSize.height();
</ins><span class="cx">     if (!m_imageWidth || !m_imageHeight)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicsgtkGdkCairoUtilitiescpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -24,16 +24,19 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><ins>+#include &quot;CairoUtilities.h&quot;
+
</ins><span class="cx"> #include &quot;GdkCairoUtilities.h&quot;
</span><span class="cx"> #include &quot;GtkVersioning.h&quot;
</span><del>-
</del><ins>+#include &quot;IntSize.h&quot;
</ins><span class="cx"> #include &lt;cairo.h&gt;
</span><span class="cx"> #include &lt;gtk/gtk.h&gt;
</span><span class="cx"> 
</span><del>-GdkPixbuf* cairoImageSurfaceToGdkPixbuf(cairo_surface_t* surface)
</del><ins>+using namespace WebCore;
+
+GdkPixbuf* cairoSurfaceToGdkPixbuf(cairo_surface_t* surface)
</ins><span class="cx"> {
</span><del>-    return gdk_pixbuf_get_from_surface(surface, 0, 0,
-                                       cairo_image_surface_get_width(surface),
-                                       cairo_image_surface_get_height(surface));
</del><ins>+    IntSize size = cairoSurfaceSize(surface);
+    return gdk_pixbuf_get_from_surface(surface, 0, 0, size.width(), size.height());
</ins><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicsgtkGdkCairoUtilitiesh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.h (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.h        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.h        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -26,6 +26,6 @@
</span><span class="cx"> #ifndef GdkCairoUtilities_h
</span><span class="cx"> #define GdkCairoUtilities_h
</span><span class="cx"> 
</span><del>-GdkPixbuf* cairoImageSurfaceToGdkPixbuf(cairo_surface_t* surface);
</del><ins>+GdkPixbuf* cairoSurfaceToGdkPixbuf(cairo_surface_t*);
</ins><span class="cx"> 
</span><span class="cx"> #endif // GdkCairoUtilities_h
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicsgtkImageBufferGtkcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -19,6 +19,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;ImageBuffer.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CairoUtilities.h&quot;
</ins><span class="cx"> #include &quot;GdkCairoUtilities.h&quot;
</span><span class="cx"> #include &lt;wtf/gobject/GOwnPtr.h&gt;
</span><span class="cx"> #include &quot;GRefPtrGtk.h&quot;
</span><span class="lines">@@ -44,14 +45,23 @@
</span><span class="cx">     if (type == &quot;jpeg&quot;) {
</span><span class="cx">         // JPEG doesn't support alpha channel. The &lt;canvas&gt; spec states that toDataURL() must encode a Porter-Duff
</span><span class="cx">         // composite source-over black for image types that do not support alpha.
</span><del>-        RefPtr&lt;cairo_surface_t&gt; newSurface = adoptRef(cairo_image_surface_create_for_data(cairo_image_surface_get_data(surface),
-                                                                                          CAIRO_FORMAT_RGB24,
-                                                                                          cairo_image_surface_get_width(surface),
-                                                                                          cairo_image_surface_get_height(surface),
-                                                                                          cairo_image_surface_get_stride(surface)));
-        pixbuf = adoptGRef(cairoImageSurfaceToGdkPixbuf(newSurface.get()));
</del><ins>+        RefPtr&lt;cairo_surface_t&gt; newSurface;
+        if (cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE) {
+            newSurface = adoptRef(cairo_image_surface_create_for_data(cairo_image_surface_get_data(surface),
+                CAIRO_FORMAT_RGB24,
+                cairo_image_surface_get_width(surface),
+                cairo_image_surface_get_height(surface),
+                cairo_image_surface_get_stride(surface)));
+        } else {
+            IntSize size = cairoSurfaceSize(surface);
+            newSurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_RGB24, size.width(), size.height()));
+            RefPtr&lt;cairo_t&gt; cr = adoptRef(cairo_create(newSurface.get()));
+            cairo_set_source_surface(cr.get(), surface, 0, 0);
+            cairo_paint(cr.get());
+        }
+        pixbuf = adoptGRef(cairoSurfaceToGdkPixbuf(newSurface.get()));
</ins><span class="cx">     } else
</span><del>-        pixbuf = adoptGRef(cairoImageSurfaceToGdkPixbuf(surface));
</del><ins>+        pixbuf = adoptGRef(cairoSurfaceToGdkPixbuf(surface));
</ins><span class="cx">     if (!pixbuf)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgraphicsgtkImageGtkcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx"> GdkPixbuf* BitmapImage::getGdkPixbuf()
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;cairo_surface_t&gt; surface = nativeImageForCurrentFrame();
</span><del>-    return surface ? cairoImageSurfaceToGdkPixbuf(surface.get()) : 0;
</del><ins>+    return surface ? cairoSurfaceToGdkPixbuf(surface.get()) : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebCoreplatformgtkDragIconcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/gtk/DragIcon.cpp (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/gtk/DragIcon.cpp        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebCore/platform/gtk/DragIcon.cpp        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #ifdef GTK_API_VERSION_2
</span><del>-    m_pixbuf = adoptGRef(cairoImageSurfaceToGdkPixbuf(image));
</del><ins>+    m_pixbuf = adoptGRef(cairoSurfaceToGdkPixbuf(image));
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebKitgtkChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit/gtk/ChangeLog (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebKit/gtk/ChangeLog        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit/gtk/ChangeLog        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2013-08-29  Arnaud Renevier  &lt;a.renevier@samsung.com&gt;
+
+        [cairo] canvas drawing on itself doesn't work with accelerated canvas
+        https://bugs.webkit.org/show_bug.cgi?id=118808
+
+        Reviewed by Martin Robinson.
+
+        Change cairoImageSurfaceToGdkPixbuf to cairoSurfaceToGdkPixbuf.
+
+        * webkit/webkitfavicondatabase.cpp:
+        (getIconPixbufSynchronously):
+
</ins><span class="cx"> 2013-12-02  Gustavo Noronha Silva  &lt;gustavo.noronha@collabora.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] GTK2 paint code path does not render AC layers
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebKitgtkwebkitwebkitfavicondatabasecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit/gtk/webkit/webkitfavicondatabase.cpp (160079 => 160080)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebKit/gtk/webkit/webkitfavicondatabase.cpp        2013-12-04 09:30:03 UTC (rev 160079)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit/gtk/webkit/webkitfavicondatabase.cpp        2013-12-04 09:47:51 UTC (rev 160080)
</span><span class="lines">@@ -396,7 +396,7 @@
</span><span class="cx">     if (!surface)
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    GRefPtr&lt;GdkPixbuf&gt; pixbuf = adoptGRef(cairoImageSurfaceToGdkPixbuf(surface.get()));
</del><ins>+    GRefPtr&lt;GdkPixbuf&gt; pixbuf = adoptGRef(cairoSurfaceToGdkPixbuf(surface.get()));
</ins><span class="cx">     if (!pixbuf)
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>