[GTK] Add a configure option to build without Redirected XComposite Window
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2015 08:06:02 +0000 (08:06 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2015 08:06:02 +0000 (08:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142865

Reviewed by Žan Doberšek.

.:

The Redirected XComposite Window was added to support some
features like GtkOverlay, but in cases where we don't need such
features, it's more efficient to use the XID of the WebKitWebView
window as the native surface handle for the accelerated
compositing. This patch adds USE_REDIRECTED_XCOMPOSITE_WINDOW,
that is enabled by default for X11 target when OpenGL is enabled.

* Source/cmake/OptionsGTK.cmake:

Source/WebKit2:

Use USE(REDIRECTED_XCOMPOSITE_WINDOW) instead of
USE(TEXTURE_MAPPER_GL) && PLATFORM(X11).

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseRealize): Use the XID of the WebKitWebView
window as native surface handle when REDIRECTED_XCOMPOSITE_WINDOW
is disabled.
(webkitWebViewRenderAcceleratedCompositingResults):
(resizeWebKitWebViewBaseFromAllocation):
(webkitWebViewBaseEnterAcceleratedCompositingMode):
(webkitWebViewBaseExitAcceleratedCompositingMode):
* UIProcess/gtk/RedirectedXCompositeWindow.cpp:
* UIProcess/gtk/RedirectedXCompositeWindow.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181847 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp
Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h
Source/cmake/OptionsGTK.cmake

index a4fb8d7..64e8656 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2015-03-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add a configure option to build without Redirected XComposite Window
+        https://bugs.webkit.org/show_bug.cgi?id=142865
+
+        Reviewed by Žan Doberšek.
+
+        The Redirected XComposite Window was added to support some
+        features like GtkOverlay, but in cases where we don't need such
+        features, it's more efficient to use the XID of the WebKitWebView
+        window as the native surface handle for the accelerated
+        compositing. This patch adds USE_REDIRECTED_XCOMPOSITE_WINDOW,
+        that is enabled by default for X11 target when OpenGL is enabled.
+
+        * Source/cmake/OptionsGTK.cmake:
+
 2015-03-20  Zan Dobersek  <zdobersek@igalia.com>
 
         [GTK] Search for the Wayland dependency when enabling Wayland target
index 73e29e4..cdc4544 100644 (file)
@@ -1,3 +1,24 @@
+2015-03-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add a configure option to build without Redirected XComposite Window
+        https://bugs.webkit.org/show_bug.cgi?id=142865
+
+        Reviewed by Žan Doberšek.
+
+        Use USE(REDIRECTED_XCOMPOSITE_WINDOW) instead of
+        USE(TEXTURE_MAPPER_GL) && PLATFORM(X11).
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseRealize): Use the XID of the WebKitWebView
+        window as native surface handle when REDIRECTED_XCOMPOSITE_WINDOW
+        is disabled.
+        (webkitWebViewRenderAcceleratedCompositingResults):
+        (resizeWebKitWebViewBaseFromAllocation):
+        (webkitWebViewBaseEnterAcceleratedCompositingMode):
+        (webkitWebViewBaseExitAcceleratedCompositingMode):
+        * UIProcess/gtk/RedirectedXCompositeWindow.cpp:
+        * UIProcess/gtk/RedirectedXCompositeWindow.h:
+
 2015-03-22  Eric Carlson  <eric.carlson@apple.com>
 
         [Mac] Enable WIRELESS_PLAYBACK_TARGET for WK1
index 38ba498..f2e6250 100644 (file)
 #include "WebFullScreenManagerProxy.h"
 #endif
 
-#if PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
 #include <gdk/gdkx.h>
 #endif
+
 #if PLATFORM(WAYLAND)
 #include <gdk/gdkwayland.h>
 #endif
@@ -184,7 +185,7 @@ struct _WebKitWebViewBasePrivate {
     WebFullScreenClientGtk fullScreenClient;
 #endif
 
-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     std::unique_ptr<RedirectedXCompositeWindow> redirectedWindow;
 #endif
 
@@ -318,7 +319,7 @@ static void webkitWebViewBaseRealize(GtkWidget* widget)
     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
     WebKitWebViewBasePrivate* priv = webView->priv;
 
-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
     if (GDK_IS_X11_DISPLAY(display)) {
         priv->redirectedWindow = RedirectedXCompositeWindow::create(
@@ -369,6 +370,11 @@ static void webkitWebViewBaseRealize(GtkWidget* widget)
     gtk_widget_set_window(widget, window);
     gdk_window_set_user_data(window, widget);
 
+#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
+    drawingArea->setNativeSurfaceHandleForCompositing(GDK_WINDOW_XID(window));
+#endif
+
     gtk_style_context_set_background(gtk_widget_get_style_context(widget), window);
 
     gtk_im_context_set_client_window(priv->inputMethodFilter.context(), window);
@@ -517,7 +523,7 @@ static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase*
     if (!drawingArea->isInAcceleratedCompositingMode())
         return false;
 
-#if PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     // 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;
@@ -630,7 +636,7 @@ static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase
 
     DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
 
-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     if (sizeChanged && priv->redirectedWindow && drawingArea && drawingArea->isInAcceleratedCompositingMode())
         priv->redirectedWindow->resize(viewRect.size());
 #endif
@@ -1323,7 +1329,7 @@ void webkitWebViewBaseResetClickCounter(WebKitWebViewBase* webkitWebViewBase)
 
 void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
 {
-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
     if (!priv->redirectedWindow)
         return;
@@ -1341,7 +1347,7 @@ void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitW
 
 void webkitWebViewBaseExitAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
 {
-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
     if (priv->redirectedWindow)
         priv->redirectedWindow->resize(IntSize());
index b311fcb..444f864 100644 (file)
@@ -27,7 +27,7 @@
 #include "config.h"
 #include "RedirectedXCompositeWindow.h"
 
-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
 
 #include <X11/extensions/Xcomposite.h>
 #include <X11/extensions/Xdamage.h>
@@ -282,4 +282,4 @@ cairo_surface_t* RedirectedXCompositeWindow::surface()
 
 } // namespace WebCore
 
-#endif // USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
index a40ae0b..3aa4ff5 100644 (file)
@@ -27,7 +27,7 @@
 #ifndef  RedirectedXCompositeWindow_h
 #define  RedirectedXCompositeWindow_h
 
-#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
 
 #include <WebCore/IntSize.h>
 #include <WebCore/RefPtrCairo.h>
@@ -64,6 +64,6 @@ private:
 
 } // namespace WebKit
 
-#endif // USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
+#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
 
 #endif // RedirectedXCompositeWindow_h
index 8c4842c..190c380 100644 (file)
@@ -82,10 +82,17 @@ endif ()
 
 WEBKIT_OPTION_BEGIN()
 WEBKIT_OPTION_DEFINE(ENABLE_PLUGIN_PROCESS_GTK2 "Whether to build WebKitPluginProcess2 to load GTK2 based plugins." ON)
+WEBKIT_OPTION_DEFINE(USE_REDIRECTED_XCOMPOSITE_WINDOW "Whether to use a Redirected XComposite Window for accelerated compositing in X11." ON)
 
 if ((OPENGL_FOUND OR OPENGLES2_FOUND) AND (GLX_FOUND OR EGL_FOUND))
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL ON)
 
+    if (ENABLE_X11_TARGET)
+        WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_REDIRECTED_XCOMPOSITE_WINDOW ON)
+    else ()
+        WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_REDIRECTED_XCOMPOSITE_WINDOW OFF)
+    endif ()
+
     if (OPENGL_FOUND)
         if (GLX_FOUND)
             list(APPEND CAIRO_GL_COMPONENTS cairo-glx)
@@ -106,6 +113,7 @@ if ((OPENGL_FOUND OR OPENGLES2_FOUND) AND (GLX_FOUND OR EGL_FOUND))
 else ()
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL OFF)
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS OFF)
+    WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_REDIRECTED_XCOMPOSITE_WINDOW OFF)
 endif ()
 
 if (ENABLE_ACCELERATED_2D_CANVAS AND NOT(CAIRO_GL_FOUND))
@@ -360,6 +368,10 @@ if ((OPENGL_FOUND OR OPENGLES2_FOUND) AND (GLX_FOUND OR EGL_FOUND))
     add_definitions(-DWTF_USE_TEXTURE_MAPPER_GL=1)
     add_definitions(-DENABLE_3D_RENDERING=1)
 
+    if (ENABLE_X11_TARGET AND USE_REDIRECTED_XCOMPOSITE_WINDOW)
+        add_definitions(-DWTF_USE_REDIRECTED_XCOMPOSITE_WINDOW=1)
+    endif ()
+
     if (OPENGLES2_FOUND)
         set(WTF_USE_OPENGL_ES_2 1)
         add_definitions(-DWTF_USE_OPENGL_ES_2=1)