<!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>[184197] 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/184197">184197</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-05-12 04:11:00 -0700 (Tue, 12 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[X11] Add XUniquePtr and XUniqueResource to automatically free X resources
https://bugs.webkit.org/show_bug.cgi?id=144521

Reviewed by Darin Adler.

Source/WebCore:

Add XUniquePtr as a template alias of std:unique_ptr to handle X
resources using pointers and XUniqueResource as a new class to
handle X resources using a long unsigned identifier. This
simplifies the code and makes it more difficult to leak X resources.

* PlatformEfl.cmake: Add new files to compilation.
* PlatformGTK.cmake: Ditto.
* platform/graphics/cairo/BackingStoreBackendCairoX11.cpp:
(WebCore::BackingStoreBackendCairoX11::BackingStoreBackendCairoX11):
Remove the display member, and use XUnique for Pixmap and GC.
(WebCore::BackingStoreBackendCairoX11::~BackingStoreBackendCairoX11):
Remove code to explicitly free Pixmap and GC.
(WebCore::BackingStoreBackendCairoX11::scroll):
* platform/graphics/cairo/BackingStoreBackendCairoX11.h:
* platform/graphics/glx/GLContextGLX.cpp:
(WebCore::GLContextGLX::createWindowContext): Use XUnique and the
new constructor that receives a XID, since there's no longer
conflict with the one receiving a Pbuffer.
(WebCore::GLContextGLX::createPbufferContext): Use XUnique and the
new constructor that receives a XUniqueGLXPbuffer&amp;&amp;.
(WebCore::GLContextGLX::createPixmapContext):
(WebCore::GLContextGLX::createContext):
(WebCore::GLContextGLX::GLContextGLX):
(WebCore::GLContextGLX::~GLContextGLX): Remove code to explicitly
free X resources.
(WebCore::GLContextGLX::makeContextCurrent):
(WebCore::GLContextGLX::cairoDevice):
(WebCore::GLContextGLX::platformContext):
* platform/graphics/glx/GLContextGLX.h:
* platform/graphics/surfaces/egl/EGLXSurface.cpp:
(WebCore::EGLXTransportSurfaceClient::EGLXTransportSurfaceClient):
(WebCore::EGLXTransportSurfaceClient::destroy):
(WebCore::EGLXTransportSurfaceClient::prepareTexture):
* platform/graphics/surfaces/egl/EGLXSurface.h:
* platform/graphics/surfaces/glx/GLXConfigSelector.h:
(WebCore::GLXConfigSelector::findMatchingConfig): Use XUnique
instead of the custom std::unique X11Deleter.
(WebCore::GLXConfigSelector::findMatchingConfigWithVisualId): Ditto.
* platform/graphics/surfaces/glx/GLXSurface.cpp:
(WebCore::GLXTransportSurface::GLXTransportSurface): Ditto.
(WebCore::GLXOffScreenSurface::initialize):
* platform/graphics/surfaces/glx/X11Helper.cpp:
(WebCore::X11Helper::createOffScreenWindow): Ditto.
(WebCore::X11Helper::createPixmap): Ditto.
* platform/graphics/surfaces/glx/X11Helper.h:
* platform/graphics/x11/XUniquePtr.h: Remove X11Deleter.
(WebCore::XPtrDeleter::operator()):
* platform/graphics/x11/XUniqueResource.cpp: Added.
(WebCore::XUniqueResource&lt;XResource::Colormap&gt;::deleteXResource):
(WebCore::XUniqueResource&lt;XResource::Damage&gt;::deleteXResource):
(WebCore::XUniqueResource&lt;XResource::Pixmap&gt;::deleteXResource):
(WebCore::XUniqueResource&lt;XResource::Window&gt;::deleteXResource):
(WebCore::XUniqueResource&lt;XResource::GLXPbuffer&gt;::deleteXResource):
(WebCore::XUniqueResource&lt;XResource::GLXPixmap&gt;::deleteXResource):
* platform/graphics/x11/XUniqueResource.h: Added.
(WebCore::XUniqueResource::XUniqueResource):
(WebCore::XUniqueResource::operator=):
(WebCore::XUniqueResource::~XUniqueResource):
(WebCore::XUniqueResource::get):
(WebCore::XUniqueResource::release):
(WebCore::XUniqueResource::reset):
(WebCore::XUniqueResource::operator!):
(WebCore::XUniqueResource::operator UnspecifiedBoolType*):

Source/WebKit2:

Use XUniquePtr and XUniqueResource to free X resources.

* PlatformEfl.cmake: Add Source/WebCore/platform/graphics/x11 dir
to the include dir list.
* PlatformGTK.cmake: Ditto.
* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::BackingStore::createBackend): Do not pass the display to
the BackingStoreBackendCairoX11 constructor.
* UIProcess/gtk/RedirectedXCompositeWindow.cpp:
(WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
(WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
(WebKit::RedirectedXCompositeWindow::resize):
(WebKit::RedirectedXCompositeWindow::cleanupPixmapAndPixmapSurface):
(WebKit::RedirectedXCompositeWindow::surface):
* UIProcess/gtk/RedirectedXCompositeWindow.h:
(WebKit::RedirectedXCompositeWindow::windowID):
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp:
(WebKit::NetscapePlugin::platformPostInitializeWindowless):
(WebKit::NetscapePlugin::platformDestroy):
(WebKit::NetscapePlugin::platformGeometryDidChange):
(WebKit::NetscapePlugin::platformPaint):</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="#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>
<li><a href="#trunkSourceWebCoreplatformgraphicsglxGLContextGLXcpp">trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsglxGLContextGLXh">trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicssurfaceseglEGLXSurfacecpp">trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicssurfaceseglEGLXSurfaceh">trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicssurfacesglxGLXConfigSelectorh">trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicssurfacesglxGLXSurfacecpp">trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicssurfacesglxX11Helpercpp">trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicssurfacesglxX11Helperh">trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformEflcmake">trunk/Source/WebKit2/PlatformEfl.cmake</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2UIProcesscairoBackingStoreCairocpp">trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowcpp">trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowh">trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePluginh">trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsNetscapex11NetscapePluginX11cpp">trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsx11XUniquePtrh">trunk/Source/WebCore/platform/graphics/x11/XUniquePtr.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsx11XUniqueResourcecpp">trunk/Source/WebCore/platform/graphics/x11/XUniqueResource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsx11XUniqueResourceh">trunk/Source/WebCore/platform/graphics/x11/XUniqueResource.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/ChangeLog        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -1,3 +1,74 @@
</span><ins>+2015-05-08  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [X11] Add XUniquePtr and XUniqueResource to automatically free X resources
+        https://bugs.webkit.org/show_bug.cgi?id=144521
+
+        Reviewed by Darin Adler.
+
+        Add XUniquePtr as a template alias of std:unique_ptr to handle X
+        resources using pointers and XUniqueResource as a new class to
+        handle X resources using a long unsigned identifier. This
+        simplifies the code and makes it more difficult to leak X resources.
+
+        * PlatformEfl.cmake: Add new files to compilation.
+        * PlatformGTK.cmake: Ditto.
+        * platform/graphics/cairo/BackingStoreBackendCairoX11.cpp:
+        (WebCore::BackingStoreBackendCairoX11::BackingStoreBackendCairoX11):
+        Remove the display member, and use XUnique for Pixmap and GC.
+        (WebCore::BackingStoreBackendCairoX11::~BackingStoreBackendCairoX11):
+        Remove code to explicitly free Pixmap and GC.
+        (WebCore::BackingStoreBackendCairoX11::scroll):
+        * platform/graphics/cairo/BackingStoreBackendCairoX11.h:
+        * platform/graphics/glx/GLContextGLX.cpp:
+        (WebCore::GLContextGLX::createWindowContext): Use XUnique and the
+        new constructor that receives a XID, since there's no longer
+        conflict with the one receiving a Pbuffer.
+        (WebCore::GLContextGLX::createPbufferContext): Use XUnique and the
+        new constructor that receives a XUniqueGLXPbuffer&amp;&amp;.
+        (WebCore::GLContextGLX::createPixmapContext):
+        (WebCore::GLContextGLX::createContext):
+        (WebCore::GLContextGLX::GLContextGLX):
+        (WebCore::GLContextGLX::~GLContextGLX): Remove code to explicitly
+        free X resources.
+        (WebCore::GLContextGLX::makeContextCurrent):
+        (WebCore::GLContextGLX::cairoDevice):
+        (WebCore::GLContextGLX::platformContext):
+        * platform/graphics/glx/GLContextGLX.h:
+        * platform/graphics/surfaces/egl/EGLXSurface.cpp:
+        (WebCore::EGLXTransportSurfaceClient::EGLXTransportSurfaceClient):
+        (WebCore::EGLXTransportSurfaceClient::destroy):
+        (WebCore::EGLXTransportSurfaceClient::prepareTexture):
+        * platform/graphics/surfaces/egl/EGLXSurface.h:
+        * platform/graphics/surfaces/glx/GLXConfigSelector.h:
+        (WebCore::GLXConfigSelector::findMatchingConfig): Use XUnique
+        instead of the custom std::unique X11Deleter.
+        (WebCore::GLXConfigSelector::findMatchingConfigWithVisualId): Ditto.
+        * platform/graphics/surfaces/glx/GLXSurface.cpp:
+        (WebCore::GLXTransportSurface::GLXTransportSurface): Ditto.
+        (WebCore::GLXOffScreenSurface::initialize):
+        * platform/graphics/surfaces/glx/X11Helper.cpp:
+        (WebCore::X11Helper::createOffScreenWindow): Ditto.
+        (WebCore::X11Helper::createPixmap): Ditto.
+        * platform/graphics/surfaces/glx/X11Helper.h:
+        * platform/graphics/x11/XUniquePtr.h: Remove X11Deleter.
+        (WebCore::XPtrDeleter::operator()):
+        * platform/graphics/x11/XUniqueResource.cpp: Added.
+        (WebCore::XUniqueResource&lt;XResource::Colormap&gt;::deleteXResource):
+        (WebCore::XUniqueResource&lt;XResource::Damage&gt;::deleteXResource):
+        (WebCore::XUniqueResource&lt;XResource::Pixmap&gt;::deleteXResource):
+        (WebCore::XUniqueResource&lt;XResource::Window&gt;::deleteXResource):
+        (WebCore::XUniqueResource&lt;XResource::GLXPbuffer&gt;::deleteXResource):
+        (WebCore::XUniqueResource&lt;XResource::GLXPixmap&gt;::deleteXResource):
+        * platform/graphics/x11/XUniqueResource.h: Added.
+        (WebCore::XUniqueResource::XUniqueResource):
+        (WebCore::XUniqueResource::operator=):
+        (WebCore::XUniqueResource::~XUniqueResource):
+        (WebCore::XUniqueResource::get):
+        (WebCore::XUniqueResource::release):
+        (WebCore::XUniqueResource::reset):
+        (WebCore::XUniqueResource::operator!):
+        (WebCore::XUniqueResource::operator UnspecifiedBoolType*):
+
</ins><span class="cx"> 2015-05-12  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move TransformOperation-based classes off of PassRefPtr
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformEflcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformEfl.cmake (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformEfl.cmake        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/PlatformEfl.cmake        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -197,6 +197,7 @@
</span><span class="cx">     platform/graphics/texmap/coordinated/UpdateAtlas.cpp
</span><span class="cx"> 
</span><span class="cx">     platform/graphics/x11/PlatformDisplayX11.cpp
</span><ins>+    platform/graphics/x11/XUniqueResource.cpp
</ins><span class="cx"> 
</span><span class="cx">     platform/image-decoders/ImageDecoder.cpp
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -126,6 +126,7 @@
</span><span class="cx">     platform/graphics/opentype/OpenTypeVerticalData.cpp
</span><span class="cx"> 
</span><span class="cx">     platform/graphics/x11/PlatformDisplayX11.cpp
</span><ins>+    platform/graphics/x11/XUniqueResource.cpp
</ins><span class="cx"> 
</span><span class="cx">     platform/gtk/ErrorsGtk.cpp
</span><span class="cx">     platform/gtk/EventLoopGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoX11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -26,17 +26,17 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-BackingStoreBackendCairoX11::BackingStoreBackendCairoX11(Display* display, unsigned long rootWindowID, Visual* visual, int depth, const IntSize&amp; size, float deviceScaleFactor)
</del><ins>+BackingStoreBackendCairoX11::BackingStoreBackendCairoX11(unsigned long rootWindowID, Visual* visual, int depth, const IntSize&amp; size, float deviceScaleFactor)
</ins><span class="cx">     : BackingStoreBackendCairo(size)
</span><del>-    , m_display(display)
</del><span class="cx"> {
</span><span class="cx">     IntSize scaledSize = size;
</span><span class="cx">     scaledSize.scale(deviceScaleFactor);
</span><span class="cx"> 
</span><del>-    m_pixmap = XCreatePixmap(m_display, rootWindowID, scaledSize.width(), scaledSize.height(), depth);
-    m_gc = XCreateGC(m_display, m_pixmap, 0, nullptr);
</del><ins>+    auto* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
+    m_pixmap = XCreatePixmap(display, rootWindowID, scaledSize.width(), scaledSize.height(), depth);
+    m_gc.reset(XCreateGC(display, m_pixmap.get(), 0, nullptr));
</ins><span class="cx"> 
</span><del>-    m_surface = adoptRef(cairo_xlib_surface_create(m_display, m_pixmap, visual, scaledSize.width(), scaledSize.height()));
</del><ins>+    m_surface = adoptRef(cairo_xlib_surface_create(display, m_pixmap.get(), visual, scaledSize.width(), scaledSize.height()));
</ins><span class="cx">     cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -44,8 +44,6 @@
</span><span class="cx"> {
</span><span class="cx">     // The pixmap needs to exist when the surface is destroyed, so begin by clearing it.
</span><span class="cx">     m_surface.clear();
</span><del>-    XFreePixmap(m_display, m_pixmap);
-    XFreeGC(m_display, m_gc);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BackingStoreBackendCairoX11::scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset)
</span><span class="lines">@@ -65,7 +63,7 @@
</span><span class="cx">     scaledScrollOffset.scale(xScale, yScale);
</span><span class="cx"> 
</span><span class="cx">     cairo_surface_flush(m_surface.get());
</span><del>-    XCopyArea(m_display, m_pixmap, m_pixmap, m_gc,
</del><ins>+    XCopyArea(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native(), m_pixmap.get(), m_pixmap.get(), m_gc.get(),
</ins><span class="cx">         targetRect.x() - scaledScrollOffset.width(), targetRect.y() - scaledScrollOffset.height(),
</span><span class="cx">         targetRect.width(), targetRect.height(), targetRect.x(), targetRect.y());
</span><span class="cx">     cairo_surface_mark_dirty_rectangle(m_surface.get(), targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoBackingStoreBackendCairoX11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -22,21 +22,21 @@
</span><span class="cx"> #include &quot;BackingStoreBackendCairo.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if USE(CAIRO) &amp;&amp; PLATFORM(X11)
</span><del>-#include &lt;X11/Xlib.h&gt;
</del><ins>+#include &quot;XUniquePtr.h&quot;
+#include &quot;XUniqueResource.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class BackingStoreBackendCairoX11 final : public BackingStoreBackendCairo {
</span><span class="cx"> public:
</span><del>-    BackingStoreBackendCairoX11(Display*, unsigned long rootWindowID, Visual*, int depth, const IntSize&amp;, float deviceScaleFactor);
</del><ins>+    BackingStoreBackendCairoX11(unsigned long rootWindowID, Visual*, int depth, const IntSize&amp;, float deviceScaleFactor);
</ins><span class="cx">     virtual ~BackingStoreBackendCairoX11();
</span><span class="cx"> 
</span><span class="cx">     void scroll(const IntRect&amp; scrollRect, const IntSize&amp; scrollOffset) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    Display* m_display;
-    Pixmap m_pixmap;
-    GC m_gc;
</del><ins>+    XUniquePixmap m_pixmap;
+    XUniqueGC m_gc;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsglxGLContextGLXcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -43,25 +43,19 @@
</span><span class="cx">     visualInfo.visualid = XVisualIDFromVisual(attributes.visual);
</span><span class="cx"> 
</span><span class="cx">     int numReturned = 0;
</span><del>-    XVisualInfo* visualInfoList = XGetVisualInfo(display, VisualIDMask, &amp;visualInfo, &amp;numReturned);
</del><ins>+    XUniquePtr&lt;XVisualInfo&gt; visualInfoList(XGetVisualInfo(display, VisualIDMask, &amp;visualInfo, &amp;numReturned));
</ins><span class="cx"> 
</span><del>-    GLXContext glxSharingContext = sharingContext ? static_cast&lt;GLContextGLX*&gt;(sharingContext)-&gt;m_context : 0;
-    GLXContext context = glXCreateContext(display, visualInfoList, glxSharingContext, True);
-    XFree(visualInfoList);
-
</del><ins>+    GLXContext glxSharingContext = sharingContext ? static_cast&lt;GLContextGLX*&gt;(sharingContext)-&gt;m_context.get() : nullptr;
+    XUniqueGLXContext context(glXCreateContext(display, visualInfoList.get(), glxSharingContext, True));
</ins><span class="cx">     if (!context)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    // GLXPbuffer and XID are both the same types underneath, so we have to share
-    // a constructor here with the window path.
-    auto contextWrapper = std::make_unique&lt;GLContextGLX&gt;(context);
-    contextWrapper-&gt;m_window = window;
-    return WTF::move(contextWrapper);
</del><ins>+    return std::make_unique&lt;GLContextGLX&gt;(WTF::move(context), window);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createPbufferContext(GLXContext sharingContext)
</span><span class="cx"> {
</span><del>-    int fbConfigAttributes[] = {
</del><ins>+    static const int fbConfigAttributes[] = {
</ins><span class="cx">         GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
</span><span class="cx">         GLX_RENDER_TYPE, GLX_RGBA_BIT,
</span><span class="cx">         GLX_RED_SIZE, 1,
</span><span class="lines">@@ -74,32 +68,21 @@
</span><span class="cx"> 
</span><span class="cx">     int returnedElements;
</span><span class="cx">     Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</span><del>-    GLXFBConfig* configs = glXChooseFBConfig(display, 0, fbConfigAttributes, &amp;returnedElements);
-    if (!returnedElements) {
-        XFree(configs);
</del><ins>+    XUniquePtr&lt;GLXFBConfig&gt; configs(glXChooseFBConfig(display, 0, fbConfigAttributes, &amp;returnedElements));
+    if (!returnedElements)
</ins><span class="cx">         return nullptr;
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     // We will be rendering to a texture, so our pbuffer does not need to be large.
</span><span class="cx">     static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, 0 };
</span><del>-    GLXPbuffer pbuffer = glXCreatePbuffer(display, configs[0], pbufferAttributes);
-    if (!pbuffer) {
-        XFree(configs);
</del><ins>+    XUniqueGLXPbuffer pbuffer(glXCreatePbuffer(display, configs.get()[0], pbufferAttributes));
+    if (!pbuffer)
</ins><span class="cx">         return nullptr;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    GLXContext context = glXCreateNewContext(display, configs[0], GLX_RGBA_TYPE, sharingContext, GL_TRUE);
-    XFree(configs);
-    if (!context) {
-        glXDestroyPbuffer(display, pbuffer);
</del><ins>+    XUniqueGLXContext context(glXCreateNewContext(display, configs.get()[0], GLX_RGBA_TYPE, sharingContext, GL_TRUE));
+    if (!context)
</ins><span class="cx">         return nullptr;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    // GLXPbuffer and XID are both the same types underneath, so we have to share
-    // a constructor here with the window path.
-    auto contextWrapper = std::make_unique&lt;GLContextGLX&gt;(context);
-    contextWrapper-&gt;m_pbuffer = pbuffer;
-    return WTF::move(contextWrapper);
</del><ins>+    return std::make_unique&lt;GLContextGLX&gt;(WTF::move(context), WTF::move(pbuffer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createPixmapContext(GLXContext sharingContext)
</span><span class="lines">@@ -114,31 +97,23 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</span><del>-    XVisualInfo* visualInfo = glXChooseVisual(display, DefaultScreen(display), visualAttributes);
</del><ins>+    XUniquePtr&lt;XVisualInfo&gt; visualInfo(glXChooseVisual(display, DefaultScreen(display), visualAttributes));
</ins><span class="cx">     if (!visualInfo)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    GLXContext context = glXCreateContext(display, visualInfo, sharingContext, GL_TRUE);
-    if (!context) {
-        XFree(visualInfo);
</del><ins>+    XUniqueGLXContext context(glXCreateContext(display, visualInfo.get(), sharingContext, GL_TRUE));
+    if (!context)
</ins><span class="cx">         return nullptr;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    Pixmap pixmap = XCreatePixmap(display, DefaultRootWindow(display), 1, 1, visualInfo-&gt;depth);
-    if (!pixmap) {
-        XFree(visualInfo);
</del><ins>+    XUniquePixmap pixmap(XCreatePixmap(display, DefaultRootWindow(display), 1, 1, visualInfo-&gt;depth));
+    if (!pixmap)
</ins><span class="cx">         return nullptr;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    GLXPixmap glxPixmap = glXCreateGLXPixmap(display, visualInfo, pixmap);
-    if (!glxPixmap) {
-        XFreePixmap(display, pixmap);
-        XFree(visualInfo);
</del><ins>+    XUniqueGLXPixmap glxPixmap(glXCreateGLXPixmap(display, visualInfo.get(), pixmap.get()));
+    if (!glxPixmap)
</ins><span class="cx">         return nullptr;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    XFree(visualInfo);
-    return std::make_unique&lt;GLContextGLX&gt;(context, pixmap, glxPixmap);
</del><ins>+    return std::make_unique&lt;GLContextGLX&gt;(WTF::move(context), WTF::move(pixmap), WTF::move(glxPixmap));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createContext(XID window, GLContext* sharingContext)
</span><span class="lines">@@ -152,7 +127,7 @@
</span><span class="cx">     if (!success)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    GLXContext glxSharingContext = sharingContext ? static_cast&lt;GLContextGLX*&gt;(sharingContext)-&gt;m_context : 0;
</del><ins>+    GLXContext glxSharingContext = sharingContext ? static_cast&lt;GLContextGLX*&gt;(sharingContext)-&gt;m_context.get() : nullptr;
</ins><span class="cx">     auto context = window ? createWindowContext(window, sharingContext) : nullptr;
</span><span class="cx">     if (!context)
</span><span class="cx">         context = createPbufferContext(glxSharingContext);
</span><span class="lines">@@ -164,52 +139,37 @@
</span><span class="cx">     return WTF::move(context);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContextGLX::GLContextGLX(GLXContext context)
-    : m_context(context)
-    , m_window(0)
-    , m_pbuffer(0)
-    , m_pixmap(0)
-    , m_glxPixmap(0)
-    , m_cairoDevice(0)
</del><ins>+GLContextGLX::GLContextGLX(XUniqueGLXContext&amp;&amp; context, XID window)
+    : m_context(WTF::move(context))
+    , m_window(window)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContextGLX::GLContextGLX(GLXContext context, Pixmap pixmap, GLXPixmap glxPixmap)
-    : m_context(context)
-    , m_window(0)
-    , m_pbuffer(0)
-    , m_pixmap(pixmap)
-    , m_glxPixmap(glxPixmap)
-    , m_cairoDevice(0)
</del><ins>+GLContextGLX::GLContextGLX(XUniqueGLXContext&amp;&amp; context, XUniqueGLXPbuffer&amp;&amp; pbuffer)
+    : m_context(WTF::move(context))
+    , m_pbuffer(WTF::move(pbuffer))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GLContextGLX::GLContextGLX(XUniqueGLXContext&amp;&amp; context, XUniquePixmap&amp;&amp; pixmap, XUniqueGLXPixmap&amp;&amp; glxPixmap)
+    : m_context(WTF::move(context))
+    , m_pixmap(WTF::move(pixmap))
+    , m_glxPixmap(WTF::move(glxPixmap))
+{
+}
+
</ins><span class="cx"> GLContextGLX::~GLContextGLX()
</span><span class="cx"> {
</span><span class="cx">     if (m_cairoDevice)
</span><span class="cx">         cairo_device_destroy(m_cairoDevice);
</span><span class="cx"> 
</span><del>-    Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</del><span class="cx">     if (m_context) {
</span><span class="cx">         // This may be necessary to prevent crashes with NVidia's closed source drivers. Originally
</span><span class="cx">         // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/
</span><ins>+        Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</ins><span class="cx">         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
</span><span class="cx">         glXMakeCurrent(display, None, None);
</span><del>-        glXDestroyContext(display, m_context);
</del><span class="cx">     }
</span><del>-
-    if (m_pbuffer) {
-        glXDestroyPbuffer(display, m_pbuffer);
-        m_pbuffer = 0;
-    }
-    if (m_glxPixmap) {
-        glXDestroyGLXPixmap(display, m_glxPixmap);
-        m_glxPixmap = 0;
-    }
-    if (m_pixmap) {
-        XFreePixmap(display, m_pixmap);
-        m_pixmap = 0;
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool GLContextGLX::canRenderToDefaultFramebuffer()
</span><span class="lines">@@ -237,17 +197,17 @@
</span><span class="cx">     ASSERT(m_context &amp;&amp; (m_window || m_pbuffer || m_glxPixmap));
</span><span class="cx"> 
</span><span class="cx">     GLContext::makeContextCurrent();
</span><del>-    if (glXGetCurrentContext() == m_context)
</del><ins>+    if (glXGetCurrentContext() == m_context.get())
</ins><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</span><span class="cx">     if (m_window)
</span><del>-        return glXMakeCurrent(display, m_window, m_context);
</del><ins>+        return glXMakeCurrent(display, m_window, m_context.get());
</ins><span class="cx"> 
</span><span class="cx">     if (m_pbuffer)
</span><del>-        return glXMakeCurrent(display, m_pbuffer, m_context);
</del><ins>+        return glXMakeCurrent(display, m_pbuffer.get(), m_context.get());
</ins><span class="cx"> 
</span><del>-    return ::glXMakeCurrent(display, m_glxPixmap, m_context);
</del><ins>+    return ::glXMakeCurrent(display, m_glxPixmap.get(), m_context.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GLContextGLX::swapBuffers()
</span><span class="lines">@@ -267,7 +227,7 @@
</span><span class="cx">         return m_cairoDevice;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS)
</span><del>-    m_cairoDevice = cairo_glx_device_create(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native(), m_context);
</del><ins>+    m_cairoDevice = cairo_glx_device_create(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native(), m_context.get());
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     return m_cairoDevice;
</span><span class="lines">@@ -276,7 +236,7 @@
</span><span class="cx"> #if ENABLE(GRAPHICS_CONTEXT_3D)
</span><span class="cx"> PlatformGraphicsContext3D GLContextGLX::platformContext()
</span><span class="cx"> {
</span><del>-    return m_context;
</del><ins>+    return m_context.get();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsglxGLContextGLXh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -23,12 +23,10 @@
</span><span class="cx"> #if USE(GLX)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;GLContext.h&quot;
</span><ins>+#include &quot;XUniquePtr.h&quot;
+#include &quot;XUniqueResource.h&quot;
</ins><span class="cx"> 
</span><del>-typedef struct __GLXcontextRec* GLXContext;
-typedef unsigned long GLXPbuffer;
-typedef unsigned long GLXPixmap;
</del><span class="cx"> typedef unsigned char GLubyte;
</span><del>-typedef unsigned long Pixmap;
</del><span class="cx"> typedef unsigned long XID;
</span><span class="cx"> typedef void* ContextKeyType;
</span><span class="cx"> 
</span><span class="lines">@@ -40,8 +38,9 @@
</span><span class="cx">     static std::unique_ptr&lt;GLContextGLX&gt; createContext(XID window, GLContext* sharingContext);
</span><span class="cx">     static std::unique_ptr&lt;GLContextGLX&gt; createWindowContext(XID window, GLContext* sharingContext);
</span><span class="cx"> 
</span><del>-    GLContextGLX(GLXContext);
-    GLContextGLX(GLXContext, Pixmap, GLXPixmap);
</del><ins>+    GLContextGLX(XUniqueGLXContext&amp;&amp;, XID);
+    GLContextGLX(XUniqueGLXContext&amp;&amp;, XUniqueGLXPbuffer&amp;&amp;);
+    GLContextGLX(XUniqueGLXContext&amp;&amp;, XUniquePixmap&amp;&amp;, XUniqueGLXPixmap&amp;&amp;);
</ins><span class="cx">     virtual ~GLContextGLX();
</span><span class="cx">     virtual bool makeContextCurrent();
</span><span class="cx">     virtual void swapBuffers();
</span><span class="lines">@@ -59,12 +58,12 @@
</span><span class="cx">     static std::unique_ptr&lt;GLContextGLX&gt; createPbufferContext(GLXContext sharingContext);
</span><span class="cx">     static std::unique_ptr&lt;GLContextGLX&gt; createPixmapContext(GLXContext sharingContext);
</span><span class="cx"> 
</span><del>-    GLXContext m_context;
-    XID m_window;
-    GLXPbuffer m_pbuffer;
-    Pixmap m_pixmap;
-    GLXPixmap m_glxPixmap;
-    cairo_device_t* m_cairoDevice;
</del><ins>+    XUniqueGLXContext m_context;
+    XID m_window { 0 };
+    XUniqueGLXPbuffer m_pbuffer;
+    XUniquePixmap m_pixmap;
+    XUniqueGLXPixmap m_glxPixmap;
+    cairo_device_t* m_cairoDevice { nullptr };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicssurfaceseglEGLXSurfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -141,7 +141,6 @@
</span><span class="cx"> 
</span><span class="cx"> EGLXTransportSurfaceClient::EGLXTransportSurfaceClient(const PlatformBufferHandle handle, const IntSize&amp; size, bool hasAlpha)
</span><span class="cx">     : GLTransportSurfaceClient()
</span><del>-    , m_image(0)
</del><span class="cx">     , m_size(size)
</span><span class="cx">     , m_totalBytes(0)
</span><span class="cx"> {
</span><span class="lines">@@ -197,11 +196,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     eglWaitGL();
</span><del>-
-    if (m_image) {
-        XDestroyImage(m_image);
-        m_image = 0;
-    }
</del><ins>+    m_image = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void EGLXTransportSurfaceClient::prepareTexture()
</span><span class="lines">@@ -214,7 +209,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Fallback to use XImage in case EGLImage and TextureToPixmap are not supported.
</span><del>-    m_image = XGetImage(NativeWrapper::nativeDisplay(), m_handle, 0, 0, m_size.width(), m_size.height(), AllPlanes, ZPixmap);
</del><ins>+    m_image.reset(XGetImage(NativeWrapper::nativeDisplay(), m_handle, 0, 0, m_size.width(), m_size.height(), AllPlanes, ZPixmap));
</ins><span class="cx"> 
</span><span class="cx"> #if USE(OPENGL_ES_2)
</span><span class="cx">     if (m_format != GraphicsContext3D::BGRA) {
</span><span class="lines">@@ -225,10 +220,7 @@
</span><span class="cx"> 
</span><span class="cx">     glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_size.width(), m_size.height(), 0, m_format, GL_UNSIGNED_BYTE, m_image-&gt;data);
</span><span class="cx"> 
</span><del>-    if (m_image) {
-        XDestroyImage(m_image);
-        m_image = 0;
-    }
</del><ins>+    m_image = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> EGLTextureFromPixmap::EGLTextureFromPixmap(const NativePixmap handle, bool hasAlpha, EGLConfig config)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicssurfaceseglEGLXSurfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -29,11 +29,11 @@
</span><span class="cx"> #if PLATFORM(X11) &amp;&amp; USE(EGL) &amp;&amp; USE(GRAPHICS_SURFACE)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;EGLSurface.h&quot;
</span><ins>+#include &quot;XUniquePtr.h&quot;
</ins><span class="cx"> #include &lt;glx/X11Helper.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-typedef X11Helper NativeWrapper;
</del><span class="cx"> typedef Pixmap NativePixmap;
</span><span class="cx"> 
</span><span class="cx"> // Contents of the surface are backed by native window.
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx">     virtual void destroy() override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    XImage* m_image;
</del><ins>+    XUniquePtr&lt;XImage&gt; m_image;
</ins><span class="cx">     IntSize m_size;
</span><span class="cx">     PlatformBufferHandle m_handle;
</span><span class="cx">     GLuint m_format;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicssurfacesglxGLXConfigSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if USE(GLX)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;X11Helper.h&quot;
</span><ins>+#include &quot;XUniquePtr.h&quot;
</ins><span class="cx"> #include &lt;opengl/GLDefs.h&gt;
</span><span class="cx"> #include &lt;opengl/GLPlatformSurface.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -140,13 +141,13 @@
</span><span class="cx">     GLXFBConfig findMatchingConfig(const int attributes[], int depth = 32)
</span><span class="cx">     {
</span><span class="cx">         int numAvailableConfigs;
</span><del>-        std::unique_ptr&lt;GLXFBConfig[], X11Deleter&gt; temp(glXChooseFBConfig(X11Helper::nativeDisplay(), DefaultScreen(X11Helper::nativeDisplay()), attributes, &amp;numAvailableConfigs));
</del><ins>+        XUniquePtr&lt;GLXFBConfig&gt; temp(glXChooseFBConfig(X11Helper::nativeDisplay(), DefaultScreen(X11Helper::nativeDisplay()), attributes, &amp;numAvailableConfigs));
</ins><span class="cx"> 
</span><span class="cx">         if (!numAvailableConfigs || !temp.get())
</span><span class="cx">             return 0;
</span><span class="cx"> 
</span><span class="cx">         for (int i = 0; i &lt; numAvailableConfigs; ++i) {
</span><del>-            std::unique_ptr&lt;XVisualInfo, X11Deleter&gt; scopedVisualInfo { glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp[i]) };
</del><ins>+            XUniquePtr&lt;XVisualInfo&gt; scopedVisualInfo { glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp.get()[i]) };
</ins><span class="cx">             if (!scopedVisualInfo.get())
</span><span class="cx">                 continue;
</span><span class="cx"> 
</span><span class="lines">@@ -157,40 +158,40 @@
</span><span class="cx">                 if (format) {
</span><span class="cx">                     if (m_attributes &amp; GLPlatformSurface::SupportAlpha) {
</span><span class="cx">                         if (scopedVisualInfo-&gt;depth == depth &amp;&amp; format-&gt;direct.alphaMask &gt; 0)
</span><del>-                            return temp[i];
</del><ins>+                            return temp.get()[i];
</ins><span class="cx">                     } else if (!format-&gt;direct.alphaMask)
</span><del>-                        return temp[i];
</del><ins>+                        return temp.get()[i];
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx"> #endif
</span><span class="cx">             if (scopedVisualInfo-&gt;depth == depth)
</span><del>-                return temp[i];
</del><ins>+                return temp.get()[i];
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Did not find any visual supporting alpha, select the first available config.
</span><del>-        std::unique_ptr&lt;XVisualInfo, X11Deleter&gt; scopedVisualInfo { glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp[0]) };
</del><ins>+        XUniquePtr&lt;XVisualInfo&gt; scopedVisualInfo { glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp.get()[0]) };
</ins><span class="cx"> 
</span><span class="cx">         if ((m_attributes &amp; GLPlatformSurface::SupportAlpha) &amp;&amp; (scopedVisualInfo-&gt;depth != 32))
</span><span class="cx">             m_attributes &amp;= ~GLPlatformSurface::SupportAlpha;
</span><span class="cx"> 
</span><del>-        return temp[0];
</del><ins>+        return temp.get()[0];
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     GLXFBConfig findMatchingConfigWithVisualId(const int attributes[], int depth, VisualID id)
</span><span class="cx">     {
</span><span class="cx">         int numAvailableConfigs;
</span><del>-        std::unique_ptr&lt;GLXFBConfig[], X11Deleter&gt; temp(glXChooseFBConfig(X11Helper::nativeDisplay(), DefaultScreen(X11Helper::nativeDisplay()), attributes, &amp;numAvailableConfigs));
</del><ins>+        XUniquePtr&lt;GLXFBConfig&gt; temp(glXChooseFBConfig(X11Helper::nativeDisplay(), DefaultScreen(X11Helper::nativeDisplay()), attributes, &amp;numAvailableConfigs));
</ins><span class="cx"> 
</span><span class="cx">         if (!numAvailableConfigs || !temp.get())
</span><span class="cx">             return 0;
</span><span class="cx"> 
</span><span class="cx">         for (int i = 0; i &lt; numAvailableConfigs; ++i) {
</span><del>-            std::unique_ptr&lt;XVisualInfo, X11Deleter&gt; scopedVisualInfo { glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp[i]) };
</del><ins>+            XUniquePtr&lt;XVisualInfo&gt; scopedVisualInfo { glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp.get()[i]) };
</ins><span class="cx">             if (!scopedVisualInfo.get())
</span><span class="cx">                 continue;
</span><span class="cx"> 
</span><span class="cx">             if (id &amp;&amp; scopedVisualInfo-&gt;depth == depth &amp;&amp; scopedVisualInfo-&gt;visualid == id)
</span><del>-                return temp[i];
</del><ins>+                return temp.get()[i];
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicssurfacesglxGLXSurfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -28,6 +28,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(GLX)
</span><span class="cx"> 
</span><ins>+#include &quot;XUniquePtr.h&quot;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> static PFNGLXBINDTEXIMAGEEXTPROC pGlXBindTexImageEXT = 0;
</span><span class="lines">@@ -66,7 +68,7 @@
</span><span class="cx"> {
</span><span class="cx">     attributes |= GLPlatformSurface::DoubleBuffered;
</span><span class="cx">     m_configSelector = std::make_unique&lt;GLXConfigSelector&gt;(attributes);
</span><del>-    std::unique_ptr&lt;XVisualInfo, X11Deleter&gt; visInfo(m_configSelector-&gt;visualInfo(m_configSelector-&gt;surfaceContextConfig()));
</del><ins>+    XUniquePtr&lt;XVisualInfo&gt; visInfo(m_configSelector-&gt;visualInfo(m_configSelector-&gt;surfaceContextConfig()));
</ins><span class="cx"> 
</span><span class="cx">     if (!visInfo.get()) {
</span><span class="cx">         destroy();
</span><span class="lines">@@ -142,7 +144,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_configSelector = std::make_unique&lt;GLXConfigSelector&gt;(attributes);
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;XVisualInfo, X11Deleter&gt; visualInfo(m_configSelector-&gt;visualInfo(m_configSelector-&gt;pixmapContextConfig()));
</del><ins>+    XUniquePtr&lt;XVisualInfo&gt; visualInfo(m_configSelector-&gt;visualInfo(m_configSelector-&gt;pixmapContextConfig()));
</ins><span class="cx">     X11Helper::createPixmap(&amp;m_pixmap, *visualInfo.get());
</span><span class="cx"> 
</span><span class="cx">     if (!m_pixmap) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicssurfacesglxX11Helpercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;X11Helper.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;PlatformDisplayX11.h&quot;
</span><ins>+#include &quot;XUniquePtr.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -223,7 +224,7 @@
</span><span class="cx">     memset(&amp;visualInfoTemplate, 0, sizeof(XVisualInfo));
</span><span class="cx">     visualInfoTemplate.visualid = visualId;
</span><span class="cx">     int matchingCount = 0;
</span><del>-    std::unique_ptr&lt;XVisualInfo, X11Deleter&gt; matchingVisuals(XGetVisualInfo(nativeDisplay(), VisualIDMask, &amp;visualInfoTemplate, &amp;matchingCount));
</del><ins>+    XUniquePtr&lt;XVisualInfo&gt; matchingVisuals(XGetVisualInfo(nativeDisplay(), VisualIDMask, &amp;visualInfoTemplate, &amp;matchingCount));
</ins><span class="cx">     XVisualInfo* foundVisual = 0;
</span><span class="cx"> 
</span><span class="cx">     if (matchingVisuals) {
</span><span class="lines">@@ -260,7 +261,7 @@
</span><span class="cx">     memset(&amp;visualInfoTemplate, 0, sizeof(XVisualInfo));
</span><span class="cx">     visualInfoTemplate.visualid = visualId;
</span><span class="cx">     int matchingCount = 0;
</span><del>-    std::unique_ptr&lt;XVisualInfo, X11Deleter&gt; matchingVisuals(XGetVisualInfo(nativeDisplay(), VisualIDMask, &amp;visualInfoTemplate, &amp;matchingCount));
</del><ins>+    XUniquePtr&lt;XVisualInfo&gt; matchingVisuals(XGetVisualInfo(nativeDisplay(), VisualIDMask, &amp;visualInfoTemplate, &amp;matchingCount));
</ins><span class="cx">     XVisualInfo* foundVisual = 0;
</span><span class="cx">     int requiredDepth = hasAlpha ? 32 : 24;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicssurfacesglxX11Helperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -42,15 +42,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class X11Deleter {
-public:
-    template&lt;typename T&gt; void operator()(T* resource)
-    {
-        if (resource)
-            XFree(resource);
-    }
-};
-
</del><span class="cx"> class X11Helper {
</span><span class="cx"> public:
</span><span class="cx">     static void createPixmap(Pixmap*, const XVisualInfo&amp;, const IntSize&amp; = IntSize(1, 1));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsx11XUniquePtrh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/x11/XUniquePtr.h (0 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/x11/XUniquePtr.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/x11/XUniquePtr.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 AND ITS CONTRIBUTORS &quot;AS IS&quot; 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 OR ITS 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 XUniquePtr_h
+#define XUniquePtr_h
+
+#if PLATFORM(X11)
+#include &quot;PlatformDisplayX11.h&quot;
+#include &lt;X11/Xutil.h&gt;
+
+#if USE(GLX)
+typedef struct __GLXcontextRec* GLXContext;
+extern &quot;C&quot; void glXDestroyContext(Display*, GLXContext);
+#endif
+
+namespace WebCore {
+
+template&lt;typename T&gt;
+struct XPtrDeleter {
+    void operator()(T* ptr) const
+    {
+        if (ptr)
+            XFree(ptr);
+    }
+};
+
+template&lt;typename T&gt;
+using XUniquePtr = std::unique_ptr&lt;T, XPtrDeleter&lt;T&gt;&gt;;
+
+template&lt;&gt; struct XPtrDeleter&lt;XImage&gt; {
+    void operator() (XImage* ptr) const
+    {
+        if (ptr)
+            XDestroyImage(ptr);
+    }
+};
+
+template&lt;&gt; struct XPtrDeleter&lt;_XGC&gt; {
+    void operator() (_XGC* ptr) const
+    {
+        if (ptr)
+            XFreeGC(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native(), ptr);
+    }
+};
+// Give a name to this to avoid having to use the internal struct name.
+using XUniqueGC = XUniquePtr&lt;_XGC&gt;;
+
+#if USE(GLX)
+template&lt;&gt; struct XPtrDeleter&lt;__GLXcontextRec&gt; {
+    void operator() (__GLXcontextRec* ptr)
+    {
+        if (ptr)
+            glXDestroyContext(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native(), ptr);
+    }
+};
+// Give a name to this to avoid having to use the internal struct name.
+using XUniqueGLXContext = XUniquePtr&lt;__GLXcontextRec&gt;;
+#endif
+
+} // namespace WebCore
+
+#endif // PLATFORM(X11)
+
+#endif // XUniquePtr_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsx11XUniqueResourcecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/x11/XUniqueResource.cpp (0 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/x11/XUniqueResource.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/x11/XUniqueResource.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 AND ITS CONTRIBUTORS &quot;AS IS&quot; 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 OR ITS 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 &quot;config.h&quot;
+#include &quot;XUniqueResource.h&quot;
+
+#if PLATFORM(X11)
+#include &quot;PlatformDisplayX11.h&quot;
+#include &lt;X11/Xlib.h&gt;
+#include &lt;X11/Xutil.h&gt;
+
+#if PLATFORM(GTK)
+#include &lt;X11/extensions/Xdamage.h&gt;
+#endif
+
+#if USE(GLX)
+#include &lt;GL/glx.h&gt;
+#endif
+
+namespace WebCore {
+
+static inline Display* sharedDisplay()
+{
+    return downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
+}
+
+template&lt;&gt; void XUniqueResource&lt;XResource::Colormap&gt;::deleteXResource(unsigned long resource)
+{
+    if (resource)
+        XFreeColormap(sharedDisplay(), resource);
+}
+
+#if PLATFORM(GTK)
+template&lt;&gt; void XUniqueResource&lt;XResource::Damage&gt;::deleteXResource(unsigned long resource)
+{
+    if (resource)
+        XDamageDestroy(sharedDisplay(), resource);
+}
+#endif
+
+template&lt;&gt; void XUniqueResource&lt;XResource::Pixmap&gt;::deleteXResource(unsigned long resource)
+{
+    if (resource)
+        XFreePixmap(sharedDisplay(), resource);
+}
+
+template&lt;&gt; void XUniqueResource&lt;XResource::Window&gt;::deleteXResource(unsigned long resource)
+{
+    if (resource)
+        XDestroyWindow(sharedDisplay(), resource);
+}
+
+#if USE(GLX)
+template&lt;&gt; void XUniqueResource&lt;XResource::GLXPbuffer&gt;::deleteXResource(unsigned long resource)
+{
+    if (resource)
+        glXDestroyPbuffer(sharedDisplay(), resource);
+}
+
+template&lt;&gt; void XUniqueResource&lt;XResource::GLXPixmap&gt;::deleteXResource(unsigned long resource)
+{
+    if (resource)
+        glXDestroyGLXPixmap(sharedDisplay(), resource);
+}
+#endif // USE(GLX)
+
+} // namespace WebCore
+
+#endif // PLATFORM(X11)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsx11XUniqueResourceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/x11/XUniqueResource.h (0 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/x11/XUniqueResource.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/x11/XUniqueResource.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -0,0 +1,110 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 AND ITS CONTRIBUTORS &quot;AS IS&quot; 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 OR ITS 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 XUniqueResource_h
+#define XUniqueResource_h
+
+#if PLATFORM(X11)
+
+#if USE(GLX)
+typedef unsigned long GLXPbuffer;
+typedef unsigned long GLXPixmap;
+#endif
+
+namespace WebCore {
+
+enum class XResource {
+    Colormap,
+#if PLATFORM(GTK)
+    Damage,
+#endif
+    Pixmap,
+    Window,
+#if USE(GLX)
+    GLXPbuffer,
+    GLXPixmap,
+#endif
+};
+
+template &lt;XResource T&gt; class XUniqueResource {
+public:
+    XUniqueResource()
+    {
+    }
+
+    XUniqueResource(unsigned long resource)
+        : m_resource(resource)
+    {
+    }
+
+    XUniqueResource(XUniqueResource&amp;&amp; uniqueResource)
+        : m_resource(uniqueResource.release())
+    {
+    }
+
+    XUniqueResource&amp; operator=(XUniqueResource&amp;&amp; uniqueResource)
+    {
+        reset(uniqueResource.release());
+        return *this;
+    }
+
+    ~XUniqueResource()
+    {
+        reset();
+    }
+
+    unsigned long get() const { return m_resource; }
+    unsigned long release() { return std::exchange(m_resource, 0); }
+
+    void reset(unsigned long resource = 0)
+    {
+        std::swap(m_resource, resource);
+        deleteXResource(resource);
+    }
+
+    explicit operator bool() const { return m_resource; }
+
+private:
+    static void deleteXResource(unsigned long resource);
+
+    unsigned long m_resource { 0 };
+};
+
+using XUniqueColormap = XUniqueResource&lt;XResource::Colormap&gt;;
+#if PLATFORM(GTK)
+using XUniqueDamage = XUniqueResource&lt;XResource::Damage&gt;;
+#endif
+using XUniquePixmap = XUniqueResource&lt;XResource::Pixmap&gt;;
+using XUniqueWindow = XUniqueResource&lt;XResource::Window&gt;;
+#if USE(GLX)
+using XUniqueGLXPbuffer = XUniqueResource&lt;XResource::GLXPbuffer&gt;;
+using XUniqueGLXPixmap = XUniqueResource&lt;XResource::GLXPixmap&gt;;
+#endif
+
+} // namespace WebCore
+
+#endif // PLATFORM(X11)
+
+#endif // XUniqueResource_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebKit2/ChangeLog        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-05-08  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [X11] Add XUniquePtr and XUniqueResource to automatically free X resources
+        https://bugs.webkit.org/show_bug.cgi?id=144521
+
+        Reviewed by Darin Adler.
+
+        Use XUniquePtr and XUniqueResource to free X resources.
+
+        * PlatformEfl.cmake: Add Source/WebCore/platform/graphics/x11 dir
+        to the include dir list.
+        * PlatformGTK.cmake: Ditto.
+        * UIProcess/cairo/BackingStoreCairo.cpp:
+        (WebKit::BackingStore::createBackend): Do not pass the display to
+        the BackingStoreBackendCairoX11 constructor.
+        * UIProcess/gtk/RedirectedXCompositeWindow.cpp:
+        (WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
+        (WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
+        (WebKit::RedirectedXCompositeWindow::resize):
+        (WebKit::RedirectedXCompositeWindow::cleanupPixmapAndPixmapSurface):
+        (WebKit::RedirectedXCompositeWindow::surface):
+        * UIProcess/gtk/RedirectedXCompositeWindow.h:
+        (WebKit::RedirectedXCompositeWindow::windowID):
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp:
+        (WebKit::NetscapePlugin::platformPostInitializeWindowless):
+        (WebKit::NetscapePlugin::platformDestroy):
+        (WebKit::NetscapePlugin::platformGeometryDidChange):
+        (WebKit::NetscapePlugin::platformPaint):
+
</ins><span class="cx"> 2015-05-11  Dan Bernstein  &lt;mitz@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebKit2 part of &lt;rdar://problem/20878075&gt; Trying to navigate to an invalid URL loads about:blank, but -[WKWebView URL] returns the invalid URL
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformEflcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformEfl.cmake (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformEfl.cmake        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebKit2/PlatformEfl.cmake        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -226,6 +226,7 @@
</span><span class="cx">     &quot;${WEBCORE_DIR}/platform/graphics/cairo&quot;
</span><span class="cx">     &quot;${WEBCORE_DIR}/platform/graphics/efl&quot;
</span><span class="cx">     &quot;${WEBCORE_DIR}/platform/graphics/opentype&quot;
</span><ins>+    &quot;${WEBCORE_DIR}/platform/graphics/x11&quot;
</ins><span class="cx">     &quot;${WEBCORE_DIR}/platform/network/soup&quot;
</span><span class="cx">     &quot;${WEBCORE_DIR}/platform/text/enchant&quot;
</span><span class="cx">     &quot;${WEBKIT2_DIR}/NetworkProcess/efl&quot;
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -455,6 +455,7 @@
</span><span class="cx">     &quot;${WEBCORE_DIR}/platform/gtk&quot;
</span><span class="cx">     &quot;${WEBCORE_DIR}/platform/graphics/cairo&quot;
</span><span class="cx">     &quot;${WEBCORE_DIR}/platform/graphics/opentype&quot;
</span><ins>+    &quot;${WEBCORE_DIR}/platform/graphics/x11&quot;
</ins><span class="cx">     &quot;${WEBCORE_DIR}/platform/network/soup&quot;
</span><span class="cx">     &quot;${WEBCORE_DIR}/platform/text/enchant&quot;
</span><span class="cx">     &quot;${WEBKIT2_DIR}/DatabaseProcess/unix&quot;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcesscairoBackingStoreCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">         GdkVisual* visual = gtk_widget_get_visual(m_webPageProxy.viewWidget());
</span><span class="cx">         GdkScreen* screen = gdk_visual_get_screen(visual);
</span><span class="cx">         ASSERT(downcast&lt;PlatformDisplayX11&gt;(sharedDisplay).native() == GDK_SCREEN_XDISPLAY(screen));
</span><del>-        return std::make_unique&lt;BackingStoreBackendCairoX11&gt;(downcast&lt;PlatformDisplayX11&gt;(sharedDisplay).native(), GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
</del><ins>+        return std::make_unique&lt;BackingStoreBackendCairoX11&gt;(GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
</ins><span class="cx">             GDK_VISUAL_XVISUAL(visual), gdk_visual_get_depth(visual), m_size, m_deviceScaleFactor);
</span><span class="cx">     }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><span class="cx"> 
</span><ins>+#include &lt;X11/Xlib.h&gt;
</ins><span class="cx"> #include &lt;X11/extensions/Xcomposite.h&gt;
</span><span class="cx"> #include &lt;X11/extensions/Xdamage.h&gt;
</span><span class="cx"> #include &lt;cairo-xlib.h&gt;
</span><span class="lines">@@ -135,21 +136,18 @@
</span><span class="cx"> 
</span><span class="cx"> RedirectedXCompositeWindow::RedirectedXCompositeWindow(GdkWindow* parentWindow, std::function&lt;void()&gt; damageNotify)
</span><span class="cx">     : m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(parentWindow)))
</span><del>-    , m_window(0)
-    , m_parentWindow(0)
-    , m_pixmap(0)
-    , m_damage(0)
</del><span class="cx">     , m_needsNewPixmapAfterResize(false)
</span><span class="cx"> {
</span><ins>+    ASSERT(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native() == m_display);
</ins><span class="cx">     Screen* screen = DefaultScreenOfDisplay(m_display);
</span><span class="cx"> 
</span><span class="cx">     GdkVisual* visual = gdk_window_get_visual(parentWindow);
</span><del>-    Colormap colormap = XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone);
</del><ins>+    XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
</ins><span class="cx"> 
</span><span class="cx">     // This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc
</span><span class="cx">     XSetWindowAttributes windowAttributes;
</span><span class="cx">     windowAttributes.override_redirect = True;
</span><del>-    windowAttributes.colormap = colormap;
</del><ins>+    windowAttributes.colormap = colormap.get();
</ins><span class="cx"> 
</span><span class="cx">     // CWBorderPixel must be present when the depth doesn't match the parent's one.
</span><span class="cx">     // See http://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c?id=xorg-server-1.16.0#n703.
</span><span class="lines">@@ -164,13 +162,13 @@
</span><span class="cx">         GDK_VISUAL_XVISUAL(visual),
</span><span class="cx">         CWOverrideRedirect | CWColormap | CWBorderPixel,
</span><span class="cx">         &amp;windowAttributes);
</span><del>-    XMapWindow(m_display, m_parentWindow);
</del><ins>+    XMapWindow(m_display, m_parentWindow.get());
</ins><span class="cx"> 
</span><span class="cx">     windowAttributes.event_mask = StructureNotifyMask;
</span><span class="cx">     windowAttributes.override_redirect = False;
</span><span class="cx">     // Create the window of at last 1x1 since X doesn't allow to create empty windows.
</span><span class="cx">     m_window = XCreateWindow(m_display,
</span><del>-        m_parentWindow,
</del><ins>+        m_parentWindow.get(),
</ins><span class="cx">         0, 0,
</span><span class="cx">         std::max(1, m_size.width()),
</span><span class="cx">         std::max(1, m_size.height()),
</span><span class="lines">@@ -180,21 +178,19 @@
</span><span class="cx">         CopyFromParent,
</span><span class="cx">         CWEventMask,
</span><span class="cx">         &amp;windowAttributes);
</span><del>-    XMapWindow(m_display, m_window);
</del><ins>+    XMapWindow(m_display, m_window.get());
</ins><span class="cx"> 
</span><del>-    XFreeColormap(m_display, colormap);
</del><ins>+    xDamageNotifier().add(m_window.get(), WTF::move(damageNotify));
</ins><span class="cx"> 
</span><del>-    xDamageNotifier().add(m_window, WTF::move(damageNotify));
-
</del><span class="cx">     while (1) {
</span><span class="cx">         XEvent event;
</span><del>-        XWindowEvent(m_display, m_window, StructureNotifyMask, &amp;event);
-        if (event.type == MapNotify &amp;&amp; event.xmap.window == m_window)
</del><ins>+        XWindowEvent(m_display, m_window.get(), StructureNotifyMask, &amp;event);
+        if (event.type == MapNotify &amp;&amp; event.xmap.window == m_window.get())
</ins><span class="cx">             break;
</span><span class="cx">     }
</span><del>-    XSelectInput(m_display, m_window, NoEventMask);
-    XCompositeRedirectWindow(m_display, m_window, CompositeRedirectManual);
-    m_damage = XDamageCreate(m_display, m_window, XDamageReportNonEmpty);
</del><ins>+    XSelectInput(m_display, m_window.get(), NoEventMask);
+    XCompositeRedirectWindow(m_display, m_window.get(), CompositeRedirectManual);
+    m_damage = XDamageCreate(m_display, m_window.get(), XDamageReportNonEmpty);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RedirectedXCompositeWindow::~RedirectedXCompositeWindow()
</span><span class="lines">@@ -204,12 +200,12 @@
</span><span class="cx">     ASSERT(m_window);
</span><span class="cx">     ASSERT(m_parentWindow);
</span><span class="cx"> 
</span><del>-    xDamageNotifier().remove(m_window);
</del><ins>+    xDamageNotifier().remove(m_window.get());
</ins><span class="cx"> 
</span><del>-    XDamageDestroy(m_display, m_damage);
-    XDestroyWindow(m_display, m_window);
-    XDestroyWindow(m_display, m_parentWindow);
-    cleanupPixmapAndPixmapSurface();
</del><ins>+    // Explicitly reset these because we need to ensure it happens in this order.
+    m_damage.reset();
+    m_window.reset();
+    m_parentWindow.reset();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RedirectedXCompositeWindow::resize(const IntSize&amp; size)
</span><span class="lines">@@ -218,7 +214,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // Resize the window to at last 1x1 since X doesn't allow to create empty windows.
</span><del>-    XResizeWindow(m_display, m_window, std::max(1, size.width()), std::max(1, size.height()));
</del><ins>+    XResizeWindow(m_display, m_window.get(), std::max(1, size.width()), std::max(1, size.height()));
</ins><span class="cx">     XFlush(m_display);
</span><span class="cx"> 
</span><span class="cx">     m_size = size;
</span><span class="lines">@@ -232,9 +228,8 @@
</span><span class="cx">     if (!m_pixmap)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    XFreePixmap(m_display, m_pixmap);
-    m_pixmap = 0;
</del><span class="cx">     m_surface = nullptr;
</span><ins>+    m_pixmap.reset();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> cairo_surface_t* RedirectedXCompositeWindow::surface()
</span><span class="lines">@@ -247,20 +242,19 @@
</span><span class="cx"> 
</span><span class="cx">     m_needsNewPixmapAfterResize = false;
</span><span class="cx"> 
</span><del>-    Pixmap newPixmap = XCompositeNameWindowPixmap(m_display, m_window);
</del><ins>+    XUniquePixmap newPixmap(XCompositeNameWindowPixmap(m_display, m_window.get()));
</ins><span class="cx">     if (!newPixmap) {
</span><span class="cx">         cleanupPixmapAndPixmapSurface();
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     XWindowAttributes windowAttributes;
</span><del>-    if (!XGetWindowAttributes(m_display, m_window, &amp;windowAttributes)) {
</del><ins>+    if (!XGetWindowAttributes(m_display, m_window.get(), &amp;windowAttributes)) {
</ins><span class="cx">         cleanupPixmapAndPixmapSurface();
</span><del>-        XFreePixmap(m_display, newPixmap);
</del><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RefPtr&lt;cairo_surface_t&gt; newSurface = adoptRef(cairo_xlib_surface_create(m_display, newPixmap, windowAttributes.visual, m_size.width(), m_size.height()));
</del><ins>+    RefPtr&lt;cairo_surface_t&gt; newSurface = adoptRef(cairo_xlib_surface_create(m_display, newPixmap.get(), windowAttributes.visual, m_size.width(), m_size.height()));
</ins><span class="cx"> 
</span><span class="cx">     // Nvidia drivers seem to prepare their redirected window pixmap asynchronously, so for a few fractions
</span><span class="cx">     // of a second after each resize, while doing continuous resizing (which constantly destroys and creates
</span><span class="lines">@@ -275,7 +269,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     cleanupPixmapAndPixmapSurface();
</span><del>-    m_pixmap = newPixmap;
</del><ins>+    m_pixmap = WTF::move(newPixmap);
</ins><span class="cx">     m_surface = newSurface;
</span><span class="cx">     return m_surface.get();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -31,11 +31,12 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;WebCore/IntSize.h&gt;
</span><span class="cx"> #include &lt;WebCore/RefPtrCairo.h&gt;
</span><del>-#include &lt;X11/Xlib.h&gt;
</del><ins>+#include &lt;WebCore/XUniqueResource.h&gt;
</ins><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> 
</span><span class="cx"> typedef struct _GdkWindow GdkWindow;
</span><del>-typedef unsigned long Damage;
</del><ins>+typedef struct _XDisplay Display;
+typedef unsigned long Window;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="lines">@@ -44,7 +45,7 @@
</span><span class="cx">     static std::unique_ptr&lt;RedirectedXCompositeWindow&gt; create(GdkWindow*, std::function&lt;void()&gt; damageNotify);
</span><span class="cx">     ~RedirectedXCompositeWindow();
</span><span class="cx"> 
</span><del>-    Window windowID() const { return m_window; }
</del><ins>+    Window windowID() const { return m_window.get(); }
</ins><span class="cx">     void resize(const WebCore::IntSize&amp;);
</span><span class="cx">     cairo_surface_t* surface();
</span><span class="cx"> 
</span><span class="lines">@@ -54,10 +55,10 @@
</span><span class="cx"> 
</span><span class="cx">     Display* m_display;
</span><span class="cx">     WebCore::IntSize m_size;
</span><del>-    Window m_window;
-    Window m_parentWindow;
-    Pixmap m_pixmap;
-    Damage m_damage;
</del><ins>+    WebCore::XUniqueWindow m_window;
+    WebCore::XUniqueWindow m_parentWindow;
+    WebCore::XUniquePixmap m_pixmap;
+    WebCore::XUniqueDamage m_damage;
</ins><span class="cx">     RefPtr&lt;cairo_surface_t&gt; m_surface;
</span><span class="cx">     bool m_needsNewPixmapAfterResize;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePluginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -42,6 +42,10 @@
</span><span class="cx"> #include &quot;WebHitTestResult.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLUGIN_ARCHITECTURE(X11)
+#include &lt;WebCore/XUniqueResource.h&gt;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> class MachSendRight;
</span><span class="cx"> class HTTPHeaderMap;
</span><span class="lines">@@ -388,7 +392,7 @@
</span><span class="cx">     NP_CGContext m_npCGContext;
</span><span class="cx"> #endif
</span><span class="cx"> #elif PLUGIN_ARCHITECTURE(X11)
</span><del>-    Pixmap m_drawable;
</del><ins>+    WebCore::XUniquePixmap m_drawable;
</ins><span class="cx">     Display* m_pluginDisplay;
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx">     GtkWidget* m_platformPluginWidget;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsNetscapex11NetscapePluginX11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp (184196 => 184197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp        2015-05-12 10:17:57 UTC (rev 184196)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp        2015-05-12 11:11:00 UTC (rev 184197)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &lt;WebCore/GraphicsContext.h&gt;
</span><span class="cx"> #include &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #include &lt;WebCore/PlatformDisplayX11.h&gt;
</span><ins>+#include &lt;WebCore/XUniquePtr.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx"> #include &lt;gtk/gtk.h&gt;
</span><span class="lines">@@ -175,12 +176,10 @@
</span><span class="cx">     visualTemplate.depth = depth;
</span><span class="cx">     visualTemplate.c_class = TrueColor;
</span><span class="cx">     int numMatching;
</span><del>-    XVisualInfo* visualInfo = XGetVisualInfo(display, VisualScreenMask | VisualDepthMask | VisualClassMask,
-                                             &amp;visualTemplate, &amp;numMatching);
</del><ins>+    XUniquePtr&lt;XVisualInfo&gt; visualInfo(XGetVisualInfo(display, VisualScreenMask | VisualDepthMask | VisualClassMask, &amp;visualTemplate, &amp;numMatching));
</ins><span class="cx">     ASSERT(visualInfo);
</span><del>-    Visual* visual = visualInfo[0].visual;
</del><ins>+    Visual* visual = visualInfo.get()[0].visual;
</ins><span class="cx">     ASSERT(visual);
</span><del>-    XFree(visualInfo);
</del><span class="cx"> 
</span><span class="cx">     callbackStruct-&gt;visual = visual;
</span><span class="cx">     callbackStruct-&gt;colormap = XCreateColormap(display, rootWindowID(), visual, AllocNone);
</span><span class="lines">@@ -232,10 +231,7 @@
</span><span class="cx">     XFreeColormap(hostDisplay, callbackStruct-&gt;colormap);
</span><span class="cx">     delete callbackStruct;
</span><span class="cx"> 
</span><del>-    if (m_drawable) {
-        XFreePixmap(hostDisplay, m_drawable);
-        m_drawable = 0;
-    }
</del><ins>+    m_drawable.reset();
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx">     if (m_platformPluginWidget) {
</span><span class="lines">@@ -262,18 +258,12 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Display* display = x11HostDisplay();
-    if (m_drawable)
-        XFreePixmap(display, m_drawable);
-
-    if (m_pluginSize.isEmpty()) {
-        m_drawable = 0;
</del><ins>+    m_drawable.reset();
+    if (m_pluginSize.isEmpty())
</ins><span class="cx">         return;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    m_drawable = XCreatePixmap(display, rootWindowID(), m_pluginSize.width(), m_pluginSize.height(), displayDepth());
-
-    XSync(display, false); // Make sure that the server knows about the Drawable.
</del><ins>+    m_drawable = XCreatePixmap(x11HostDisplay(), rootWindowID(), m_pluginSize.width(), m_pluginSize.height(), displayDepth());
+    XSync(x11HostDisplay(), false); // Make sure that the server knows about the Drawable.
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NetscapePlugin::platformVisibilityDidChange()
</span><span class="lines">@@ -307,7 +297,7 @@
</span><span class="cx">     XGraphicsExposeEvent&amp; exposeEvent = xevent.xgraphicsexpose;
</span><span class="cx">     exposeEvent.type = GraphicsExpose;
</span><span class="cx">     exposeEvent.display = x11HostDisplay();
</span><del>-    exposeEvent.drawable = m_drawable;
</del><ins>+    exposeEvent.drawable = m_drawable.get();
</ins><span class="cx"> 
</span><span class="cx">     IntRect exposedRect(dirtyRect);
</span><span class="cx">     exposeEvent.x = exposedRect.x();
</span><span class="lines">@@ -324,11 +314,8 @@
</span><span class="cx">         XSync(m_pluginDisplay, false);
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK) || (PLATFORM(EFL) &amp;&amp; USE(CAIRO))
</span><del>-    RefPtr&lt;cairo_surface_t&gt; drawableSurface = adoptRef(cairo_xlib_surface_create(m_pluginDisplay,
-                                                                                 m_drawable,
-                                                                                 static_cast&lt;NPSetWindowCallbackStruct*&gt;(m_npWindow.ws_info)-&gt;visual,
-                                                                                 m_pluginSize.width(),
-                                                                                 m_pluginSize.height()));
</del><ins>+    RefPtr&lt;cairo_surface_t&gt; drawableSurface = adoptRef(cairo_xlib_surface_create(m_pluginDisplay, m_drawable.get(),
+        static_cast&lt;NPSetWindowCallbackStruct*&gt;(m_npWindow.ws_info)-&gt;visual, m_pluginSize.width(), m_pluginSize.height()));
</ins><span class="cx">     cairo_t* cr = context-&gt;platformContext()-&gt;cr();
</span><span class="cx">     cairo_save(cr);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>