<!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>[175159] trunk/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/175159">175159</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-10-23 23:58:13 -0700 (Thu, 23 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK][Cairo] Remove GTK dependency of WidgetBackingStoreGtkX11
https://bugs.webkit.org/show_bug.cgi?id=138004

Reviewed by Gustavo Noronha Silva.

Source/WebCore:

Rename all WidgetBackingStore* classes as
BackingStoreBackendCairo* since all of them are actually
BackingStore backends based on cairo, and move them from
platform/cairo and platform/gtk to platform/graphics/cairo.
BackingStoreBackendCairo is the base class that contains common
members like the surface and size. BackingStoreBackendCairoImpl is
the implementation using only cairo, and BackingStoreBackendCairoX11
using xlib. BackingStoreBackendCairoX11 receives all the X11
information it needs as constructor parameters, instead of using a
GtkWidget and GTK+ X11 API. BackingStoreBackendCairoImpl receives
the surface already created as constructor parameter, so that it
doesn't have any platform specific code now.

* PlatformEfl.cmake: Update compilation files.
* PlatformGTK.cmake: Ditto.
* platform/cairo/WidgetBackingStoreCairo.cpp: Removed.
* platform/graphics/cairo/BackingStoreBackendCairo.h: Renamed from Source/WebCore/platform/cairo/WidgetBackingStore.h.
(WebCore::BackingStoreBackendCairo::~BackingStoreBackendCairo):
(WebCore::BackingStoreBackendCairo::surface):
(WebCore::BackingStoreBackendCairo::size):
(WebCore::BackingStoreBackendCairo::BackingStoreBackendCairo):
* platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp: Added.
(WebCore::BackingStoreBackendCairoImpl::BackingStoreBackendCairoImpl):
(WebCore::BackingStoreBackendCairoImpl::~BackingStoreBackendCairoImpl):
(WebCore::BackingStoreBackendCairoImpl::scroll):
* platform/graphics/cairo/BackingStoreBackendCairoImpl.h: Renamed from Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h.
* platform/graphics/cairo/BackingStoreBackendCairoX11.cpp: Renamed from Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp.
(WebCore::BackingStoreBackendCairoX11::BackingStoreBackendCairoX11):
(WebCore::BackingStoreBackendCairoX11::~BackingStoreBackendCairoX11):
(WebCore::BackingStoreBackendCairoX11::scroll):
* platform/graphics/cairo/BackingStoreBackendCairoX11.h: Renamed from Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h.
* platform/graphics/cairo/CairoUtilities.cpp:
(WebCore::cairoSurfaceGetDeviceScale):
* platform/graphics/cairo/CairoUtilities.h:

Source/WebKit2:

* UIProcess/BackingStore.h: Rename m_backingStore as m_backend,
since it's a bit confusing that a BackingStore class has a
m_backingStore member and WidgetBackingStore has been renamed as
BackingStoreBackendCairo.
* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::BackingStore::createBackend): Helper function to create
the BackingStore backend depending on the platform.
(WebKit::BackingStore::paint): Use m_backend instead of m_backingStore.
(WebKit::BackingStore::incorporateUpdate): Ditto.
(WebKit::BackingStore::scroll): Ditto.
(WebKit::createBackingStoreForGTK): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformEflcmake">trunk/Source/WebCore/PlatformEfl.cmake</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoCairoUtilitiescpp">trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoCairoUtilitiesh">trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessBackingStoreh">trunk/Source/WebKit2/UIProcess/BackingStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcesscairoBackingStoreCairocpp">trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoh">trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairo.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoImplcpp">trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoImplh">trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoX11cpp">trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoX11h">trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li>trunk/Source/WebCore/platform/cairo/</li>
<li><a href="#trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11cpp">trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11h">trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/ChangeLog        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2014-10-23  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK][Cairo] Remove GTK dependency of WidgetBackingStoreGtkX11
+        https://bugs.webkit.org/show_bug.cgi?id=138004
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Rename all WidgetBackingStore* classes as
+        BackingStoreBackendCairo* since all of them are actually
+        BackingStore backends based on cairo, and move them from
+        platform/cairo and platform/gtk to platform/graphics/cairo.
+        BackingStoreBackendCairo is the base class that contains common
+        members like the surface and size. BackingStoreBackendCairoImpl is
+        the implementation using only cairo, and BackingStoreBackendCairoX11
+        using xlib. BackingStoreBackendCairoX11 receives all the X11
+        information it needs as constructor parameters, instead of using a
+        GtkWidget and GTK+ X11 API. BackingStoreBackendCairoImpl receives
+        the surface already created as constructor parameter, so that it
+        doesn't have any platform specific code now.
+
+        * PlatformEfl.cmake: Update compilation files.
+        * PlatformGTK.cmake: Ditto.
+        * platform/cairo/WidgetBackingStoreCairo.cpp: Removed.
+        * platform/graphics/cairo/BackingStoreBackendCairo.h: Renamed from Source/WebCore/platform/cairo/WidgetBackingStore.h.
+        (WebCore::BackingStoreBackendCairo::~BackingStoreBackendCairo):
+        (WebCore::BackingStoreBackendCairo::surface):
+        (WebCore::BackingStoreBackendCairo::size):
+        (WebCore::BackingStoreBackendCairo::BackingStoreBackendCairo):
+        * platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp: Added.
+        (WebCore::BackingStoreBackendCairoImpl::BackingStoreBackendCairoImpl):
+        (WebCore::BackingStoreBackendCairoImpl::~BackingStoreBackendCairoImpl):
+        (WebCore::BackingStoreBackendCairoImpl::scroll):
+        * platform/graphics/cairo/BackingStoreBackendCairoImpl.h: Renamed from Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h.
+        * platform/graphics/cairo/BackingStoreBackendCairoX11.cpp: Renamed from Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp.
+        (WebCore::BackingStoreBackendCairoX11::BackingStoreBackendCairoX11):
+        (WebCore::BackingStoreBackendCairoX11::~BackingStoreBackendCairoX11):
+        (WebCore::BackingStoreBackendCairoX11::scroll):
+        * platform/graphics/cairo/BackingStoreBackendCairoX11.h: Renamed from Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h.
+        * platform/graphics/cairo/CairoUtilities.cpp:
+        (WebCore::cairoSurfaceGetDeviceScale):
+        * platform/graphics/cairo/CairoUtilities.h:
+
</ins><span class="cx"> 2014-10-23  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebContent crash at WebCore::RenderTextControl::textFormControlElement const.
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformEflcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformEfl.cmake (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformEfl.cmake        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/PlatformEfl.cmake        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -73,8 +73,6 @@
</span><span class="cx">     platform/audio/gstreamer/FFTFrameGStreamer.cpp
</span><span class="cx">     platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp
</span><span class="cx"> 
</span><del>-    platform/cairo/WidgetBackingStoreCairo.cpp
-
</del><span class="cx">     platform/efl/BatteryProviderEfl.cpp
</span><span class="cx">     platform/efl/CursorEfl.cpp
</span><span class="cx">     platform/efl/DragDataEfl.cpp
</span><span class="lines">@@ -109,6 +107,7 @@
</span><span class="cx">     platform/graphics/ImageSource.cpp
</span><span class="cx">     platform/graphics/WOFFFileFormat.cpp
</span><span class="cx"> 
</span><ins>+    platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
</ins><span class="cx">     platform/graphics/cairo/BitmapImageCairo.cpp
</span><span class="cx">     platform/graphics/cairo/CairoUtilities.cpp
</span><span class="cx">     platform/graphics/cairo/DrawingBufferCairo.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -67,6 +67,8 @@
</span><span class="cx">     platform/graphics/OpenGLShims.cpp
</span><span class="cx">     platform/graphics/WOFFFileFormat.cpp
</span><span class="cx"> 
</span><ins>+    platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
+    platform/graphics/cairo/BackingStoreBackendCairoX11.cpp
</ins><span class="cx">     platform/graphics/cairo/BitmapImageCairo.cpp
</span><span class="cx">     platform/graphics/cairo/CairoUtilities.cpp
</span><span class="cx">     platform/graphics/cairo/DrawingBufferCairo.cpp
</span><span class="lines">@@ -197,8 +199,6 @@
</span><span class="cx">     page/gtk/DragControllerGtk.cpp
</span><span class="cx">     page/gtk/EventHandlerGtk.cpp
</span><span class="cx"> 
</span><del>-    platform/cairo/WidgetBackingStoreCairo.cpp
-
</del><span class="cx">     platform/graphics/GLContext.cpp
</span><span class="cx"> 
</span><span class="cx">     platform/graphics/egl/GLContextEGL.cpp
</span><span class="lines">@@ -236,7 +236,6 @@
</span><span class="cx">     platform/gtk/ScrollbarThemeGtk.cpp
</span><span class="cx">     platform/gtk/SharedTimerGtk.cpp
</span><span class="cx">     platform/gtk/SoundGtk.cpp
</span><del>-    platform/gtk/WidgetBackingStoreGtkX11.cpp
</del><span class="cx">     platform/gtk/WidgetGtk.cpp
</span><span class="cx"> 
</span><span class="cx">     rendering/RenderThemeGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairohfromrev175158trunkSourceWebCoreplatformcairoWidgetBackingStoreh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairo.h (from rev 175158, trunk/Source/WebCore/platform/cairo/WidgetBackingStore.h) (0 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairo.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairo.h        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * Copyright (C) 2011,2014 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
+ */
+
+#ifndef BackingStoreBackendCairo_h
+#define BackingStoreBackendCairo_h
+
+#if USE(CAIRO)
+
+#include &quot;IntRect.h&quot;
+#include &quot;RefPtrCairo.h&quot;
+#include &lt;wtf/FastMalloc.h&gt;
+#include &lt;wtf/Noncopyable.h&gt;
+
+typedef struct _cairo_surface cairo_surface_t;
+
+namespace WebCore {
+
+class BackingStoreBackendCairo {
+    WTF_MAKE_NONCOPYABLE(BackingStoreBackendCairo);
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    virtual ~BackingStoreBackendCairo() { }
+
+    cairo_surface_t* surface() const { return m_surface.get(); }
+    const IntSize&amp; size() const { return m_size; }
+
+    virtual void scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset) = 0;
+
+protected:
+    BackingStoreBackendCairo(const IntSize&amp; size)
+        : m_size(size)
+    {
+    }
+
+    RefPtr&lt;cairo_surface_t&gt; m_surface;
+    IntSize m_size;
+};
+
+#endif // USE(CAIRO)
+
+} // namespace WebCore
+
+#endif // BackingStoreBackendCairo_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoImplcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp (0 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+/*
+ * Copyright (C) 2011,2014 Igalia S.L.
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ *  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 &quot;config.h&quot;
+#include &quot;BackingStoreBackendCairoImpl.h&quot;
+
+#if USE(CAIRO)
+
+#include &quot;CairoUtilities.h&quot;
+
+namespace WebCore {
+
+BackingStoreBackendCairoImpl::BackingStoreBackendCairoImpl(cairo_surface_t* surface, const IntSize&amp; size)
+    : BackingStoreBackendCairo(size)
+{
+    m_surface = surface;
+
+    // We keep two copies of the surface here, which will double the memory usage, but increase
+    // scrolling performance since we do not have to keep reallocating a memory region during
+    // quick scrolling requests.
+    double xScale, yScale;
+    cairoSurfaceGetDeviceScale(m_surface.get(), xScale, yScale);
+    IntSize scaledSize = size;
+    scaledSize.scale(xScale, yScale);
+    m_scrollSurface = adoptRef(cairo_surface_create_similar(surface, CAIRO_CONTENT_COLOR_ALPHA, scaledSize.width(), scaledSize.height()));
+}
+
+BackingStoreBackendCairoImpl::~BackingStoreBackendCairoImpl()
+{
+}
+
+void BackingStoreBackendCairoImpl::scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset)
+{
+    IntRect targetRect = scrollRect;
+    targetRect.move(scrollOffset);
+    targetRect.shiftMaxXEdgeTo(targetRect.maxX() - scrollOffset.width());
+    targetRect.shiftMaxYEdgeTo(targetRect.maxY() - scrollOffset.height());
+    if (targetRect.isEmpty())
+        return;
+
+    copyRectFromOneSurfaceToAnother(m_surface.get(), m_scrollSurface.get(), scrollOffset, targetRect);
+    copyRectFromOneSurfaceToAnother(m_scrollSurface.get(), m_surface.get(), IntSize(), targetRect);
+}
+
+} // namespace WebCore
+
+#endif // USE(CAIRO)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoImplhfromrev175158trunkSourceWebCoreplatformcairoWidgetBackingStoreCairoh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.h (from rev 175158, trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h) (0 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.h        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+/*
+ * Copyright (C) 2013,2014 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
+ */
+
+#ifndef BackingStoreBackendCairoImpl_h
+#define BackingStoreBackendCairoImpl_h
+
+#include &quot;BackingStoreBackendCairo.h&quot;
+
+#if USE(CAIRO)
+
+namespace WebCore {
+
+class BackingStoreBackendCairoImpl final : public BackingStoreBackendCairo {
+public:
+    BackingStoreBackendCairoImpl(cairo_surface_t*, const IntSize&amp;);
+    virtual ~BackingStoreBackendCairoImpl();
+
+    void scroll(const IntRect&amp;, const IntSize&amp;) override;
+
+private:
+    RefPtr&lt;cairo_surface_t&gt; m_scrollSurface;
+};
+
+} // namespace WebCore
+
+#endif // USE(CAIRO)
+
+#endif // BackingStoreBackendCairoImpl_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoX11cppfromrev175158trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11cpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp (from rev 175158, trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp) (0 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+/*
+ * Copyright (C) 2011,2014 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 &quot;config.h&quot;
+#include &quot;BackingStoreBackendCairoX11.h&quot;
+
+#if USE(CAIRO) &amp;&amp; PLATFORM(X11)
+
+#include &quot;CairoUtilities.h&quot;
+#include &lt;cairo-xlib.h&gt;
+
+namespace WebCore {
+
+BackingStoreBackendCairoX11::BackingStoreBackendCairoX11(Display* display, unsigned long rootWindowID, Visual* visual, int depth, const IntSize&amp; size, float deviceScaleFactor)
+    : BackingStoreBackendCairo(size)
+    , m_display(display)
+{
+    IntSize scaledSize = size;
+    scaledSize.scale(deviceScaleFactor);
+
+    m_pixmap = XCreatePixmap(m_display, rootWindowID, scaledSize.width(), scaledSize.height(), depth);
+    m_gc = XCreateGC(m_display, m_pixmap, 0, nullptr);
+
+    m_surface = adoptRef(cairo_xlib_surface_create(m_display, m_pixmap, visual, scaledSize.width(), scaledSize.height()));
+    cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
+}
+
+BackingStoreBackendCairoX11::~BackingStoreBackendCairoX11()
+{
+    // The pixmap needs to exist when the surface is destroyed, so begin by clearing it.
+    m_surface.clear();
+    XFreePixmap(m_display, m_pixmap);
+    XFreeGC(m_display, m_gc);
+}
+
+void BackingStoreBackendCairoX11::scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset)
+{
+    IntRect targetRect = scrollRect;
+    targetRect.move(scrollOffset);
+    targetRect.intersect(scrollRect);
+    if (targetRect.isEmpty())
+        return;
+
+    double xScale, yScale;
+    cairoSurfaceGetDeviceScale(m_surface.get(), xScale, yScale);
+    ASSERT(xScale == yScale);
+
+    IntSize scaledScrollOffset = scrollOffset;
+    targetRect.scale(xScale);
+    scaledScrollOffset.scale(xScale, yScale);
+
+    cairo_surface_flush(m_surface.get());
+    XCopyArea(m_display, m_pixmap, m_pixmap, m_gc,
+        targetRect.x() - scaledScrollOffset.width(), targetRect.y() - scaledScrollOffset.height(),
+        targetRect.width(), targetRect.height(), targetRect.x(), targetRect.y());
+    cairo_surface_mark_dirty_rectangle(m_surface.get(), targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height());
+}
+
+} // namespace WebCore
+
+#endif // USE(CAIRO) &amp;&amp; PLATFORM(X11)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoX11hfromrev175158trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11h"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h (from rev 175158, trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h) (0 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2013,2014 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
+ */
+
+#ifndef BackingStoreBackendCairoX11_h
+#define BackingStoreBackendCairoX11_h
+
+#include &quot;BackingStoreBackendCairo.h&quot;
+
+#if USE(CAIRO) &amp;&amp; PLATFORM(X11)
+#include &lt;X11/Xlib.h&gt;
+
+namespace WebCore {
+
+class BackingStoreBackendCairoX11 final : public BackingStoreBackendCairo {
+public:
+    BackingStoreBackendCairoX11(Display*, unsigned long rootWindowID, Visual*, int depth, const IntSize&amp;, float deviceScaleFactor);
+    virtual ~BackingStoreBackendCairoX11();
+
+    void scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset) override;
+
+private:
+    Display* m_display;
+    Pixmap m_pixmap;
+    GC m_gc;
+};
+
+} // namespace WebCore
+
+#endif // USE(CAIRO) &amp;&amp; PLATFORM(X11)
+
+#endif // GtkWidgetBackingStoreX11_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoCairoUtilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -294,4 +294,16 @@
</span><span class="cx">     ASSERT_UNUSED(yScale, 1 == yScale);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><ins>+
+void cairoSurfaceGetDeviceScale(cairo_surface_t* surface, double&amp; xScale, double&amp; yScale)
+{
+#if HAVE(CAIRO_SURFACE_SET_DEVICE_SCALE)
+    cairo_surface_get_device_scale(surface, &amp;xScale, &amp;yScale);
+#else
+    UNUSED_PARAM(surface);
+    xScale = 1;
+    yScale = 1;
+#endif
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoCairoUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> IntSize cairoSurfaceSize(cairo_surface_t*);
</span><span class="cx"> void flipImageSurfaceVertically(cairo_surface_t*);
</span><span class="cx"> void cairoSurfaceSetDeviceScale(cairo_surface_t*, double xScale, double yScale);
</span><ins>+void cairoSurfaceGetDeviceScale(cairo_surface_t*, double&amp; xScale, double&amp; yScale);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11cpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -1,90 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011, 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 &quot;config.h&quot;
-#include &quot;WidgetBackingStoreGtkX11.h&quot;
-
-#if PLATFORM(GTK) &amp;&amp; PLATFORM(X11) &amp;&amp; defined(GDK_WINDOWING_X11)
-
-#include &quot;CairoUtilities.h&quot;
-#include &quot;GtkVersioning.h&quot;
-#include &quot;RefPtrCairo.h&quot;
-#include &lt;cairo-xlib.h&gt;
-#include &lt;cairo.h&gt;
-#include &lt;gdk/gdkx.h&gt;
-
-namespace WebCore {
-
-WidgetBackingStoreGtkX11::WidgetBackingStoreGtkX11(GtkWidget* widget, const IntSize&amp; size, float deviceScaleFactor)
-    : WidgetBackingStore(size, deviceScaleFactor)
-{
-    IntSize scaledSize = size;
-    scaledSize.scale(deviceScaleFactor);
-
-    GdkVisual* visual = gtk_widget_get_visual(widget);
-    GdkScreen* screen = gdk_visual_get_screen(visual);
-    m_display = GDK_SCREEN_XDISPLAY(screen);
-    m_pixmap = XCreatePixmap(m_display, GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
-        scaledSize.width(), scaledSize.height(), gdk_visual_get_depth(visual));
-    m_gc = XCreateGC(m_display, m_pixmap, 0, 0);
-
-    m_surface = adoptRef(cairo_xlib_surface_create(m_display, m_pixmap,
-        GDK_VISUAL_XVISUAL(visual), scaledSize.width(), scaledSize.height()));
-
-    cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
-}
-
-WidgetBackingStoreGtkX11::~WidgetBackingStoreGtkX11()
-{
-    // The pixmap needs to exist when the surface is destroyed, so begin by clearing it.
-    m_surface.clear();
-    XFreePixmap(m_display, m_pixmap);
-    XFreeGC(m_display, m_gc);
-}
-
-cairo_surface_t* WidgetBackingStoreGtkX11::cairoSurface()
-{
-    return m_surface.get();
-}
-
-void WidgetBackingStoreGtkX11::scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset)
-{
-    IntRect targetRect(scrollRect);
-    targetRect.move(scrollOffset);
-    targetRect.intersect(scrollRect);
-    if (targetRect.isEmpty())
-        return;
-
-    targetRect.scale(m_deviceScaleFactor);
-
-    IntSize scaledScrollOffset = scrollOffset;
-    scaledScrollOffset.scale(m_deviceScaleFactor);
-
-    cairo_surface_flush(m_surface.get());
-    XCopyArea(m_display, m_pixmap, m_pixmap, m_gc, 
-        targetRect.x() - scaledScrollOffset.width(), targetRect.y() - scaledScrollOffset.height(),
-        targetRect.width(), targetRect.height(),
-        targetRect.x(), targetRect.y());
-    cairo_surface_mark_dirty_rectangle(m_surface.get(),
-        targetRect.x(), targetRect.y(),
-        targetRect.width(), targetRect.height());
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(GTK) &amp;&amp; PLATFORM(X11) &amp;&amp; defined(GDK_WINDOWING_X11)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkWidgetBackingStoreGtkX11h"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -1,49 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013, 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
- */
-
-#ifndef WidgetBackingStoreGtkX11_h
-#define WidgetBackingStoreGtkX11_h
-
-#include &quot;WidgetBackingStore.h&quot;
-#include &lt;wtf/RefPtr.h&gt;
-
-#if PLATFORM(GTK) &amp;&amp; PLATFORM(X11) &amp;&amp; defined(GDK_WINDOWING_X11)
-#include &lt;X11/Xlib.h&gt;
-
-namespace WebCore {
-
-class WidgetBackingStoreGtkX11 : public WidgetBackingStore {
-
-public:
-    WidgetBackingStoreGtkX11(GtkWidget*, const IntSize&amp;, float deviceScaleFactor);
-    ~WidgetBackingStoreGtkX11();
-    cairo_surface_t* cairoSurface();
-    void scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset);
-
-private:
-    Display* m_display;
-    Pixmap m_pixmap;
-    GC m_gc;
-    RefPtr&lt;cairo_surface_t&gt; m_surface;
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(GTK) &amp;&amp; PLATFORM(X11) &amp;&amp; defined(GDK_WINDOWING_X11)
-
-#endif // GtkWidgetBackingStoreX11_h
</del></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebKit2/ChangeLog        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-10-23  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK][Cairo] Remove GTK dependency of WidgetBackingStoreGtkX11
+        https://bugs.webkit.org/show_bug.cgi?id=138004
+
+        Reviewed by Gustavo Noronha Silva.
+
+        * UIProcess/BackingStore.h: Rename m_backingStore as m_backend,
+        since it's a bit confusing that a BackingStore class has a
+        m_backingStore member and WidgetBackingStore has been renamed as
+        BackingStoreBackendCairo.
+        * UIProcess/cairo/BackingStoreCairo.cpp:
+        (WebKit::BackingStore::createBackend): Helper function to create
+        the BackingStore backend depending on the platform.
+        (WebKit::BackingStore::paint): Use m_backend instead of m_backingStore.
+        (WebKit::BackingStore::incorporateUpdate): Ditto.
+        (WebKit::BackingStore::scroll): Ditto.
+        (WebKit::createBackingStoreForGTK): Deleted.
+
</ins><span class="cx"> 2014-10-23  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix a bad find-and-replace in r175153
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/BackingStore.h (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/BackingStore.h        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebKit2/UIProcess/BackingStore.h        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -30,8 +30,7 @@
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if USE(CAIRO)
</span><del>-#include &lt;RefPtrCairo.h&gt;
-#include &lt;WebCore/WidgetBackingStore.h&gt;
</del><ins>+#include &lt;WebCore/BackingStoreBackendCairo.h&gt;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -61,12 +60,15 @@
</span><span class="cx">     void incorporateUpdate(ShareableBitmap*, const UpdateInfo&amp;);
</span><span class="cx">     void scroll(const WebCore::IntRect&amp; scrollRect, const WebCore::IntSize&amp; scrollOffset);
</span><span class="cx"> 
</span><ins>+#if USE(CAIRO)
+    std::unique_ptr&lt;WebCore::BackingStoreBackendCairo&gt; createBackend();
+#endif
+
</ins><span class="cx">     WebCore::IntSize m_size;
</span><span class="cx">     float m_deviceScaleFactor;
</span><span class="cx">     WebPageProxy&amp; m_webPageProxy;
</span><del>-
</del><span class="cx"> #if USE(CAIRO)
</span><del>-    std::unique_ptr&lt;WebCore::WidgetBackingStore&gt; m_backingStore;
</del><ins>+    std::unique_ptr&lt;WebCore::BackingStoreBackendCairo&gt; m_backend;
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcesscairoBackingStoreCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp (175158 => 175159)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp        2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp        2014-10-24 06:58:13 UTC (rev 175159)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2011 Apple Inc. All rights reserved.
</span><del>- * Copyright (C) 2011 Igalia S.L.
</del><ins>+ * Copyright (C) 2011,2014 Igalia S.L.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -30,62 +30,69 @@
</span><span class="cx"> #include &quot;ShareableBitmap.h&quot;
</span><span class="cx"> #include &quot;UpdateInfo.h&quot;
</span><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><ins>+#include &lt;WebCore/BackingStoreBackendCairoImpl.h&gt;
+#include &lt;WebCore/CairoUtilities.h&gt;
</ins><span class="cx"> #include &lt;WebCore/GraphicsContext.h&gt;
</span><del>-#include &lt;WebCore/WidgetBackingStoreCairo.h&gt;
</del><ins>+#include &lt;WebCore/RefPtrCairo.h&gt;
</ins><span class="cx"> #include &lt;cairo.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK) &amp;&amp; PLATFORM(X11) &amp;&amp; defined(GDK_WINDOWING_X11)
</span><del>-#include &lt;WebCore/WidgetBackingStoreGtkX11.h&gt;
</del><ins>+#include &lt;WebCore/BackingStoreBackendCairoX11.h&gt;
</ins><span class="cx"> #include &lt;gdk/gdkx.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(EFL)
-#include &quot;EwkView.h&quot;
-#endif
-
</del><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-#if PLATFORM(GTK)
-static std::unique_ptr&lt;WidgetBackingStore&gt; createBackingStoreForGTK(GtkWidget* widget, const IntSize&amp; size, float deviceScaleFactor)
</del><ins>+std::unique_ptr&lt;BackingStoreBackendCairo&gt; BackingStore::createBackend()
</ins><span class="cx"> {
</span><del>-#if PLATFORM(X11) &amp;&amp; defined(GDK_WINDOWING_X11)
</del><ins>+#if PLATFORM(GTK) &amp;&amp; defined(GDK_WINDOWING_X11)
</ins><span class="cx">     GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
</span><del>-    if (GDK_IS_X11_DISPLAY(display))
-        return std::make_unique&lt;WidgetBackingStoreGtkX11&gt;(widget, size, deviceScaleFactor);
</del><ins>+    if (GDK_IS_X11_DISPLAY(display)) {
+        GdkVisual* visual = gtk_widget_get_visual(m_webPageProxy.viewWidget());
+        GdkScreen* screen = gdk_visual_get_screen(visual);
+        return std::make_unique&lt;BackingStoreBackendCairoX11&gt;(GDK_SCREEN_XDISPLAY(screen), GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
+            GDK_VISUAL_XVISUAL(visual), gdk_visual_get_depth(visual), m_size, m_deviceScaleFactor);
+    }
</ins><span class="cx"> #endif
</span><del>-    return std::make_unique&lt;WidgetBackingStoreCairo&gt;(widget, size, deviceScaleFactor);
-}
</del><ins>+
+    IntSize scaledSize = m_size;
+    scaledSize.scale(m_deviceScaleFactor);
+
+#if PLATFORM(GTK)
+    RefPtr&lt;cairo_surface_t&gt; surface = adoptRef(gdk_window_create_similar_surface(gtk_widget_get_window(m_webPageProxy.viewWidget()),
+        CAIRO_CONTENT_COLOR_ALPHA, scaledSize.width(), scaledSize.height()));
+#else
+    RefPtr&lt;cairo_surface_t&gt; surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, scaledSize.width(), scaledSize.height()));
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    cairoSurfaceSetDeviceScale(surface.get(), m_deviceScaleFactor, m_deviceScaleFactor);
+    return std::make_unique&lt;BackingStoreBackendCairoImpl&gt;(surface.get(), m_size);
+}
+
</ins><span class="cx"> void BackingStore::paint(cairo_t* context, const IntRect&amp; rect)
</span><span class="cx"> {
</span><del>-    ASSERT(m_backingStore);
</del><ins>+    ASSERT(m_backend);
</ins><span class="cx"> 
</span><span class="cx">     cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
</span><del>-    cairo_set_source_surface(context, m_backingStore-&gt;cairoSurface(), 0, 0);
</del><ins>+    cairo_set_source_surface(context, m_backend-&gt;surface(), 0, 0);
</ins><span class="cx">     cairo_rectangle(context, rect.x(), rect.y(), rect.width(), rect.height());
</span><span class="cx">     cairo_fill(context);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo&amp; updateInfo)
</span><span class="cx"> {
</span><del>-    if (!m_backingStore)
-#if PLATFORM(EFL)
-        m_backingStore = std::make_unique&lt;WidgetBackingStoreCairo&gt;(EwkView::toEvasObject(toAPI(&amp;m_webPageProxy)), size(), deviceScaleFactor());
-#else
-        m_backingStore = createBackingStoreForGTK(m_webPageProxy.viewWidget(), size(), deviceScaleFactor());
-#endif
</del><ins>+    if (!m_backend)
+        m_backend = createBackend();
</ins><span class="cx"> 
</span><span class="cx">     scroll(updateInfo.scrollRect, updateInfo.scrollOffset);
</span><span class="cx"> 
</span><span class="cx">     // Paint all update rects.
</span><span class="cx">     IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
</span><del>-    RefPtr&lt;cairo_t&gt; context(adoptRef(cairo_create(m_backingStore-&gt;cairoSurface())));
</del><ins>+    RefPtr&lt;cairo_t&gt; context = adoptRef(cairo_create(m_backend-&gt;surface()));
</ins><span class="cx">     GraphicsContext graphicsContext(context.get());
</span><del>-    for (size_t i = 0; i &lt; updateInfo.updateRects.size(); ++i) {
-        IntRect updateRect = updateInfo.updateRects[i];
</del><ins>+    for (const auto&amp; updateRect : updateInfo.updateRects) {
</ins><span class="cx">         IntRect srcRect = updateRect;
</span><span class="cx">         srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
</span><span class="cx">         bitmap-&gt;paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
</span><span class="lines">@@ -97,8 +104,8 @@
</span><span class="cx">     if (scrollOffset.isZero())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ASSERT(m_backingStore);
-    m_backingStore-&gt;scroll(scrollRect, scrollOffset);
</del><ins>+    ASSERT(m_backend);
+    m_backend-&gt;scroll(scrollRect, scrollOffset);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>

</body>
</html>