0016-Allow-multiple-wayland-compositor-state-data-per-pro.patch 4.5 KB

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