summaryrefslogtreecommitdiffstats
path: root/meta-uhmi/meta-rvgpu/recipes-graphics/remote-virtio-gpu/remote-virtio-gpu/0002-Add-agl-shell-desktop-and-xdg-shell-support.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-uhmi/meta-rvgpu/recipes-graphics/remote-virtio-gpu/remote-virtio-gpu/0002-Add-agl-shell-desktop-and-xdg-shell-support.patch')
-rw-r--r--meta-uhmi/meta-rvgpu/recipes-graphics/remote-virtio-gpu/remote-virtio-gpu/0002-Add-agl-shell-desktop-and-xdg-shell-support.patch482
1 files changed, 0 insertions, 482 deletions
diff --git a/meta-uhmi/meta-rvgpu/recipes-graphics/remote-virtio-gpu/remote-virtio-gpu/0002-Add-agl-shell-desktop-and-xdg-shell-support.patch b/meta-uhmi/meta-rvgpu/recipes-graphics/remote-virtio-gpu/remote-virtio-gpu/0002-Add-agl-shell-desktop-and-xdg-shell-support.patch
deleted file mode 100644
index db5a6922..00000000
--- a/meta-uhmi/meta-rvgpu/recipes-graphics/remote-virtio-gpu/remote-virtio-gpu/0002-Add-agl-shell-desktop-and-xdg-shell-support.patch
+++ /dev/null
@@ -1,482 +0,0 @@
-From b60e0a361d29723643fe81b47bff8f86d5200258 Mon Sep 17 00:00:00 2001
-From: Kenta <murakami.kenta002@jp.panasonic.com>
-Date: Wed, 6 Sep 2023 18:44:22 +0900
-Subject: [PATCH] Add agl-shell-desktop and xdg-shell supports
-
----
- CMakeLists.txt | 25 +++
- include/rvgpu-renderer/renderer/rvgpu-egl.h | 9 +-
- src/rvgpu-renderer/CMakeLists.txt | 3 +
- src/rvgpu-renderer/backend/rvgpu-gbm.c | 2 +
- src/rvgpu-renderer/backend/rvgpu-wayland.c | 192 +++++++++++++++++---
- src/rvgpu-renderer/renderer/rvgpu-egl.c | 3 +
- src/rvgpu-renderer/rvgpu-renderer.c | 11 +-
- 7 files changed, 220 insertions(+), 25 deletions(-)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index f569ca2..85c875a 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -20,6 +20,31 @@ cmake_minimum_required(VERSION 3.2)
- project(rvgpu C)
- set(CMAKE_C_STANDARD 11)
-
-+find_program(WAYLAND_SCANNER_EXECUTABLE wayland-scanner)
-+
-+message("generating agl-shell-desktop client files from: agl-shell-desktop.xml")
-+
-+execute_process ( COMMAND mkdir ${CMAKE_BINARY_DIR}/protocol)
-+
-+execute_process ( COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code
-+ ${CMAKE_SYSROOT}/usr/share/agl-compositor/protocols/agl-shell-desktop.xml
-+ ${CMAKE_BINARY_DIR}/protocol/agl-shell-desktop-protocol.c)
-+
-+execute_process ( COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
-+ ${CMAKE_SYSROOT}/usr/share/agl-compositor/protocols/agl-shell-desktop.xml
-+ ${CMAKE_BINARY_DIR}/protocol/agl-shell-desktop-protocol.h)
-+
-+message("generating agl-shell-desktop client files from: xdg-shell.xml")
-+
-+execute_process ( COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code
-+ ${CMAKE_SYSROOT}/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml
-+ ${CMAKE_BINARY_DIR}/protocol/xdg-shell-protocol.c)
-+
-+execute_process ( COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
-+ ${CMAKE_SYSROOT}/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml
-+ ${CMAKE_BINARY_DIR}/protocol/xdg-shell-protocol.h)
-+
-+
- if (CMAKE_SYSROOT AND NOT ENV{PKG_CONFIG_LIBDIR})
- set(ENV{PKG_CONFIG_DIR} "")
- set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig")
-diff --git a/include/rvgpu-renderer/renderer/rvgpu-egl.h b/include/rvgpu-renderer/renderer/rvgpu-egl.h
-index ebd2bd2..dcff36a 100644
---- a/include/rvgpu-renderer/renderer/rvgpu-egl.h
-+++ b/include/rvgpu-renderer/renderer/rvgpu-egl.h
-@@ -59,6 +59,9 @@ struct rvgpu_scanout_params {
- uint32_t id; /**< ID for scanout window (i.e. IVI id)*/
- bool enabled; /**< enable/disable scanout */
- bool boxed; /**< box is set by user */
-+ struct rvgpu_box agl_win; /** Window position & limit on AGL */
-+ bool agl_win_set;
-+
- };
-
- struct rvgpu_scanout {
-@@ -118,6 +121,8 @@ struct rvgpu_egl_state {
- bool spawn_support;
-
- bool use_scissors;
-+
-+ bool user_specified_scanouts;
- };
-
- /** Initialize main context */
-@@ -150,11 +155,11 @@ void rvgpu_egl_destroy_scanout(struct rvgpu_egl_state *e,
-
- /** Draw Virgl output on the surface */
- void rvgpu_egl_draw(struct rvgpu_egl_state *e, struct rvgpu_scanout *s,
-- bool vsync);
-+ bool vsync);
-
- /** Redraw all scanouts with given resource id */
- void rvgpu_egl_drawall(struct rvgpu_egl_state *e, unsigned int res_id,
-- bool vsync);
-+ bool vsync);
-
- /* Async event handling */
- /** Call before polling */
-diff --git a/src/rvgpu-renderer/CMakeLists.txt b/src/rvgpu-renderer/CMakeLists.txt
-index dc5f5b0..c8a8c34 100644
---- a/src/rvgpu-renderer/CMakeLists.txt
-+++ b/src/rvgpu-renderer/CMakeLists.txt
-@@ -17,6 +17,8 @@
-
-
- add_executable(rvgpu-renderer
-+ ${CMAKE_BINARY_DIR}/protocol/agl-shell-desktop-protocol.c
-+ ${CMAKE_BINARY_DIR}/protocol/xdg-shell-protocol.c
- backend/rvgpu-wayland.c
- backend/rvgpu-gbm.c
- renderer/rvgpu-egl.c
-@@ -28,6 +30,7 @@ add_executable(rvgpu-renderer
- target_include_directories(rvgpu-renderer
- PRIVATE
- ${PROJECT_SOURCE_DIR}/include
-+ ${CMAKE_BINARY_DIR}/protocol
- ${extlibs_INCLUDE_DIRS}
- )
- target_compile_definitions(rvgpu-renderer PRIVATE _GNU_SOURCE)
-diff --git a/src/rvgpu-renderer/backend/rvgpu-gbm.c b/src/rvgpu-renderer/backend/rvgpu-gbm.c
-index 4194b0d..b2b3ed3 100644
---- a/src/rvgpu-renderer/backend/rvgpu-gbm.c
-+++ b/src/rvgpu-renderer/backend/rvgpu-gbm.c
-@@ -259,6 +259,8 @@ static void rvgpu_gbm_create_scanout(struct rvgpu_egl_state *e,
-
- eglMakeCurrent(e->dpy, s->surface, s->surface, e->context);
- glGenFramebuffers(1, &s->fb);
-+
-+ rvgpu_egl_draw(e, s, false);
- }
-
- static void rvgpu_gbm_page_flip_handler(int fd, unsigned int sequence,
-diff --git a/src/rvgpu-renderer/backend/rvgpu-wayland.c b/src/rvgpu-renderer/backend/rvgpu-wayland.c
-index 0aaeaa7..c00ff00 100644
---- a/src/rvgpu-renderer/backend/rvgpu-wayland.c
-+++ b/src/rvgpu-renderer/backend/rvgpu-wayland.c
-@@ -39,12 +39,18 @@
- #include <rvgpu-renderer/renderer/rvgpu-egl.h>
- #include <rvgpu-renderer/renderer/rvgpu-input.h>
-
-+#include "agl-shell-desktop-protocol.h"
-+#include "xdg-shell-protocol.h"
-+
- struct rvgpu_native {
- /* Window structures */
- struct wl_surface *surface;
- struct wl_shell_surface *shell_surface;
- struct wl_egl_window *egl_window;
- struct ivi_surface *ivi_surface;
-+ struct xdg_surface *xdg_surface;
-+ struct xdg_toplevel *xdg_toplevel;
-+ bool wait_for_configure;
- };
-
- struct rvgpu_wl_state {
-@@ -58,6 +64,9 @@ struct rvgpu_wl_state {
- struct wl_keyboard *keyboard;
- struct wl_shell *shell;
- struct ivi_application *ivi_app;
-+ struct xdg_wm_base *wm_base;
-+ struct agl_shell_desktop *agl_shell_desktop;
-+ struct wl_output *output;
-
- /* EGL structures */
- struct rvgpu_egl_state egl;
-@@ -78,6 +87,16 @@ static inline struct rvgpu_wl_state *to_wl(struct rvgpu_egl_state *e)
- return rvgpu_container_of(e, struct rvgpu_wl_state, egl);
- }
-
-+static void xdg_wm_base_ping(void *data, struct xdg_wm_base *shell,
-+ uint32_t serial)
-+{
-+ xdg_wm_base_pong(shell, serial);
-+}
-+
-+static const struct xdg_wm_base_listener xdg_wm_base_listener = {
-+ xdg_wm_base_ping,
-+};
-+
- static struct wl_seat_listener seat_listener;
-
- static void registry_add_object(void *data, struct wl_registry *registry,
-@@ -98,8 +117,17 @@ static void registry_add_object(void *data, struct wl_registry *registry,
- wl_registry_bind(registry, name, &wl_seat_interface, 1);
- wl_seat_add_listener(r->seat, &seat_listener, r);
- } else if (!strcmp(interface, "ivi_application")) {
-- r->ivi_app = wl_registry_bind(registry, name,
-- &ivi_application_interface, 1);
-+ r->ivi_app = wl_registry_bind(registry, name, &ivi_application_interface, 1);
-+ } else if (strcmp(interface, "xdg_wm_base") == 0) {
-+ r->wm_base = wl_registry_bind(registry, name,
-+ &xdg_wm_base_interface, 1);
-+ xdg_wm_base_add_listener(r->wm_base, &xdg_wm_base_listener, r);
-+ } else if (strcmp(interface, "agl_shell_desktop") == 0) {
-+ r->agl_shell_desktop = wl_registry_bind(registry, name,
-+ &agl_shell_desktop_interface, 1);
-+ } else if (strcmp(interface, "wl_output") == 0) {
-+ r->output = wl_registry_bind(registry, name,
-+ &wl_output_interface, 1);
- }
- }
-
-@@ -157,6 +185,57 @@ static const struct ivi_surface_listener ivi_surface_listener = {
- handle_ivi_surface_configure,
- };
-
-+static void handle_xdg_toplevel_configure(void *data,
-+ struct xdg_toplevel *xdg_toplevel,
-+ int32_t width, int32_t height, struct wl_array *states)
-+{
-+ (void)xdg_toplevel;
-+ struct rvgpu_scanout *s = data;
-+
-+ s->window.w = (unsigned int)width;
-+ s->window.h = (unsigned int)height;
-+
-+ wl_egl_window_resize(s->native->egl_window, width, height, 0, 0);
-+}
-+
-+static const struct xdg_toplevel_listener xdg_toplevel_listener = {
-+ handle_xdg_toplevel_configure,
-+};
-+
-+static struct config_param {
-+ struct rvgpu_egl_state *egl_state;
-+ struct rvgpu_scanout *scanout;
-+};
-+
-+static void handle_xdg_surface_configure(void *data,
-+ struct xdg_surface *surface, uint32_t serial)
-+{
-+ struct config_param *cp = data;
-+ struct rvgpu_scanout *s = cp->scanout;
-+ struct rvgpu_egl_state *egl = cp->egl_state;
-+
-+ if (surface == NULL)
-+ return;
-+
-+ xdg_surface_ack_configure(surface, serial);
-+ if (s->native->wait_for_configure) {
-+ if (egl->user_specified_scanouts){
-+ for (unsigned int i = 0; i < VIRTIO_GPU_MAX_SCANOUTS; i++) {
-+ if (egl->scanouts[i].params.enabled) {
-+ rvgpu_egl_draw(egl, &egl->scanouts[i], false);
-+ }
-+ }
-+ } else {
-+ rvgpu_egl_draw(egl, &egl->scanouts[0], false);
-+ }
-+ s->native->wait_for_configure = false;
-+ }
-+}
-+
-+static const struct xdg_surface_listener xdg_surface_listener = {
-+ handle_xdg_surface_configure,
-+};
-+
- static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
- uint32_t serial, struct wl_surface *surface,
- wl_fixed_t sx, wl_fixed_t sy)
-@@ -493,6 +572,12 @@ static void rvgpu_wl_destroy_scanout(struct rvgpu_egl_state *e,
- if (s->native->ivi_surface)
- ivi_surface_destroy(s->native->ivi_surface);
-
-+ if (s->native->xdg_toplevel)
-+ xdg_toplevel_destroy(s->native->xdg_toplevel);
-+
-+ if (s->native->xdg_surface)
-+ xdg_surface_destroy(s->native->xdg_surface);
-+
- wl_surface_destroy(s->native->surface);
- free(s->native);
- }
-@@ -510,6 +595,12 @@ static void rvgpu_wl_free(struct rvgpu_egl_state *e)
- if (r->shell)
- wl_shell_destroy(r->shell);
-
-+ if (r->wm_base)
-+ xdg_wm_base_destroy(r->wm_base);
-+
-+ if (r->agl_shell_desktop)
-+ agl_shell_desktop_destroy(r->agl_shell_desktop);
-+
- wl_seat_destroy(r->seat);
- if (r->pointer)
- wl_pointer_destroy(r->pointer);
-@@ -564,6 +655,21 @@ static void rvgpu_wl_process_events(struct rvgpu_egl_state *e, const void *ev,
- }
- }
-
-+static void create_opaque_region(struct rvgpu_egl_state *e,
-+ struct rvgpu_scanout *s)
-+{
-+ struct rvgpu_wl_state *r = to_wl(e);
-+ struct wl_region *region =
-+ wl_compositor_create_region(r->comp);
-+ assert(region);
-+ wl_region_add(region, 0, 0, (int)s->window.w,
-+ (int)s->window.h);
-+ wl_surface_set_opaque_region(s->native->surface,
-+ region);
-+ wl_region_destroy(region);
-+}
-+
-+
- static void rvgpu_wl_set_scanout(struct rvgpu_egl_state *e,
- struct rvgpu_scanout *s)
- {
-@@ -572,15 +678,9 @@ static void rvgpu_wl_set_scanout(struct rvgpu_egl_state *e,
- if (!r->fullscreen) {
- s->window = s->virgl.box;
- if (s->native) {
-- if (!r->translucent) {
-- struct wl_region *region =
-- wl_compositor_create_region(r->comp);
-- wl_region_add(region, 0, 0, (int)s->window.w,
-- (int)s->window.h);
-- wl_surface_set_opaque_region(s->native->surface,
-- region);
-- wl_region_destroy(region);
-- }
-+ if (!r->translucent)
-+ create_opaque_region(e, s);
-+
- wl_egl_window_resize(s->native->egl_window,
- (int)s->window.w, (int)s->window.h,
- 0, 0);
-@@ -629,6 +729,59 @@ static void rvgpu_wl_create_scanout(struct rvgpu_egl_state *e,
- assert(n->ivi_surface);
- ivi_surface_add_listener(n->ivi_surface, &ivi_surface_listener,
- s);
-+
-+ } else if (r->wm_base) {
-+ if (r->agl_shell_desktop){
-+ /* Default create window at the center of the AGL homescreen */
-+ unsigned int agl_x = 0;
-+ unsigned int agl_y = 215;
-+ unsigned int agl_w = 1080;
-+ unsigned int agl_h = 1500;
-+ if (sp && sp->agl_win_set) {
-+ agl_x = sp->agl_win.x;
-+ agl_y = sp->agl_win.y;
-+ }
-+
-+ /*
-+ * Because we can not resize the surface automatically, window size
-+ * have to be fit to the size of renderer box.
-+ */
-+ if (sp && sp->boxed) {
-+ agl_w = s->window.w;
-+ agl_h = s->window.h;
-+ }
-+
-+ agl_shell_desktop_set_app_property(r->agl_shell_desktop,
-+ "rvgpu-renderer",
-+ AGL_SHELL_DESKTOP_APP_ROLE_POPUP,
-+ agl_x, agl_y,
-+ 0, 0, agl_w, agl_h,
-+ r->output);
-+ }
-+
-+ n->xdg_surface =
-+ xdg_wm_base_get_xdg_surface(r->wm_base, n->surface);
-+ assert(n->xdg_surface);
-+
-+ struct config_param *cp = malloc(sizeof(*cp));
-+ assert(cp);
-+
-+ cp->egl_state = e;
-+ cp->scanout = s;
-+
-+ xdg_surface_add_listener(n->xdg_surface,
-+ &xdg_surface_listener, cp);
-+ n->xdg_toplevel = xdg_surface_get_toplevel(n->xdg_surface);
-+ assert(n->xdg_toplevel);
-+
-+ xdg_toplevel_add_listener(n->xdg_toplevel,
-+ &xdg_toplevel_listener, s);
-+
-+ xdg_toplevel_set_app_id(n->xdg_toplevel, "rvgpu-renderer");
-+ wl_surface_commit(n->surface);
-+ n->wait_for_configure = true;
-+ create_opaque_region(e, s);
-+
- } else if (r->shell) {
- char title[32];
-
-@@ -654,16 +807,9 @@ static void rvgpu_wl_create_scanout(struct rvgpu_egl_state *e,
- NULL);
- } else {
- wl_shell_surface_set_toplevel(n->shell_surface);
-- if (!r->translucent) {
-- struct wl_region *region =
-- wl_compositor_create_region(r->comp);
-- assert(region);
-- wl_region_add(region, 0, 0, (int)s->window.w,
-- (int)s->window.h);
-- wl_surface_set_opaque_region(n->surface,
-- region);
-- wl_region_destroy(region);
-- }
-+ if (!r->translucent)
-+ create_opaque_region(e, s);
-+
- }
- }
-
-@@ -677,6 +823,10 @@ static void rvgpu_wl_create_scanout(struct rvgpu_egl_state *e,
- eglMakeCurrent(e->dpy, s->surface, s->surface, e->context);
-
- glGenFramebuffers(1, &s->fb);
-+
-+ if(!r->wm_base){
-+ rvgpu_egl_draw(e, s, false);
-+ }
- }
-
- static const struct rvgpu_egl_callbacks wl_callbacks = {
-diff --git a/src/rvgpu-renderer/renderer/rvgpu-egl.c b/src/rvgpu-renderer/renderer/rvgpu-egl.c
-index a9dd398..6918843 100644
---- a/src/rvgpu-renderer/renderer/rvgpu-egl.c
-+++ b/src/rvgpu-renderer/renderer/rvgpu-egl.c
-@@ -21,6 +21,7 @@
- #include <assert.h>
- #include <err.h>
- #include <stdlib.h>
-+#include <stdio.h>
-
- #include <rvgpu-renderer/renderer/rvgpu-egl.h>
-
-@@ -146,6 +147,7 @@ void rvgpu_egl_free(struct rvgpu_egl_state *e)
- e->cb->free(e);
- }
-
-+
- void rvgpu_egl_draw(struct rvgpu_egl_state *e, struct rvgpu_scanout *s,
- bool vsync)
- {
-@@ -191,6 +193,7 @@ void rvgpu_egl_draw(struct rvgpu_egl_state *e, struct rvgpu_scanout *s,
- (int)s->window.w, (int)s->window.h,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- }
-+
- if (e->cb->draw)
- e->cb->draw(e, s, vsync);
- else
-diff --git a/src/rvgpu-renderer/rvgpu-renderer.c b/src/rvgpu-renderer/rvgpu-renderer.c
-index 3e74289..40b78d4 100644
---- a/src/rvgpu-renderer/rvgpu-renderer.c
-+++ b/src/rvgpu-renderer/rvgpu-renderer.c
-@@ -52,6 +52,7 @@ static void usage(void)
- info("\t-f\t\tRun in fullscreen mode\n");
- info("\t-p port\t\tport for listening (default: %u)\n",
- RVGPU_DEFAULT_PORT);
-+ info("\t-w\t\tSet AGL window position\n");
- info("\t-h\t\tShow this message\n");
-
- info("\nNote:\n");
-@@ -189,7 +190,7 @@ int main(int argc, char **argv)
-
- memset(sp, 0, sizeof(sp));
-
-- while ((opt = getopt(argc, argv, "afhi:c:s:S:b:B:p:g:")) != -1) {
-+ while ((opt = getopt(argc, argv, "afhi:c:s:S:b:w:B:p:g:")) != -1) {
- switch (opt) {
- case 'a':
- translucent = true;
-@@ -240,6 +241,13 @@ int main(int argc, char **argv)
- }
- cp->boxed = true;
- break;
-+ case 'w':
-+ if (sscanf(optarg, "%u,%u",
-+ &cp->agl_win.x, &cp->agl_win.y) != 2) {
-+ errx(1, "invalid AGL popup application window%s", optarg);
-+ }
-+ cp->agl_win_set = true;
-+ break;
- case 'i':
- cp->id = (uint32_t)sanity_strtonum(
- optarg, 1, UINT32_MAX, &errstr);
-@@ -300,7 +308,6 @@ int main(int argc, char **argv)
- s->params = sp[i];
- if (sp[i].enabled) {
- rvgpu_egl_create_scanout(egl, &egl->scanouts[i]);
-- rvgpu_egl_draw(egl, &egl->scanouts[i], false);
- }
- }
-
---
-2.25.1
-