Title: [185620] trunk
Revision
185620
Author
clo...@igalia.com
Date
2015-06-16 15:18:39 -0700 (Tue, 16 Jun 2015)

Log Message

[GTK] [Wayland] Should be possible to build with support for both X11 and Wayland.
https://bugs.webkit.org/show_bug.cgi?id=145701

Reviewed by Darin Adler.

.:

* Source/cmake/OptionsGTK.cmake: Remove conflicting options.

Source/WebCore:

No new tests, no behavior changes.

When building both targets, we have to include the wayland-egl
headers in order to build the Wayland target. This causes that
EGLNativePixmapType and EGLNativeWindowType get defined as
different types than when building only the X11 target.

By type casting them to the ones that are expected, we are able
to build both targets at the same time.

I have done tests (building each target alone as also both targets
at the same time), and everything seems to works as expected.

Once built for both targets, if you try to launch the MiniBrowser
from inside a Wayland compositor (Weston on top of X for example),
it will trigger the X11 target if the DISPLAY environment variable
is set and the environment variable GDK_BACKEND is not set to wayland,
otherwise it will trigger the Wayland target.

* platform/graphics/GLContext.cpp:
(WebCore::GLContext::createContextForWindow): Add type casts. We have
to consider here two different type casts depending on the type of
GLNativeWindowType to avoid a build failure on 32-bits platforms.
The static_cast one was already beeing done as an implicit cast
(from uint64_t to XID), the reinterpret_cast is the new one that
we need to do only when building on both platforms.
* platform/graphics/egl/GLContextEGL.cpp: Add missing include when
building both targets that is required for defining DefaultRootWindow().
(WebCore::GLContextEGL::createPixmapContext): Add type cast.

Modified Paths

Diff

Modified: trunk/ChangeLog (185619 => 185620)


--- trunk/ChangeLog	2015-06-16 22:17:28 UTC (rev 185619)
+++ trunk/ChangeLog	2015-06-16 22:18:39 UTC (rev 185620)
@@ -1,3 +1,12 @@
+2015-06-16  Carlos Alberto Lopez Perez  <clo...@igalia.com>
+
+        [GTK] [Wayland] Should be possible to build with support for both X11 and Wayland.
+        https://bugs.webkit.org/show_bug.cgi?id=145701
+
+        Reviewed by Darin Adler.
+
+        * Source/cmake/OptionsGTK.cmake: Remove conflicting options.
+
 2015-06-15  Jon Honeycutt  <jhoneyc...@apple.com>
 
         [iOS] Crash long pressing on <input type=file>

Modified: trunk/Source/WebCore/ChangeLog (185619 => 185620)


--- trunk/Source/WebCore/ChangeLog	2015-06-16 22:17:28 UTC (rev 185619)
+++ trunk/Source/WebCore/ChangeLog	2015-06-16 22:18:39 UTC (rev 185620)
@@ -1,3 +1,40 @@
+2015-06-16  Carlos Alberto Lopez Perez  <clo...@igalia.com>
+
+        [GTK] [Wayland] Should be possible to build with support for both X11 and Wayland.
+        https://bugs.webkit.org/show_bug.cgi?id=145701
+
+        Reviewed by Darin Adler.
+
+        No new tests, no behavior changes.
+
+        When building both targets, we have to include the wayland-egl
+        headers in order to build the Wayland target. This causes that
+        EGLNativePixmapType and EGLNativeWindowType get defined as
+        different types than when building only the X11 target.
+
+        By type casting them to the ones that are expected, we are able
+        to build both targets at the same time.
+
+        I have done tests (building each target alone as also both targets
+        at the same time), and everything seems to works as expected.
+
+        Once built for both targets, if you try to launch the MiniBrowser
+        from inside a Wayland compositor (Weston on top of X for example),
+        it will trigger the X11 target if the DISPLAY environment variable
+        is set and the environment variable GDK_BACKEND is not set to wayland,
+        otherwise it will trigger the Wayland target.
+
+        * platform/graphics/GLContext.cpp:
+        (WebCore::GLContext::createContextForWindow): Add type casts. We have
+        to consider here two different type casts depending on the type of
+        GLNativeWindowType to avoid a build failure on 32-bits platforms.
+        The static_cast one was already beeing done as an implicit cast
+        (from uint64_t to XID), the reinterpret_cast is the new one that
+        we need to do only when building on both platforms.
+        * platform/graphics/egl/GLContextEGL.cpp: Add missing include when
+        building both targets that is required for defining DefaultRootWindow().
+        (WebCore::GLContextEGL::createPixmapContext): Add type cast.
+
 2015-06-15  Jon Honeycutt  <jhoneyc...@apple.com>
 
         [iOS] Crash long pressing on <input type=file>

Modified: trunk/Source/WebCore/platform/graphics/GLContext.cpp (185619 => 185620)


--- trunk/Source/WebCore/platform/graphics/GLContext.cpp	2015-06-16 22:17:28 UTC (rev 185619)
+++ trunk/Source/WebCore/platform/graphics/GLContext.cpp	2015-06-16 22:18:39 UTC (rev 185620)
@@ -123,7 +123,12 @@
 #endif
 
 #if USE(GLX)
-    if (auto glxContext = GLContextGLX::createContext(windowHandle, sharingContext))
+#if PLATFORM(WAYLAND) // Building both X11 and Wayland targets
+    XID GLXWindowHandle = reinterpret_cast<XID>(windowHandle);
+#else
+    XID GLXWindowHandle = static_cast<XID>(windowHandle);
+#endif
+    if (auto glxContext = GLContextGLX::createContext(GLXWindowHandle, sharingContext))
         return WTF::move(glxContext);
 #endif
 #if USE(EGL)

Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (185619 => 185620)


--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2015-06-16 22:17:28 UTC (rev 185619)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2015-06-16 22:18:39 UTC (rev 185620)
@@ -37,6 +37,7 @@
 
 #if PLATFORM(X11)
 #include "PlatformDisplayX11.h"
+#include <X11/Xlib.h>
 #endif
 
 #if ENABLE(ACCELERATED_2D_CANVAS)
@@ -171,7 +172,7 @@
         return nullptr;
     }
 
-    EGLSurface surface = eglCreatePixmapSurface(display, config, pixmap.get(), 0);
+    EGLSurface surface = eglCreatePixmapSurface(display, config, reinterpret_cast<EGLNativePixmapType>(pixmap.get()), 0);
     if (surface == EGL_NO_SURFACE) {
         eglDestroyContext(display, context);
         return nullptr;

Modified: trunk/Source/cmake/OptionsGTK.cmake (185619 => 185620)


--- trunk/Source/cmake/OptionsGTK.cmake	2015-06-16 22:17:28 UTC (rev 185619)
+++ trunk/Source/cmake/OptionsGTK.cmake	2015-06-16 22:18:39 UTC (rev 185620)
@@ -80,9 +80,6 @@
 # FIXME: Can we use cairo-glesv2 to avoid this conflict?
 WEBKIT_OPTION_CONFLICT(ENABLE_ACCELERATED_2D_CANVAS ENABLE_GLES2)
 
-# FIXME: Should be possible to build with support for both X11 and Wayland.
-WEBKIT_OPTION_CONFLICT(ENABLE_WAYLAND_TARGET ENABLE_X11_TARGET)
-
 WEBKIT_OPTION_DEPEND(ENABLE_3D_TRANSFORMS ENABLE_OPENGL)
 WEBKIT_OPTION_DEPEND(ENABLE_ACCELERATED_2D_CANVAS ENABLE_OPENGL)
 WEBKIT_OPTION_DEPEND(ENABLE_GLES2 ENABLE_OPENGL)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to