blob: 34ad90cd81bb90228ea32de11a8da8ae8efe1b9f [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From bff03f92c0d8bae113e0c7234c719f8385808b38 Mon Sep 17 00:00:00 2001
2From: Jeff Wannamaker <jeff_wannamaker@cable.comcast.com>
3Date: Sat, 27 Jan 2018 12:28:31 -0500
4Subject: [PATCH 16/18] Allow multiple wayland compositor state data per
5 process
6
7When eglBindWaylandDisplayWL is called store the wl_global
8created in a list associated with the wayland display.
9This allows multiple wayland compositor instances to be
10created and used per process. This scenario is common for
11applications integrating externl process UI elements
12via embedded composition e.g. westeros
13
14Signed-off-by: Jeff Wannamaker <jeff_wannamaker@cable.comcast.com>
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 interface/khronos/common/khrn_client.c | 2 +-
18 interface/khronos/common/khrn_client.h | 11 +++++-
19 interface/khronos/ext/egl_wayland.c | 50 ++++++++++++++++++++++----
20 3 files changed, 55 insertions(+), 8 deletions(-)
21
22diff --git a/interface/khronos/common/khrn_client.c b/interface/khronos/common/khrn_client.c
23index d7e798e..60bdb63 100644
24--- a/interface/khronos/common/khrn_client.c
25+++ b/interface/khronos/common/khrn_client.c
26@@ -147,7 +147,7 @@ bool client_process_state_init(CLIENT_PROCESS_STATE_T *process)
27 {
28 if (!process->inited) {
29 #ifdef BUILD_WAYLAND
30- process->wl_global = NULL;
31+ process->wlStateMap = NULL;
32 #endif
33
34 if (!khrn_pointer_map_init(&process->contexts, 64))
35diff --git a/interface/khronos/common/khrn_client.h b/interface/khronos/common/khrn_client.h
36index 615f7b4..4fa86f7 100644
37--- a/interface/khronos/common/khrn_client.h
38+++ b/interface/khronos/common/khrn_client.h
39@@ -170,6 +170,15 @@ static INLINE CLIENT_THREAD_STATE_T *CLIENT_GET_CHECK_THREAD_STATE(void)
40 return (CLIENT_THREAD_STATE_T *)platform_tls_get_check(client_tls);
41 }
42
43+#ifdef BUILD_WAYLAND
44+typedef struct WAYLAND_STATE
45+{
46+ struct WAYLAND_STATE *next;
47+ struct wl_display *display;
48+ struct wl_global *wl_global;
49+} WAYLAND_STATE_T;
50+#endif
51+
52 /*
53 per-process state
54
55@@ -318,7 +327,7 @@ struct CLIENT_PROCESS_STATE {
56 struct wl_event_queue *wl_queue;
57
58 /* Compositor-side Wayland state */
59- struct wl_global *wl_global;
60+ WAYLAND_STATE_T *wlStateMap;
61 #endif
62 };
63
64diff --git a/interface/khronos/ext/egl_wayland.c b/interface/khronos/ext/egl_wayland.c
65index 9ef89cd..abd5ab3 100644
66--- a/interface/khronos/ext/egl_wayland.c
67+++ b/interface/khronos/ext/egl_wayland.c
68@@ -208,17 +208,38 @@ eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display)
69 {
70 CLIENT_THREAD_STATE_T *thread;
71 CLIENT_PROCESS_STATE_T *process;
72+ WAYLAND_STATE_T *stateIter;
73+ WAYLAND_STATE_T *stateNew;
74+ struct wl_global *wl_global;
75
76 if (!CLIENT_LOCK_AND_GET_STATES(dpy, &thread, &process))
77 return EGL_FALSE;
78
79- if (process->wl_global != NULL)
80+ stateIter= process->wlStateMap;
81+ while( stateIter )
82+ {
83+ if ( stateIter->display == display )
84+ goto error;
85+ stateIter= stateIter->next;
86+ }
87+
88+ wl_global = wl_global_create(display, &wl_dispmanx_interface, 1,
89+ NULL, bind_dispmanx);
90+ if (wl_global == NULL)
91 goto error;
92
93- process->wl_global = wl_global_create(display, &wl_dispmanx_interface, 1,
94- NULL, bind_dispmanx);
95- if (process->wl_global == NULL)
96+ stateNew= (WAYLAND_STATE_T*)calloc( 1, sizeof(WAYLAND_STATE_T));
97+ if (stateNew == NULL )
98+ {
99+ wl_global_destroy(wl_global);
100 goto error;
101+ }
102+
103+ stateNew->next= process->wlStateMap;
104+ stateNew->display= display;
105+ stateNew->wl_global= wl_global;
106+ process->wlStateMap= stateNew;
107+ CLIENT_UNLOCK();
108
109 return EGL_TRUE;
110
111@@ -232,12 +253,29 @@ eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display)
112 {
113 CLIENT_THREAD_STATE_T *thread;
114 CLIENT_PROCESS_STATE_T *process;
115+ WAYLAND_STATE_T *stateIter;
116+ WAYLAND_STATE_T *statePrev;
117
118 if (!CLIENT_LOCK_AND_GET_STATES(dpy, &thread, &process))
119 return EGL_FALSE;
120
121- wl_global_destroy(process->wl_global);
122- process->wl_global = NULL;
123+ statePrev= NULL;
124+ stateIter= process->wlStateMap;
125+ while( stateIter )
126+ {
127+ if ( stateIter->display == display )
128+ {
129+ wl_global_destroy(stateIter->wl_global);
130+ if ( statePrev )
131+ statePrev->next= stateIter->next;
132+ else
133+ process->wlStateMap= stateIter->next;
134+ free( stateIter );
135+ break;
136+ }
137+ statePrev= stateIter;
138+ stateIter= stateIter->next;
139+ }
140
141 CLIENT_UNLOCK();
142
143--
1442.19.1
145