LIST(APPEND WebCore_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/platform/graphics/surfaces/x"
)
+ELSEIF (WTF_PLATFORM_WAYLAND)
+ LIST(APPEND WebCore_INCLUDE_DIRECTORIES
+ "${WEBCORE_DIR}/platform/graphics/surfaces/wayland"
+ )
ENDIF ()
LIST(APPEND WebCore_LIBRARIES
platform/graphics/surfaces/egl/EGLXSurface.cpp
platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.cpp
)
+ ELSEIF (WTF_PLATFORM_WAYLAND)
+ LIST(APPEND WebCore_SOURCES
+ platform/graphics/surfaces/wayland/WaylandHelper.cpp
+ )
ENDIF()
ENDIF()
bool SharedPlatformSurfaceTizen::supportsLockSurfaceExtension()
{
-#if PLATFORM(X11)
static bool extSupportQueried = false;
static bool supportLockSurfaceExt = false;
supportLockSurfaceExt = GLPlatformContext::supportsEGLExtension(display, "EGL_KHR_lock_surface");
return supportLockSurfaceExt;
-#else
- return false;
-#endif
}
SharedPlatformSurfaceTizen::SharedPlatformSurfaceTizen(const IntSize& size, bool lockable, bool hasAlpha, bool hasDepth, bool hasStencil)
#if PLATFORM(X11)
#include "X11Helper.h"
+#elif PLATFORM(WAYLAND)
+#include "WaylandHelper.h"
#endif
namespace WebCore {
#if PLATFORM(X11)
typedef X11Helper NativeWrapper;
typedef Display NativeSharedDisplay;
-#else
-typedef void NativeSharedDisplay;
+#elif PLATFORM(WAYLAND)
+typedef WaylandHelper NativeWrapper;
+typedef struct wl_display NativeSharedDisplay;
#endif
static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
}
EGLBoolean success;
- success = eglInitialize(m_eglDisplay, 0, 0);
+ EGLint major, minor;
+ success = eglInitialize(m_eglDisplay, &major, &minor);
if (success != EGL_TRUE) {
LOG_ERROR("EGLInitialization failed.");
PlatformDisplay EGLHelper::eglDisplay()
{
// Display connection will only be broken at program shutdown.
-#if PLATFORM(X11)
static EGLDisplayConnection displayConnection(NativeWrapper::nativeDisplay());
-#else
- static EGLDisplayConnection displayConnection;
-#endif
return displayConnection.display();
}
#include "GLPlatformSurface.h"
#include <wtf/PassOwnPtr.h>
+#if PLATFORM(WAYLAND)
+#include <wayland-client.h>
+#include <wayland-egl.h>
+#endif
+
#define EGL_EGLEXT_PROTOTYPES 1
#include <EGL/egl.h>
#include <EGL/eglext.h>
--- /dev/null
+/*
+ * Copyright (C) 2013 Intel Corporation. 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. AND ITS CONTRIBUTORS ``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 ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WaylandHelper.h"
+
+#include <string.h>
+
+namespace WebCore {
+struct wl_compositor* WaylandHelper::m_compositor = 0;
+
+static const struct wl_registry_listener registrylistener = {
+ WaylandHelper::handleGlobal,
+ WaylandHelper::handleGlobalRemove
+};
+
+struct DisplayConnection {
+ DisplayConnection()
+ : m_display(0)
+ , m_registry(0)
+ {
+ m_display = wl_display_connect(0);
+ if (!m_display) {
+ LOG_ERROR("Failed to make connection with Wayland.");
+ return;
+ }
+
+ m_registry = wl_display_get_registry(m_display);
+ wl_registry_add_listener(m_registry, ®istrylistener, 0);
+
+ if (wl_display_roundtrip(m_display) < 0) {
+ LOG_ERROR("Failed to process Wayland connection.");
+ close();
+ }
+ }
+
+ ~DisplayConnection()
+ {
+ close();
+ }
+
+ struct wl_display* display() const { return m_display; }
+
+private:
+ void close()
+ {
+ if (m_registry) {
+ wl_registry_destroy(m_registry);
+ m_registry = 0;
+ }
+
+ if (m_display) {
+ wl_display_flush(m_display);
+ wl_display_disconnect(m_display);
+ m_display = 0;
+ }
+ }
+
+ struct wl_display* m_display;
+ struct wl_registry* m_registry;
+};
+
+struct wl_display* WaylandHelper::nativeDisplay()
+{
+ // Display connection will only be broken at program shutdown.
+ static DisplayConnection displayConnection;
+ return displayConnection.display();
+}
+
+void WaylandHelper::handleGlobal(void*, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t)
+{
+ if (!strcmp(interface, "wl_compositor"))
+ m_compositor = static_cast<struct wl_compositor*>(wl_registry_bind(registry, name, &wl_compositor_interface, 1));
+}
+
+void WaylandHelper::handleGlobalRemove(void*, struct wl_registry*, uint32_t)
+{
+}
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2013 Intel Corporation. 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. AND ITS CONTRIBUTORS ``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 ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WaylandHelper_h
+#define WaylandHelper_h
+
+#include <wayland-client.h>
+#include <wayland-egl.h>
+
+namespace WebCore {
+
+class WaylandHelper {
+public:
+ static struct wl_display* nativeDisplay();
+ static struct wl_compositor* compositor() { return m_compositor; }
+
+ // Used for registration purpose only.
+ static void handleGlobal(void*, struct wl_registry*, uint32_t, const char*, uint32_t);
+ static void handleGlobalRemove(void*, struct wl_registry*, uint32_t);
+private:
+ static struct wl_compositor* m_compositor;
+};
+
+}
+#endif
ADD_DEFINITIONS(-DHAVE_ECORE_X)
ADD_DEFINITIONS(-DWTF_PLATFORM_X11=1)
SET(WTF_PLATFORM_X11 1)
+ELSE ()
+ ADD_DEFINITIONS(-DWTF_PLATFORM_WAYLAND=1)
+ SET(WTF_PLATFORM_WAYLAND 1)
ENDIF ()
FIND_PACKAGE(Eina 1.2 REQUIRED)