diff --git a/Source/WPE/CMakeLists.txt b/Source/WPE/CMakeLists.txt index 760227b065c97..d39e26a89fd3e 100644 --- a/Source/WPE/CMakeLists.txt +++ b/Source/WPE/CMakeLists.txt @@ -44,6 +44,10 @@ if (USE_WPE_BACKEND_INTEL_CE) add_definitions(-DWPE_BACKEND_INTEL_CE=1) endif () +if (USE_WPE_BACKEND_STM) + add_definitions(-DWPE_BACKEND_STM=1) +endif () + if (USE_WPE_BACKEND_WESTEROS) find_package(westeros REQUIRED) add_definitions(-DWPE_BACKEND_WESTEROS=1) @@ -71,6 +75,7 @@ set(WPE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Graphics/GBM" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Graphics/IntelCE" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Graphics/Westeros" + "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Graphics/STM" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Input" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Pasteboard" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Pasteboard" @@ -84,6 +89,7 @@ set(WPE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/Source/WPE/Source/ViewBackend/Wayland" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/ViewBackend/Wayland/Protocols" "${CMAKE_SOURCE_DIR}/Source/WPE/Source/ViewBackend/Westeros" + "${CMAKE_SOURCE_DIR}/Source/WPE/Source/ViewBackend/STM" ${BCM_HOST_INCLUDE_DIRS} ${GDL_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS} @@ -131,6 +137,7 @@ if (USE_WPE_BACKEND_BCM_NEXUS) Source/ViewBackend/BCMNexus/ViewBackendBCMNexus.cpp ) + list(APPEND WPE_LIBRARIES nxclient) endif () if (USE_WPE_BACKEND_BCM_RPI) @@ -140,6 +147,7 @@ if (USE_WPE_BACKEND_BCM_RPI) Source/ViewBackend/BCMRPi/ViewBackendBCMRPi.cpp ) + list(APPEND WPE_LIBRARIES nxclient) endif () if (USE_WPE_BACKEND_INTEL_CE) @@ -176,6 +184,22 @@ if (USE_WPE_BACKEND_WESTEROS) ) endif () +if (USE_WPE_BACKEND_STM) + list(APPEND WPE_INCLUDE_DIRECTORIES + ${STM_INCLUDE_DIRS} + ${STMEGL_INCLUDE_DIRS} + ) + list(APPEND WPE_LIBRARIES + ${STM_LIBRARIES} + ${STMEGL_LIBRARIES} + ) + list(APPEND WPE_SOURCES + Source/Graphics/STM/RenderingBackendSTM.cpp + Source/Graphics/RenderingBackend.cpp + Source/ViewBackend/STM/ViewBackendSTM.cpp + ) +endif () + if (USE_WPE_BUFFER_MANAGEMENT_GBM) list(APPEND WPE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/Source/WPE/Source/Graphics/GBM" diff --git a/Source/WPE/Headers/WPE/Graphics/RenderingBackend.h b/Source/WPE/Headers/WPE/Graphics/RenderingBackend.h index 3db18e06600c5..11137cd635301 100644 --- a/Source/WPE/Headers/WPE/Graphics/RenderingBackend.h +++ b/Source/WPE/Headers/WPE/Graphics/RenderingBackend.h @@ -35,6 +35,12 @@ namespace WPE { +namespace Input { + struct KeyboardEvent; + struct PointerEvent; + struct AxisEvent; +} + namespace Graphics { class RenderingBackend { @@ -46,6 +52,10 @@ class RenderingBackend { class Client { public: virtual void destroyBuffer(uint32_t) = 0; +/* FIXME Input handling + virtual void handleKeyboardEvent(Input::KeyboardEvent& event) = 0; + virtual void handlePointerEvent(Input::PointerEvent& event) = 0; + virtual void handleAxisEvent(Input::AxisEvent& event) = 0;*/ }; virtual ~Surface(); diff --git a/Source/WPE/Headers/WPE/Input/Events.h b/Source/WPE/Headers/WPE/Input/Events.h index 4a136004fd5ea..40dcd2f4f276c 100644 --- a/Source/WPE/Headers/WPE/Input/Events.h +++ b/Source/WPE/Headers/WPE/Input/Events.h @@ -29,6 +29,11 @@ #include +namespace IPC { + class ArgumentDecoder; + class ArgumentEncoder; +} + namespace WPE { namespace Input { @@ -52,6 +57,19 @@ struct KeyboardEvent { uint32_t unicode; bool pressed; uint8_t modifiers; + + KeyboardEvent(){} + KeyboardEvent(uint32_t in_time, uint32_t in_keyCode, uint32_t in_unicode, bool in_pressed, uint8_t in_modifiers) + : time(in_time) + , keyCode(in_keyCode) + , unicode(in_unicode) + , pressed(in_pressed) + , modifiers(in_modifiers) + { + } + + void encode(IPC::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, KeyboardEvent&); }; struct PointerEvent { @@ -70,12 +88,25 @@ struct PointerEvent { uint32_t state; }; - Type type; + uint32_t type; uint32_t time; int x; int y; uint32_t button; uint32_t state; + PointerEvent() {} + PointerEvent(uint32_t in_type, uint32_t in_time, int in_x, int in_y, uint32_t in_button, uint32_t in_state) + : type(in_type) + , time(in_time) + , x(in_x) + , y(in_y) + , button(in_button) + , state(in_state) + { + } + + void encode(IPC::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, PointerEvent&); }; struct AxisEvent { @@ -91,12 +122,24 @@ struct AxisEvent { int32_t value; }; - Type type; + uint32_t type; uint32_t time; int x; int y; uint32_t axis; int32_t value; + AxisEvent() {} + AxisEvent(uint32_t in_type, uint32_t in_time, int in_x, int in_y, uint32_t in_axis, int32_t in_value) + : type(in_type) + , time(in_time) + , x(in_x) + , y(in_y) + , axis(in_axis) + , value(in_value) + { + } + void encode(IPC::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, AxisEvent&); }; struct TouchEvent { diff --git a/Source/WPE/Headers/WPE/ViewBackend/ViewBackend.h b/Source/WPE/Headers/WPE/ViewBackend/ViewBackend.h index 9c8fda84eef18..0b170435e8c48 100644 --- a/Source/WPE/Headers/WPE/ViewBackend/ViewBackend.h +++ b/Source/WPE/Headers/WPE/ViewBackend/ViewBackend.h @@ -35,6 +35,9 @@ namespace WPE { namespace Input { class Client; +struct KeyboardEvent; +struct PointerEvent; +struct AxisEvent; } namespace ViewBackend { @@ -57,6 +60,10 @@ class ViewBackend { virtual void commitBuffer(int, const uint8_t*, size_t) = 0; virtual void destroyBuffer(uint32_t) = 0; + virtual void handleKeyboardEvent(const Input::KeyboardEvent& event); + virtual void handlePointerEvent(const Input::PointerEvent& event); + virtual void handleAxisEvent(const Input::AxisEvent& event); + virtual void setInputClient(Input::Client*); }; diff --git a/Source/WPE/Source/Graphics/RenderingBackend.cpp b/Source/WPE/Source/Graphics/RenderingBackend.cpp index 778aeeb860550..db01dd5e36b25 100644 --- a/Source/WPE/Source/Graphics/RenderingBackend.cpp +++ b/Source/WPE/Source/Graphics/RenderingBackend.cpp @@ -29,6 +29,7 @@ #include "RenderingBackendBCMNexus.h" #include "RenderingBackendBCMRPi.h" #include "RenderingBackendIntelCE.h" +#include "RenderingBackendSTM.h" #include #if WPE_BUFFER_MANAGEMENT(GBM) @@ -47,6 +48,10 @@ #include "RenderingBackendWesteros.h" #endif +#if WPE_BACKEND(STM) +#include "RenderingBackendSTM.h" +#endif + namespace WPE { namespace Graphics { @@ -84,6 +89,10 @@ std::unique_ptr RenderingBackend::create(const uint8_t* data, return std::unique_ptr(new RenderingBackendWesteros); #endif +#if WPE_BACKEND(STM) + return std::unique_ptr(new RenderingBackendSTM); +#endif + fprintf(stderr, "RenderingBackend: no usable backend found, will crash.\n"); return nullptr; } diff --git a/Source/WPE/Source/Graphics/STM/RenderingBackendSTM.cpp b/Source/WPE/Source/Graphics/STM/RenderingBackendSTM.cpp new file mode 100644 index 0000000000000..e8a543f883d19 --- /dev/null +++ b/Source/WPE/Source/Graphics/STM/RenderingBackendSTM.cpp @@ -0,0 +1,661 @@ +#include "Config.h" +#include "RenderingBackendSTM.h" + +#if WPE_BACKEND(STM) + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace WPE { + +namespace Graphics { + +typedef struct _GSource GSource; + +class EventSource { +public: + static GSourceFuncs sourceFuncs1; + + GSource source; + GPollFD pfd; + struct wl_display* display; +}; + +GSourceFuncs EventSource::sourceFuncs1 = { + // prepare + [](GSource* base, gint* timeout) -> gboolean + { + auto* source = reinterpret_cast(base); + struct wl_display* display = source->display; + + *timeout = -1; + wl_display_flush(display); + wl_display_dispatch_pending(display); + + return FALSE; + }, + // check + [](GSource* base) -> gboolean + { + auto* source = reinterpret_cast(base); + return !!source->pfd.revents; + }, + // dispatch + [](GSource* base, GSourceFunc, gpointer) -> gboolean + { + auto* source = reinterpret_cast(base); + struct wl_display* display = source->display; + + if (source->pfd.revents & G_IO_IN) + wl_display_dispatch(display); + + if (source->pfd.revents & (G_IO_ERR | G_IO_HUP)) + return FALSE; + + source->pfd.revents = 0; + return TRUE; + }, + nullptr, // finalize + nullptr, // closure_callback + nullptr, // closure_marshall +}; + + +//For sending pong in response to ping from server +static void +handle_ping(void *data, struct wl_shell_surface *shell_surface, + uint32_t serial) +{ + wl_shell_surface_pong(shell_surface, serial); +} + +static void +handle_configure(void *data, struct wl_shell_surface *shell_surface, + uint32_t edges, int32_t width, int32_t height) +{ +} + +static void +handle_popup_done(void *data, struct wl_shell_surface *shell_surface) +{ +} + +static const struct wl_shell_surface_listener shell_surface_listener = { + handle_ping, + handle_configure, + handle_popup_done +}; +//For sending pong in response to ping from server + + +const struct wl_registry_listener RenderingBackendSTM::m_registryListener = { + RenderingBackendSTM::globalCallback, + RenderingBackendSTM::globalRemoveCallback +}; + +const struct wl_seat_listener RenderingBackendSTM::m_seatListener = { + RenderingBackendSTM::globalSeatCapabilities, + RenderingBackendSTM::globalSeatName +}; + +static const struct wl_pointer_listener g_pointerListener = { + // enter + [](void* data, struct wl_pointer*, uint32_t serial, struct wl_surface* surface, wl_fixed_t, wl_fixed_t) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + seatData.serial = serial; + seatData.pointer.surface = surface; + }, + // leave + [](void* data, struct wl_pointer*, uint32_t serial, struct wl_surface* surface) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + seatData.serial = serial; + seatData.pointer.surface = nullptr; + }, + // motion + [](void* data, struct wl_pointer*, uint32_t time, wl_fixed_t fixedX, wl_fixed_t fixedY) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + auto x = wl_fixed_to_int(fixedX); + auto y = wl_fixed_to_int(fixedY); + + auto& pointer = seatData.pointer; + pointer.coords = { x, y }; + if (pointer.surface == backend.getWlSurface()) + { + WPE::Input::PointerEvent event{Input::PointerEvent::Motion, time, x, y, 0, 0}; +/* FIXME Input handling + backend.getClient().handlePointerEvent(event); +*/ + } + }, + // button + [](void* data, struct wl_pointer*, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + + seatData.serial = serial; + + if (button >= BTN_MOUSE) + button = button - BTN_MOUSE + 1; + else + button = 0; + + auto& pointer = seatData.pointer; + auto& coords = pointer.coords; + if (pointer.surface == backend.getWlSurface()) + { + WPE::Input::PointerEvent event{Input::PointerEvent::Button, time, coords.first, coords.second, button, state}; +/* FIXME Input handling + backend.getClient().handlePointerEvent(event); +*/ + } + }, + // axis + [](void* data, struct wl_pointer*, uint32_t time, uint32_t axis, wl_fixed_t value) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + auto& pointer = seatData.pointer; + auto& coords = pointer.coords; + if (pointer.surface == backend.getWlSurface()) + { + WPE::Input::AxisEvent event{Input::AxisEvent::Motion, time, coords.first, coords.second, axis, -wl_fixed_to_int(value)}; +/* FIXME Input handling + backend.getClient().handleAxisEvent(event); +*/ + } + }, +}; + +static void +handleKeyEvent(void* data, uint32_t key, uint32_t state, uint32_t time) +{ + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + auto& xkb = seatData.xkb; + uint32_t keysym = xkb_state_key_get_one_sym(xkb.state, key); + uint32_t unicode = xkb_state_key_get_utf32(xkb.state, key); + + if (xkb.composeState + && state == WL_KEYBOARD_KEY_STATE_PRESSED + && xkb_compose_state_feed(xkb.composeState, keysym) == XKB_COMPOSE_FEED_ACCEPTED + && xkb_compose_state_get_status(xkb.composeState) == XKB_COMPOSE_COMPOSED) + { + keysym = xkb_compose_state_get_one_sym(xkb.composeState); + unicode = xkb_keysym_to_utf32(keysym); + } + + if (seatData.keyboard.surface == backend.getWlSurface()) + { + WPE::Input::KeyboardEvent event{time, keysym, unicode, !!state, xkb.modifiers}; +/* FIXME Input handling + backend.getClient().handleKeyboardEvent(event); +*/ + } +} + +static gboolean +repeatRateTimeout(void* data) +{ + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + handleKeyEvent(data, seatData.repeatData.key, seatData.repeatData.state, seatData.repeatData.time); + return G_SOURCE_CONTINUE; +} + +static gboolean +repeatDelayTimeout(void* data) +{ + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + handleKeyEvent(data, seatData.repeatData.key, seatData.repeatData.state, seatData.repeatData.time); + seatData.repeatData.eventSource = g_timeout_add(seatData.repeatInfo.rate, static_cast(repeatRateTimeout), data); + return G_SOURCE_REMOVE; +} + + +static const struct wl_keyboard_listener g_keyboardListener = { + // keymap + [](void* data, struct wl_keyboard*, uint32_t format, int fd, uint32_t size) + { + if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { + close(fd); + return; + } + + void* mapping = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); + if (mapping == MAP_FAILED) { + close(fd); + return; + } + + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + auto& xkb = seatData.xkb; + xkb.keymap = xkb_keymap_new_from_string(xkb.context, static_cast(mapping), + XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + munmap(mapping, size); + close(fd); + + if (!xkb.keymap) + return; + + xkb.state = xkb_state_new(xkb.keymap); + if (!xkb.state) + return; + + xkb.indexes.control = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_CTRL); + xkb.indexes.alt = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_ALT); + xkb.indexes.shift = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_SHIFT); + }, + // enter + [](void* data, struct wl_keyboard*, uint32_t serial, struct wl_surface* surface, struct wl_array*) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + seatData.serial = serial; + seatData.keyboard.surface = surface; + }, + // leave + [](void* data, struct wl_keyboard*, uint32_t serial, struct wl_surface* surface) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + seatData.serial = serial; + seatData.keyboard.surface = nullptr; + }, + // key + [](void* data, struct wl_keyboard*, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) + { + // IDK. + key += 8; + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + + seatData.serial = serial; + handleKeyEvent(data, key, state, time); + + if (!seatData.repeatInfo.rate) + return; + + if (state == WL_KEYBOARD_KEY_STATE_RELEASED + && seatData.repeatData.key == key) { + if (seatData.repeatData.eventSource) + g_source_remove(seatData.repeatData.eventSource); + seatData.repeatData = { 0, 0, 0, 0 }; + } else if (state == WL_KEYBOARD_KEY_STATE_PRESSED + && xkb_keymap_key_repeats(seatData.xkb.keymap, key)) { + + if (seatData.repeatData.eventSource) + g_source_remove(seatData.repeatData.eventSource); + + seatData.repeatData = { key, time, state, g_timeout_add(seatData.repeatInfo.delay, static_cast(repeatDelayTimeout), data) }; + } + }, + // modifiers + [](void* data, struct wl_keyboard*, uint32_t serial, uint32_t depressedMods, uint32_t latchedMods, uint32_t lockedMods, uint32_t group) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + seatData.serial = serial; + auto& xkb = seatData.xkb; + xkb_state_update_mask(xkb.state, depressedMods, latchedMods, lockedMods, 0, 0, group); + + auto& modifiers = xkb.modifiers; + modifiers = 0; + auto component = static_cast(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.control, component)) + modifiers |= Input::KeyboardEvent::Control; + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.alt, component)) + modifiers |= Input::KeyboardEvent::Alt; + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.shift, component)) + modifiers |= Input::KeyboardEvent::Shift; + }, + // repeat_info + [](void* data, struct wl_keyboard*, int32_t rate, int32_t delay) + { + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + auto& repeatInfo = seatData.repeatInfo; + repeatInfo = { rate, delay }; + + // A rate of zero disables any repeating. + if (!rate) { + auto& repeatData = seatData.repeatData; + if (repeatData.eventSource) { + g_source_remove(repeatData.eventSource); + repeatData = { 0, 0, 0, 0 }; + } + } + }, +}; + +static const struct wl_touch_listener g_touchListener = { + // down + [](void* data, struct wl_touch*, uint32_t serial, uint32_t time, struct wl_surface* surface, int32_t id, wl_fixed_t x, wl_fixed_t y) + { +/* + auto& seatData = *static_cast(data); + seatData.serial = serial; + + int32_t arraySize = std::tuple_size::value; + if (id < 0 || id >= arraySize) + return; + + auto& target = seatData.touch.targets[id]; + assert(!target.first && !target.second); + + auto it = seatData.inputClients.find(surface); + if (it == seatData.inputClients.end()) + return; + + target = { surface, it->second }; + + auto& touchPoints = seatData.touch.touchPoints; + touchPoints[id] = { Input::TouchEvent::Down, time, id, wl_fixed_to_int(x), wl_fixed_to_int(y) }; + target.second->handleTouchEvent({ touchPoints, Input::TouchEvent::Down, id, time }); +*/ + }, + // up + [](void* data, struct wl_touch*, uint32_t serial, uint32_t time, int32_t id) + { +/* + auto& seatData = *static_cast(data); + seatData.serial = serial; + + int32_t arraySize = std::tuple_size::value; + if (id < 0 || id >= arraySize) + return; + + auto& target = seatData.touch.targets[id]; + assert(target.first && target.second); + + auto& touchPoints = seatData.touch.touchPoints; + auto& point = touchPoints[id]; + point = { Input::TouchEvent::Up, time, id, point.x, point.y }; + target.second->handleTouchEvent({ touchPoints, Input::TouchEvent::Up, id, time }); + + point = { Input::TouchEvent::Null, 0, 0, 0, 0 }; + target = { nullptr, nullptr }; +*/ + }, + // motion + [](void* data, struct wl_touch*, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y) + { +/* + auto& seatData = *static_cast(data); + + int32_t arraySize = std::tuple_size::value; + if (id < 0 || id >= arraySize) + return; + + auto& target = seatData.touch.targets[id]; + assert(target.first && target.second); + + auto& touchPoints = seatData.touch.touchPoints; + touchPoints[id] = { Input::TouchEvent::Motion, time, id, wl_fixed_to_int(x), wl_fixed_to_int(y) }; + target.second->handleTouchEvent({ touchPoints, Input::TouchEvent::Motion, id, time }); +*/ + }, + // frame + [](void*, struct wl_touch*) + { + // FIXME: Dispatching events via frame() would avoid dispatching events + // for every single event that's encapsulated in a frame with multiple + // other events. + }, + // cancel + [](void*, struct wl_touch*) { }, +}; + +void RenderingBackendSTM::globalSeatCapabilities(void* data, struct wl_seat* seat, uint32_t capabilities) +{ + auto& backend = *static_cast(data); + auto& seatData = backend.getSeatData(); + + // WL_SEAT_CAPABILITY_POINTER + const bool hasPointerCap = capabilities & WL_SEAT_CAPABILITY_POINTER; + if (hasPointerCap && !seatData.pointer.object) { + seatData.pointer.object = wl_seat_get_pointer(seat); + wl_pointer_add_listener(seatData.pointer.object, &g_pointerListener, data); + } + if (!hasPointerCap && seatData.pointer.object) { + wl_pointer_destroy(seatData.pointer.object); + seatData.pointer.object = nullptr; + } + + // WL_SEAT_CAPABILITY_KEYBOARD + const bool hasKeyboardCap = capabilities & WL_SEAT_CAPABILITY_KEYBOARD; + if (hasKeyboardCap && !seatData.keyboard.object) { + seatData.keyboard.object = wl_seat_get_keyboard(seat); + wl_keyboard_add_listener(seatData.keyboard.object, &g_keyboardListener, data); + } + if (!hasKeyboardCap && seatData.keyboard.object) { + wl_keyboard_destroy(seatData.keyboard.object); + seatData.keyboard.object = nullptr; + } + + // WL_SEAT_CAPABILITY_TOUCH + const bool hasTouchCap = capabilities & WL_SEAT_CAPABILITY_TOUCH; + if (hasTouchCap && !seatData.touch.object) { + seatData.touch.object = wl_seat_get_touch(seat); + wl_touch_add_listener(seatData.touch.object, &g_touchListener, data); + } + if (!hasTouchCap && seatData.touch.object) { + wl_touch_destroy(seatData.touch.object); + seatData.touch.object = nullptr; + } +} + +void RenderingBackendSTM::globalSeatName(void* data, struct wl_seat* seat, const char* name) +{ +} + +void RenderingBackendSTM::globalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t) +{ + auto backend = static_cast(data); + if (!std::strcmp(interface, "wl_compositor")) + backend->m_compositor = static_cast(wl_registry_bind(registry, name, &wl_compositor_interface, 1)); + if (!std::strcmp(interface, "wl_seat")) { + backend->m_seat = static_cast(wl_registry_bind(registry, name, &wl_seat_interface, 4)); + backend->initializeSeatData(); + } + if (!std::strcmp(interface, "wl_shell")) + backend->m_shell = static_cast(wl_registry_bind(registry, name, &wl_shell_interface, 1)); +} + +void RenderingBackendSTM::initializeSeatData() +{ + // This should be inside a lock as it can cause a race condition + if(m_seat && input_surface && !m_seatDataInitialized) { + + m_seatDataInitialized = true; + wl_seat_add_listener(m_seat, &m_seatListener, this); + + m_seatData.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + m_seatData.xkb.composeTable = xkb_compose_table_new_from_locale(m_seatData.xkb.context, setlocale(LC_CTYPE, nullptr), XKB_COMPOSE_COMPILE_NO_FLAGS); + if (m_seatData.xkb.composeTable) + m_seatData.xkb.composeState = xkb_compose_state_new(m_seatData.xkb.composeTable, XKB_COMPOSE_STATE_NO_FLAGS); + } +} + +void RenderingBackendSTM::globalRemoveCallback(void*, struct wl_registry*, uint32_t) +{ + // FIXME: if this can happen without the UI Process getting shut down + // we should probably destroy our cached display instance. +} + +static wl_display* g_wldisplay = nullptr; +RenderingBackendSTM::RenderingBackendSTM() + : input_surface(nullptr) + , m_seatDataInitialized(false) +{ + m_display = wl_display_connect(nullptr); + + g_wldisplay = m_display; + m_registry = wl_display_get_registry(m_display); + wl_registry_add_listener(m_registry, &m_registryListener, this); + wl_display_roundtrip(m_display); + + m_eventSource = g_source_new(&EventSource::sourceFuncs1, sizeof(EventSource)); + auto* source = reinterpret_cast(m_eventSource); + source->display = m_display; + + source->pfd.fd = wl_display_get_fd(m_display); + source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; + source->pfd.revents = 0; + g_source_add_poll(m_eventSource, &source->pfd); + + g_source_set_name(m_eventSource, "[WPE] PlatformDisplayWPE"); + g_source_set_priority(m_eventSource, G_PRIORITY_HIGH + 30); + g_source_set_can_recurse(m_eventSource, TRUE); + g_source_attach(m_eventSource, g_main_context_get_thread_default()); +} + +RenderingBackendSTM::~RenderingBackendSTM() +{ + if (m_eventSource) + g_source_unref(m_eventSource); + m_eventSource = nullptr; + + if (m_seatData.pointer.object) + wl_pointer_destroy(m_seatData.pointer.object); + if (m_seatData.keyboard.object) + wl_keyboard_destroy(m_seatData.keyboard.object); + if (m_seatData.touch.object) + wl_touch_destroy(m_seatData.touch.object); + if (m_seatData.xkb.context) + xkb_context_unref(m_seatData.xkb.context); + if (m_seatData.xkb.keymap) + xkb_keymap_unref(m_seatData.xkb.keymap); + if (m_seatData.xkb.state) + xkb_state_unref(m_seatData.xkb.state); + if (m_seatData.xkb.composeTable) + xkb_compose_table_unref(m_seatData.xkb.composeTable); + if (m_seatData.xkb.composeState) + xkb_compose_state_unref(m_seatData.xkb.composeState); + if (m_seatData.repeatData.eventSource) + g_source_remove(m_seatData.repeatData.eventSource); + m_seatData = SeatData{ }; + + + if (m_compositor) + wl_compositor_destroy(m_compositor); + if (m_seat) + wl_seat_destroy(m_seat); + if (m_registry) + wl_registry_destroy(m_registry); + g_wldisplay = nullptr; + if (m_display) + wl_display_disconnect(m_display); + + m_eventSource = nullptr; + m_compositor = nullptr; + m_seat = nullptr; + m_registry = nullptr; + m_display = nullptr; +} + +EGLNativeDisplayType RenderingBackendSTM::nativeDisplay() +{ + return m_display; +} + +std::unique_ptr RenderingBackendSTM::createSurface(uint32_t width, uint32_t height, uint32_t targetHandle, RenderingBackend::Surface::Client& client) +{ + return std::unique_ptr(new RenderingBackendSTM::Surface(*this, width, height, targetHandle, client)); +} + +std::unique_ptr RenderingBackendSTM::createOffscreenSurface() +{ + return std::unique_ptr(new RenderingBackendSTM::OffscreenSurface(*this)); +} + +RenderingBackendSTM::Surface::Surface(const RenderingBackendSTM& backend, uint32_t width, uint32_t height, uint32_t, RenderingBackendSTM::Surface::Client& client) + : m_client(client) +{ + m_surface = wl_compositor_create_surface(backend.m_compositor); + + struct wl_shell_surface *shell_surface; + shell_surface = wl_shell_get_shell_surface(backend.m_shell, m_surface); + + if (shell_surface) + wl_shell_surface_add_listener(shell_surface, + &shell_surface_listener, NULL); + wl_shell_surface_set_toplevel(shell_surface); + + struct wl_region *region; + region = wl_compositor_create_region(backend.m_compositor); + wl_region_add(region, 0, 0, + width, + height); + wl_surface_set_opaque_region(m_surface, region); + + + + if (m_surface) { + backend.setInputSurface(this); + backend.initializeSeatData(); + m_window = wl_egl_window_create(m_surface, width, height); + } +} + +RenderingBackendSTM::Surface::~Surface() +{ + if (m_window) + wl_egl_window_destroy(m_window); + if (m_surface) + wl_surface_destroy(m_surface); +} + +EGLNativeWindowType RenderingBackendSTM::Surface::nativeWindow() +{ + return m_window; +} + +void RenderingBackendSTM::Surface::resize(uint32_t, uint32_t) +{ +} + +RenderingBackend::BufferExport RenderingBackendSTM::Surface::lockFrontBuffer() +{ + if(g_wldisplay) + wl_display_flush(g_wldisplay); + return std::make_tuple(-1, nullptr, 0); +} + +void RenderingBackendSTM::Surface::releaseBuffer(uint32_t) +{ +} + +RenderingBackendSTM::OffscreenSurface::OffscreenSurface(const RenderingBackendSTM&) +{ +} + +RenderingBackendSTM::OffscreenSurface::~OffscreenSurface() = default; + +EGLNativeWindowType RenderingBackendSTM::OffscreenSurface::nativeWindow() +{ + return nullptr; +} + +} // namespace Graphics + +} // namespace WPE +#endif // WPE_BACKEND(STM); diff --git a/Source/WPE/Source/Graphics/STM/RenderingBackendSTM.h b/Source/WPE/Source/Graphics/STM/RenderingBackendSTM.h new file mode 100644 index 0000000000000..c421876a27938 --- /dev/null +++ b/Source/WPE/Source/Graphics/STM/RenderingBackendSTM.h @@ -0,0 +1,132 @@ +#ifndef WPE_Graphics_RenderingBackendSTM_h +#define WPE_Graphics_RenderingBackendSTM_h + +#include +#include +#include +#include +#include +#include +#include + +struct wl_egl_window; +struct wl_surface; + +namespace WPE { + +namespace Graphics { + +class RenderingBackendSTM final : public RenderingBackend { +public: + using Client = WPE::Graphics::RenderingBackend::Surface::Client; + class Surface final : public RenderingBackend::Surface { + public: + Surface(const RenderingBackendSTM&, uint32_t, uint32_t, uint32_t, Client&); + WPE_EXPORT virtual ~Surface(); + + EGLNativeWindowType nativeWindow() override; + void resize(uint32_t, uint32_t) override; + + BufferExport lockFrontBuffer() override; + void releaseBuffer(uint32_t) override; + + Client& getClient() {return m_client;} + wl_surface* getWlSurface() {return m_surface;} + private: + struct wl_surface* m_surface; + struct wl_egl_window* m_window; + Client& m_client; + }; + + class OffscreenSurface final : public RenderingBackend::OffscreenSurface { + public: + OffscreenSurface(const RenderingBackendSTM&); + virtual ~OffscreenSurface(); + + EGLNativeWindowType nativeWindow() override; + }; + + + struct SeatData { + struct { + struct wl_pointer* object; + struct wl_surface* surface; + std::pair coords; + } pointer { nullptr, nullptr, { 0, 0 } }; + struct { + struct wl_keyboard* object; + struct wl_surface* surface; + } keyboard { nullptr, nullptr}; + struct { + struct wl_touch* object; + std::array targets; + std::array touchPoints; + } touch { nullptr, { }, { } }; + + struct { + struct xkb_context* context; + struct xkb_keymap* keymap; + struct xkb_state* state; + struct { + xkb_mod_index_t control; + xkb_mod_index_t alt; + xkb_mod_index_t shift; + } indexes; + uint8_t modifiers; + struct xkb_compose_table* composeTable; + struct xkb_compose_state* composeState; + } xkb { nullptr, nullptr, nullptr, { 0, 0, 0 }, 0, nullptr, nullptr }; + + struct { + int32_t rate; + int32_t delay; + } repeatInfo { 0, 0 }; + + struct { + uint32_t key; + uint32_t time; + uint32_t state; + uint32_t eventSource; + } repeatData { 0, 0, 0, 0 }; + + uint32_t serial; + }; + + setInputSurface(Surface* surface) { input_surface = surface; } + SeatData& getSeatData() { return m_seatData; } + wl_surface* getWlSurface() { return input_surface->getWlSurface(); } + Client& getClient() { return input_surface->getClient(); } + void initializeSeatData(); + RenderingBackendSTM(); + virtual ~RenderingBackendSTM(); + + EGLNativeDisplayType nativeDisplay() override; + std::unique_ptr createSurface(uint32_t, uint32_t, uint32_t, RenderingBackend::Surface::Client&) override; + std::unique_ptr createOffscreenSurface() override; + +private: + static const struct wl_registry_listener m_registryListener; + static const struct wl_seat_listener m_seatListener; + static void globalCallback(void* data, struct wl_registry*, uint32_t name, const char* interface, uint32_t version); + static void globalRemoveCallback(void* data, struct wl_registry*, uint32_t name); + static void globalSeatCapabilities(void* data, struct wl_seat* seat, uint32_t capabilities); + static void globalSeatName(void* data, struct wl_seat* seat, const char* name); + + Surface* input_surface; + struct wl_display* m_display; + struct wl_registry* m_registry; + struct wl_compositor* m_compositor; + struct wl_shell* m_shell; + struct wl_seat* m_seat; + struct wl_pointer* m_pointer; + struct wl_keyboard* m_keyboard; + struct wl_touch* m_touch; + bool m_seatDataInitialized; + SeatData m_seatData; + GSource* m_eventSource; +}; + +} // namespace Graphics + +} // namespace WPE +#endif diff --git a/Source/WPE/Source/ViewBackend/STM/ViewBackendSTM.cpp b/Source/WPE/Source/ViewBackend/STM/ViewBackendSTM.cpp new file mode 100644 index 0000000000000..a5e907e5e2b2e --- /dev/null +++ b/Source/WPE/Source/ViewBackend/STM/ViewBackendSTM.cpp @@ -0,0 +1,66 @@ +#include "Config.h" +#include "ViewBackendSTM.h" +#include + +#if WPE_BACKEND(STM) + +namespace WPE { + +namespace ViewBackend { + +ViewBackendSTM::ViewBackendSTM() +{ +} + +ViewBackendSTM::~ViewBackendSTM() +{ +} + +void ViewBackendSTM::setClient(Client* client) +{ + m_client = client; +} + +uint32_t ViewBackendSTM::constructRenderingTarget(uint32_t, uint32_t) +{ + return 0; +} + +void ViewBackendSTM::commitBuffer(int, const uint8_t*, size_t) +{ + if (m_client) + m_client->frameComplete(); +} + +void ViewBackendSTM::destroyBuffer(uint32_t) +{ +} + +void ViewBackendSTM::setInputClient(Input::Client* client) +{ + m_input_client = client; +} + +void ViewBackendSTM::handleKeyboardEvent(const Input::KeyboardEvent& event) +{ + if(m_input_client) + m_input_client->handleKeyboardEvent({event.time, event.keyCode, event.unicode, event.pressed, event.modifiers}); +} + +void ViewBackendSTM::handlePointerEvent(const Input::PointerEvent& event) +{ + if(m_input_client) + m_input_client->handlePointerEvent({event.type, event.time, event.x, event.y, event.button, event.state}); +} + +void ViewBackendSTM::handleAxisEvent(const Input::AxisEvent& event) +{ + if(m_input_client) + m_input_client->handleAxisEvent({event.type, event.time, event.x, event.y, event.axis, event.value}); +} + +} // namespace ViewBackend + +} // namespace WPE + +#endif // WPE_BACKEND(STM) diff --git a/Source/WPE/Source/ViewBackend/STM/ViewBackendSTM.h b/Source/WPE/Source/ViewBackend/STM/ViewBackendSTM.h new file mode 100644 index 0000000000000..de4a94114dff2 --- /dev/null +++ b/Source/WPE/Source/ViewBackend/STM/ViewBackendSTM.h @@ -0,0 +1,35 @@ +#if WPE_BACKEND(STM) + +#include + +namespace WPE { + +namespace ViewBackend { + +class ViewBackendSTM final : public ViewBackend { +public: + ViewBackendSTM(); + virtual ~ViewBackendSTM(); + + void setClient(Client*) override; + uint32_t constructRenderingTarget(uint32_t, uint32_t) override; + std::pair authenticate() override { return { nullptr, 0 }; }; + void commitBuffer(int, const uint8_t*, size_t) override; + void destroyBuffer(uint32_t) override; + + void handleKeyboardEvent(const Input::KeyboardEvent& event) override; + void handlePointerEvent(const Input::PointerEvent& event) override; + void handleAxisEvent(const Input::AxisEvent& event) override; + + void setInputClient(Input::Client*) override; + +private: + Client* m_client; + Input::Client* m_input_client; +}; + +} // namespace ViewBackend + +} // namespace WPE + +#endif // WPE_BACKEND(STM) diff --git a/Source/WPE/Source/ViewBackend/ViewBackend.cpp b/Source/WPE/Source/ViewBackend/ViewBackend.cpp index df169a9b00a33..8f4d76d2a5968 100644 --- a/Source/WPE/Source/ViewBackend/ViewBackend.cpp +++ b/Source/WPE/Source/ViewBackend/ViewBackend.cpp @@ -31,6 +31,7 @@ #include "ViewBackendBCMRPi.h" #include "ViewBackendIntelCE.h" #include "ViewBackendWesteros.h" +#include "ViewBackendSTM.h" #include #include #include @@ -80,6 +81,11 @@ std::unique_ptr ViewBackend::create() return std::unique_ptr(new ViewBackendWesteros); #endif +#if WPE_BACKEND(STM) + if (!backendEnv || !std::strcmp(backendEnv, "stm")) + return std::unique_ptr(new ViewBackendSTM); +#endif + fprintf(stderr, "ViewBackend: no usable backend found, will crash.\n"); return nullptr; } @@ -96,6 +102,18 @@ void ViewBackend::setInputClient(Input::Client*) { } +void ViewBackend::handleKeyboardEvent(const Input::KeyboardEvent& event) +{ +} + +void ViewBackend::handlePointerEvent(const Input::PointerEvent& event) +{ +} + +void ViewBackend::handleAxisEvent(const Input::AxisEvent& event) +{ +} + } // namespace ViewBackend } // namespace WPE diff --git a/Source/WebCore/PlatformWPE.cmake b/Source/WebCore/PlatformWPE.cmake index 8243f7866861c..e96b4fdda8088 100644 --- a/Source/WebCore/PlatformWPE.cmake +++ b/Source/WebCore/PlatformWPE.cmake @@ -42,6 +42,7 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/text/icu" ${WPE_DIR} ${WTF_DIR} + ${WAYLAND_INCLUDE_DIRS} ) list(APPEND WebCore_SOURCES @@ -111,7 +112,9 @@ list(APPEND WebCore_SOURCES platform/graphics/opentype/OpenTypeVerticalData.cpp platform/graphics/wpe/PlatformDisplayWPE.cpp - + platform/graphics/wayland/PlatformDisplayWayland.cpp + platform/graphics/wayland/WaylandEventSource.cpp + platform/graphics/wayland/WaylandSurface.cpp platform/image-encoders/JPEGImageEncoder.cpp platform/image-decoders/cairo/ImageDecoderCairo.cpp @@ -213,6 +216,7 @@ list(APPEND WebCore_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${SQLITE_LIBRARIES} + ${WAYLAND_LIBRARIES} WPE ) @@ -271,5 +275,3 @@ if (ENABLE_SUBTLE_CRYPTO) crypto/keys/CryptoKeySerializationRaw.cpp ) endif () - - diff --git a/Source/WebCore/platform/graphics/GLContext.cpp b/Source/WebCore/platform/graphics/GLContext.cpp index b2d3ab265c111..9c2f245af5763 100644 --- a/Source/WebCore/platform/graphics/GLContext.cpp +++ b/Source/WebCore/platform/graphics/GLContext.cpp @@ -34,8 +34,12 @@ #endif #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) +#include "PlatformDisplayWayland.h" +#else #include "PlatformDisplayWPE.h" #endif +#endif using WTF::ThreadSpecific; @@ -151,8 +155,13 @@ GLContext::GLContext() std::unique_ptr GLContext::createOffscreenContext(GLContext* sharingContext) { #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) + return downcast(PlatformDisplay::sharedDisplay()).createSharingGLContext(); +#else if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::WPE) return downcast(PlatformDisplay::sharedDisplay()).createOffscreenContext(sharingContext); +#endif #endif return createContextForWindow(0, sharingContext); } diff --git a/Source/WebCore/platform/graphics/PlatformDisplay.cpp b/Source/WebCore/platform/graphics/PlatformDisplay.cpp index e6c7954d90820..80c9896255535 100644 --- a/Source/WebCore/platform/graphics/PlatformDisplay.cpp +++ b/Source/WebCore/platform/graphics/PlatformDisplay.cpp @@ -42,8 +42,10 @@ #endif #if PLATFORM(WPE) +#if !PLATFORM(WAYLAND) #include "PlatformDisplayWPE.h" #endif +#endif #if PLATFORM(GTK) #include @@ -94,9 +96,12 @@ std::unique_ptr PlatformDisplay::createPlatformDisplay() #endif #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + return PlatformDisplayWayland::create(); +#else return std::make_unique(); #endif - +#endif ASSERT_NOT_REACHED(); return nullptr; } diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp index 07f42f4ecca48..bf96ee1ebfc3e 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp @@ -86,7 +86,7 @@ #define WL_EGL_PLATFORM #if USE(OPENGL_ES_2) -#if GST_CHECK_VERSION(1, 3, 0) +#if GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) #if !USE(HOLE_PUNCH_GSTREAMER) #define GST_USE_UNSTABLE_API #include @@ -650,7 +650,7 @@ void MediaPlayerPrivateGStreamerBase::updateTexture(BitmapTextureGL& texture, Gs { GstBuffer* buffer = gst_sample_get_buffer(m_sample.get()); -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 1, 2) && !USE(HOLE_PUNCH_GSTREAMER) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 1, 2) && !USE(HOLE_PUNCH_GSTREAMER) && USE(GSTREAMER_GL) GstMemory *mem; if (gst_buffer_n_memory (buffer) >= 1) { if ((mem = gst_buffer_peek_memory (buffer, 0)) && gst_is_egl_image_memory (mem)) { @@ -942,7 +942,7 @@ void MediaPlayerPrivateGStreamerBase::paintToTextureMapper(TextureMapper& textur #endif #if USE(GSTREAMER_GL) -NativeImagePtr MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime() +PassNativeImagePtr MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime() { #if !USE(CAIRO) || !ENABLE(ACCELERATED_2D_CANVAS) return nullptr; diff --git a/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp index 3122b8d42a567..e6aa050ce5c30 100644 --- a/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp @@ -38,7 +38,7 @@ #include #include -#if USE(EGL) +#if USE(EGL) && USE(GSTREAMER_GL) #define WL_EGL_PLATFORM #include #include @@ -70,7 +70,7 @@ using namespace WebCore; #if GST_CHECK_VERSION(1, 1, 0) #define GST_FEATURED_CAPS_GL GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, GST_CAPS_FORMAT) ";" -#if GST_CHECK_VERSION(1, 3, 0) +#if GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) #define GST_FEATURED_CAPS GST_FEATURED_CAPS_GL GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_MEMORY_EGL_IMAGE, GST_CAPS_FORMAT) ";" #else #define GST_FEATURED_CAPS GST_FEATURED_CAPS_GL @@ -205,7 +205,7 @@ struct _WebKitVideoSinkPrivate { if (currentCaps) gst_caps_unref(currentCaps); -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 5, 1) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 5, 1) && USE(GSTREAMER_GL) if (context) { gst_gl_context_destroy(context); gst_object_unref(context); @@ -225,7 +225,7 @@ struct _WebKitVideoSinkPrivate { GstVideoInfo info; GstCaps* currentCaps; -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) GstGLDisplay *display; GstGLContext *context; GstGLContext *other_context; @@ -433,7 +433,7 @@ static gboolean webkitVideoSinkProposeAllocation(GstBaseSink* baseSink, GstQuery if (!gst_video_info_from_caps(&sink->priv->info, caps)) return FALSE; -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) // Code adapted from gst-plugins-bad's glimagesink. if (!_ensure_gl_setup(sink)) @@ -492,7 +492,7 @@ static gboolean webkitVideoSinkQuery(GstBaseSink* baseSink, GstQuery* query) switch (GST_QUERY_TYPE(query)) { case GST_QUERY_DRAIN: { -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) priv->scheduler.drain(); LOG_MEDIA_MESSAGE("Drain query, emitting DRAIN signal and releasing EGL samples"); @@ -525,7 +525,7 @@ static gboolean webkitVideoSinkEvent(GstBaseSink *baseSink, GstEvent *event) switch (GST_EVENT_TYPE(event)) { case GST_EVENT_FLUSH_START: -#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) +#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) priv->scheduler.drain(); LOG_MEDIA_MESSAGE("Flush-start, emitting DRAIN signal and releasing EGL samples"); @@ -541,7 +541,7 @@ static gboolean webkitVideoSinkEvent(GstBaseSink *baseSink, GstEvent *event) } } -#if GST_CHECK_VERSION(1, 3, 0) +#if GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) static void webkitVideoSinkSetContext(GstElement* element, GstContext* context) { @@ -579,7 +579,7 @@ static void webkit_video_sink_class_init(WebKitVideoSinkClass* klass) baseSinkClass->query = webkitVideoSinkQuery; baseSinkClass->event = webkitVideoSinkEvent; -#if GST_CHECK_VERSION(1, 3, 0) +#if GST_CHECK_VERSION(1, 3, 0) && USE(GSTREAMER_GL) elementClass->set_context = webkitVideoSinkSetContext; #endif diff --git a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp index d3305e16a2433..88756dcb51cda 100644 --- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp +++ b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp @@ -34,7 +34,306 @@ #include #include +//KEYBOARD SUPPORT +#if !PLATFORM(GTK) +#include +#include +#include +#endif +//KEYBOARD SUPPORT +//MOUSE SUPPORT +#include +//MOUSE SUPPORT + namespace WebCore { + +#if !PLATFORM(GTK) + +typedef struct _GSource GSource; + +class EventSource { +public: + static GSourceFuncs sourceFuncs1; + + GSource source; + GPollFD pfd; + struct wl_display* display; +}; + +GSourceFuncs EventSource::sourceFuncs1 = { + // prepare + [](GSource* base, gint* timeout) -> gboolean + { + auto* source = reinterpret_cast(base); + struct wl_display* display = source->display; + + *timeout = -1; + wl_display_flush(display); + wl_display_dispatch_pending(display); + + return FALSE; + }, + // check + [](GSource* base) -> gboolean + { + auto* source = reinterpret_cast(base); + return !!source->pfd.revents; + }, + // dispatch + [](GSource* base, GSourceFunc, gpointer) -> gboolean + { + auto* source = reinterpret_cast(base); + struct wl_display* display = source->display; + + if (source->pfd.revents & G_IO_IN) + wl_display_dispatch(display); + + if (source->pfd.revents & (G_IO_ERR | G_IO_HUP)) + return FALSE; + + source->pfd.revents = 0; + return TRUE; + }, + nullptr, // finalize + nullptr, // closure_callback + nullptr, // closure_marshall +}; +//KEYBOARD SUPPORT +static void +handleKeyEvent(PlatformDisplayWayland::SeatData& seatData, uint32_t key, uint32_t state, uint32_t time) +{ + auto& xkb = seatData.xkb; + uint32_t keysym = xkb_state_key_get_one_sym(xkb.state, key); + uint32_t unicode = xkb_state_key_get_utf32(xkb.state, key); + + if (state == WL_KEYBOARD_KEY_STATE_PRESSED + && xkb_compose_state_feed(xkb.composeState, keysym) == XKB_COMPOSE_FEED_ACCEPTED + && xkb_compose_state_get_status(xkb.composeState) == XKB_COMPOSE_COMPOSED) + { + keysym = xkb_compose_state_get_one_sym(xkb.composeState); + unicode = xkb_keysym_to_utf32(keysym); + } + seatData.inputHandler->handleKeyboardEvent({ time, keysym, unicode, !!state, xkb.modifiers }); +} + +static gboolean +repeatRateTimeout(void* data) +{ + auto& seatData = *static_cast(data); + handleKeyEvent(seatData, seatData.repeatData.key, seatData.repeatData.state, seatData.repeatData.time); + return G_SOURCE_CONTINUE; +} + +static gboolean +repeatDelayTimeout(void* data) +{ + auto& seatData = *static_cast(data); + handleKeyEvent(seatData, seatData.repeatData.key, seatData.repeatData.state, seatData.repeatData.time); + seatData.repeatData.eventSource = g_timeout_add(seatData.repeatInfo.rate, static_cast(repeatRateTimeout), data); + return G_SOURCE_REMOVE; +} + +static const struct wl_keyboard_listener g_keyboardListener = { + // keymap + [](void* data, struct wl_keyboard*, uint32_t format, int fd, uint32_t size) + { + if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { + close(fd); + return; + } + + void* mapping = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); + if (mapping == MAP_FAILED) { + close(fd); + return; + } + + auto& xkb = static_cast(data)->xkb; + xkb.keymap = xkb_keymap_new_from_string(xkb.context, static_cast(mapping), + XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + munmap(mapping, size); + close(fd); + + if (!xkb.keymap) + return; + + xkb.state = xkb_state_new(xkb.keymap); + if (!xkb.state) + return; + + xkb.indexes.control = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_CTRL); + xkb.indexes.alt = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_ALT); + xkb.indexes.shift = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_SHIFT); + }, + // enter + [](void* data, struct wl_keyboard*, uint32_t serial, struct wl_surface* surface, struct wl_array*) + { + auto& seatData = *static_cast(data); + seatData.serial = serial; + auto it = seatData.inputClients.find(surface); + if (it != seatData.inputClients.end()) + seatData.keyboard.target = *it; + }, + // leave + [](void* data, struct wl_keyboard*, uint32_t serial, struct wl_surface* surface) + { + auto& seatData = *static_cast(data); + seatData.serial = serial; + auto it = seatData.inputClients.find(surface); + if (it != seatData.inputClients.end() && seatData.keyboard.target.first == it->first) + seatData.keyboard.target = { }; + }, + // key + [](void* data, struct wl_keyboard*, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) + { + // IDK. + key += 8; + + auto& seatData = *static_cast(data); + seatData.serial = serial; + handleKeyEvent(seatData, key, state, time); + + if (!seatData.repeatInfo.rate) + return; + + if (state == WL_KEYBOARD_KEY_STATE_RELEASED + && seatData.repeatData.key == key) { + if (seatData.repeatData.eventSource) + g_source_remove(seatData.repeatData.eventSource); + seatData.repeatData = { 0, 0, 0, 0 }; + } else if (state == WL_KEYBOARD_KEY_STATE_PRESSED + && xkb_keymap_key_repeats(seatData.xkb.keymap, key)) { + + if (seatData.repeatData.eventSource) + g_source_remove(seatData.repeatData.eventSource); + + seatData.repeatData = { key, time, state, g_timeout_add(seatData.repeatInfo.delay, static_cast(repeatDelayTimeout), data) }; + } + + }, + // modifiers + [](void* data, struct wl_keyboard*, uint32_t serial, uint32_t depressedMods, uint32_t latchedMods, uint32_t lockedMods, uint32_t group) + { + + static_cast(data)->serial = serial; + auto& xkb = static_cast(data)->xkb; + xkb_state_update_mask(xkb.state, depressedMods, latchedMods, lockedMods, 0, 0, group); + + auto& modifiers = xkb.modifiers; + modifiers = 0; + auto component = static_cast(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.control, component)) + modifiers |= WPE::Input::KeyboardEvent::Control; + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.alt, component)) + modifiers |= WPE::Input::KeyboardEvent::Alt; + if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.shift, component)) + modifiers |= WPE::Input::KeyboardEvent::Shift; + + }, + // repeat_info + [](void* data, struct wl_keyboard*, int32_t rate, int32_t delay) + { + auto& repeatInfo = static_cast(data)->repeatInfo; + repeatInfo = { rate, delay }; + + // A rate of zero disables any repeating. + if (!rate) { + auto& repeatData = static_cast(data)->repeatData; + if (repeatData.eventSource) { + g_source_remove(repeatData.eventSource); + repeatData = { 0, 0, 0, 0 }; + } + } + }, +}; + + +static const struct wl_pointer_listener g_pointerListener = { + // enter + [](void* data, struct wl_pointer*, uint32_t serial, struct wl_surface* surface, wl_fixed_t, wl_fixed_t) + { + auto& seatData = *static_cast(data); + seatData.serial = serial; + auto it = seatData.inputClients.find(surface); + if (it != seatData.inputClients.end()) + seatData.pointer.target = *it; + }, + // leave + [](void* data, struct wl_pointer*, uint32_t serial, struct wl_surface* surface) + { + auto& seatData = *static_cast(data); + seatData.serial = serial; + auto it = seatData.inputClients.find(surface); + if (it != seatData.inputClients.end() && seatData.pointer.target.first == it->first) + seatData.pointer.target = { }; + }, + // motion + [](void* data, struct wl_pointer*, uint32_t time, wl_fixed_t fixedX, wl_fixed_t fixedY) + { + auto x = wl_fixed_to_int(fixedX); + auto y = wl_fixed_to_int(fixedY); + auto& seatData = *static_cast(data); + seatData.pointer.coords = { x, y }; + seatData.inputHandler->handlePointerEvent({ WPE::Input::PointerEvent::Motion, time, x, y, 0, 0 }); + }, + // button + [](void* data, struct wl_pointer*, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) + { + printf("PlatformDisplayWayland::button pressed\n"); + static_cast(data)->serial = serial; + + if (button >= BTN_MOUSE) + button = button - BTN_MOUSE + 1; + else + button = 0; + + auto& seatData = *static_cast(data); + auto& coords = seatData.pointer.coords; + seatData.inputHandler->handlePointerEvent( + { WPE::Input::PointerEvent::Button, time, coords.first, coords.second, button, state }); + }, + // axis + [](void* data, struct wl_pointer*, uint32_t time, uint32_t axis, wl_fixed_t value) + { + auto& seatData = *static_cast(data); + auto& coords = seatData.pointer.coords; + seatData.inputHandler->handleAxisEvent( + { WPE::Input::AxisEvent::Motion, time, coords.first, coords.second, axis, -wl_fixed_to_int(value) }); + }, +}; + +static const struct wl_seat_listener g_seatListener = { + // capabilities + [](void* data, struct wl_seat* seat, uint32_t capabilities) + { + auto& seatData = *static_cast(data); + // WL_SEAT_CAPABILITY_POINTER + const bool hasPointerCap = capabilities & WL_SEAT_CAPABILITY_POINTER; + if (hasPointerCap && !seatData.pointer.object) { + seatData.pointer.object = wl_seat_get_pointer(seat); + wl_pointer_add_listener(seatData.pointer.object, &g_pointerListener, &seatData); + } + if (!hasPointerCap && seatData.pointer.object) { + wl_pointer_destroy(seatData.pointer.object); + seatData.pointer.object = nullptr; + } + + // WL_SEAT_CAPABILITY_KEYBOARD + const bool hasKeyboardCap = capabilities & WL_SEAT_CAPABILITY_KEYBOARD; + if (hasKeyboardCap && !seatData.keyboard.object) { + seatData.keyboard.object = wl_seat_get_keyboard(seat); + wl_keyboard_add_listener(seatData.keyboard.object, &g_keyboardListener, &seatData); + } + if (!hasKeyboardCap && seatData.keyboard.object) { + wl_keyboard_destroy(seatData.keyboard.object); + seatData.keyboard.object = nullptr; + } + }, + // name + [](void*, struct wl_seat*, const char*) { } +}; +//KEYBOARD SUPPORT +#endif const struct wl_registry_listener PlatformDisplayWayland::m_registryListener = { PlatformDisplayWayland::globalCallback, @@ -46,10 +345,46 @@ void PlatformDisplayWayland::globalCallback(void* data, struct wl_registry* regi auto display = static_cast(data); if (!std::strcmp(interface, "wl_compositor")) display->m_compositor = static_cast(wl_registry_bind(registry, name, &wl_compositor_interface, 1)); +if (!std::strcmp(interface, "wl_shell")) +display->m_shell = static_cast(wl_registry_bind(registry, name, &wl_shell_interface, 1)); +#if PLATFORM(GTK) else if (!std::strcmp(interface, "wl_webkitgtk")) display->m_webkitgtk = static_cast(wl_registry_bind(registry, name, &wl_webkitgtk_interface, 1)); +#endif +//KEYBOARD SUPPORT +#if !PLATFORM(GTK) + else if (!std::strcmp(interface, "wl_seat")) + display->m_seat = static_cast(wl_registry_bind(registry, name, &wl_seat_interface, 4)); +#endif +//KEYBOARD SUPPORT } +//For sending pong in response to ping from server +static void +handle_ping(void *data, struct wl_shell_surface *shell_surface, + uint32_t serial) +{ + wl_shell_surface_pong(shell_surface, serial); +} + +static void +handle_configure(void *data, struct wl_shell_surface *shell_surface, + uint32_t edges, int32_t width, int32_t height) +{ +} + +static void +handle_popup_done(void *data, struct wl_shell_surface *shell_surface) +{ +} + +static const struct wl_shell_surface_listener shell_surface_listener = { + handle_ping, + handle_configure, + handle_popup_done +}; +//For sending pong in response to ping from server + void PlatformDisplayWayland::globalRemoveCallback(void*, struct wl_registry*, uint32_t) { // FIXME: if this can happen without the UI Process getting shut down @@ -81,6 +416,29 @@ PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) wl_registry_add_listener(m_registry, &m_registryListener, this); wl_display_roundtrip(m_display); +#if !PLATFORM(GTK) + m_eventSource = g_source_new(&EventSource::sourceFuncs1, sizeof(EventSource)); + auto* source = reinterpret_cast(m_eventSource); + source->display = wlDisplay; + + source->pfd.fd = wl_display_get_fd(wlDisplay); + source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; + source->pfd.revents = 0; + g_source_add_poll(m_eventSource, &source->pfd); + + g_source_set_name(m_eventSource, "[WPE] PlatformDisplayWayland"); + g_source_set_priority(m_eventSource, G_PRIORITY_HIGH + 30); + g_source_set_can_recurse(m_eventSource, TRUE); + g_source_attach(m_eventSource, g_main_context_get_thread_default()); +//KEYBOARD SUPPORT + wl_seat_add_listener(m_seat, &g_seatListener, &m_seatData); + m_seatData.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + m_seatData.xkb.composeTable = xkb_compose_table_new_from_locale(m_seatData.xkb.context, setlocale(LC_CTYPE, nullptr), XKB_COMPOSE_COMPILE_NO_FLAGS); + if (m_seatData.xkb.composeTable) + m_seatData.xkb.composeState = xkb_compose_state_new(m_seatData.xkb.composeTable, XKB_COMPOSE_STATE_NO_FLAGS); +//KEYBOARD SUPPORT +#endif + static const EGLint configAttributes[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 1, @@ -92,9 +450,7 @@ PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) }; m_eglDisplay = eglGetDisplay(m_display); - PlatformDisplay::initializeEGLDisplay(); - if (m_eglDisplay == EGL_NO_DISPLAY) - return; + if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {return;} EGLint numberOfConfigs; if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) { @@ -107,24 +463,59 @@ PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) PlatformDisplayWayland::~PlatformDisplayWayland() { +#if PLATFORM(GTK) if (m_webkitgtk) wl_webkitgtk_destroy(m_webkitgtk); +#endif if (m_compositor) wl_compositor_destroy(m_compositor); if (m_registry) wl_registry_destroy(m_registry); if (m_display) wl_display_disconnect(m_display); +#if !PLATFORM(GTK) +//KEYBOARD SUPPORT + if (m_seat) + wl_seat_destroy(m_seat); + if (m_seatData.xkb.context) + xkb_context_unref(m_seatData.xkb.context); + if (m_seatData.xkb.keymap) + xkb_keymap_unref(m_seatData.xkb.keymap); + if (m_seatData.xkb.state) + xkb_state_unref(m_seatData.xkb.state); + if (m_seatData.xkb.composeTable) + xkb_compose_table_unref(m_seatData.xkb.composeTable); + if (m_seatData.xkb.composeState) + xkb_compose_state_unref(m_seatData.xkb.composeState); +//KEYBOARD SUPPORT +#endif } std::unique_ptr PlatformDisplayWayland::createSurface(const IntSize& size, int widgetId) { struct wl_surface* wlSurface = wl_compositor_create_surface(m_compositor); + + struct wl_shell_surface *shell_surface; + shell_surface = wl_shell_get_shell_surface(m_shell, wlSurface); + + if (shell_surface) + wl_shell_surface_add_listener(shell_surface, + &shell_surface_listener, NULL); + wl_shell_surface_set_toplevel(shell_surface); + + struct wl_region *region; + region = wl_compositor_create_region(m_compositor); + wl_region_add(region, 0, 0, + std::max(1, size.width()), + std::max(1, size.height())); + wl_surface_set_opaque_region(wlSurface, region); + // We keep the minimum size at 1x1px since Mesa returns null values in wl_egl_window_create() for zero width or height. EGLNativeWindowType nativeWindow = wl_egl_window_create(wlSurface, std::max(1, size.width()), std::max(1, size.height())); +#if PLATFORM(GTK) wl_webkitgtk_set_surface_for_widget(m_webkitgtk, wlSurface, widgetId); - wl_display_roundtrip(m_display); +#endif return std::make_unique(wlSurface, nativeWindow); } @@ -151,6 +542,25 @@ std::unique_ptr PlatformDisplayWayland::createSharingGLContext() return GLContextEGL::createWindowContext(nativeWindow, nullptr, WTFMove(contextData)); } +//KEYBOARD SUPPORT +#if !PLATFORM(GTK) +void PlatformDisplayWayland::registerInputClient(struct wl_surface* surface, WPE::Input::Client* client) +{ + m_seatData.inputHandler = client; + auto result = m_seatData.inputClients.insert({ surface, client }); + assert(result.second); +} +void PlatformDisplayWayland::unregisterInputClient(struct wl_surface* surface) +{ + auto it = m_seatData.inputClients.find(surface); + assert(it != m_seatData.inputClients.end()); + + if (m_seatData.keyboard.target.first == it->first) + m_seatData.keyboard.target = { }; + m_seatData.inputClients.erase(it); +} +#endif +//KEYBOARD SUPPORT } // namespace WebCore #endif // PLATFORM(WAYLAND) diff --git a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h index 4cc9044380ff1..e335b3b14385f 100644 --- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h +++ b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h @@ -29,12 +29,25 @@ #if PLATFORM(WAYLAND) #include "PlatformDisplay.h" +#if PLATFORM(GTK) #include "WebKitGtkWaylandClientProtocol.h" +#endif #include #include #include #include +#if !PLATFORM(GTK) +#include +//KEYBOARD SUPPORT +#include +#include +#include +#include +#include +//KEYBOARD SUPPORT +#endif + namespace WebCore { class GLContextEGL; @@ -52,6 +65,55 @@ class PlatformDisplayWayland final: public PlatformDisplay { std::unique_ptr createSharingGLContext(); +//KEYBOARD SUPPORT +#if !PLATFORM(GTK) + void registerInputClient(struct wl_surface*, WPE::Input::Client*); + void unregisterInputClient(struct wl_surface*); + struct SeatData { + std::unordered_map inputClients; + + struct { + struct wl_pointer* object; + std::pair target; + std::pair coords; + } pointer { nullptr, { }, { 0, 0 } }; + + struct { + struct wl_keyboard* object; + std::pair target; + } keyboard { nullptr, { } }; + + struct { + struct xkb_context* context; + struct xkb_keymap* keymap; + struct xkb_state* state; + struct { + xkb_mod_index_t control; + xkb_mod_index_t alt; + xkb_mod_index_t shift; + } indexes; + uint8_t modifiers; + struct xkb_compose_table* composeTable; + struct xkb_compose_state* composeState; + } xkb { nullptr, nullptr, nullptr, { 0, 0, 0 }, 0, nullptr, nullptr }; + struct { + int32_t rate; + int32_t delay; + } repeatInfo { 0, 0 }; + + struct { + uint32_t key; + uint32_t time; + uint32_t state; + uint32_t eventSource; + } repeatData { 0, 0, 0, 0 }; + + uint32_t serial; + WPE::Input::Client* inputHandler; //RISKY + }; + uint32_t serial() const { return m_seatData.serial; } +#endif +//KEYBOARD SUPPORT private: static const struct wl_registry_listener m_registryListener; static void globalCallback(void* data, struct wl_registry*, uint32_t name, const char* interface, uint32_t version); @@ -67,8 +129,15 @@ class PlatformDisplayWayland final: public PlatformDisplay { struct wl_display* m_display; struct wl_registry* m_registry; struct wl_compositor* m_compositor; + struct wl_shell *m_shell; +#if PLATFORM(GTK) struct wl_webkitgtk* m_webkitgtk; - +#endif +#if !PLATFORM(GTK) + struct wl_seat* m_seat; + GSource* m_eventSource; + SeatData m_seatData; +#endif EGLConfig m_eglConfig; bool m_eglConfigChosen; }; diff --git a/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp b/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp index 971ab19ed3495..6a4171431ac2c 100644 --- a/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp +++ b/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp @@ -78,6 +78,11 @@ void WaylandSurface::requestFrame() wl_callback_add_listener(frameCallback, &frameListener, this); } +#if !PLATFORM(GTK) +void WaylandSurface::releaseBuffer(uint32_t handle) +{ +} +#endif } // namespace WebCore #endif // PLATFORM(WAYLAND) diff --git a/Source/WebCore/platform/graphics/wayland/WaylandSurface.h b/Source/WebCore/platform/graphics/wayland/WaylandSurface.h index 69f22b1cd6f3b..7219036827631 100644 --- a/Source/WebCore/platform/graphics/wayland/WaylandSurface.h +++ b/Source/WebCore/platform/graphics/wayland/WaylandSurface.h @@ -52,6 +52,9 @@ class WaylandSurface { void requestFrame(); +#if !PLATFORM(GTK) + void releaseBuffer(uint32_t handle); +#endif private: struct wl_surface* m_wlSurface; EGLNativeWindowType m_nativeWindow; diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp index 8be6198c9041d..e67812693c9f3 100644 --- a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp +++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp @@ -29,6 +29,11 @@ #include "ThreadedCompositor.h" #include +#if PLATFORM(WAYLAND) +#include +#include +#endif +#include #include #include #include @@ -44,9 +49,102 @@ #include #endif +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +//KEYBOARD SUPPORT +#include "NativeWebKeyboardEvent.h" +#include "NativeWebMouseEvent.h" +//KEYBOARD SUPPORT +#endif + using namespace WebCore; namespace WebKit { +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +const struct wl_callback_listener g_frameCallbackListener = { + // frame + [](void* data, struct wl_callback* callback, uint32_t) + { + auto& callbackData = *static_cast(data); + callbackData.didFrameComplete(); + wl_callback_destroy(callback); + }, +}; +#endif + +class CompositingRunLoop { + WTF_MAKE_NONCOPYABLE(CompositingRunLoop); + WTF_MAKE_FAST_ALLOCATED; +public: + CompositingRunLoop(std::function updateFunction) + : m_runLoop(RunLoop::current()) + , m_updateTimer(m_runLoop, this, &CompositingRunLoop::updateTimerFired) + , m_updateFunction(WTFMove(updateFunction)) + { + m_updateState.store(UpdateState::Completed); + } + + void callOnCompositingRunLoop(std::function function) + { + if (&m_runLoop == &RunLoop::current()) { + function(); + return; + } + + m_runLoop.dispatch(WTFMove(function)); + } + + void scheduleUpdate() + { + if (m_updateState.compareExchangeStrong(UpdateState::Completed, UpdateState::InProgress)) { + m_updateTimer.startOneShot(0); + return; + } + + if (m_updateState.compareExchangeStrong(UpdateState::InProgress, UpdateState::PendingAfterCompletion)) + return; + } + + void stopUpdates() + { + m_updateTimer.stop(); + m_updateState.store(UpdateState::Completed); + } + + void updateCompleted() + { + if (m_updateState.compareExchangeStrong(UpdateState::InProgress, UpdateState::Completed)) + return; + + if (m_updateState.compareExchangeStrong(UpdateState::PendingAfterCompletion, UpdateState::InProgress)) { + m_updateTimer.startOneShot(0); + return; + } + + ASSERT_NOT_REACHED(); + } + + RunLoop& runLoop() + { + return m_runLoop; + } + +private: + enum class UpdateState { + Completed, + InProgress, + PendingAfterCompletion, + }; + + void updateTimerFired() + { + m_updateFunction(); + } + + RunLoop& m_runLoop; + RunLoop::Timer m_updateTimer; + std::function m_updateFunction; + Atomic m_updateState; +}; Ref ThreadedCompositor::create(Client* client, WebPage& webPage) { @@ -61,6 +159,11 @@ ThreadedCompositor::ThreadedCompositor(Client* client, WebPage& webPage) #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) , m_displayRefreshMonitor(adoptRef(new DisplayRefreshMonitor(*this))) #endif +//KEYBOARD SUPPORT - //THIS NEEDS TO BE TESTED WITH THIS WEBPAGE TO AVOID HAVING ONE MORE API getWebPage in threaded client +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + , webpage(webPage) +#endif +//KEYBOARD SUPPORT { m_clientRendersNextFrame.store(false); m_coordinateUpdateCompletionWithClient.store(false); @@ -188,14 +291,29 @@ GLContext* ThreadedCompositor::glContext() return m_context.get(); #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + RELEASE_ASSERT(is(PlatformDisplay::sharedDisplay())); +#else RELEASE_ASSERT(is(PlatformDisplay::sharedDisplay())); - +#endif IntSize size(viewportController()->visibleContentsRect().size()); uint32_t targetHandle = m_compositingManager->constructRenderingTarget(std::max(0, size.width()), std::max(0, size.height())); +#if PLATFORM(WAYLAND) + m_surface = downcast(PlatformDisplay::sharedDisplay()).createSurface(size, targetHandle); +#else m_surface = downcast(PlatformDisplay::sharedDisplay()).createSurface(size, targetHandle, *m_compositingManager); +#endif if (!m_surface) return nullptr; +#if PLATFORM(WAYLAND) +//KEYBOARD SUPPORT + printf("Registering input client [%x] \n",this); + fflush(stdout); + downcast(PlatformDisplay::sharedDisplay()).registerInputClient(m_surface->surface(),this); +//KEYBOARD SUPPORT +#endif + setNativeSurfaceHandleForCompositing(0); m_context = m_surface->createGLContext(); #endif @@ -237,12 +355,22 @@ void ThreadedCompositor::renderLayerTree() m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::white, false, scrollPostion); +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + requestFrame(); +#endif + glContext()->swapBuffers(); #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + using BufferExport = WPE::Graphics::RenderingBackend::BufferExport; + BufferExport bufferExport = {}; + m_compositingManager->commitBuffer(bufferExport); +#else auto bufferExport = m_surface->lockFrontBuffer(); m_compositingManager->commitBuffer(bufferExport); #endif +#endif } void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state) @@ -296,6 +424,11 @@ void ThreadedCompositor::runCompositingThread() m_viewportController = std::make_unique(this); m_initializeRunLoopCondition.notifyOne(); +#if PLATFORM(WAYLAND) +//KEYBOARD SUPPORT + downcast(PlatformDisplay::sharedDisplay()).unregisterInputClient(m_surface->surface()); +//KEYBOARD SUPPORT +#endif } m_compositingRunLoop->runLoop().run(); @@ -343,11 +476,13 @@ static void debugThreadedCompositorFPS() } } +#if PLATFORM(WPE) void ThreadedCompositor::releaseBuffer(uint32_t handle) { ASSERT(&RunLoop::current() == &m_compositingRunLoop->runLoop()); m_surface->releaseBuffer(handle); } +#endif void ThreadedCompositor::frameComplete() { @@ -497,5 +632,40 @@ void ThreadedCompositor::CompositingRunLoop::updateTimerFired() m_updateFunction(); } +#if PLATFORM(WAYLAND) +void ThreadedCompositor::requestFrame() +{ + struct wl_callback* frameCallback = wl_surface_frame(m_surface->surface()); + wl_callback_add_listener(frameCallback, &(WebKit::g_frameCallbackListener), this); + wl_display_flush(downcast(PlatformDisplay::sharedDisplay()).native()); +} +void ThreadedCompositor::didFrameComplete() +{ + frameComplete(); +} +#endif +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +void ThreadedCompositor::handleKeyboardEvent(WPE::Input::KeyboardEvent&& event) +{ + fflush(stdout); + m_client->getWebPage()->keyEvent(WebKit::NativeWebKeyboardEvent(WTFMove(event))); +} +void ThreadedCompositor::handlePointerEvent(WPE::Input::PointerEvent&& event) +{ + fflush(stdout); + m_client->getWebPage()->mouseEvent(WebKit::NativeWebMouseEvent(WTFMove(event))); +} + +void ThreadedCompositor::handleAxisEvent(WPE::Input::AxisEvent&& event) +{ +} + +void ThreadedCompositor::handleTouchEvent(WPE::Input::TouchEvent&& event) +{ +} +#endif +//KEYBOARD SUPPORT + } #endif // USE(COORDINATED_GRAPHICS_THREADED) diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h index b2673c7587abf..e72a0fe782fac 100644 --- a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h +++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h @@ -45,6 +45,20 @@ #include #endif +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +#include +//KEYBOARD SUPPORT +#include +#include "WebPage.h" +//KEYBOARD SUPPORT +#endif + + + +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +#include +#endif + namespace WebCore { struct CoordinatedGraphicsState; } @@ -55,7 +69,13 @@ class CoordinatedGraphicsScene; class CoordinatedGraphicsSceneClient; class WebPage; +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +class ThreadedCompositor : public ThreadSafeRefCounted, public SimpleViewportController::Client, public CoordinatedGraphicsSceneClient, public CompositingManager::Client, public WPE::Input::Client { +#else class ThreadedCompositor : public ThreadSafeRefCounted, public SimpleViewportController::Client, public CoordinatedGraphicsSceneClient, public CompositingManager::Client { +#endif +//KEYBOARD SUPPORT WTF_MAKE_NONCOPYABLE(ThreadedCompositor); WTF_MAKE_FAST_ALLOCATED; public: @@ -65,6 +85,11 @@ class ThreadedCompositor : public ThreadSafeRefCounted, publ virtual void purgeBackingStores() = 0; virtual void renderNextFrame() = 0; virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0; +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + virtual WebPage* getWebPage() = 0; +#endif +//KEYBOARD SUPPORT }; static Ref create(Client*, WebPage&); @@ -84,7 +109,17 @@ class ThreadedCompositor : public ThreadSafeRefCounted, publ void scrollBy(const WebCore::IntSize&); RefPtr createDisplayRefreshMonitor(PlatformDisplayID); +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + void requestFrame(); + void didFrameComplete(); +//KEYBOARD SUPPORT + void handleKeyboardEvent(WPE::Input::KeyboardEvent&&) override; + void handlePointerEvent(WPE::Input::PointerEvent&& event) override; + void handleAxisEvent(WPE::Input::AxisEvent&& event) override; + void handleTouchEvent(WPE::Input::TouchEvent&& event) override; +//KEYBOARD SUPPORT +#endif private: ThreadedCompositor(Client*, WebPage&); @@ -117,7 +152,11 @@ class ThreadedCompositor : public ThreadSafeRefCounted, publ std::unique_ptr m_viewportController; #if PLATFORM(WPE) +#if PLATFORM(WAYLAND) + std::unique_ptr m_surface; +#else std::unique_ptr m_surface; +#endif #endif std::unique_ptr m_context; @@ -186,6 +225,11 @@ class ThreadedCompositor : public ThreadSafeRefCounted, publ Atomic m_clientRendersNextFrame; Atomic m_coordinateUpdateCompletionWithClient; +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + WebPage& webpage; +#endif +//KEYBOARD SUPPORT }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp index 05767d2a121a4..6ba1b59e2b9fd 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp @@ -47,6 +47,10 @@ #include #include +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +#include "NativeWebKeyboardEvent.h" +#endif + using namespace WebCore; namespace WebKit { @@ -285,6 +289,15 @@ void ThreadedCoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, cons m_coordinator->commitScrollOffset(layerID, offset); } +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) +WebPage* ThreadedCoordinatedLayerTreeHost::getWebPage() +{ + return m_webPage; +} +#endif +//KEYBOARD SUPPORT + void ThreadedCoordinatedLayerTreeHost::notifyFlushRequired() { scheduleLayerFlush(); diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h index 82298a5ddfce8..26c7e123bad3d 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h @@ -121,6 +121,12 @@ class ThreadedCoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::C void renderNextFrame() override; void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override; +//KEYBOARD SUPPORT +#if PLATFORM(WPE) && PLATFORM(WAYLAND) + virtual WebPage* getWebPage(); +#endif +//KEYBOARD SUPPORT + // CompositingCoordinator::Client void didFlushRootLayer(const WebCore::FloatRect&) override { } void notifyFlushRequired() override; diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 65d16bf80f6d3..671d100507161 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -2148,7 +2148,12 @@ void WebPage::mouseEvent(const WebMouseEvent& mouseEvent) #endif if (!shouldHandleEvent) { +//MOUSE SUPPORT +#if !(PLATFORM(WPE) && PLATFORM(WAYLAND)) send(Messages::WebPageProxy::DidReceiveEvent(static_cast(mouseEvent.type()), false)); +#endif +//MOUSE SUPPORT + return; } @@ -2172,8 +2177,11 @@ void WebPage::mouseEvent(const WebMouseEvent& mouseEvent) bool onlyUpdateScrollbars = !(m_page->focusController().isActive() || (mouseEvent.button() != WebMouseEvent::NoButton)); handled = handleMouseEvent(mouseEvent, this, onlyUpdateScrollbars); } - +//MOUSE SUPPORT +#if !(PLATFORM(WPE) && PLATFORM(WAYLAND)) send(Messages::WebPageProxy::DidReceiveEvent(static_cast(mouseEvent.type()), handled)); +#endif +//MOUSE SUPPORT } static bool handleWheelEvent(const WebWheelEvent& wheelEvent, Page* page) @@ -2218,7 +2226,11 @@ void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent) if (!handled) handled = performDefaultBehaviorForKeyEvent(keyboardEvent); - send(Messages::WebPageProxy::DidReceiveEvent(static_cast(keyboardEvent.type()), handled)); +//KEYBOARD SUPPORT +#if !(PLATFORM(WPE) && PLATFORM(WAYLAND)) + send(Messages::WebPageProxy::DidReceiveEvent(static_cast(keyboardEvent.type()), handled)); +#endif +//KEYBOARD SUPPORT } void WebPage::validateCommand(const String& commandName, uint64_t callbackID) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index bede7936cb9ba..99fd7ec9c8ce2 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -939,6 +939,13 @@ class WebPage : public API::ObjectImpl, public IP void insertNewlineInQuotedContent(); +//KEYBOARD SUPPORT +#if (PLATFORM(WPE) && PLATFORM(WAYLAND)) + void keyEvent(const WebKeyboardEvent&); + void mouseEvent(const WebMouseEvent&); +#endif +//KEYBOARD SUPPORT + #if USE(OS_STATE) std::chrono::system_clock::time_point loadCommitTime() const { return m_loadCommitTime; } #endif @@ -1018,8 +1025,13 @@ class WebPage : public API::ObjectImpl, public IP void updateUserActivity(); +//KEYBOARD SUPPORT +#if !(PLATFORM(WPE) && PLATFORM(WAYLAND)) void mouseEvent(const WebMouseEvent&); void keyEvent(const WebKeyboardEvent&); +#endif +//KEYBOARD SUPPORT + #if ENABLE(IOS_TOUCH_EVENTS) void touchEventSync(const WebTouchEvent&, bool& handled); #elif ENABLE(TOUCH_EVENTS) diff --git a/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.cpp b/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.cpp index ccfb50c43313a..c8bd7df673c1f 100644 --- a/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.cpp +++ b/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.cpp @@ -63,27 +63,41 @@ Vector CompositingManager::authenticate() uint32_t CompositingManager::constructRenderingTarget(uint32_t width, uint32_t height) { +#if PLATFORM(WAYLAND) + return 0; +#else uint32_t handle = 0; m_connection->sendSync(Messages::CompositingManagerProxy::ConstructRenderingTarget(width, height), Messages::CompositingManagerProxy::ConstructRenderingTarget::Reply(handle), 0); return handle; +#endif } +#if PLATFORM(WAYLAND) +void CompositingManager::commitBuffer(const WPE::Graphics::RenderingBackend::BufferExport& bufferExport) +{ +} +#else void CompositingManager::commitBuffer(const WebCore::PlatformDisplayWPE::BufferExport& bufferExport) { m_connection->send(Messages::CompositingManagerProxy::CommitBuffer( IPC::Attachment(std::get<0>(bufferExport)), IPC::DataReference(std::get<1>(bufferExport), std::get<2>(bufferExport))), 0); } +#endif void CompositingManager::destroyBuffer(uint32_t handle) { +#if !PLATFORM(WAYLAND) m_connection->send(Messages::CompositingManagerProxy::DestroyBuffer(handle), 0); +#endif } void CompositingManager::releaseBuffer(uint32_t handle) { +#if !PLATFORM(WAYLAND) m_client.releaseBuffer(handle); +#endif } void CompositingManager::frameComplete() diff --git a/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.h b/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.h deleted file mode 100644 index 667fdf042e408..0000000000000 --- a/Source/WebKit2/WebProcess/WebPage/wpe/CompositingManager.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2015 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. 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 CompositingManager_h -#define CompositingManager_h - -#include "Connection.h" -#include "MessageReceiver.h" -#include - -namespace WebKit { - -class WebPage; - -class CompositingManager final : public IPC::Connection::Client, public WebCore::PlatformDisplayWPE::Surface::Client { - WTF_MAKE_FAST_ALLOCATED; -public: - class Client { - public: - virtual void releaseBuffer(uint32_t) = 0; - virtual void frameComplete() = 0; - }; - - CompositingManager(Client&); - virtual ~CompositingManager(); - - void establishConnection(WebPage&, WTF::RunLoop&); - - Vector authenticate(); - uint32_t constructRenderingTarget(uint32_t, uint32_t); - void commitBuffer(const WebCore::PlatformDisplayWPE::BufferExport&); - - CompositingManager(const CompositingManager&) = delete; - CompositingManager& operator=(const CompositingManager&) = delete; - CompositingManager(CompositingManager&&) = delete; - CompositingManager& operator=(CompositingManager&&) = delete; - -private: - // IPC::MessageReceiver - virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override; - - // IPC::Connection::Client - void didClose(IPC::Connection&) override { } - void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference) override { } - IPC::ProcessType localProcessType() override { return IPC::ProcessType::Web; } - IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::UI; } - - // PlatformDisplayWPE::Surface::Client - void destroyBuffer(uint32_t) override; - - void releaseBuffer(uint32_t); - void frameComplete(); - - Client& m_client; - - RefPtr m_connection; -}; - -} // namespace WebKit - -#endif // CompositingManager diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake index 3002a17649cbb..aa605ff7b8aa1 100644 --- a/Source/cmake/OptionsWPE.cmake +++ b/Source/cmake/OptionsWPE.cmake @@ -2,7 +2,7 @@ include(GNUInstallDirs) set(PROJECT_VERSION_MAJOR 0) set(PROJECT_VERSION_MINOR 0) -set(PROJECT_VERSION_PATCH 20160331) +set(PROJECT_VERSION_PATCH 20160512) set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) set(WPE_API_VERSION 0.1) @@ -15,12 +15,16 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_GRID_LAYOUT PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_IMAGE_SET PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_REGIONS PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_SELECTORS_LEVEL4 PUBLIC ON) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATABASE_PROCESS PRIVATE ON) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DEVICE_ORIENTATION PUBLIC OFF) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA PUBLIC OFF) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA_V2 PUBLIC OFF) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION PUBLIC OFF) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE PRIVATE ON) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE_IN_WORKERS PRIVATE OFF) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CONTROLS_SCRIPT PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API PRIVATE OFF) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME PUBLIC ON) -WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TEMPLATE_ELEMENT PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_THREADED_COMPOSITOR PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO PUBLIC ON) @@ -40,6 +44,7 @@ WEBKIT_OPTION_DEFINE(USE_WPE_BACKEND_DRM_TEGRA "Whether to enable support for th WEBKIT_OPTION_DEFINE(USE_WPE_BACKEND_WAYLAND "Whether to enable support for the Wayland WPE backend" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WPE_BACKEND_WESTEROS "Whether to enable support for the Westeros WPE backend" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WESTEROS_SINK "Westeros-Sink to be used as video-sink for GStreamer video player" PUBLIC OFF) +WEBKIT_OPTION_DEFINE(USE_FUSION_SINK "Fusion-Sink to be used as video-sink for GStreamer video player" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WPE_BUFFER_MANAGEMENT_GBM "Whether to enable support for the GBM WPE rendering backend" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WPE_BUFFER_MANAGEMENT_BCM_RPI "Whether to enable support for the BCM RPi rendering backend" PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WPE_BUFFER_MANAGEMENT_BCM_NEXUS "Whether to enable support for the BCM_NEXUS rendering backend" PUBLIC OFF) @@ -95,6 +100,11 @@ if (USE_WPE_BACKEND_BCM_RPI) find_package(BCMHost REQUIRED) endif () +if (USE_WPE_BACKEND_STM) +find_package(Wayland REQUIRED) +find_package(WaylandEGL REQUIRED) +endif(USE_WPE_BACKEND_STM) + if (USE_WPE_BACKEND_WESTEROS) find_package(Wayland REQUIRED) find_package(WaylandEGL REQUIRED) diff --git a/Source/cmake/WebKitFeatures.cmake b/Source/cmake/WebKitFeatures.cmake deleted file mode 100644 index ea7c25722b2b9..0000000000000 --- a/Source/cmake/WebKitFeatures.cmake +++ /dev/null @@ -1,358 +0,0 @@ -set(_WEBKIT_AVAILABLE_OPTIONS "") - -set(PUBLIC YES) -set(PRIVATE NO) - -macro(_ENSURE_OPTION_MODIFICATION_IS_ALLOWED) - if (NOT _SETTING_WEBKIT_OPTIONS) - message(FATAL_ERROR "Options must be set between WEBKIT_OPTION_BEGIN and WEBKIT_OPTION_END") - endif () -endmacro() - -macro(_ENSURE_IS_WEBKIT_OPTION _name) - list(FIND _WEBKIT_AVAILABLE_OPTIONS ${_name} ${_name}_OPTION_INDEX) - if (${_name}_OPTION_INDEX EQUAL -1) - message(FATAL_ERROR "${_name} is not a valid WebKit option") - endif () -endmacro() - -macro(WEBKIT_OPTION_DEFINE _name _description _public _initial_value) - _ENSURE_OPTION_MODIFICATION_IS_ALLOWED() - - set(_WEBKIT_AVAILABLE_OPTIONS_DESCRIPTION_${_name} ${_description}) - set(_WEBKIT_AVAILABLE_OPTIONS_IS_PUBLIC_${_name} ${_public}) - set(_WEBKIT_AVAILABLE_OPTIONS_INITIAL_VALUE_${_name} ${_initial_value}) - set(_WEBKIT_AVAILABLE_OPTIONS_${_name}_CONFLICTS "") - set(_WEBKIT_AVAILABLE_OPTIONS_${_name}_DEPENDENCIES "") - list(APPEND _WEBKIT_AVAILABLE_OPTIONS ${_name}) - - EXPOSE_VARIABLE_TO_BUILD(${_name}) -endmacro() - -macro(WEBKIT_OPTION_DEFAULT_PORT_VALUE _name _public _value) - _ENSURE_OPTION_MODIFICATION_IS_ALLOWED() - _ENSURE_IS_WEBKIT_OPTION(${_name}) - - set(_WEBKIT_AVAILABLE_OPTIONS_IS_PUBLIC_${_name} ${_public}) - set(_WEBKIT_AVAILABLE_OPTIONS_INITIAL_VALUE_${_name} ${_value}) -endmacro() - -macro(WEBKIT_OPTION_CONFLICT _name _conflict) - _ENSURE_OPTION_MODIFICATION_IS_ALLOWED() - _ENSURE_IS_WEBKIT_OPTION(${_name}) - _ENSURE_IS_WEBKIT_OPTION(${_conflict}) - - list(APPEND _WEBKIT_AVAILABLE_OPTIONS_${_name}_CONFLICTS ${_conflict}) -endmacro() - -macro(WEBKIT_OPTION_DEPEND _name _depend) - _ENSURE_OPTION_MODIFICATION_IS_ALLOWED() - _ENSURE_IS_WEBKIT_OPTION(${_name}) - _ENSURE_IS_WEBKIT_OPTION(${_depend}) - - list(APPEND _WEBKIT_AVAILABLE_OPTIONS_${_name}_DEPENDENCIES ${_depend}) -endmacro() - -macro(WEBKIT_OPTION_BEGIN) - set(_SETTING_WEBKIT_OPTIONS TRUE) - - WEBKIT_OPTION_DEFINE(ENABLE_3D_TRANSFORMS "Toggle 3D transforms support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ACCELERATED_2D_CANVAS "Toggle accelerated 2D canvas support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ACCELERATED_OVERFLOW_SCROLLING "Toggle accelerated scrolling support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ACCESSIBILITY "Toggle accessibility support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ALLINONE_BUILD "Toggle all-in-one build" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_API_TESTS "Enable public API unit tests" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ASYNC_SCROLLING "Enable asynchronouse scrolling" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ATTACHMENT_ELEMENT "Toggle attachment element support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_AVF_CAPTIONS "Toggle AVFoundation caption support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ASSEMBLER_WX_EXCLUSIVE "Toggle Assembler WX Exclusive support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_BATTERY_STATUS "Toggle battery status API support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CACHE_PARTITIONING "Toggle cache partitioning support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CANVAS_PATH "Toggle Canvas Path support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_CANVAS_PROXY "Toggle CanvasProxy support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CHANNEL_MESSAGING "Toggle MessageChannel and MessagePort support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_CONTENT_FILTERING "Toggle content filtering support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CONTEXT_MENUS "Toggle Context Menu support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_CREDENTIAL_STORAGE "Toggle Credential Storage support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSP_NEXT "Toggle Content Security Policy 1.1 support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS3_TEXT "Toggle CSS3 Text support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS3_TEXT_LINE_BREAK "Toggle CSS3 Text Line Break support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_BOX_DECORATION_BREAK "Toggle Box Decoration break (CSS Backgrounds and Borders) support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_COMPOSITING "Toggle CSS COMPOSITING support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_DEVICE_ADAPTATION "Toggle CSS Device Adaptation support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_GRID_LAYOUT "Toggle CSS Grid Layout support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_IMAGE_ORIENTATION "Toggle CSS image-orientation support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_IMAGE_RESOLUTION "Toggle CSS image-resolution support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_IMAGE_SET "Toggle CSS image-set support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_REGIONS "Toggle CSS regions support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_SCROLL_SNAP "Toggle CSS snap scroll support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_SELECTORS_LEVEL4 "Toggle CSS Selectors Level 4 support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CSS_SHAPES "Toggle CSS Shapes support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CURSOR_VISIBILITY "Toggle cursor visibility support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CUSTOM_ELEMENTS "Toggle custom elements support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_CUSTOM_SCHEME_HANDLER "Toggle Custom Scheme Handler support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DASHBOARD_SUPPORT "Toggle dashboard support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DATABASE_PROCESS "Toggle database process support in WebKit2" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DATACUE_VALUE "Toggle datacue value support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DATALIST_ELEMENT "Toggle HTML5 datalist support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DATA_TRANSFER_ITEMS "Toggle HTML5 data transfer items support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DETAILS_ELEMENT "Toggle HTML5 details support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_DEVICE_ORIENTATION "Toggle DeviceOrientation support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DFG_JIT "Toggle data flow graph JIT tier" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_DOM4_EVENTS_CONSTRUCTOR "Toggle DOM4 Events constructors" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DOWNLOAD_ATTRIBUTE "Toggle download attribute support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_DRAG_SUPPORT "Toggle Drag Support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ENCRYPTED_MEDIA "Toggle EME support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ENCRYPTED_MEDIA_V2 "Support EME v2" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ES6_ARROWFUNCTION_SYNTAX "Toggle ES6 arrow function syntax support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_ES6_CLASS_SYNTAX "Toggle ES6 class syntax support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_ES6_GENERATORS "Toggle ES6 generators support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_ES6_MODULES "Toggle ES6 modules support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_FETCH_API "Toggle Fetch API support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_FILTERS_LEVEL_2 "Toggle Filters Module Level 2" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_FONT_LOAD_EVENTS "Toggle Font Load Events support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_FTPDIR "Toggle FTP directory support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_FTL_JIT "Toggle FTL support for JSC" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_FULLSCREEN_API "Toggle Fullscreen API support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_GAMEPAD "Toggle Gamepad support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_GAMEPAD_DEPRECATED "Toggle deprecated Gamepad support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_GEOLOCATION "Toggle Geolocation support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ICONDATABASE "Toggle Icon database support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_IMAGE_DECODER_DOWN_SAMPLING "Toggle image decoder down sampling support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INDEXED_DATABASE "Toggle Indexed Database API support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INDEXED_DATABASE_IN_WORKERS "Toggle support for indexed database in workers" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INDIE_UI "Toggle Indie UI support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INPUT_TYPE_COLOR "Toggle Color Input support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INPUT_TYPE_COLOR_POPOVER "Toggle popover color input support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INPUT_TYPE_DATE "Toggle date type support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE "Toggle broken datetime type support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INPUT_TYPE_DATETIMELOCAL "Toggle datetime-local type support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INPUT_TYPE_MONTH "Toggle month type support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INPUT_TYPE_TIME "Toggle time type support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INPUT_TYPE_WEEK "Toggle week type support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_INTL "Toggle Intl support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_IOS_AIRPLAY "Toggle iOS airplay support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_IOS_TEXT_AUTOSIZING "Toggle iOS text autosizing support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_JIT "Enable JustInTime javascript support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_LEGACY_CSS_VENDOR_PREFIXES "Toggle legacy css vendor prefix support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_LEGACY_NOTIFICATIONS "Toggle Legacy Desktop Notifications Support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_LEGACY_VENDOR_PREFIXES "Toggle Legacy Vendor Prefix Support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_LEGACY_WEB_AUDIO "Toggle Legacy Web Audio support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_LETTERPRESS "Toggle letterpress support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_LINK_PREFETCH "Toggle pre fetching support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MAC_LONG_PRESS "Toggle mac long press support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MATHML "Toggle MathML support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_MEDIA_CAPTURE "Toggle Media Capture support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MEDIA_CONTROLS_SCRIPT "Toggle definition of media controls in Javascript" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MEDIA_SOURCE "Toggle Media Source support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MEDIA_STREAM "Toggle Media Stream support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MEDIA_STATISTICS "Toggle Media Statistics support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MEMORY_SAMPLER "Toggle Memory Sampler support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_METER_ELEMENT "Toggle Meter Tag support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_MHTML "Toggle MHTML support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MINIBROWSER "Whether to enable MiniBrowser compilation." PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_MOUSE_CURSOR_SCALE "Toggle Scaled mouse cursor support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_NAVIGATOR_CONTENT_UTILS "Toggle Navigator Content Utils support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_NAVIGATOR_HWCONCURRENCY "Toggle Navigator hardware concurrency support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_NOSNIFF "Toggle support for 'X-Content-Type-Options: nosniff'" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_NETSCAPE_PLUGIN_API "Toggle Netscape Plugin support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_NOTIFICATIONS "Toggle Desktop Notifications Support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_ORIENTATION_EVENTS "Toggle Orientation Events support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_PDFKIT_PLUGIN "Toggle PDFKit plugin support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_PERFORMANCE_TIMELINE "Toggle Performance Timeline support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_POINTER_LOCK "Toggle pointer lock support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_PROXIMITY_EVENTS "Toggle Proximity Events support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_PUBLIC_SUFFIX_LIST "Toggle public suffix list support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_QUOTA "Toggle Quota support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_REMOTE_INSPECTOR "Toggle remote inspector support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_REQUEST_ANIMATION_FRAME "Toggle requestAnimationFrame support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_RESOLUTION_MEDIA_QUERY "Toggle resolution media query support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_RESOURCE_TIMING "Toggle Resource Timing support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_RESOURCE_USAGE "Toggle resource usage support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_RUBBER_BANDING "Toggle rubber banding support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_SAMPLING_PROFILER "Toggle sampling profiler support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_SECCOMP_FILTERS "Toggle Linux seccomp filters for the WebProcess support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_SERVICE_CONTROLS "Toggle service controls support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_SHADOW_DOM "Toggle shadow dom" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_SMOOTH_SCROLLING "Toggle smooth scrolling" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_SPEECH_SYNTHESIS "Toggle Speech Synthesis API support)" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_SPELLCHECK "Toggle Spellchecking support (requires Enchant)" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_STREAMS_API "Toggle Streams API support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_SUBTLE_CRYPTO "Toggle subtle crypto support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_SVG_FONTS "Toggle SVG fonts support (imples SVG support)" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_TELEPHONE_NUMBER_DETECTION "Toggle telephone number detection support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_TEMPLATE_ELEMENT "Toggle Template support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_TEXT_AUTOSIZING "Toggle Text auto sizing support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_THREADED_COMPOSITOR "Toggle threaded compositor support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_TOUCH_EVENTS "Toggle Touch Events support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_TOUCH_SLIDER "Toggle Touch Slider support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_TOUCH_ICON_LOADING "Toggle Touch Icon Loading Support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_USERSELECT_ALL "Toggle user-select:all support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_USER_MESSAGE_HANDLERS "Toggle user script message handler support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_USER_TIMING "Toggle User Timing support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_VIBRATION "Toggle Vibration API support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_VIDEO "Toggle Video support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_VIDEO_TRACK "Toggle Track support for HTML5 video" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_VIEW_MODE_CSS_MEDIA "Toggle Track support for the view-mode media Feature" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_WEBASSEMBLY "Toggle WebAssembly support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_WEBGL "Toggle 3D canvas (WebGL) support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_WEBVTT_REGIONS "Toggle webvtt region support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_WEB_ANIMATIONS "Toggle Web Animations support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_WEB_AUDIO "Toggle Web Audio support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_WEB_REPLAY "Toggle Web Replay support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_WEB_RTC "Toggle WebRTC API support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_WEB_SOCKETS "Toggle Web Sockets support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(ENABLE_WEB_TIMING "Toggle Web Timing support" PRIVATE OFF) - WEBKIT_OPTION_DEFINE(ENABLE_XSLT "Toggle XSLT support" PRIVATE ON) - WEBKIT_OPTION_DEFINE(USE_SYSTEM_MALLOC "Toggle system allocator instead of WebKit's custom allocator" PRIVATE OFF) - - WEBKIT_OPTION_DEPEND(ENABLE_WEB_RTC ENABLE_MEDIA_STREAM) - WEBKIT_OPTION_DEPEND(ENABLE_ENCRYPTED_MEDIA_V2 ENABLE_VIDEO) - WEBKIT_OPTION_DEPEND(ENABLE_DFG_JIT ENABLE_JIT) - WEBKIT_OPTION_DEPEND(ENABLE_FTL_JIT ENABLE_DFG_JIT) - WEBKIT_OPTION_DEPEND(ENABLE_SAMPLING_PROFILER ENABLE_JIT) - WEBKIT_OPTION_DEPEND(ENABLE_MEDIA_CONTROLS_SCRIPT ENABLE_VIDEO) - WEBKIT_OPTION_DEPEND(ENABLE_VIDEO_TRACK ENABLE_VIDEO) - WEBKIT_OPTION_DEPEND(ENABLE_TOUCH_SLIDER ENABLE_TOUCH_EVENTS) -endmacro() - -macro(_WEBKIT_OPTION_ENFORCE_DEPENDS _name) - foreach (_dependency ${_WEBKIT_AVAILABLE_OPTIONS_${_name}_DEPENDENCIES}) - if (NOT ${_dependency}) - message(STATUS "Disabling ${_name} since ${_dependency} is disabled.") - set(${_name} OFF) - set(_OPTION_CHANGED TRUE) - break () - endif () - endforeach () -endmacro() - -macro(_WEBKIT_OPTION_ENFORCE_ALL_DEPENDS) - set(_OPTION_CHANGED TRUE) - while (${_OPTION_CHANGED}) - set(_OPTION_CHANGED FALSE) - foreach (_name ${_WEBKIT_AVAILABLE_OPTIONS}) - if (${_name}) - _WEBKIT_OPTION_ENFORCE_DEPENDS(${_name}) - endif () - endforeach () - endwhile () -endmacro() - -macro(_WEBKIT_OPTION_ENFORCE_CONFLICTS _name) - foreach (_conflict ${_WEBKIT_AVAILABLE_OPTIONS_${_name}_CONFLICTS}) - if (${_conflict}) - message(FATAL_ERROR "${_name} conflicts with ${_conflict}. You must disable one or the other.") - endif () - endforeach () -endmacro() - -macro(_WEBKIT_OPTION_ENFORCE_ALL_CONFLICTS) - foreach (_name ${_WEBKIT_AVAILABLE_OPTIONS}) - if (${_name}) - _WEBKIT_OPTION_ENFORCE_CONFLICTS(${_name}) - endif () - endforeach () -endmacro() - -macro(WEBKIT_OPTION_END) - set(_SETTING_WEBKIT_OPTIONS FALSE) - - list(SORT _WEBKIT_AVAILABLE_OPTIONS) - set(_MAX_FEATURE_LENGTH 0) - foreach (_name ${_WEBKIT_AVAILABLE_OPTIONS}) - string(LENGTH ${_name} _name_length) - if (_name_length GREATER _MAX_FEATURE_LENGTH) - set(_MAX_FEATURE_LENGTH ${_name_length}) - endif () - - option(${_name} "${_WEBKIT_AVAILABLE_OPTIONS_DESCRIPTION_${_name}}" ${_WEBKIT_AVAILABLE_OPTIONS_INITIAL_VALUE_${_name}}) - if (NOT _WEBKIT_AVAILABLE_OPTIONS_IS_PUBLIC_${_name}) - mark_as_advanced(FORCE ${_name}) - endif () - endforeach () - - # Run through every possible depends to make sure we have disabled anything - # that could cause an unnecessary conflict before processing conflicts. - _WEBKIT_OPTION_ENFORCE_ALL_DEPENDS() - _WEBKIT_OPTION_ENFORCE_ALL_CONFLICTS() - - foreach (_name ${_WEBKIT_AVAILABLE_OPTIONS}) - if (${_name}) - list(APPEND FEATURE_DEFINES ${_name}) - set(FEATURE_DEFINES_WITH_SPACE_SEPARATOR "${FEATURE_DEFINES_WITH_SPACE_SEPARATOR} ${_name}") - endif () - endforeach () -endmacro() - -macro(PRINT_WEBKIT_OPTIONS) - message(STATUS "Enabled features:") - - set(_should_print_dots ON) - foreach (_name ${_WEBKIT_AVAILABLE_OPTIONS}) - if (${_WEBKIT_AVAILABLE_OPTIONS_IS_PUBLIC_${_name}}) - string(LENGTH ${_name} _name_length) - set(_message " ${_name} ") - - # Print dots on every other row, for readability. - foreach (IGNORE RANGE ${_name_length} ${_MAX_FEATURE_LENGTH}) - if (${_should_print_dots}) - set(_message "${_message}.") - else () - set(_message "${_message} ") - endif () - endforeach () - - set(_should_print_dots (NOT ${_should_print_dots})) - - set(_message "${_message} ${${_name}}") - message(STATUS "${_message}") - endif () - endforeach () -endmacro() - -set(_WEBKIT_CONFIG_FILE_VARIABLES "") - -macro(EXPOSE_VARIABLE_TO_BUILD _variable_name) - list(APPEND _WEBKIT_CONFIG_FILE_VARIABLES ${_variable_name}) -endmacro() - -macro(SET_AND_EXPOSE_TO_BUILD _variable_name) - # It's important to handle the case where the value isn't passed, because often - # during configuration an empty variable is the result of a failed package search. - if (${ARGC} GREATER 1) - set(_variable_value ${ARGV1}) - else () - set(_variable_value OFF) - endif () - - set(${_variable_name} ${_variable_value}) - EXPOSE_VARIABLE_TO_BUILD(${_variable_name}) -endmacro() - -macro(_ADD_CONFIGURATION_LINE_TO_HEADER_STRING _string _variable_name _output_variable_name) - if (${${_variable_name}}) - set(${_string} "${_file_contents}#define ${_output_variable_name} 1\n") - else () - set(${_string} "${_file_contents}#define ${_output_variable_name} 0\n") - endif () -endmacro() - -macro(CREATE_CONFIGURATION_HEADER) - list(SORT _WEBKIT_CONFIG_FILE_VARIABLES) - set(_file_contents "#ifndef CMAKECONFIG_H\n") - set(_file_contents "${_file_contents}#define CMAKECONFIG_H\n\n") - - foreach (_variable_name ${_WEBKIT_CONFIG_FILE_VARIABLES}) - _ADD_CONFIGURATION_LINE_TO_HEADER_STRING(_file_contents ${_variable_name} ${_variable_name}) - endforeach () - set(_file_contents "${_file_contents}\n#endif /* CMAKECONFIG_H */\n") - - file(WRITE "${CMAKE_BINARY_DIR}/cmakeconfig.h.tmp" "${_file_contents}") - execute_process(COMMAND ${CMAKE_COMMAND} - -E copy_if_different - "${CMAKE_BINARY_DIR}/cmakeconfig.h.tmp" - "${CMAKE_BINARY_DIR}/cmakeconfig.h" - ) - file(REMOVE "${CMAKE_BINARY_DIR}/cmakeconfig.h.tmp") -endmacro()