<!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>[176016] 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/176016">176016</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-11-12 04:13:10 -0800 (Wed, 12 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Move RedirectedXCompositeWindow from platform to WebKit2 layer
https://bugs.webkit.org/show_bug.cgi?id=138093
Reviewed by Martin Robinson.
Source/WebCore:
Remove RedirectedXCompositeWindow.
* PlatformGTK.cmake:
Source/WebKit2:
It's only used by WebKitWebViewBase. While moving the code the
following cleanups have been made:
- Use NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL.
- Use a helper class XDamageNotifier to handle the XDamage
events filtering and notification.
- Use std::function instead of pointer to function for the
damage callback.
- Pass the X display to the RedirectedXCompositeWindow constructor
and keep it as a member to use it everywhere, instead of using
the default display in some places and the widget display in others.
- Pass the damage notify function as a contructor parameter of
RedirectedXCompositeWindow instead of setting the callback
right after creating the object.
- Remove GLContextNeeded and all the dead code related to the
CreateGLContext mode that is no longer used.
- Rename cairoSurfaceForWidget() as surface().
- windowId() has been renamed as windowID() and made const.
- Use std::unique_ptr instead of PassOwnPtr.
- Fix coding style issues.
* PlatformGTK.cmake:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseConstructed):
(webkitWebViewRenderAcceleratedCompositingResults):
(webkitWebViewBaseCreateWebPage):
(redirectedWindowDamagedCallback): Deleted.
* UIProcess/gtk/RedirectedXCompositeWindow.cpp: Renamed from Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp.
(WebKit::XDamageNotifier::XDamageNotifier):
(WebKit::XDamageNotifier::add):
(WebKit::XDamageNotifier::remove):
(WebKit::XDamageNotifier::filterXDamageEvent):
(WebKit::XDamageNotifier::filterXEvent):
(WebKit::xDamageNotifier):
(WebKit::supportsXDamageAndXComposite):
(WebKit::RedirectedXCompositeWindow::create):
(WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
(WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
(WebKit::RedirectedXCompositeWindow::resize):
(WebKit::RedirectedXCompositeWindow::cleanupPixmapAndPixmapSurface):
(WebKit::RedirectedXCompositeWindow::surface):
* UIProcess/gtk/RedirectedXCompositeWindow.h: Renamed from Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h.
(WebKit::RedirectedXCompositeWindow::windowID):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<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>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgtkRedirectedXCompositeWindowcpp">trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkRedirectedXCompositeWindowh">trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (176015 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-12 11:25:16 UTC (rev 176015)
+++ trunk/Source/WebCore/ChangeLog        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-11-12 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Move RedirectedXCompositeWindow from platform to WebKit2 layer
+ https://bugs.webkit.org/show_bug.cgi?id=138093
+
+ Reviewed by Martin Robinson.
+
+ Remove RedirectedXCompositeWindow.
+
+ * PlatformGTK.cmake:
+
</ins><span class="cx"> 2014-09-01 Philippe Normand <pnormand@igalia.com>
</span><span class="cx">
</span><span class="cx"> [WK2] UserMediaClient support
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (176015 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2014-11-12 11:25:16 UTC (rev 176015)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -233,7 +233,6 @@
</span><span class="cx"> platform/gtk/PlatformMouseEventGtk.cpp
</span><span class="cx"> platform/gtk/PlatformScreenGtk.cpp
</span><span class="cx"> platform/gtk/PlatformWheelEventGtk.cpp
</span><del>- platform/gtk/RedirectedXCompositeWindow.cpp
</del><span class="cx"> platform/gtk/ScrollbarThemeGtk.cpp
</span><span class="cx"> platform/gtk/SoundGtk.cpp
</span><span class="cx"> platform/gtk/WidgetGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkRedirectedXCompositeWindowcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp (176015 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp        2014-11-12 11:25:16 UTC (rev 176015)
+++ trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -1,270 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012 Igalia S.L.
- * All rights reserved.
- *
- * 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 INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "RedirectedXCompositeWindow.h"
-
-#if USE(OPENGL) && PLATFORM(X11)
-
-#include <X11/extensions/Xcomposite.h>
-#include <X11/extensions/Xdamage.h>
-#include <cairo-xlib.h>
-#include <gdk/gdkx.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-typedef HashMap<Window, RedirectedXCompositeWindow*> WindowHashMap;
-static WindowHashMap& getWindowHashMap()
-{
- DEPRECATED_DEFINE_STATIC_LOCAL(WindowHashMap, windowHashMap, ());
- return windowHashMap;
-}
-
-static int gDamageEventBase;
-static GdkFilterReturn filterXDamageEvent(GdkXEvent* gdkXEvent, GdkEvent*, void*)
-{
- XEvent* xEvent = static_cast<XEvent*>(gdkXEvent);
- if (xEvent->type != gDamageEventBase + XDamageNotify)
- return GDK_FILTER_CONTINUE;
-
- XDamageNotifyEvent* damageEvent = reinterpret_cast<XDamageNotifyEvent*>(xEvent);
- WindowHashMap& windowHashMap = getWindowHashMap();
- WindowHashMap::iterator i = windowHashMap.find(damageEvent->drawable);
- if (i == windowHashMap.end())
- return GDK_FILTER_CONTINUE;
-
- i->value->callDamageNotifyCallback();
- XDamageSubtract(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), damageEvent->damage, None, None);
- return GDK_FILTER_REMOVE;
-}
-
-static bool supportsXDamageAndXComposite()
-{
- static bool initialized = false;
- static bool hasExtensions = false;
-
- if (initialized)
- return hasExtensions;
-
- initialized = true;
-
- int errorBase;
- Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
- if (!XDamageQueryExtension(display, &gDamageEventBase, &errorBase))
- return false;
-
- int eventBase;
- if (!XCompositeQueryExtension(display, &eventBase, &errorBase))
- return false;
-
- // We need to support XComposite version 0.2.
- int major, minor;
- XCompositeQueryVersion(display, &major, &minor);
- if (major < 0 || (!major && minor < 2))
- return false;
-
- hasExtensions = true;
- return true;
-}
-
-PassOwnPtr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(const IntSize& size, GLContextNeeded needsContext)
-{
- return supportsXDamageAndXComposite() ? adoptPtr(new RedirectedXCompositeWindow(size, needsContext)) : nullptr;
-}
-
-RedirectedXCompositeWindow::RedirectedXCompositeWindow(const IntSize& size, GLContextNeeded needsContext)
- : m_size(size)
- , m_window(0)
- , m_parentWindow(0)
- , m_pixmap(0)
- , m_needsContext(needsContext)
- , m_surface(0)
- , m_needsNewPixmapAfterResize(false)
- , m_damage(0)
- , m_damageNotifyCallback(0)
- , m_damageNotifyData(0)
-{
- Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
- Screen* screen = DefaultScreenOfDisplay(display);
-
- // This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc
- XSetWindowAttributes windowAttributes;
- windowAttributes.override_redirect = True;
- m_parentWindow = XCreateWindow(display,
- RootWindowOfScreen(screen),
- WidthOfScreen(screen) + 1, 0, 1, 1,
- 0,
- CopyFromParent,
- InputOutput,
- CopyFromParent,
- CWOverrideRedirect,
- &windowAttributes);
- XMapWindow(display, m_parentWindow);
-
- windowAttributes.event_mask = StructureNotifyMask;
- windowAttributes.override_redirect = False;
- m_window = XCreateWindow(display,
- m_parentWindow,
- 0, 0, size.width(), size.height(),
- 0,
- CopyFromParent,
- InputOutput,
- CopyFromParent,
- CWEventMask,
- &windowAttributes);
- XMapWindow(display, m_window);
-
- if (getWindowHashMap().isEmpty())
- gdk_window_add_filter(0, reinterpret_cast<GdkFilterFunc>(filterXDamageEvent), 0);
- getWindowHashMap().add(m_window, this);
-
- while (1) {
- XEvent event;
- XWindowEvent(display, m_window, StructureNotifyMask, &event);
- if (event.type == MapNotify && event.xmap.window == m_window)
- break;
- }
- XSelectInput(display, m_window, NoEventMask);
- XCompositeRedirectWindow(display, m_window, CompositeRedirectManual);
- m_damage = XDamageCreate(display, m_window, XDamageReportNonEmpty);
-}
-
-RedirectedXCompositeWindow::~RedirectedXCompositeWindow()
-{
- ASSERT(m_damage);
- ASSERT(m_window);
- ASSERT(m_parentWindow);
-
- getWindowHashMap().remove(m_window);
- if (getWindowHashMap().isEmpty())
- gdk_window_remove_filter(0, reinterpret_cast<GdkFilterFunc>(filterXDamageEvent), 0);
-
- Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
- XDamageDestroy(display, m_damage);
- XDestroyWindow(display, m_window);
- XDestroyWindow(display, m_parentWindow);
- cleanupPixmapAndPixmapSurface();
-}
-
-void RedirectedXCompositeWindow::resize(const IntSize& size)
-{
- Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
- XResizeWindow(display, m_window, size.width(), size.height());
-
- XFlush(display);
-
- if (m_needsContext == CreateGLContext) {
- context()->waitNative();
- // This swap is based on code in Chromium. It tries to work-around a bug in the Intel drivers
- // where a swap is necessary to ensure the front and back buffers are properly resized.
- if (context() == GLContext::getCurrent())
- context()->swapBuffers();
- }
-
- m_size = size;
- m_needsNewPixmapAfterResize = true;
-}
-
-GLContext* RedirectedXCompositeWindow::context()
-{
- ASSERT(m_needsContext == CreateGLContext);
-
- if (m_context)
- return m_context.get();
-
- ASSERT(m_window);
- m_context = GLContext::createContextForWindow(m_window, GLContext::sharingContext());
- return m_context.get();
-}
-
-void RedirectedXCompositeWindow::cleanupPixmapAndPixmapSurface()
-{
- if (!m_pixmap)
- return;
-
- XFreePixmap(cairo_xlib_surface_get_display(m_surface.get()), m_pixmap);
- m_pixmap = 0;
- m_surface = nullptr;
-}
-
-cairo_surface_t* RedirectedXCompositeWindow::cairoSurfaceForWidget(GtkWidget* widget)
-{
- if (!m_needsNewPixmapAfterResize && m_surface)
- return m_surface.get();
-
- m_needsNewPixmapAfterResize = false;
-
- // It's important that the new pixmap be created with the same Display pointer as the target
- // widget or else drawing speed can be 100x slower.
- Display* newPixmapDisplay = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(widget));
- Pixmap newPixmap = XCompositeNameWindowPixmap(newPixmapDisplay, m_window);
- if (!newPixmap) {
- cleanupPixmapAndPixmapSurface();
- return 0;
- }
-
- XWindowAttributes windowAttributes;
- if (!XGetWindowAttributes(newPixmapDisplay, m_window, &windowAttributes)) {
- cleanupPixmapAndPixmapSurface();
- XFreePixmap(newPixmapDisplay, newPixmap);
- return 0;
- }
-
- RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_xlib_surface_create(newPixmapDisplay, newPixmap,
- windowAttributes.visual,
- m_size.width(), m_size.height()));
-
- // Nvidia drivers seem to prepare their redirected window pixmap asynchronously, so for a few fractions
- // of a second after each resize, while doing continuous resizing (which constantly destroys and creates
- // pixmap window-backings), the pixmap memory is uninitialized. To work around this issue, paint the old
- // pixmap to the new one to properly initialize it.
- if (m_surface) {
- RefPtr<cairo_t> cr = adoptRef(cairo_create(newSurface.get()));
- cairo_set_source_rgb(cr.get(), 1, 1, 1);
- cairo_paint(cr.get());
- cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0);
- cairo_paint(cr.get());
- }
-
- cleanupPixmapAndPixmapSurface();
- m_pixmap = newPixmap;
- m_surface = newSurface;
-
- return m_surface.get();
-}
-
-void RedirectedXCompositeWindow::callDamageNotifyCallback()
-{
- if (m_damageNotifyCallback)
- m_damageNotifyCallback(m_damageNotifyData);
-}
-
-} // namespace WebCore
-
-#endif // USE(OPENGL) && PLATFORM(X11)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkRedirectedXCompositeWindowh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h (176015 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h        2014-11-12 11:25:16 UTC (rev 176015)
+++ trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -1,84 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012, Igalia S.L.
- * All rights reserved.
- *
- * 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 INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef RedirectedXCompositeWindow_h
-#define RedirectedXCompositeWindow_h
-
-#if USE(OPENGL) && PLATFORM(X11)
-
-#include "GLContext.h"
-#include "IntSize.h"
-#include "RefPtrCairo.h"
-
-typedef unsigned long Pixmap;
-typedef unsigned long Window;
-typedef unsigned long Damage;
-typedef void (*DamageNotifyCallback)(void*);
-
-namespace WebCore {
-
-class RedirectedXCompositeWindow {
-public:
- enum GLContextNeeded { CreateGLContext, DoNotCreateGLContext };
- static PassOwnPtr<RedirectedXCompositeWindow> create(const IntSize&, GLContextNeeded = CreateGLContext);
- virtual ~RedirectedXCompositeWindow();
- const IntSize& size() { return m_size; }
-
- void resize(const IntSize& newSize);
- GLContext* context();
- cairo_surface_t* cairoSurfaceForWidget(GtkWidget*);
- Window windowId() { return m_window; }
- void callDamageNotifyCallback();
-
- void setDamageNotifyCallback(DamageNotifyCallback callback, void* data)
- {
- m_damageNotifyCallback = callback;
- m_damageNotifyData = data;
- }
-
-private:
- RedirectedXCompositeWindow(const IntSize&, GLContextNeeded);
- void cleanupPixmapAndPixmapSurface();
-
- IntSize m_size;
- Window m_window;
- Window m_parentWindow;
- Pixmap m_pixmap;
- GLContextNeeded m_needsContext;
- OwnPtr<GLContext> m_context;
- RefPtr<cairo_surface_t> m_surface;
- bool m_needsNewPixmapAfterResize;
-
- Damage m_damage;
- DamageNotifyCallback m_damageNotifyCallback;
- void* m_damageNotifyData;
-};
-
-} // namespace WebCore
-
-#endif // USE(OPENGL) && PLATFORM(X11)
-
-#endif // RedirectedXCompositeWindow_h
</del></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (176015 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-11-12 11:25:16 UTC (rev 176015)
+++ trunk/Source/WebKit2/ChangeLog        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2014-11-12 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Move RedirectedXCompositeWindow from platform to WebKit2 layer
+ https://bugs.webkit.org/show_bug.cgi?id=138093
+
+ Reviewed by Martin Robinson.
+
+ It's only used by WebKitWebViewBase. While moving the code the
+ following cleanups have been made:
+
+ - Use NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL.
+ - Use a helper class XDamageNotifier to handle the XDamage
+ events filtering and notification.
+ - Use std::function instead of pointer to function for the
+ damage callback.
+ - Pass the X display to the RedirectedXCompositeWindow constructor
+ and keep it as a member to use it everywhere, instead of using
+ the default display in some places and the widget display in others.
+ - Pass the damage notify function as a contructor parameter of
+ RedirectedXCompositeWindow instead of setting the callback
+ right after creating the object.
+ - Remove GLContextNeeded and all the dead code related to the
+ CreateGLContext mode that is no longer used.
+ - Rename cairoSurfaceForWidget() as surface().
+ - windowId() has been renamed as windowID() and made const.
+ - Use std::unique_ptr instead of PassOwnPtr.
+ - Fix coding style issues.
+
+ * PlatformGTK.cmake:
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseConstructed):
+ (webkitWebViewRenderAcceleratedCompositingResults):
+ (webkitWebViewBaseCreateWebPage):
+ (redirectedWindowDamagedCallback): Deleted.
+ * UIProcess/gtk/RedirectedXCompositeWindow.cpp: Renamed from Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp.
+ (WebKit::XDamageNotifier::XDamageNotifier):
+ (WebKit::XDamageNotifier::add):
+ (WebKit::XDamageNotifier::remove):
+ (WebKit::XDamageNotifier::filterXDamageEvent):
+ (WebKit::XDamageNotifier::filterXEvent):
+ (WebKit::xDamageNotifier):
+ (WebKit::supportsXDamageAndXComposite):
+ (WebKit::RedirectedXCompositeWindow::create):
+ (WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
+ (WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
+ (WebKit::RedirectedXCompositeWindow::resize):
+ (WebKit::RedirectedXCompositeWindow::cleanupPixmapAndPixmapSurface):
+ (WebKit::RedirectedXCompositeWindow::surface):
+ * UIProcess/gtk/RedirectedXCompositeWindow.h: Renamed from Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h.
+ (WebKit::RedirectedXCompositeWindow::windowID):
+
</ins><span class="cx"> 2014-09-01 Philippe Normand <pnormand@igalia.com>
</span><span class="cx">
</span><span class="cx"> [WK2] UserMediaClient support
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (176015 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2014-11-12 11:25:16 UTC (rev 176015)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -253,6 +253,7 @@
</span><span class="cx"> UIProcess/gtk/ExperimentalFeatures.cpp
</span><span class="cx"> UIProcess/gtk/GestureController.cpp
</span><span class="cx"> UIProcess/gtk/InputMethodFilter.cpp
</span><ins>+ UIProcess/gtk/RedirectedXCompositeWindow.cpp
</ins><span class="cx"> UIProcess/gtk/TextCheckerGtk.cpp
</span><span class="cx"> UIProcess/gtk/WebContextGtk.cpp
</span><span class="cx"> UIProcess/gtk/WebContextMenuProxyGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (176015 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2014-11-12 11:25:16 UTC (rev 176015)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include "NativeWebMouseEvent.h"
</span><span class="cx"> #include "NativeWebWheelEvent.h"
</span><span class="cx"> #include "PageClientImpl.h"
</span><ins>+#include "RedirectedXCompositeWindow.h"
</ins><span class="cx"> #include "ViewState.h"
</span><span class="cx"> #include "WebContext.h"
</span><span class="cx"> #include "WebEventFactory.h"
</span><span class="lines">@@ -70,10 +71,6 @@
</span><span class="cx"> #include "WebFullScreenManagerProxy.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
-#include <WebCore/RedirectedXCompositeWindow.h>
-#endif
-
</del><span class="cx"> // gtk_widget_get_scale_factor() appeared in GTK 3.10, but we also need
</span><span class="cx"> // to make sure we have cairo new enough to support cairo_surface_set_device_scale
</span><span class="cx"> #define HAVE_GTK_SCALE_FACTOR HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE && GTK_CHECK_VERSION(3, 10, 0)
</span><span class="lines">@@ -84,10 +81,6 @@
</span><span class="cx"> typedef HashMap<GtkWidget*, IntRect> WebKitWebViewChildrenMap;
</span><span class="cx"> typedef HashMap<uint32_t, GUniquePtr<GdkEvent>> TouchEventsMap;
</span><span class="cx">
</span><del>-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
-void redirectedWindowDamagedCallback(void* data);
-#endif
-
</del><span class="cx"> struct _WebKitWebViewBasePrivate {
</span><span class="cx"> WebKitWebViewChildrenMap children;
</span><span class="cx"> std::unique_ptr<PageClientImpl> pageClient;
</span><span class="lines">@@ -132,7 +125,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
</span><del>- OwnPtr<RedirectedXCompositeWindow> redirectedWindow;
</del><ins>+ std::unique_ptr<RedirectedXCompositeWindow> redirectedWindow;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="lines">@@ -437,11 +430,8 @@
</span><span class="cx">
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
</span><span class="cx"> GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
</span><del>- if (GDK_IS_X11_DISPLAY(display)) {
- priv->redirectedWindow = RedirectedXCompositeWindow::create(IntSize(1, 1), RedirectedXCompositeWindow::DoNotCreateGLContext);
- if (priv->redirectedWindow)
- priv->redirectedWindow->setDamageNotifyCallback(redirectedWindowDamagedCallback, object);
- }
</del><ins>+ if (GDK_IS_X11_DISPLAY(display))
+ priv->redirectedWindow = RedirectedXCompositeWindow::create(GDK_DISPLAY_XDISPLAY(display), IntSize(1, 1), [viewWidget] { gtk_widget_queue_draw(viewWidget); });
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> priv->authenticationDialog = 0;
</span><span class="lines">@@ -460,10 +450,12 @@
</span><span class="cx"> if (!priv->redirectedWindow)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
- cairo_surface_t* surface = priv->redirectedWindow->cairoSurfaceForWidget(GTK_WIDGET(webViewBase));
- cairo_set_source_surface(cr, surface, 0, 0);
- cairo_fill(cr);
</del><ins>+ if (cairo_surface_t* surface = priv->redirectedWindow->surface()) {
+ cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
+ cairo_set_source_surface(cr, surface, 0, 0);
+ cairo_fill(cr);
+ }
+
</ins><span class="cx"> return true;
</span><span class="cx"> #else
</span><span class="cx"> return false;
</span><span class="lines">@@ -1065,7 +1057,7 @@
</span><span class="cx">
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
</span><span class="cx"> if (priv->redirectedWindow)
</span><del>- priv->pageProxy->setAcceleratedCompositingWindowId(priv->redirectedWindow->windowId());
</del><ins>+ priv->pageProxy->setAcceleratedCompositingWindowId(priv->redirectedWindow->windowID());
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if HAVE(GTK_SCALE_FACTOR)
</span><span class="lines">@@ -1182,13 +1174,6 @@
</span><span class="cx"> return webkitWebViewBase->priv->contextMenuEvent.release();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
-void redirectedWindowDamagedCallback(void* data)
-{
- gtk_widget_queue_draw(GTK_WIDGET(data));
-}
-#endif
-
</del><span class="cx"> void webkitWebViewBaseSetFocus(WebKitWebViewBase* webViewBase, bool focused)
</span><span class="cx"> {
</span><span class="cx"> WebKitWebViewBasePrivate* priv = webViewBase->priv;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowcppfromrev176015trunkSourceWebCoreplatformgtkRedirectedXCompositeWindowcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp (from rev 176015, trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp) (0 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -0,0 +1,261 @@
</span><ins>+/*
+ * Copyright (C) 2012,2014 Igalia S.L.
+ * All rights reserved.
+ *
+ * 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 INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RedirectedXCompositeWindow.h"
+
+#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+
+#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/Xdamage.h>
+#include <cairo-xlib.h>
+#include <gdk/gdkx.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class XDamageNotifier {
+ WTF_MAKE_NONCOPYABLE(XDamageNotifier);
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ static int s_damageEventBase;
+
+ XDamageNotifier()
+ {
+ }
+
+ void add(Window window, std::function<void()> notifyFunction)
+ {
+ if (m_notifyFunctions.isEmpty())
+ gdk_window_add_filter(nullptr, reinterpret_cast<GdkFilterFunc>(&filterXDamageEvent), this);
+ m_notifyFunctions.add(window, WTF::move(notifyFunction));
+ }
+
+ void remove(Window window)
+ {
+ m_notifyFunctions.remove(window);
+ if (m_notifyFunctions.isEmpty())
+ gdk_window_remove_filter(nullptr, reinterpret_cast<GdkFilterFunc>(&filterXDamageEvent), this);
+ }
+
+private:
+ static GdkFilterReturn filterXDamageEvent(GdkXEvent* event, GdkEvent*, XDamageNotifier* notifier)
+ {
+ return notifier->filterXEvent(static_cast<XEvent*>(event));
+ }
+
+ GdkFilterReturn filterXEvent(XEvent* event) const
+ {
+ if (event->type != s_damageEventBase + XDamageNotify)
+ return GDK_FILTER_CONTINUE;
+
+ XDamageNotifyEvent* damageEvent = reinterpret_cast<XDamageNotifyEvent*>(event);
+ if (const auto& notifyFunction = m_notifyFunctions.get(damageEvent->drawable)) {
+ notifyFunction();
+ XDamageSubtract(event->xany.display, damageEvent->damage, None, None);
+ return GDK_FILTER_REMOVE;
+ }
+
+ return GDK_FILTER_CONTINUE;
+ }
+
+ HashMap<Window, std::function<void()>> m_notifyFunctions;
+};
+
+int XDamageNotifier::s_damageEventBase = 0;
+
+static XDamageNotifier& xDamageNotifier()
+{
+ static NeverDestroyed<XDamageNotifier> notifier;
+ return notifier;
+}
+
+static bool supportsXDamageAndXComposite(Display* display)
+{
+ static bool initialized = false;
+ static bool hasExtensions = false;
+
+ if (initialized)
+ return hasExtensions;
+
+ initialized = true;
+
+ int errorBase;
+ if (!XDamageQueryExtension(display, &XDamageNotifier::s_damageEventBase, &errorBase))
+ return false;
+
+ int eventBase;
+ if (!XCompositeQueryExtension(display, &eventBase, &errorBase))
+ return false;
+
+ // We need to support XComposite version 0.2.
+ int major, minor;
+ XCompositeQueryVersion(display, &major, &minor);
+ if (major < 0 || (!major && minor < 2))
+ return false;
+
+ hasExtensions = true;
+ return true;
+}
+
+std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(Display* display, const IntSize& size, std::function<void()> damageNotify)
+{
+ return supportsXDamageAndXComposite(display) ? std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(display, size, damageNotify)) : nullptr;
+}
+
+RedirectedXCompositeWindow::RedirectedXCompositeWindow(Display* display, const IntSize& size, std::function<void()> damageNotify)
+ : m_display(display)
+ , m_size(size)
+ , m_window(0)
+ , m_parentWindow(0)
+ , m_pixmap(0)
+ , m_damage(0)
+ , m_needsNewPixmapAfterResize(false)
+{
+ Screen* screen = DefaultScreenOfDisplay(display);
+
+ // This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc
+ XSetWindowAttributes windowAttributes;
+ windowAttributes.override_redirect = True;
+ m_parentWindow = XCreateWindow(display,
+ RootWindowOfScreen(screen),
+ WidthOfScreen(screen) + 1, 0, 1, 1,
+ 0,
+ CopyFromParent,
+ InputOutput,
+ CopyFromParent,
+ CWOverrideRedirect,
+ &windowAttributes);
+ XMapWindow(display, m_parentWindow);
+
+ windowAttributes.event_mask = StructureNotifyMask;
+ windowAttributes.override_redirect = False;
+ m_window = XCreateWindow(display,
+ m_parentWindow,
+ 0, 0, size.width(), size.height(),
+ 0,
+ CopyFromParent,
+ InputOutput,
+ CopyFromParent,
+ CWEventMask,
+ &windowAttributes);
+ XMapWindow(display, m_window);
+
+ xDamageNotifier().add(m_window, WTF::move(damageNotify));
+
+ while (1) {
+ XEvent event;
+ XWindowEvent(display, m_window, StructureNotifyMask, &event);
+ if (event.type == MapNotify && event.xmap.window == m_window)
+ break;
+ }
+ XSelectInput(display, m_window, NoEventMask);
+ XCompositeRedirectWindow(display, m_window, CompositeRedirectManual);
+ m_damage = XDamageCreate(display, m_window, XDamageReportNonEmpty);
+}
+
+RedirectedXCompositeWindow::~RedirectedXCompositeWindow()
+{
+ ASSERT(m_display);
+ ASSERT(m_damage);
+ ASSERT(m_window);
+ ASSERT(m_parentWindow);
+
+ xDamageNotifier().remove(m_window);
+
+ XDamageDestroy(m_display, m_damage);
+ XDestroyWindow(m_display, m_window);
+ XDestroyWindow(m_display, m_parentWindow);
+ cleanupPixmapAndPixmapSurface();
+}
+
+void RedirectedXCompositeWindow::resize(const IntSize& size)
+{
+ XResizeWindow(m_display, m_window, size.width(), size.height());
+ XFlush(m_display);
+
+ m_size = size;
+ m_needsNewPixmapAfterResize = true;
+}
+
+void RedirectedXCompositeWindow::cleanupPixmapAndPixmapSurface()
+{
+ if (!m_pixmap)
+ return;
+
+ XFreePixmap(m_display, m_pixmap);
+ m_pixmap = 0;
+ m_surface = nullptr;
+}
+
+cairo_surface_t* RedirectedXCompositeWindow::surface()
+{
+ if (!m_needsNewPixmapAfterResize && m_surface)
+ return m_surface.get();
+
+ m_needsNewPixmapAfterResize = false;
+
+ Pixmap newPixmap = XCompositeNameWindowPixmap(m_display, m_window);
+ if (!newPixmap) {
+ cleanupPixmapAndPixmapSurface();
+ return nullptr;
+ }
+
+ XWindowAttributes windowAttributes;
+ if (!XGetWindowAttributes(m_display, m_window, &windowAttributes)) {
+ cleanupPixmapAndPixmapSurface();
+ XFreePixmap(m_display, newPixmap);
+ return nullptr;
+ }
+
+ RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_xlib_surface_create(m_display, newPixmap, windowAttributes.visual, m_size.width(), m_size.height()));
+
+ // Nvidia drivers seem to prepare their redirected window pixmap asynchronously, so for a few fractions
+ // of a second after each resize, while doing continuous resizing (which constantly destroys and creates
+ // pixmap window-backings), the pixmap memory is uninitialized. To work around this issue, paint the old
+ // pixmap to the new one to properly initialize it.
+ if (m_surface) {
+ RefPtr<cairo_t> cr = adoptRef(cairo_create(newSurface.get()));
+ cairo_set_source_rgb(cr.get(), 1, 1, 1);
+ cairo_paint(cr.get());
+ cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0);
+ cairo_paint(cr.get());
+ }
+
+ cleanupPixmapAndPixmapSurface();
+ m_pixmap = newPixmap;
+ m_surface = newSurface;
+ return m_surface.get();
+}
+
+} // namespace WebCore
+
+#endif // USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowhfromrev176015trunkSourceWebCoreplatformgtkRedirectedXCompositeWindowh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h (from rev 176015, trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h) (0 => 176016)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h        2014-11-12 12:13:10 UTC (rev 176016)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+/*
+ * Copyright (C) 2012 Igalia S.L.
+ * All rights reserved.
+ *
+ * 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 INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RedirectedXCompositeWindow_h
+#define RedirectedXCompositeWindow_h
+
+#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+
+#include <WebCore/IntSize.h>
+#include <WebCore/RefPtrCairo.h>
+
+typedef struct _XDisplay Display;
+typedef unsigned long Damage;
+typedef unsigned long Pixmap;
+typedef unsigned long Window;
+
+namespace WebKit {
+
+class RedirectedXCompositeWindow {
+public:
+ static std::unique_ptr<RedirectedXCompositeWindow> create(Display*, const WebCore::IntSize&, std::function<void()> damageNotify);
+ ~RedirectedXCompositeWindow();
+
+ Window windowID() const { return m_window; }
+ void resize(const WebCore::IntSize&);
+ cairo_surface_t* surface();
+
+private:
+ RedirectedXCompositeWindow(Display*, const WebCore::IntSize&, std::function<void()> damageNotify);
+ void cleanupPixmapAndPixmapSurface();
+
+ Display* m_display;
+ WebCore::IntSize m_size;
+ Window m_window;
+ Window m_parentWindow;
+ Pixmap m_pixmap;
+ Damage m_damage;
+ RefPtr<cairo_surface_t> m_surface;
+ bool m_needsNewPixmapAfterResize;
+};
+
+} // namespace WebKit
+
+#endif // USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+
+#endif // RedirectedXCompositeWindow_h
</ins></span></pre>
</div>
</div>
</body>
</html>