Diff
Modified: trunk/Source/WebCore/ChangeLog (204012 => 204013)
--- trunk/Source/WebCore/ChangeLog 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebCore/ChangeLog 2016-08-02 06:42:18 UTC (rev 204013)
@@ -1,3 +1,17 @@
+2016-08-01 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Move the redirected XComposite window to the web process
+ https://bugs.webkit.org/show_bug.cgi?id=160389
+
+ Reviewed by Žan Doberšek.
+
+ Add helper methods to PlatformDisplayX11 to query X extensions supported by the display.
+
+ * platform/graphics/x11/PlatformDisplayX11.cpp:
+ (WebCore::PlatformDisplayX11::supportsXComposite):
+ (WebCore::PlatformDisplayX11::supportsXDamage):
+ * platform/graphics/x11/PlatformDisplayX11.h:
+
2016-08-01 Andreas Kling <[email protected]>
Shrink MediaQuerySets to fit after parsing.
Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp (204012 => 204013)
--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -28,6 +28,10 @@
#if PLATFORM(X11)
#include <X11/Xlib.h>
+#include <X11/extensions/Xcomposite.h>
+#if PLATFORM(GTK)
+#include <X11/extensions/Xdamage.h>
+#endif
#if USE(EGL)
#include <EGL/egl.h>
@@ -61,6 +65,32 @@
}
#endif
+bool PlatformDisplayX11::supportsXComposite() const
+{
+ if (!m_supportsXComposite) {
+ int eventBase, errorBase;
+ m_supportsXComposite = XCompositeQueryExtension(m_display, &eventBase, &errorBase);
+ }
+ return m_supportsXComposite.value();
+}
+
+bool PlatformDisplayX11::supportsXDamage(Optional<int>& damageEventBase) const
+{
+ if (!m_supportsXDamage) {
+#if PLATFORM(GTK)
+ int eventBase, errorBase;
+ m_supportsXDamage = XDamageQueryExtension(m_display, &eventBase, &errorBase);
+ if (m_supportsXDamage.value())
+ m_damageEventBase = eventBase;
+#else
+ m_supportsXDamage = false;
+#endif
+ }
+
+ damageEventBase = m_damageEventBase;
+ return m_supportsXDamage.value();
+}
+
} // namespace WebCore
#endif // PLATFORM(X11)
Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h (204012 => 204013)
--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -29,6 +29,7 @@
#if PLATFORM(X11)
#include "PlatformDisplay.h"
+#include <wtf/Optional.h>
typedef struct _XDisplay Display;
@@ -41,6 +42,8 @@
virtual ~PlatformDisplayX11();
Display* native() const { return m_display; }
+ bool supportsXComposite() const;
+ bool supportsXDamage(Optional<int>& damageEventBase) const;
private:
Type type() const override { return PlatformDisplay::Type::X11; }
@@ -51,6 +54,9 @@
Display* m_display;
bool m_ownedDisplay;
+ mutable Optional<bool> m_supportsXComposite;
+ mutable Optional<bool> m_supportsXDamage;
+ mutable Optional<int> m_damageEventBase;
};
} // namespace WebCore
Modified: trunk/Source/WebKit2/ChangeLog (204012 => 204013)
--- trunk/Source/WebKit2/ChangeLog 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/ChangeLog 2016-08-02 06:42:18 UTC (rev 204013)
@@ -1,5 +1,143 @@
2016-08-01 Carlos Garcia Campos <[email protected]>
+ [GTK] Move the redirected XComposite window to the web process
+ https://bugs.webkit.org/show_bug.cgi?id=160389
+
+ Reviewed by Žan Doberšek.
+
+ In the current code, the UI process creates the redirected window that the web process uses to render
+ accelerated contents. The redirected window is sent to the web process as native surface handle, and using
+ XDamage extension the UI process takes a pixmap of the redirected window to render into the widget when there
+ are updates. This requires several points of synchronization between UI and web processes. When the web view is
+ resized, the UI process first resizes the redirected window and then sends a new backing store ID to the web
+ process. The time between the redirected window is resized and the web process renders the new contents the UI
+ process keeps rendering the previous contents with the previous size in the new window with the new size. This
+ makes the resize process slow, and it produces rendering artifacts quite often. The redirected window is created
+ when the web view is realized, to be able to inherit the XVisual from the parent window, and the native window
+ handle is sent to the web process. The time until the window is realized, the web process doesn't have a context
+ to render into, so the UI process simply renders an empty page. When the web view is unrealized, for example if
+ the web view is reparented, the redirected window is destroyed, and a sync message is sent to the web process to
+ destroy the current gl context and stop drawing. This needs to happen synchronously, because the UI process
+ can't remove the redirected window until the web process has stopped rendering into it. This makes also the
+ reparenting process quite unstable and risky.
+ To all those synchronization points we now have to add the synchronization with the compositing thread when
+ using the threaded compositor. The threaded compositor made resizing, reparenting, etc. even worse. We can't
+ avoid the synchronization with the threaded compositor, but we can reduce the synchronization points and improve
+ the current ones by moving the redirected window to the web process. In this case is web process who creates the
+ redirected window, so we can be sure that it always has a valid native surface handle to render into. This means
+ we no longer need the IPC message to send the native surface handle from the UI process to the web process, nor
+ the sync message to destroy it either. This also means we no longer need to wait until the view is realized to
+ start rendering accelerated contents, and we don't need to stop when it's unrealized either. We don't really
+ need to inherit the XVisual from the parent window if the redirected window always uses always a RGBA visual
+ when available. That way we always render into a transparent window that is composed into the web view
+ widget. And when the web view is resized, we no longer need to destroy the GL context either, because we use the
+ same redirected window as the native handle, but create a new pixmap that is what we send to the UI process as
+ layer tree context ID. The layer tree context ID is already sent to the UI process by the drawing area as part
+ of the backing store update process, so we don't need any new IPC message for this. When the web view is
+ resized, the UI process sends a backing store state update message to the web process that updates its size,
+ relayouts and then renders the new contents, so that when the update backing store state reply gets to the UI
+ process, we already have a new pixmap with the new contents updated. This makes resizing smooth again, and
+ avoids flickering and rendering artifacts. And finally all this also prevents several race conditions that were
+ causing X errors and web process crashes.
+
+ * PlatformGTK.cmake:
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+ (WebKit::ThreadedCompositor::create): Make it possible to optionally pass a native surface handle for
+ compositing to the ThreadedCompositor contructor.
+ (WebKit::ThreadedCompositor::ThreadedCompositor): Initialize the native surface handle and make the scene active
+ after the thread initialization if we already have a valid handle.
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::enterAcceleratedCompositingMode): Pass the layer tree context ID to the web view.
+ (WebKit::PageClientImpl::updateAcceleratedCompositingMode): Notify the web view about the update.
+ (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
+ * UIProcess/API/gtk/PageClientImpl.h:
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseSetAcceleratedCompositingPixmap): Helper function to update the pixmap used to render the
+ accelerated contents.
+ (webkitWebViewBaseRealize): Remove the code to create the redirected window.
+ (webkitWebViewBaseUnrealize): Remove the code to destroy the redirected window.
+ (webkitWebViewBaseDispose): Reset the accelerated compositing pixmap.
+ (webkitWebViewRenderAcceleratedCompositingResults): Use the accelerated compositing pixmap surface.
+ (webkitWebViewBaseSizeAllocate): Remove the code to resize the redirected window.
+ (webkitWebViewBaseEnterAcceleratedCompositingMode): Update the accelerated compositing pixmap.
+ (webkitWebViewBaseUpdateAcceleratedCompositingMode): Ditto.
+ (webkitWebViewBaseExitAcceleratedCompositingMode): Reset the accelerated compositing pixmap.
+ (webkitWebViewBaseDidRelaunchWebProcess): Remove the code to send native surface handle to the web process.
+ (webkitWebViewBasePageClosed): Reset the accelerated compositing pixmap.
+ (_WebKitWebViewBasePrivate::updateViewStateTimerFired): Deleted.
+ * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+ * UIProcess/DrawingAreaProxy.h:
+ * UIProcess/DrawingAreaProxy.messages.in:
+ * UIProcess/DrawingAreaProxyImpl.cpp:
+ (WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Handle the case when the layer tree context ID
+ changes without leaving the accelerated compositing mode, calling updateAcceleratedCompositingMode().
+ (WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode): Let the web view know we are leaving accelerated
+ compositing mode even when it's forced, since in case of web process crash we need to leave the accelerated
+ compositing mode in the UI process.
+ (WebKit::DrawingAreaProxyImpl::willEnterAcceleratedCompositingMode): This message was added only to prepare the
+ redirected window when the web process was about to enter accelerated compositing mode, so it's no longer needed.
+ (WebKit::DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing): This is now only used when building
+ without redirected XComposite window support.
+ * UIProcess/DrawingAreaProxyImpl.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::willEnterAcceleratedCompositingMode): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/efl/WebView.h:
+ * UIProcess/gtk/RedirectedXCompositeWindow.cpp: Removed.
+ * UIProcess/gtk/XDamageNotifier.cpp: Helper class to be notified about XDamage events.
+ (WebKit::XDamageNotifier::singleton):
+ (WebKit::XDamageNotifier::XDamageNotifier):
+ (WebKit::XDamageNotifier::add):
+ (WebKit::XDamageNotifier::remove):
+ (WebKit::XDamageNotifier::filterXDamageEvent):
+ (WebKit::XDamageNotifier::notify):
+ * UIProcess/gtk/XDamageNotifier.h: Added.
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
+ * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
+ (WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode): Remove code to send
+ WillEnterAcceleratedCompositingMode message.
+ (WebKit::AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing): This is now only used when building
+ without redirected XComposite window support.
+ * WebProcess/WebPage/AcceleratedDrawingArea.h:
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+ (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Create a redirected window and
+ pass the window ID as native surface handle to the threaded compositor. Use the redirected window pixmap as
+ layer tree context.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::invalidate): Destroy the redirected window.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Resize the redirected window and
+ update the layer tree context.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Ditto.
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+ * WebProcess/WebPage/DrawingArea.h:
+ * WebProcess/WebPage/DrawingArea.messages.in:
+ * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+ (WebKit::LayerTreeHostGtk::LayerTreeHostGtk): Create a redirected window and texture mapper that uses the window
+ ID as native surface handle. Use the redirected window pixmap as layer tree context.
+ (WebKit::LayerTreeHostGtk::makeContextCurrent): Use the redirected window as native handle.
+ (WebKit::LayerTreeHostGtk::invalidate): Destroy the redirected window.
+ (WebKit::LayerTreeHostGtk::sizeDidChange): Resize the redirected window and update the layer tree context.
+ (WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged): Ditto.
+ (WebKit::LayerTreeHostGtk::createTextureMapper): Helper function to create the texture mapper.
+ (WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing): Use createTextureMapper().
+ * WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
+ * WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp: Added.
+ (WebKit::RedirectedXCompositeWindow::create):
+ (WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
+ (WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
+ (WebKit::RedirectedXCompositeWindow::resize):
+ * WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h: Renamed from Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h.
+ (WebKit::RedirectedXCompositeWindow::window):
+ (WebKit::RedirectedXCompositeWindow::pixmap):
+
+2016-08-01 Carlos Garcia Campos <[email protected]>
+
Database Process: ASSERTION FAILED: filePaths.size() == result.handles().size() with SANDBOX_EXTENSIONS disabled
https://bugs.webkit.org/show_bug.cgi?id=160398
Modified: trunk/Source/WebKit2/PlatformGTK.cmake (204012 => 204013)
--- trunk/Source/WebKit2/PlatformGTK.cmake 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/PlatformGTK.cmake 2016-08-02 06:42:18 UTC (rev 204013)
@@ -299,8 +299,8 @@
UIProcess/gtk/GestureController.cpp
UIProcess/gtk/InputMethodFilter.cpp
UIProcess/gtk/KeyBindingTranslator.cpp
- UIProcess/gtk/RedirectedXCompositeWindow.cpp
UIProcess/gtk/TextCheckerGtk.cpp
+ UIProcess/gtk/XDamageNotifier.cpp
UIProcess/gtk/WebColorPickerGtk.cpp
UIProcess/gtk/WebContextMenuProxyGtk.cpp
UIProcess/gtk/WebFullScreenClientGtk.cpp
@@ -350,6 +350,7 @@
WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp
WebProcess/WebPage/gtk/PrinterListGtk.cpp
+ WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp
WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp
WebProcess/WebPage/gtk/WebPageGtk.cpp
WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (204012 => 204013)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -41,18 +41,20 @@
namespace WebKit {
-Ref<ThreadedCompositor> ThreadedCompositor::create(Client* client)
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client* client, uint64_t nativeSurfaceHandle)
{
- return adoptRef(*new ThreadedCompositor(client));
+ return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle));
}
-ThreadedCompositor::ThreadedCompositor(Client* client)
+ThreadedCompositor::ThreadedCompositor(Client* client, uint64_t nativeSurfaceHandle)
: m_client(client)
+ , m_nativeSurfaceHandle(nativeSurfaceHandle)
, m_compositingRunLoop(std::make_unique<CompositingRunLoop>([this] { renderLayerTree(); }))
{
m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
m_scene = adoptRef(new CoordinatedGraphicsScene(this));
m_viewportController = std::make_unique<SimpleViewportController>(this);
+ m_scene->setActive(!!m_nativeSurfaceHandle);
});
}
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (204012 => 204013)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -57,7 +57,7 @@
virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0;
};
- static Ref<ThreadedCompositor> create(Client*);
+ static Ref<ThreadedCompositor> create(Client*, uint64_t nativeSurfaceHandle = 0);
virtual ~ThreadedCompositor();
void setNativeSurfaceHandleForCompositing(uint64_t);
@@ -77,7 +77,7 @@
void forceRepaint();
private:
- ThreadedCompositor(Client*);
+ ThreadedCompositor(Client*, uint64_t nativeSurfaceHandle);
// CoordinatedGraphicsSceneClient
void renderNextFrame() override;
@@ -101,7 +101,7 @@
WebCore::IntSize m_viewportSize;
float m_deviceScaleFactor { 1 };
bool m_drawsBackground { true };
- uint64_t m_nativeSurfaceHandle { 0 };
+ uint64_t m_nativeSurfaceHandle;
std::unique_ptr<CompositingRunLoop> m_compositingRunLoop;
};
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -216,9 +216,9 @@
return WebColorPickerGtk::create(*page, color, rect);
}
-void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
+void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
{
- webkitWebViewBaseEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
+ webkitWebViewBaseEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext);
}
void PageClientImpl::exitAcceleratedCompositingMode()
@@ -226,16 +226,11 @@
webkitWebViewBaseExitAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}
-void PageClientImpl::willEnterAcceleratedCompositingMode()
+void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
{
- webkitWebViewBaseWillEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
+ webkitWebViewBaseUpdateAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext);
}
-void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
-{
- notImplemented();
-}
-
void PageClientImpl::pageClosed()
{
webkitWebViewBasePageClosed(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -92,7 +92,6 @@
void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
void exitAcceleratedCompositingMode() override;
void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
- void willEnterAcceleratedCompositingMode() override;
void handleDownloadRequest(DownloadProxy*) override;
void didChangeContentSize(const WebCore::IntSize&) override;
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -37,7 +37,6 @@
#include "NativeWebMouseEvent.h"
#include "NativeWebWheelEvent.h"
#include "PageClientImpl.h"
-#include "RedirectedXCompositeWindow.h"
#include "ViewState.h"
#include "WebEventFactory.h"
#include "WebFullScreenClientGtk.h"
@@ -73,6 +72,15 @@
#include "WebFullScreenManagerProxy.h"
#endif
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include "XDamageNotifier.h"
+#include <WebCore/PlatformDisplayX11.h>
+#include <WebCore/XUniqueResource.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xdamage.h>
+#include <cairo-xlib.h>
+#endif
+
#if PLATFORM(X11)
#include <gdk/gdkx.h>
#endif
@@ -151,9 +159,6 @@
struct _WebKitWebViewBasePrivate {
_WebKitWebViewBasePrivate()
: updateViewStateTimer(RunLoop::main(), this, &_WebKitWebViewBasePrivate::updateViewStateTimerFired)
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- , clearRedirectedWindowSoonTimer(RunLoop::main(), this, &_WebKitWebViewBasePrivate::clearRedirectedWindowSoonTimerFired)
-#endif
{
}
@@ -165,14 +170,6 @@
viewStateFlagsToUpdate = ViewState::NoFlags;
}
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- void clearRedirectedWindowSoonTimerFired()
- {
- if (redirectedWindow)
- redirectedWindow->resize(IntSize());
- }
-#endif
-
WebKitWebViewChildrenMap children;
std::unique_ptr<PageClientImpl> pageClient;
RefPtr<WebPageProxy> pageProxy;
@@ -215,8 +212,8 @@
#endif
#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- std::unique_ptr<RedirectedXCompositeWindow> redirectedWindow;
- RunLoop::Timer<WebKitWebViewBasePrivate> clearRedirectedWindowSoonTimer;
+ RefPtr<cairo_surface_t> acceleratedCompositingSurface;
+ XUniqueDamage acceleratedCompositingSurfaceDamage;
#endif
#if ENABLE(DRAG_SUPPORT)
@@ -355,13 +352,46 @@
}
#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-static void webkitWebViewBaseResizeRedirectedWindow(WebKitWebViewBase* webView)
+static void webkitWebViewBaseSetAcceleratedCompositingPixmap(WebKitWebViewBase* webView, Pixmap pixmap)
{
+ if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
+ return;
+
WebKitWebViewBasePrivate* priv = webView->priv;
+ if (priv->acceleratedCompositingSurface
+ && cairo_xlib_surface_get_drawable(priv->acceleratedCompositingSurface.get()) == pixmap)
+ return;
+
+ if (priv->acceleratedCompositingSurface) {
+ if (priv->acceleratedCompositingSurfaceDamage) {
+ XDamageNotifier::singleton().remove(priv->acceleratedCompositingSurfaceDamage.get());
+ priv->acceleratedCompositingSurfaceDamage.reset();
+ }
+ priv->acceleratedCompositingSurface = nullptr;
+ }
+
+ if (!pixmap)
+ return;
+
DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
if (!drawingArea)
return;
- priv->redirectedWindow->resize(drawingArea->size());
+
+ IntSize size = drawingArea->size();
+ float deviceScaleFactor = priv->pageProxy->deviceScaleFactor();
+ size.scale(deviceScaleFactor);
+
+ Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
+ ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
+ GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
+ if (!visual)
+ visual = gdk_screen_get_system_visual(gdk_screen_get_default());
+ priv->acceleratedCompositingSurface = adoptRef(cairo_xlib_surface_create(display, pixmap, GDK_VISUAL_XVISUAL(visual), size.width(), size.height()));
+ cairoSurfaceSetDeviceScale(priv->acceleratedCompositingSurface.get(), deviceScaleFactor, deviceScaleFactor);
+ priv->acceleratedCompositingSurfaceDamage = XDamageCreate(display, pixmap, XDamageReportNonEmpty);
+ XDamageNotifier::singleton().add(priv->acceleratedCompositingSurfaceDamage.get(), [webView] {
+ gtk_widget_queue_draw(GTK_WIDGET(webView));
+ });
}
#endif
@@ -370,26 +400,6 @@
WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
WebKitWebViewBasePrivate* priv = webView->priv;
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
- ASSERT(!priv->redirectedWindow);
- DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
- priv->redirectedWindow = RedirectedXCompositeWindow::create(
- *priv->pageProxy,
- drawingArea && drawingArea->isInAcceleratedCompositingMode() ? drawingArea->size() : IntSize(),
- [webView] {
- DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webView->priv->pageProxy->drawingArea());
- if (drawingArea && drawingArea->isInAcceleratedCompositingMode())
- gtk_widget_queue_draw(GTK_WIDGET(webView));
- });
- if (priv->redirectedWindow && drawingArea) {
- drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID());
- if (drawingArea->isInAcceleratedCompositingMode())
- webkitWebViewBaseResizeRedirectedWindow(webView);
- }
- }
-#endif
-
gtk_widget_set_realized(widget, TRUE);
GtkAllocation allocation;
@@ -439,13 +449,10 @@
static void webkitWebViewBaseUnrealize(GtkWidget* widget)
{
WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
-#if USE(TEXTURE_MAPPER) && PLATFORM(X11)
+#if USE(TEXTURE_MAPPER) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webView->priv->pageProxy->drawingArea()))
drawingArea->destroyNativeSurfaceHandleForCompositing();
#endif
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- webView->priv->redirectedWindow = nullptr;
-#endif
gtk_im_context_set_client_window(webView->priv->inputMethodFilter.context(), nullptr);
GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->unrealize(widget);
@@ -557,6 +564,9 @@
g_cancellable_cancel(webView->priv->screenSaverInhibitCancellable.get());
webkitWebViewBaseSetToplevelOnScreenWindow(webView, nullptr);
webView->priv->pageProxy->close();
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ webkitWebViewBaseSetAcceleratedCompositingPixmap(webView, 0);
+#endif
G_OBJECT_CLASS(webkit_web_view_base_parent_class)->dispose(gobject);
}
@@ -577,38 +587,33 @@
static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase* webViewBase, DrawingAreaProxyImpl* drawingArea, cairo_t* cr, GdkRectangle* clipRect)
{
-#if USE(TEXTURE_MAPPER) && USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
ASSERT(drawingArea);
if (!drawingArea->isInAcceleratedCompositingMode())
return false;
- // To avoid flashes when initializing accelerated compositing for the first
- // time, we wait until we know there's a frame ready before rendering.
- WebKitWebViewBasePrivate* priv = webViewBase->priv;
- if (!priv->redirectedWindow)
- return false;
+ WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(webViewBase)->priv;
+ cairo_surface_t* surface = priv->acceleratedCompositingSurface.get();
+ cairo_save(cr);
- webkitWebViewBaseResizeRedirectedWindow(webViewBase);
- if (cairo_surface_t* surface = priv->redirectedWindow->surface()) {
- cairo_save(cr);
+ if (!surface || !priv->pageProxy->drawsBackground()) {
+ const WebCore::Color& color = priv->pageProxy->backgroundColor();
+ if (color.hasAlpha()) {
+ cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
+ cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
+ cairo_fill(cr);
+ }
- if (!priv->pageProxy->drawsBackground()) {
- const WebCore::Color& color = priv->pageProxy->backgroundColor();
- if (color.hasAlpha()) {
- cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
- cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
- cairo_fill(cr);
- }
-
- if (color.alpha() > 0) {
- setSourceRGBAFromColor(cr, color);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
- cairo_fill(cr);
- }
+ if (color.alpha() > 0) {
+ setSourceRGBAFromColor(cr, color);
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
+ cairo_fill(cr);
}
+ }
+ if (surface) {
// The surface can be modified by the web process at any time, so we mark it
// as dirty to ensure we always render the updated contents as soon as possible.
cairo_surface_mark_dirty(surface);
@@ -616,10 +621,10 @@
cairo_set_source_surface(cr, surface, 0, 0);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_fill(cr);
-
- cairo_restore(cr);
}
+ cairo_restore(cr);
+
return true;
#else
UNUSED_PARAM(webViewBase);
@@ -717,22 +722,8 @@
gtk_widget_size_allocate(priv->authenticationDialog, &childAllocation);
}
- DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
- if (!drawingArea)
- return;
-
-
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- if (priv->redirectedWindow && drawingArea->isInAcceleratedCompositingMode()) {
- // We don't use webkitWebViewBaseResizeRedirectedWindow here, because we want to update the
- // redirected window size before the drawing area, because on resize the drawing area sends
- // the UpdateBackingStoreState message to the web process and waits for its reply. We want
- // the web process to use the new xwindow size when UpdateBackingStoreState message arrives.
- priv->redirectedWindow->resize(viewRect.size());
- }
-#endif
-
- drawingArea->setSize(viewRect.size(), IntSize(), IntSize());
+ if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea()))
+ drawingArea->setSize(viewRect.size(), IntSize(), IntSize());
}
static void webkitWebViewBaseGetPreferredWidth(GtkWidget* widget, gint* minimumSize, gint* naturalSize)
@@ -1284,10 +1275,6 @@
#if HAVE(GTK_SCALE_FACTOR)
static void deviceScaleFactorChanged(WebKitWebViewBase* webkitWebViewBase)
{
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- if (webkitWebViewBase->priv->redirectedWindow)
- webkitWebViewBaseResizeRedirectedWindow(webkitWebViewBase);
-#endif
webkitWebViewBase->priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
}
#endif // HAVE(GTK_SCALE_FACTOR)
@@ -1577,37 +1564,19 @@
webkitWebViewBase->priv->clickCounter.reset();
}
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-static void webkitWebViewBaseClearRedirectedWindowSoon(WebKitWebViewBase* webkitWebViewBase)
+void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase, const LayerTreeContext& layerTreeContext)
{
- static const double clearRedirectedWindowSoonDelay = 2;
- webkitWebViewBase->priv->clearRedirectedWindowSoonTimer.startOneShot(clearRedirectedWindowSoonDelay);
-}
-#endif
-
-void webkitWebViewBaseWillEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
-{
#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
- if (!priv->redirectedWindow)
- return;
- DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
- if (!drawingArea)
- return;
-
- webkitWebViewBaseResizeRedirectedWindow(webkitWebViewBase);
-
- // Clear the redirected window if we don't enter AC mode in the end.
- webkitWebViewBaseClearRedirectedWindowSoon(webkitWebViewBase);
+ webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, layerTreeContext.contextID);
#else
UNUSED_PARAM(webkitWebViewBase);
#endif
}
-void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
+void webkitWebViewBaseUpdateAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase, const LayerTreeContext& layerTreeContext)
{
#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- webkitWebViewBase->priv->clearRedirectedWindowSoonTimer.stop();
+ webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, layerTreeContext.contextID);
#else
UNUSED_PARAM(webkitWebViewBase);
#endif
@@ -1616,10 +1585,7 @@
void webkitWebViewBaseExitAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
{
#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- // Resize the window later to ensure we have already rendered the
- // non composited contents and avoid flickering. We can also avoid the
- // window resize entirely if we switch back to AC mode quickly.
- webkitWebViewBaseClearRedirectedWindowSoon(webkitWebViewBase);
+ webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, 0);
#else
UNUSED_PARAM(webkitWebViewBase);
#endif
@@ -1630,7 +1596,7 @@
// Queue a resize to ensure the new DrawingAreaProxy is resized.
gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
-#if PLATFORM(X11) && USE(TEXTURE_MAPPER)
+#if PLATFORM(X11) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
return;
@@ -1637,15 +1603,11 @@
WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
ASSERT(drawingArea);
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- if (!priv->redirectedWindow)
- return;
- uint64_t windowID = priv->redirectedWindow->windowID();
-#else
+
if (!gtk_widget_get_realized(GTK_WIDGET(webkitWebViewBase)))
return;
+
uint64_t windowID = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(webkitWebViewBase)));
-#endif
drawingArea->setNativeSurfaceHandleForCompositing(windowID);
#else
UNUSED_PARAM(webkitWebViewBase);
@@ -1654,7 +1616,9 @@
void webkitWebViewBasePageClosed(WebKitWebViewBase* webkitWebViewBase)
{
-#if PLATFORM(X11) && USE(TEXTURE_MAPPER)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, 0);
+#elif PLATFORM(X11) && USE(TEXTURE_MAPPER)
if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
return;
@@ -1665,9 +1629,5 @@
DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
ASSERT(drawingArea);
drawingArea->destroyNativeSurfaceHandleForCompositing();
-
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
- priv->redirectedWindow = nullptr;
#endif
-#endif // PLATFORM(X11) && USE(TEXTURE_MAPPER)
}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -71,8 +71,8 @@
void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase*);
void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector, WebKit::AttachmentSide);
void webkitWebViewBaseResetClickCounter(WebKitWebViewBase*);
-void webkitWebViewBaseWillEnterAcceleratedCompositingMode(WebKitWebViewBase*);
-void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase*);
+void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase*, const WebKit::LayerTreeContext&);
+void webkitWebViewBaseUpdateAcceleratedCompositingMode(WebKitWebViewBase*, const WebKit::LayerTreeContext&);
void webkitWebViewBaseExitAcceleratedCompositingMode(WebKitWebViewBase*);
void webkitWebViewBaseDidRelaunchWebProcess(WebKitWebViewBase*);
void webkitWebViewBasePageClosed(WebKitWebViewBase*);
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -130,7 +130,6 @@
virtual void enterAcceleratedCompositingMode(uint64_t /* backingStoreStateID */, const LayerTreeContext&) { }
virtual void exitAcceleratedCompositingMode(uint64_t /* backingStoreStateID */, const UpdateInfo&) { }
virtual void updateAcceleratedCompositingMode(uint64_t /* backingStoreStateID */, const LayerTreeContext&) { }
- virtual void willEnterAcceleratedCompositingMode(uint64_t /* backingStoreStateID */) { }
#if PLATFORM(COCOA)
virtual void didUpdateGeometry() { }
virtual void intrinsicContentSizeDidChange(const WebCore::IntSize&) { }
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in 2016-08-02 06:42:18 UTC (rev 204013)
@@ -26,7 +26,6 @@
EnterAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
ExitAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::UpdateInfo updateInfo)
UpdateAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
- WillEnterAcceleratedCompositingMode(uint64_t backingStoreStateID)
#if PLATFORM(COCOA)
// Used by TiledCoreAnimationDrawingAreaProxy.
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -157,15 +157,16 @@
m_webPageProxy.process().responsivenessTimer().stop();
if (layerTreeContext != m_layerTreeContext) {
- if (!m_layerTreeContext.isEmpty()) {
+ if (layerTreeContext.isEmpty() && !m_layerTreeContext.isEmpty()) {
exitAcceleratedCompositingMode();
ASSERT(m_layerTreeContext.isEmpty());
- }
-
- if (!layerTreeContext.isEmpty()) {
+ } else if (!layerTreeContext.isEmpty() && m_layerTreeContext.isEmpty()) {
enterAcceleratedCompositingMode(layerTreeContext);
ASSERT(layerTreeContext == m_layerTreeContext);
- }
+ } else {
+ updateAcceleratedCompositingMode(layerTreeContext);
+ ASSERT(layerTreeContext == m_layerTreeContext);
+ }
}
if (m_nextBackingStoreStateID != m_currentBackingStoreStateID)
@@ -173,7 +174,7 @@
else {
m_hasReceivedFirstUpdate = true;
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
if (m_pendingNativeSurfaceHandleForCompositing) {
setNativeSurfaceHandleForCompositing(m_pendingNativeSurfaceHandleForCompositing);
m_pendingNativeSurfaceHandleForCompositing = 0;
@@ -221,15 +222,6 @@
updateAcceleratedCompositingMode(layerTreeContext);
}
-void DrawingAreaProxyImpl::willEnterAcceleratedCompositingMode(uint64_t backingStoreStateID)
-{
- // WillEnterAcceleratedCompositingMode message is sent when the LayerTreeHost is created in the Web Process.
- // This can happen while there's still a DidUpdateBackingStoreState pending, in which case we are receiving
- // here the new backingStoreStateID, but m_currentBackingStoreStateID hasn't been updated yet.
- ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_nextBackingStoreStateID);
- m_webPageProxy.willEnterAcceleratedCompositingMode();
-}
-
void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo)
{
ASSERT(!isInAcceleratedCompositingMode());
@@ -315,7 +307,7 @@
m_webPageProxy.enterAcceleratedCompositingMode(layerTreeContext);
}
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
void DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing(uint64_t handle)
{
if (!m_hasReceivedFirstUpdate) {
@@ -351,8 +343,7 @@
ASSERT(isInAcceleratedCompositingMode());
m_layerTreeContext = LayerTreeContext();
- if (!alwaysUseCompositing())
- m_webPageProxy.exitAcceleratedCompositingMode();
+ m_webPageProxy.exitAcceleratedCompositingMode();
}
void DrawingAreaProxyImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -48,7 +48,7 @@
bool hasReceivedFirstUpdate() const { return m_hasReceivedFirstUpdate; }
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
void setNativeSurfaceHandleForCompositing(uint64_t);
void destroyNativeSurfaceHandleForCompositing();
#endif
@@ -69,7 +69,6 @@
void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) override;
void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
- void willEnterAcceleratedCompositingMode(uint64_t backingStoreStateID) override;
void incorporateUpdate(const UpdateInfo&);
Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/PageClient.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -235,7 +235,6 @@
virtual void enterAcceleratedCompositingMode(const LayerTreeContext&) = 0;
virtual void exitAcceleratedCompositingMode() = 0;
virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) = 0;
- virtual void willEnterAcceleratedCompositingMode() = 0;
#if PLATFORM(MAC)
virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0;
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -5465,11 +5465,6 @@
m_pageClient.updateAcceleratedCompositingMode(layerTreeContext);
}
-void WebPageProxy::willEnterAcceleratedCompositingMode()
-{
- m_pageClient.willEnterAcceleratedCompositingMode();
-}
-
void WebPageProxy::backForwardClear()
{
m_backForwardList->clear();
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -824,7 +824,6 @@
virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
virtual void exitAcceleratedCompositingMode();
virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
- void willEnterAcceleratedCompositingMode();
enum UndoOrRedo { Undo, Redo };
void addEditCommand(WebEditCommandProxy*);
Modified: trunk/Source/WebKit2/UIProcess/efl/WebView.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/efl/WebView.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/efl/WebView.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -221,7 +221,6 @@
void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
void exitAcceleratedCompositingMode() override;
void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
- void willEnterAcceleratedCompositingMode() override { }
#if ENABLE(FULLSCREEN_API)
WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
Deleted: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -1,292 +0,0 @@
-/*
- * 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(REDIRECTED_XCOMPOSITE_WINDOW)
-
-#include "WebPageProxy.h"
-#include <WebCore/CairoUtilities.h>
-#include <WebCore/PlatformDisplayX11.h>
-#include <X11/Xlib.h>
-#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, WTFMove(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(GdkWindow* window)
-{
- static bool initialized = false;
- static bool hasExtensions = false;
-
- if (initialized)
- return hasExtensions;
-
- initialized = true;
- Display* display = GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window));
-
- 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(WebPageProxy& webPage, const IntSize& initialSize, std::function<void()>&& damageNotify)
-{
- GdkWindow* parentWindow = gtk_widget_get_parent_window(webPage.viewWidget());
- ASSERT(GDK_IS_WINDOW(parentWindow));
- if (!supportsXDamageAndXComposite(parentWindow))
- return nullptr;
- return std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(webPage, initialSize, WTFMove(damageNotify)));
-}
-
-RedirectedXCompositeWindow::RedirectedXCompositeWindow(WebPageProxy& webPage, const IntSize& initialSize, std::function<void()>&& damageNotify)
- : m_webPage(webPage)
- , m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(gtk_widget_get_parent_window(webPage.viewWidget()))))
- , m_size(initialSize)
-{
- m_size.scale(m_webPage.deviceScaleFactor());
-
- ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == m_display);
- Screen* screen = DefaultScreenOfDisplay(m_display);
-
- GdkVisual* visual = gdk_window_get_visual(gtk_widget_get_parent_window(webPage.viewWidget()));
- XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
-
- // This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc
- XSetWindowAttributes windowAttributes;
- windowAttributes.override_redirect = True;
- windowAttributes.colormap = colormap.get();
-
- // CWBorderPixel must be present when the depth doesn't match the parent's one.
- // See http://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c?id=xorg-server-1.16.0#n703.
- windowAttributes.border_pixel = 0;
-
- m_parentWindow = XCreateWindow(m_display,
- RootWindowOfScreen(screen),
- WidthOfScreen(screen) + 1, 0, 1, 1,
- 0,
- gdk_visual_get_depth(visual),
- InputOutput,
- GDK_VISUAL_XVISUAL(visual),
- CWOverrideRedirect | CWColormap | CWBorderPixel,
- &windowAttributes);
- XMapWindow(m_display, m_parentWindow.get());
-
- windowAttributes.event_mask = StructureNotifyMask;
- windowAttributes.override_redirect = False;
- // Create the window of at last 1x1 since X doesn't allow to create empty windows.
- m_window = XCreateWindow(m_display,
- m_parentWindow.get(),
- 0, 0,
- std::max(1, m_size.width()),
- std::max(1, m_size.height()),
- 0,
- CopyFromParent,
- InputOutput,
- CopyFromParent,
- CWEventMask,
- &windowAttributes);
- XMapWindow(m_display, m_window.get());
-
- xDamageNotifier().add(m_window.get(), WTFMove(damageNotify));
-
- while (1) {
- XEvent event;
- XWindowEvent(m_display, m_window.get(), StructureNotifyMask, &event);
- if (event.type == MapNotify && event.xmap.window == m_window.get())
- break;
- }
- XSelectInput(m_display, m_window.get(), NoEventMask);
- XCompositeRedirectWindow(m_display, m_window.get(), CompositeRedirectManual);
- if (!m_size.isEmpty())
- createNewPixampAndPixampSurface();
- m_damage = XDamageCreate(m_display, m_window.get(), XDamageReportNonEmpty);
-}
-
-RedirectedXCompositeWindow::~RedirectedXCompositeWindow()
-{
- ASSERT(m_display);
- ASSERT(m_damage);
- ASSERT(m_window);
- ASSERT(m_parentWindow);
-
- xDamageNotifier().remove(m_window.get());
-
- // Explicitly reset these because we need to ensure it happens in this order.
- m_damage.reset();
- m_window.reset();
- m_parentWindow.reset();
-}
-
-void RedirectedXCompositeWindow::resize(const IntSize& size)
-{
- IntSize scaledSize(size);
- scaledSize.scale(m_webPage.deviceScaleFactor());
- if (scaledSize == m_size)
- return;
-
- // Resize the window to at last 1x1 since X doesn't allow to create empty windows.
- XResizeWindow(m_display, m_window.get(), std::max(1, scaledSize.width()), std::max(1, scaledSize.height()));
- XFlush(m_display);
-
- m_size = scaledSize;
- if (m_size.isEmpty())
- cleanupPixmapAndPixmapSurface();
- else
- createNewPixampAndPixampSurface();
-}
-
-void RedirectedXCompositeWindow::cleanupPixmapAndPixmapSurface()
-{
- if (!m_pixmap)
- return;
-
- m_surface = nullptr;
- m_pixmap.reset();
-}
-
-void RedirectedXCompositeWindow::createNewPixampAndPixampSurface()
-{
- // This should never be called with an empty size (not in Accelerated Compositing mode).
- ASSERT(!m_size.isEmpty());
- XUniquePixmap newPixmap(XCompositeNameWindowPixmap(m_display, m_window.get()));
- if (!newPixmap) {
- cleanupPixmapAndPixmapSurface();
- return;
- }
-
- XWindowAttributes windowAttributes;
- if (!XGetWindowAttributes(m_display, m_window.get(), &windowAttributes)) {
- cleanupPixmapAndPixmapSurface();
- return;
- }
-
- RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_xlib_surface_create(m_display, newPixmap.get(), windowAttributes.visual, m_size.width(), m_size.height()));
- cairoSurfaceSetDeviceScale(newSurface.get(), m_webPage.deviceScaleFactor(), m_webPage.deviceScaleFactor());
-
- RefPtr<cairo_t> cr = adoptRef(cairo_create(newSurface.get()));
- if (!m_webPage.drawsBackground())
- cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR);
- else
- setSourceRGBAFromColor(cr.get(), m_webPage.backgroundColor());
- cairo_paint(cr.get());
-
- // 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) {
- cairo_set_operator(cr.get(), CAIRO_OPERATOR_OVER);
- cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0);
- cairo_paint(cr.get());
- }
-
- cleanupPixmapAndPixmapSurface();
- m_pixmap = WTFMove(newPixmap);
- m_surface = WTFMove(newSurface);
-}
-
-} // namespace WebCore
-
-#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
Deleted: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -1,74 +0,0 @@
-/*
- * 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(REDIRECTED_XCOMPOSITE_WINDOW)
-
-#include <WebCore/IntSize.h>
-#include <WebCore/RefPtrCairo.h>
-#include <WebCore/XUniqueResource.h>
-#include <functional>
-
-typedef struct _GdkWindow GdkWindow;
-typedef struct _XDisplay Display;
-typedef unsigned long Window;
-
-namespace WebKit {
-
-class WebPageProxy;
-
-class RedirectedXCompositeWindow {
- WTF_MAKE_NONCOPYABLE(RedirectedXCompositeWindow); WTF_MAKE_FAST_ALLOCATED;
-public:
- static std::unique_ptr<RedirectedXCompositeWindow> create(WebPageProxy&, const WebCore::IntSize&, std::function<void ()>&& damageNotify);
- ~RedirectedXCompositeWindow();
-
- Window windowID() const { return m_window.get(); }
- void resize(const WebCore::IntSize&);
- cairo_surface_t* surface() const { return m_surface.get(); };
-
-private:
- RedirectedXCompositeWindow(WebPageProxy&, const WebCore::IntSize&, std::function<void ()>&& damageNotify);
- void createNewPixampAndPixampSurface();
- void cleanupPixmapAndPixmapSurface();
-
- WebPageProxy& m_webPage;
- Display* m_display { nullptr };
- WebCore::IntSize m_size;
- WebCore::XUniqueWindow m_window;
- WebCore::XUniqueWindow m_parentWindow;
- WebCore::XUniquePixmap m_pixmap;
- WebCore::XUniqueDamage m_damage;
- RefPtr<cairo_surface_t> m_surface;
-};
-
-} // namespace WebKit
-
-#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
-
-#endif // RedirectedXCompositeWindow_h
Added: trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp (0 => 204013)
--- trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2016 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 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 "XDamageNotifier.h"
+
+#if PLATFORM(X11)
+
+#include <WebCore/PlatformDisplayX11.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xdamage.h>
+#include <gdk/gdkx.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static Optional<int> s_damageEventBase;
+
+XDamageNotifier& XDamageNotifier::singleton()
+{
+ static NeverDestroyed<XDamageNotifier> notifier;
+ return notifier;
+}
+
+XDamageNotifier::XDamageNotifier()
+{
+ downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).supportsXDamage(s_damageEventBase);
+}
+
+void XDamageNotifier::add(Damage damage, std::function<void()>&& notifyFunction)
+{
+ if (!s_damageEventBase)
+ return;
+
+ if (m_notifyFunctions.isEmpty())
+ gdk_window_add_filter(nullptr, reinterpret_cast<GdkFilterFunc>(&filterXDamageEvent), this);
+ m_notifyFunctions.add(damage, WTFMove(notifyFunction));
+}
+
+void XDamageNotifier::remove(Damage damage)
+{
+ if (!s_damageEventBase)
+ return;
+
+ m_notifyFunctions.remove(damage);
+ if (m_notifyFunctions.isEmpty())
+ gdk_window_remove_filter(nullptr, reinterpret_cast<GdkFilterFunc>(&filterXDamageEvent), this);
+}
+
+GdkFilterReturn XDamageNotifier::filterXDamageEvent(GdkXEvent* event, GdkEvent*, XDamageNotifier* notifier)
+{
+ ASSERT(s_damageEventBase);
+ auto* xEvent = static_cast<XEvent*>(event);
+ if (xEvent->type != s_damageEventBase.value() + XDamageNotify)
+ return GDK_FILTER_CONTINUE;
+
+ auto* damageEvent = reinterpret_cast<XDamageNotifyEvent*>(xEvent);
+ if (notifier->notify(damageEvent->damage)) {
+ XDamageSubtract(xEvent->xany.display, damageEvent->damage, None, None);
+ return GDK_FILTER_REMOVE;
+ }
+
+ return GDK_FILTER_CONTINUE;
+}
+
+bool XDamageNotifier::notify(Damage damage) const
+{
+ if (const auto& notifyFunction = m_notifyFunctions.get(damage)) {
+ notifyFunction();
+ return true;
+ }
+ return false;
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(X11)
Added: trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h (0 => 204013)
--- trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 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 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.
+ */
+
+#pragma once
+
+#if PLATFORM(X11)
+
+#include <gdk/gdkx.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/Noncopyable.h>
+
+typedef unsigned long Damage;
+
+namespace WebKit {
+
+class XDamageNotifier {
+ WTF_MAKE_NONCOPYABLE(XDamageNotifier); WTF_MAKE_FAST_ALLOCATED;
+ friend class NeverDestroyed<XDamageNotifier>;
+public:
+ static XDamageNotifier& singleton();
+
+ void add(Damage, std::function<void()>&&);
+ void remove(Damage);
+
+private:
+ XDamageNotifier();
+
+ static GdkFilterReturn filterXDamageEvent(GdkXEvent*, GdkEvent*, XDamageNotifier*);
+ bool notify(Damage) const;
+
+ HashMap<Damage, std::function<void()>> m_notifyFunctions;
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(X11)
Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -103,7 +103,6 @@
void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
void exitAcceleratedCompositingMode() override;
void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
- void willEnterAcceleratedCompositingMode() override;
void setAcceleratedCompositingRootLayer(LayerOrView *) override;
LayerOrView *acceleratedCompositingRootLayer() const override;
LayerHostingMode viewLayerHostingMode() override { return LayerHostingMode::OutOfProcess; }
Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm 2016-08-02 06:42:18 UTC (rev 204013)
@@ -456,10 +456,6 @@
{
}
-void PageClientImpl::willEnterAcceleratedCompositingMode()
-{
-}
-
void PageClientImpl::setAcceleratedCompositingRootLayer(LayerOrView *rootLayer)
{
[m_contentView _setAcceleratedCompositingRootView:rootLayer];
Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -138,7 +138,6 @@
void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
void exitAcceleratedCompositingMode() override;
void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
- void willEnterAcceleratedCompositingMode() override;
PassRefPtr<ViewSnapshot> takeViewSnapshot() override;
void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (204012 => 204013)
--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2016-08-02 06:42:18 UTC (rev 204013)
@@ -480,10 +480,6 @@
m_impl->setAcceleratedCompositingRootLayer(renderLayer);
}
-void PageClientImpl::willEnterAcceleratedCompositingMode()
-{
-}
-
void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
{
m_impl->setAcceleratedCompositingRootLayer(rootLayer);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp (204012 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -318,11 +318,9 @@
m_exitCompositingTimer.stop();
m_wantsToExitAcceleratedCompositingMode = false;
- m_webPage.send(Messages::DrawingAreaProxy::WillEnterAcceleratedCompositingMode(m_backingStoreStateID));
-
ASSERT(!m_layerTreeHost);
m_layerTreeHost = LayerTreeHost::create(m_webPage);
-#if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
if (m_nativeSurfaceHandleForCompositing)
m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);
#endif
@@ -354,7 +352,7 @@
}
#endif
-#if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
void AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing(uint64_t handle)
{
m_nativeSurfaceHandleForCompositing = handle;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h (204012 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -63,7 +63,7 @@
void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&, IPC::MessageDecoder&) override;
#endif
-#if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
void setNativeSurfaceHandleForCompositing(uint64_t) override;
void destroyNativeSurfaceHandleForCompositing(bool&) override;
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (204012 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -34,6 +34,10 @@
#include <WebCore/FrameView.h>
#include <WebCore/MainFrame.h>
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include "RedirectedXCompositeWindow.h"
+#endif
+
using namespace WebCore;
namespace WebKit {
@@ -50,8 +54,17 @@
ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webPage)
: CoordinatedLayerTreeHost(webPage)
, m_compositorClient(*this)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ , m_redirectedWindow(RedirectedXCompositeWindow::create(webPage))
+ , m_compositor(ThreadedCompositor::create(&m_compositorClient, m_redirectedWindow ? m_redirectedWindow->window() : 0))
+#else
, m_compositor(ThreadedCompositor::create(&m_compositorClient))
+#endif
{
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ if (m_redirectedWindow)
+ m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
+#endif
}
void ThreadedCoordinatedLayerTreeHost::invalidate()
@@ -58,6 +71,9 @@
{
m_compositor->invalidate();
CoordinatedLayerTreeHost::invalidate();
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ m_redirectedWindow = nullptr;
+#endif
}
void ThreadedCoordinatedLayerTreeHost::forceRepaint()
@@ -79,6 +95,13 @@
void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
{
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ if (m_redirectedWindow) {
+ m_redirectedWindow->resize(m_webPage.size());
+ m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
+ }
+#endif
+
CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged();
m_compositor->setDeviceScaleFactor(m_webPage.deviceScaleFactor());
}
@@ -91,6 +114,12 @@
void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
{
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ if (m_redirectedWindow) {
+ m_redirectedWindow->resize(size);
+ m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
+ }
+#endif
CoordinatedLayerTreeHost::sizeDidChange(size);
m_compositor->didChangeViewportSize(size);
}
@@ -105,7 +134,7 @@
m_webPage.scalePage(scale, origin);
}
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
void ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing(uint64_t handle)
{
m_layerTreeContext.contextID = handle;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h (204012 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -41,6 +41,7 @@
namespace WebKit {
+class RedirectedXCompositeWindow;
class WebPage;
class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost {
@@ -64,7 +65,7 @@
void forceRepaint() override;
bool forceRepaintAsync(uint64_t callbackID) override { return false; }
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
void setNativeSurfaceHandleForCompositing(uint64_t) override;
#endif
@@ -103,10 +104,13 @@
void didFlushRootLayer(const WebCore::FloatRect&) override { }
void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
- WebCore::IntPoint m_prevScrollPosition;
CompositorClient m_compositorClient;
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ std::unique_ptr<RedirectedXCompositeWindow> m_redirectedWindow;
+#endif
RefPtr<ThreadedCompositor> m_compositor;
float m_lastScaleFactor { 1 };
+ WebCore::IntPoint m_prevScrollPosition;
WebCore::IntPoint m_lastScrollPosition;
};
Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (204012 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -146,7 +146,7 @@
DrawingAreaType m_type;
WebPage& m_webPage;
-#if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
uint64_t m_nativeSurfaceHandleForCompositing { 0 };
#endif
@@ -172,7 +172,7 @@
virtual void addTransactionCallbackID(uint64_t callbackID) { ASSERT_NOT_REACHED(); }
#endif
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
virtual void setNativeSurfaceHandleForCompositing(uint64_t) = 0;
virtual void destroyNativeSurfaceHandleForCompositing(bool&) = 0;
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in (204012 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in 2016-08-02 06:42:18 UTC (rev 204013)
@@ -40,7 +40,7 @@
AddTransactionCallbackID(uint64_t callbackID)
#endif
-#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
SetNativeSurfaceHandleForCompositing(uint64_t handle)
DestroyNativeSurfaceHandleForCompositing() -> (bool handled)
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (204012 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -57,6 +57,10 @@
#include <gdk/gdkx.h>
#endif
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include "RedirectedXCompositeWindow.h"
+#endif
+
using namespace WebCore;
namespace WebKit {
@@ -133,6 +137,9 @@
LayerTreeHostGtk::LayerTreeHostGtk(WebPage& webPage)
: LayerTreeHost(webPage)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ , m_redirectedWindow(RedirectedXCompositeWindow::create(webPage))
+#endif
, m_renderFrameScheduler(std::bind(&LayerTreeHostGtk::renderFrame, this))
{
m_rootLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
@@ -159,17 +166,30 @@
m_rootLayer->addChild(m_nonCompositedContentLayer.get());
m_nonCompositedContentLayer->setNeedsDisplay();
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ if (m_redirectedWindow) {
+ createTextureMapper();
+ m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
+ }
+#endif
}
bool LayerTreeHostGtk::makeContextCurrent()
{
- if (!m_layerTreeContext.contextID) {
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ uint64_t nativeHandle = m_redirectedWindow ? m_redirectedWindow->window() : m_layerTreeContext.contextID;
+#else
+ uint64_t nativeHandle = m_layerTreeContext.contextID;
+#endif
+
+ if (!nativeHandle) {
m_context = nullptr;
return false;
}
if (!m_context) {
- m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_layerTreeContext.contextID), GLContext::sharingContext());
+ m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(nativeHandle), GLContext::sharingContext());
if (!m_context)
return false;
}
@@ -208,6 +228,10 @@
m_context = nullptr;
LayerTreeHost::invalidate();
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ m_redirectedWindow = nullptr;
+#endif
}
void LayerTreeHostGtk::setNonCompositedContentsNeedDisplay()
@@ -247,11 +271,25 @@
m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
m_nonCompositedContentLayer->setNeedsDisplay();
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ if (m_redirectedWindow) {
+ m_redirectedWindow->resize(newSize);
+ m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
+ }
+#endif
+
compositeLayersToContext(ForResize);
}
void LayerTreeHostGtk::deviceOrPageScaleFactorChanged()
{
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ if (m_redirectedWindow) {
+ m_redirectedWindow->resize(m_webPage.size());
+ m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
+ }
+#endif
+
// Other layers learn of the scale factor change via WebPage::setDeviceScaleFactor.
m_nonCompositedContentLayer->deviceOrPageScaleFactorChanged();
@@ -377,11 +415,8 @@
m_rootLayer->addChild(m_viewOverlayRootLayer);
}
-void LayerTreeHostGtk::setNativeSurfaceHandleForCompositing(uint64_t handle)
+void LayerTreeHostGtk::createTextureMapper()
{
- cancelPendingLayerFlush();
- m_layerTreeContext.contextID = handle;
-
// The creation of the TextureMapper needs an active OpenGL context.
if (!makeContextCurrent())
return;
@@ -391,9 +426,18 @@
m_textureMapper = TextureMapper::create();
static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setTextureMapper(m_textureMapper.get());
+}
+#if !USE(REDIRECTED_XCOMPOSITE_WINDOW)
+void LayerTreeHostGtk::setNativeSurfaceHandleForCompositing(uint64_t handle)
+{
+ cancelPendingLayerFlush();
+ m_layerTreeContext.contextID = handle;
+
+ createTextureMapper();
scheduleLayerFlush();
}
+#endif
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h (204012 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h 2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -39,6 +39,8 @@
namespace WebKit {
+class RedirectedXCompositeWindow;
+
class LayerTreeHostGtk final : public LayerTreeHost, WebCore::GraphicsLayerClient {
public:
static Ref<LayerTreeHostGtk> create(WebPage&);
@@ -65,7 +67,9 @@
void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override;
void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;
+#if !USE(REDIRECTED_XCOMPOSITE_WINDOW)
void setNativeSurfaceHandleForCompositing(uint64_t) override;
+#endif
class RenderFrameScheduler {
public:
@@ -98,6 +102,7 @@
void flushAndRenderLayers();
bool renderFrame();
bool makeContextCurrent();
+ void createTextureMapper();
std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
std::unique_ptr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
@@ -104,6 +109,9 @@
std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
std::unique_ptr<WebCore::GLContext> m_context;
WebCore::TransformationMatrix m_scaleMatrix;
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ std::unique_ptr<RedirectedXCompositeWindow> m_redirectedWindow;
+#endif
RenderFrameScheduler m_renderFrameScheduler;
};
Added: trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp (0 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp 2016-08-02 06:42:18 UTC (rev 204013)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2012-2016 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 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(REDIRECTED_XCOMPOSITE_WINDOW)
+
+#include "WebPage.h"
+#include <WebCore/PlatformDisplayX11.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xcomposite.h>
+#include <gdk/gdkx.h>
+#include <wtf/RunLoop.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(WebPage& webPage)
+{
+ if (!downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).supportsXComposite())
+ return nullptr;
+ return std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(webPage));
+}
+
+RedirectedXCompositeWindow::RedirectedXCompositeWindow(WebPage& webPage)
+ : m_webPage(webPage)
+ , m_display(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native())
+ , m_size(webPage.size())
+{
+ m_size.scale(m_webPage.deviceScaleFactor());
+
+ Screen* screen = DefaultScreenOfDisplay(m_display);
+
+ ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == m_display);
+ GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
+ if (!visual)
+ visual = gdk_screen_get_system_visual(gdk_screen_get_default());
+
+ XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
+
+ XSetWindowAttributes windowAttributes;
+ windowAttributes.override_redirect = True;
+ windowAttributes.colormap = colormap.get();
+
+ // CWBorderPixel must be present when the depth doesn't match the parent's one.
+ // See http://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c?id=xorg-server-1.16.0#n703.
+ windowAttributes.border_pixel = 0;
+
+ m_parentWindow = XCreateWindow(m_display,
+ RootWindowOfScreen(screen),
+ WidthOfScreen(screen) + 1, 0, 1, 1,
+ 0,
+ gdk_visual_get_depth(visual),
+ InputOutput,
+ GDK_VISUAL_XVISUAL(visual),
+ CWOverrideRedirect | CWColormap | CWBorderPixel,
+ &windowAttributes);
+ XMapWindow(m_display, m_parentWindow.get());
+
+ windowAttributes.event_mask = StructureNotifyMask;
+ windowAttributes.override_redirect = False;
+
+ // Create the window of at last 1x1 since X doesn't allow to create empty windows.
+ m_window = XCreateWindow(m_display,
+ m_parentWindow.get(),
+ 0, 0,
+ std::max(1, m_size.width()),
+ std::max(1, m_size.height()),
+ 0,
+ CopyFromParent,
+ InputOutput,
+ CopyFromParent,
+ CWEventMask,
+ &windowAttributes);
+ XMapWindow(m_display, m_window.get());
+
+ while (1) {
+ XEvent event;
+ XWindowEvent(m_display, m_window.get(), StructureNotifyMask, &event);
+ if (event.type == MapNotify && event.xmap.window == m_window.get())
+ break;
+ }
+ XSelectInput(m_display, m_window.get(), NoEventMask);
+ XCompositeRedirectWindow(m_display, m_window.get(), CompositeRedirectManual);
+ m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
+}
+
+RedirectedXCompositeWindow::~RedirectedXCompositeWindow()
+{
+ ASSERT(m_display);
+ ASSERT(m_window);
+ ASSERT(m_parentWindow);
+
+ // Explicitly reset these because we need to ensure it happens in this order.
+ m_window.reset();
+ m_parentWindow.reset();
+}
+
+void RedirectedXCompositeWindow::resize(const IntSize& size)
+{
+ IntSize scaledSize(size);
+ scaledSize.scale(m_webPage.deviceScaleFactor());
+ if (scaledSize == m_size)
+ return;
+
+ m_size = scaledSize;
+
+ // Resize the window to at last 1x1 since X doesn't allow to create empty windows.
+ XResizeWindow(m_display, m_window.get(), std::max(1, m_size.width()), std::max(1, m_size.height()));
+ XFlush(m_display);
+
+ // Release the previous pixmap later to give some time to the UI process to update.
+ RunLoop::main().dispatchAfter(std::chrono::seconds(5), [pixmap = WTFMove(m_pixmap)] { });
+ m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
+}
+
+} // namespace WebCore
+
+#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
Copied: trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h (from rev 204011, trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h) (0 => 204013)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h 2016-08-02 06:42:18 UTC (rev 204013)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012-2016 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 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.
+ */
+
+#pragma once
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+
+#include <WebCore/IntSize.h>
+#include <WebCore/XUniqueResource.h>
+#include <wtf/Noncopyable.h>
+
+typedef struct _XDisplay Display;
+typedef unsigned long Pixmap;
+typedef unsigned long Window;
+
+namespace WebKit {
+
+class WebPage;
+
+class RedirectedXCompositeWindow {
+ WTF_MAKE_NONCOPYABLE(RedirectedXCompositeWindow); WTF_MAKE_FAST_ALLOCATED;
+public:
+ static std::unique_ptr<RedirectedXCompositeWindow> create(WebPage&);
+ ~RedirectedXCompositeWindow();
+
+ Window window() const { return m_window.get(); }
+ Pixmap pixmap() const { return m_pixmap.get(); }
+ void resize(const WebCore::IntSize&);
+
+private:
+ RedirectedXCompositeWindow(WebPage&);
+
+ WebPage& m_webPage;
+ Display* m_display { nullptr };
+ WebCore::IntSize m_size;
+ WebCore::XUniqueWindow m_window;
+ WebCore::XUniqueWindow m_parentWindow;
+ WebCore::XUniquePixmap m_pixmap;
+};
+
+} // namespace WebKit
+
+#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)