[3/4]wayland-egl*: Implemented to use 'tizen_private' structure in wl_egl_window. 18/208918/4
authorJoonbum Ko <joonbum.ko@samsung.com>
Mon, 1 Jul 2019 04:48:45 +0000 (13:48 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Tue, 16 Jul 2019 09:33:26 +0000 (18:33 +0900)
 - The structure, tizen_private has tizen specific status, variables,
  callback functions.

 - Changed the usage of wl_egl_window->driver_private.
   Before : wl_egl_window->driver_private = (void *)surface pointer of each wayland backend.
   From now : wl_egl_window->driver_private = (void *)tizen_private

 - Changed tizen specific callback functions to register in tizen_private.
   ex) Before : wl_egl_window->set_window_serial_callback = callback
       From now : tizen_private->set_window_serial_callback = callback

 - This fix is to stop using wayland-egl-priv.h and
  use wayland-egl-backend.h provided by wayland.

Change-Id: I34d80f00ec444ed49c527c9d15d94e11d7bbb6cd
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl.c
src/tpl_wayland_egl_thread.c
src/wayland-egl/wayland-egl-tizen.c

index 19b06b3..1ded597 100644 (file)
@@ -3,6 +3,7 @@
 #include <wayland-client.h>
 
 #include "wayland-egl/wayland-egl-priv.h"
+#include "wayland-egl/wayland-egl-tizen-priv.h"
 
 #undef inline
 
@@ -90,6 +91,15 @@ __tpl_wayland_egl_surface_buffer_flusher_fini(tpl_surface_t *surface);
 static void
 __tpl_wayland_egl_buffer_free(tpl_wayland_egl_buffer_t *wayland_egl_buffer);
 
+static struct tizen_private *
+_get_tizen_private(struct wl_egl_window * wl_egl_window)
+{
+       if (wl_egl_window && wl_egl_window->driver_private)
+               return (struct tizen_private *)wl_egl_window->driver_private;
+
+       return NULL;
+}
+
 static TPL_INLINE tpl_wayland_egl_buffer_t *
 __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface_h surface)
 {
@@ -361,14 +371,16 @@ __tpl_wayland_egl_display_get_window_info(tpl_display_t *display,
        TPL_ASSERT(window);
 
        struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)window;
+       struct tizen_private *tizen_private = _get_tizen_private(wl_egl_window);
 
        if (format) {
                /* Wayland-egl window doesn't have native format information.
                   It is fixed from 'EGLconfig' when called eglCreateWindowSurface().
                   So we use the tpl_surface format instead. */
-               tpl_surface_t *surface = wl_egl_window->driver_private;
-               if (surface) *format = surface->format;
-               else {
+               if (tizen_private && tizen_private->data) {
+                       tpl_surface_t *surface = (tpl_surface_t *)tizen_private->data;
+                       *format = surface->format;
+               } else {
                        if (a_size == 8) *format = TBM_FORMAT_ARGB8888;
                        else if (a_size == 0) *format = TBM_FORMAT_XRGB8888;
                }
@@ -422,6 +434,9 @@ __cb_client_window_resize_callback(struct wl_egl_window *wl_egl_window,
                                                                   void *private);
 
 static void
+__cb_client_window_destroy_callback(void *private);
+
+static void
 __cb_client_window_rotate_callback(struct wl_egl_window *wl_egl_window,
                                                                   void *private);
 
@@ -504,6 +519,7 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface)
        tpl_wayland_egl_display_t *wayland_egl_display;
        tpl_wayland_egl_surface_t *wayland_egl_surface;
        struct wl_egl_window *wl_egl_window;
+       struct tizen_private *tizen_private = NULL;
        tbm_bufmgr bufmgr = NULL;
        unsigned int capability;
        int flags = TBM_BO_DEFAULT;
@@ -537,7 +553,6 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface)
        wayland_egl_surface->vblank_done = TPL_TRUE;
        wayland_egl_surface->is_activated = TPL_FALSE;
        wayland_egl_surface->current_buffer = NULL;
-       wayland_egl_surface->latest_transform = wl_egl_window->transform;
        wayland_egl_surface->set_serial_is_used = TPL_FALSE;
        wayland_egl_surface->serial = 0;
 
@@ -608,19 +623,35 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface)
                goto add_reset_cb_fail;
        }
 
+
+       if (wl_egl_window->driver_private)
+               tizen_private = _get_tizen_private(wl_egl_window);
+       else {
+               tizen_private = tizen_private_create();
+               wl_egl_window->driver_private = (void *)tizen_private;
+       }
+
+       if (!tizen_private) {
+               TPL_ERR("Failed to create tizen_private for wl_egl_window(%p)", wl_egl_window);
+               goto tizen_private_create_fail;
+       }
+
        surface->width = wl_egl_window->width;
        surface->height = wl_egl_window->height;
-       surface->rotation = wl_egl_window->rotation;
+       surface->rotation = tizen_private->rotation;
        surface->rotation_capability = TPL_FALSE;
 
-       wl_egl_window->driver_private = surface;
+       wayland_egl_surface->latest_transform = tizen_private->transform;
        wl_egl_window->resize_callback = (void *)__cb_client_window_resize_callback;
-       wl_egl_window->rotate_callback = (void *)__cb_client_window_rotate_callback;
-       wl_egl_window->get_rotation_capability = (void *)
+       wl_egl_window->destroy_window_callback = (void *)__cb_client_window_destroy_callback;
+
+       tizen_private->data = (void *)surface;
+       tizen_private->rotate_callback = (void *)__cb_client_window_rotate_callback;
+       tizen_private->get_rotation_capability = (void *)
                        __cb_client_window_get_rotation_capability;
-       wl_egl_window->set_frontbuffer_callback = (void *)
+       tizen_private->set_frontbuffer_callback = (void *)
                        __cb_client_window_set_frontbuffer_mode;
-       wl_egl_window->set_window_serial_callback = (void *)
+       tizen_private->set_window_serial_callback = (void *)
                        __cb_client_window_set_window_serial_callback;
 
        /* tdm_vblank object decide to be maintained every tpl_wayland_egl_surface
@@ -649,6 +680,7 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface)
 
        return TPL_ERROR_NONE;
 
+tizen_private_create_fail:
 create_vblank_fail:
        tbm_surface_queue_remove_reset_cb(wayland_egl_surface->tbm_queue,
                                          __cb_tbm_surface_queue_reset_callback,
@@ -688,17 +720,25 @@ __tpl_wayland_egl_surface_fini(tpl_surface_t *surface)
        if (surface->type == TPL_SURFACE_TYPE_WINDOW) {
                struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)
                                                                                          surface->native_handle;
+               struct tizen_private *tizen_private = _get_tizen_private(wl_egl_window);
                int lock_res = 0;
 
                TPL_ASSERT(wl_egl_window);
                /* TPL_ASSERT(wl_egl_window->surface); */ /* to be enabled once evas/gl patch is in place */
 
+               if (tizen_private) {
+                       tizen_private->data = NULL;
+                       tizen_private->rotate_callback = NULL;
+                       tizen_private->get_rotation_capability = NULL;
+                       tizen_private->set_frontbuffer_callback = NULL;
+                       tizen_private->set_window_serial_callback = NULL;
+                       free(tizen_private);
+                       tizen_private = NULL;
+               }
+
                wl_egl_window->driver_private = NULL;
                wl_egl_window->resize_callback = NULL;
-               wl_egl_window->rotate_callback = NULL;
-               wl_egl_window->get_rotation_capability = NULL;
-               wl_egl_window->set_frontbuffer_callback = NULL;
-               wl_egl_window->set_window_serial_callback = NULL;
+               wl_egl_window->destroy_window_callback = NULL;
 
                __tpl_wayland_egl_surface_buffer_flusher_fini(surface);
 
@@ -1185,10 +1225,13 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou
        struct wl_proxy *wl_proxy = NULL;
        struct wl_egl_window *wl_egl_window =
                (struct wl_egl_window *)surface->native_handle;
+       struct tizen_private *tizen_private = _get_tizen_private(wl_egl_window);
        tbm_surface_queue_error_e tsq_err = 0;
        int is_activated = 0;
        int lock_res = 0;
 
+       TPL_ASSERT(tizen_private);
+
        if (sync_fence)
                *sync_fence = -1;
 
@@ -1281,16 +1324,16 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou
                wayland_egl_buffer->width = wl_egl_window->width;
                wayland_egl_buffer->height = wl_egl_window->height;
 
-               if (wayland_egl_buffer->window_transform != wl_egl_window->window_transform) {
-                       wayland_egl_buffer->window_transform = wl_egl_window->window_transform;
+               if (wayland_egl_buffer->window_transform != tizen_private->window_transform) {
+                       wayland_egl_buffer->window_transform = tizen_private->window_transform;
                        wayland_egl_buffer->w_rotated = TPL_TRUE;
                } else {
                        wayland_egl_buffer->w_rotated = TPL_FALSE;
                }
 
-               if (wayland_egl_surface->latest_transform != wl_egl_window->transform) {
-                       wayland_egl_surface->latest_transform = wl_egl_window->transform;
-                       wayland_egl_buffer->transform = wl_egl_window->transform;
+               if (wayland_egl_surface->latest_transform != tizen_private->transform) {
+                       wayland_egl_surface->latest_transform = tizen_private->transform;
+                       wayland_egl_buffer->transform = tizen_private->transform;
                        wayland_egl_buffer->rotated = TPL_TRUE;
                } else {
                        wayland_egl_buffer->rotated = TPL_FALSE;
@@ -1355,8 +1398,8 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou
        if (wayland_egl_surface->set_serial_is_used) {
                wayland_egl_buffer->serial = wayland_egl_surface->serial;
        } else {
-               ++wl_egl_window->serial;
-               wayland_egl_buffer->serial = wl_egl_window->serial;
+               ++tizen_private->serial;
+               wayland_egl_buffer->serial = tizen_private->serial;
        }
 
        wayland_egl_buffer->dx = wl_egl_window->dx;
@@ -1367,18 +1410,18 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou
        wayland_egl_buffer->wl_proxy = wl_proxy;
        wayland_egl_buffer->bo = tbm_surface_internal_get_bo(tbm_surface, 0);
        wayland_egl_buffer->wayland_egl_surface = wayland_egl_surface;
-       wayland_egl_buffer->transform = wl_egl_window->transform;
+       wayland_egl_buffer->transform = tizen_private->transform;
        wayland_egl_buffer->rotated = TPL_TRUE;
 
-       if (wayland_egl_buffer->window_transform != wl_egl_window->window_transform) {
-               wayland_egl_buffer->window_transform = wl_egl_window->window_transform;
+       if (wayland_egl_buffer->window_transform != tizen_private->window_transform) {
+               wayland_egl_buffer->window_transform = tizen_private->window_transform;
                wayland_egl_buffer->w_rotated = TPL_TRUE;
        } else {
                wayland_egl_buffer->w_rotated = TPL_FALSE;
        }
 
-       if (wayland_egl_surface->latest_transform != wl_egl_window->transform) {
-               wayland_egl_surface->latest_transform = wl_egl_window->transform;
+       if (wayland_egl_surface->latest_transform != tizen_private->transform) {
+               wayland_egl_surface->latest_transform = tizen_private->transform;
                wayland_egl_buffer->rotated = TPL_TRUE;
        } else {
                wayland_egl_buffer->rotated = TPL_FALSE;
@@ -1570,14 +1613,46 @@ static const struct wl_buffer_listener buffer_release_listener = {
 };
 
 static void
+__cb_client_window_destroy_callback(void *private)
+{
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
+       tpl_surface_t *surface = NULL;
+       struct wl_egl_window *wl_egl_window = NULL;
+
+       if (!tizen_private) {
+               TPL_WARN("[DESTROY_CB] Already destroyed surface");
+               return;
+       }
+
+       surface = (tpl_surface_t *)tizen_private->data;
+       if (surface) {
+               TPL_LOG_B("WL_EGL", "[DESTROY_CB] wl_egl_window(%p) tpl_surface(%p)",
+                                 surface->native_handle, surface);
+               wl_egl_window = (struct wl_egl_window *)surface->native_handle;
+
+               wl_egl_window->driver_private = NULL;
+               surface->native_handle = NULL;
+       }
+
+       tizen_private->set_window_serial_callback = NULL;
+       tizen_private->rotate_callback = NULL;
+       tizen_private->get_rotation_capability = NULL;
+       tizen_private->set_frontbuffer_callback = NULL;
+       tizen_private->data = NULL;
+       free(tizen_private);
+       tizen_private = NULL;
+}
+
+static void
 __cb_client_window_resize_callback(struct wl_egl_window *wl_egl_window,
-                                               void *private)
+                                                                  void *private)
 {
        TPL_ASSERT(private);
        TPL_ASSERT(wl_egl_window);
 
        int cur_w, cur_h, req_w, req_h;
-       tpl_surface_t *surface = (tpl_surface_t *)private;
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
+       tpl_surface_t *surface = (tpl_surface_t *)tizen_private->data;
        tpl_wayland_egl_surface_t *wayland_egl_surface =
                (tpl_wayland_egl_surface_t *)surface->backend.data;
 
@@ -1602,9 +1677,10 @@ __cb_client_window_rotate_callback(struct wl_egl_window *wl_egl_window,
        TPL_ASSERT(wl_egl_window);
 
        int rotation;
-       tpl_surface_t *surface = (tpl_surface_t *)private;
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
+       tpl_surface_t *surface = (tpl_surface_t *)tizen_private->data;
 
-       rotation = wl_egl_window->rotation;
+       rotation = tizen_private->rotation;
 
        TPL_LOG_B("WL_EGL", "[ROTATE_CB] wl_egl_window(%p) (%d) -> (%d)",
                          wl_egl_window, surface->rotation, rotation);
@@ -1619,7 +1695,9 @@ __cb_client_window_get_rotation_capability(struct wl_egl_window *wl_egl_window,
        int rotation_capability = WL_EGL_WINDOW_CAPABILITY_NONE;
        TPL_ASSERT(private);
        TPL_ASSERT(wl_egl_window);
-       tpl_surface_t *surface = (tpl_surface_t *)private;
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
+       tpl_surface_t *surface = (tpl_surface_t *)tizen_private->data;
+
        if (TPL_TRUE == surface->rotation_capability)
                rotation_capability = WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED;
        else
@@ -1634,7 +1712,8 @@ __cb_client_window_set_frontbuffer_mode(struct wl_egl_window *wl_egl_window,
 {
        TPL_ASSERT(private);
        TPL_ASSERT(wl_egl_window);
-       tpl_surface_t *surface = (tpl_surface_t *)private;
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
+       tpl_surface_t *surface = (tpl_surface_t *)tizen_private->data;
 
        if (set)
                surface->is_frontbuffer_mode = TPL_TRUE;
@@ -1649,7 +1728,8 @@ __cb_client_window_set_window_serial_callback(struct wl_egl_window *wl_egl_windo
        TPL_ASSERT(private);
        TPL_ASSERT(wl_egl_window);
 
-       tpl_surface_t *surface = (tpl_surface_t *)private;
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
+       tpl_surface_t *surface = (tpl_surface_t *)tizen_private->data;
 
        TPL_ASSERT(surface->backend.data);
 
index ccac3f6..442c158 100644 (file)
@@ -13,6 +13,7 @@
 #include "tpl_utils.h"
 #include "tpl_internal.h"
 #include "wayland-egl/wayland-egl-priv.h"
+#include "wayland-egl/wayland-egl-tizen-priv.h"
 #include "tpl_wayland_egl_thread.h"
 #include "wayland-vulkan/wayland-vulkan-client-protocol.h"
 #include "tpl_utils.h"
@@ -200,6 +201,8 @@ static void
 __cb_buffer_remove_from_list(void *data);
 static tpl_result_t
 _twe_surface_wait_vblank(twe_wl_surf_source *surf_source);
+static struct tizen_private *
+_get_tizen_private(struct wl_egl_window *);
 
 static gpointer
 _twe_thread_loop(gpointer data)
@@ -1079,12 +1082,27 @@ twe_display_get_present_mode(twe_display_h display,
        return TPL_ERROR_NONE;
 }
 
+static struct tizen_private *
+_get_tizen_private(struct wl_egl_window * wl_egl_window)
+{
+       if (wl_egl_window && wl_egl_window->driver_private)
+               return (struct tizen_private *)wl_egl_window->driver_private;
+
+       return NULL;
+}
 
 static void
 __cb_destroy_callback(void *private)
 {
-       twe_wl_surf_source *surf_source = (twe_wl_surf_source *)private;
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
+       twe_wl_surf_source *surf_source = NULL;
+
+       if (!tizen_private) {
+               TPL_LOG_T(BACKEND, "[DESTROY_CB] Already destroyed surface");
+               return;
+       }
 
+       surf_source = (twe_wl_surf_source *)tizen_private->data;
        if (surf_source) {
                TPL_LOG_T(BACKEND, "[DESTROY_CB] wl_egl_window(%p) surf_source(%p)",
                                  surf_source->wl_egl_window, surf_source);
@@ -1093,8 +1111,24 @@ __cb_destroy_callback(void *private)
                surf_source->wl_egl_window = NULL;
                surf_source->surf = NULL;
                surf_source->is_destroying = TPL_TRUE;
+
+               tizen_private->set_window_serial_callback = NULL;
+               tizen_private->rotate_callback = NULL;
+               tizen_private->get_rotation_capability = NULL;
+               tizen_private->data = NULL;
+               free(tizen_private);
+               tizen_private = NULL;
                g_mutex_unlock(&surf_source->surf_mutex);
        }
+
+       if (tizen_private) {
+               tizen_private->set_window_serial_callback = NULL;
+               tizen_private->rotate_callback = NULL;
+               tizen_private->get_rotation_capability = NULL;
+               tizen_private->data = NULL;
+               free(tizen_private);
+               tizen_private = NULL;
+       }
 }
 
 static void
@@ -1103,9 +1137,13 @@ __cb_resize_callback(struct wl_egl_window *wl_egl_window, void *private)
        TPL_ASSERT(private);
        TPL_ASSERT(wl_egl_window);
 
-       twe_wl_surf_source *source = (twe_wl_surf_source *)private;
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
        int cur_w, cur_h, req_w, req_h, format;
 
+       TPL_ASSERT(tizen_private->data);
+
+       twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data;
+
        format = tbm_surface_queue_get_format(source->tbm_queue);
        cur_w = tbm_surface_queue_get_width(source->tbm_queue);
        cur_h = tbm_surface_queue_get_height(source->tbm_queue);
@@ -1128,8 +1166,11 @@ __cb_rotate_callback(struct wl_egl_window *wl_egl_window, void *private)
        TPL_ASSERT(private);
        TPL_ASSERT(wl_egl_window);
 
-       int rotation = wl_egl_window->rotation;
-       twe_wl_surf_source *source = (twe_wl_surf_source *)private;
+       struct tizen_private *tizen_private = (struct tizen_private *)private;
+       twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data;
+       int rotation = tizen_private->rotation;
+
+       TPL_ASSERT(source);
 
        TPL_LOG_T(BACKEND, "[ROTATE_CB] wl_egl_window(%p) (%d) -> (%d)",
                          wl_egl_window, source->rotation, rotation);
@@ -1306,6 +1347,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source,
 {
        twe_wl_buffer_info *buf_info = NULL;
        struct wl_egl_window *wl_egl_window = NULL;
+       struct tizen_private *tizen_private = NULL;
 
        if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) {
                TPL_ERR("Invalid parameter. twe_surface(%p)", surf_source);
@@ -1313,6 +1355,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source,
        }
 
        wl_egl_window = surf_source->wl_egl_window;
+       tizen_private = _get_tizen_private(wl_egl_window);
 
        if (!tbm_surface || !tbm_surface_internal_is_valid(tbm_surface)) {
                TPL_ERR("Invalid parameter. tbm_surface(%p)", tbm_surface);
@@ -1323,25 +1366,25 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source,
                                                                           (void **)&buf_info);
        /* If buf_info is already existed, reuse it. */
        if (buf_info) {
-               if (wl_egl_window) {
-                       if (buf_info->w_transform != wl_egl_window->window_transform) {
-                               buf_info->w_transform = wl_egl_window->window_transform;
+               if (tizen_private) {
+                       if (buf_info->w_transform != tizen_private->window_transform) {
+                               buf_info->w_transform = tizen_private->window_transform;
                                buf_info->w_rotated = TPL_TRUE;
                        }
 
-                       if (surf_source->latest_transform != wl_egl_window->transform) {
-                               surf_source->latest_transform = wl_egl_window->transform;
+                       if (surf_source->latest_transform != tizen_private->transform) {
+                               surf_source->latest_transform = tizen_private->transform;
                                buf_info->rotated = TPL_TRUE;
                        }
 
-                       buf_info->transform = wl_egl_window->transform;
+                       buf_info->transform = tizen_private->transform;
                        buf_info->dx = wl_egl_window->dx;
                        buf_info->dy = wl_egl_window->dy;
                        if (surf_source->set_serial_is_used) {
                                buf_info->serial = surf_source->serial;
                        } else {
-                               ++wl_egl_window->serial;
-                               buf_info->serial = wl_egl_window->serial;
+                               ++tizen_private->serial;
+                               buf_info->serial = tizen_private->serial;
                        }
                }
 
@@ -1390,29 +1433,29 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source,
                return;
        }
 
-       if (wl_egl_window) {
+       if (wl_egl_window && tizen_private) {
                buf_info->dx = wl_egl_window->dx;
                buf_info->dy = wl_egl_window->dy;
                buf_info->width = wl_egl_window->width;
                buf_info->height = wl_egl_window->height;
 
-               if (buf_info->w_transform != wl_egl_window->window_transform) {
-                       buf_info->w_transform = wl_egl_window->window_transform;
+               if (buf_info->w_transform != tizen_private->window_transform) {
+                       buf_info->w_transform = tizen_private->window_transform;
                        buf_info->w_rotated = TPL_TRUE;
                }
 
-               if (surf_source->latest_transform != wl_egl_window->transform) {
-                       surf_source->latest_transform = wl_egl_window->transform;
+               if (surf_source->latest_transform != tizen_private->transform) {
+                       surf_source->latest_transform = tizen_private->transform;
                        buf_info->rotated = TPL_TRUE;
                }
 
-               buf_info->transform = wl_egl_window->transform;
+               buf_info->transform = tizen_private->transform;
 
                if (surf_source->set_serial_is_used) {
                        buf_info->serial = surf_source->serial;
                } else {
-                       ++wl_egl_window->serial;
-                       buf_info->serial = wl_egl_window->serial;
+                       ++tizen_private->serial;
+                       buf_info->serial = tizen_private->serial;
                }
 
                if (surf_source->in_use_buffers) {
@@ -2329,13 +2372,20 @@ _twe_thread_wl_surf_source_destroy(void *source)
        surf_source->rotate_cb = NULL;
 
        if (surf_source->wl_egl_window) {
+               struct tizen_private *tizen_private = NULL;
                TPL_LOG_T(BACKEND, "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)",
                                  surf_source, surf_source->wl_egl_window, surf_source->surf);
-               surf_source->wl_egl_window->set_window_serial_callback = NULL;
+               tizen_private = _get_tizen_private(surf_source->wl_egl_window);
+               if (tizen_private) {
+                       tizen_private->set_window_serial_callback = NULL;
+                       tizen_private->rotate_callback = NULL;
+                       tizen_private->get_rotation_capability = NULL;
+                       tizen_private->data = NULL;
+                       free(tizen_private);
+               }
+
                surf_source->wl_egl_window->destroy_window_callback = NULL;
                surf_source->wl_egl_window->resize_callback = NULL;
-               surf_source->wl_egl_window->rotate_callback = NULL;
-               surf_source->wl_egl_window->get_rotation_capability = NULL;
                surf_source->wl_egl_window->driver_private = NULL;
                surf_source->wl_egl_window = NULL;
                surf_source->surf = NULL;
@@ -2446,20 +2496,31 @@ twe_surface_add(twe_thread* thread,
        if (!disp_source->is_vulkan_dpy) {
                struct wl_egl_window *wl_egl_window =
                        (struct wl_egl_window *)native_handle;
+               struct tizen_private *private = NULL;
 
-               wl_egl_window->driver_private = (void *)source;
-               wl_egl_window->destroy_window_callback = (void *)__cb_destroy_callback;
-               wl_egl_window->resize_callback = (void *)__cb_resize_callback;
-               wl_egl_window->rotate_callback = (void *)__cb_rotate_callback;
-               wl_egl_window->get_rotation_capability = (void *)
-                       __cb_get_rotation_capability;
-               wl_egl_window->set_window_serial_callback = (void *)
-                       __cb_set_window_serial_callback;
+               if (wl_egl_window->driver_private)
+                       private = (struct tizen_private *)wl_egl_window->driver_private;
+               else {
+                       private = tizen_private_create();
+                       wl_egl_window->driver_private = (void *)private;
+               }
+
+               if (private) {
+                       private->data = (void *)source;
+                       private->rotate_callback = (void *)__cb_rotate_callback;
+                       private->get_rotation_capability = (void *)
+                               __cb_get_rotation_capability;
+                       private->set_window_serial_callback = (void *)
+                               __cb_set_window_serial_callback;
+
+                       source->latest_transform = private->transform;
+
+                       wl_egl_window->destroy_window_callback = (void *)__cb_destroy_callback;
+                       wl_egl_window->resize_callback = (void *)__cb_resize_callback;
+               }
 
                source->wl_egl_window = wl_egl_window;
                source->surf = wl_egl_window->surface;
-               source->latest_transform = wl_egl_window->transform;
-
                source->vblank_waiting_buffers = __tpl_list_alloc();
 
        } else {
@@ -3270,8 +3331,9 @@ twe_get_native_window_info(tpl_handle_t window, int *width, int *height,
        if (width) *width = wl_egl_window->width;
        if (height) *height = wl_egl_window->height;
        if (format) {
-               if (wl_egl_window->driver_private) {
-                       twe_wl_surf_source *surf_source = (twe_wl_surf_source *)wl_egl_window->driver_private;
+               struct tizen_private *tizen_private = _get_tizen_private(wl_egl_window);
+               if (tizen_private && tizen_private->data) {
+                       twe_wl_surf_source *surf_source = (twe_wl_surf_source *)tizen_private->data;
                        *format = surf_source->format;
                } else {
                        if (a_size == 8)
index 238d450..acf728b 100644 (file)
@@ -1,6 +1,7 @@
 #include <wayland-egl.h>
 #include "wayland-egl-tizen.h"
 #include "wayland-egl-priv.h"
+#include "wayland-egl-tizen-priv.h"
 
 #define WL_EGL_DEBUG 1
 #if WL_EGL_DEBUG
@@ -52,34 +53,61 @@ void
 wl_egl_window_tizen_set_rotation(struct wl_egl_window *egl_window,
                                                                 int rotation)
 {
+       struct tizen_private *private = NULL;
        if (egl_window == NULL) {
                WL_EGL_ERR("egl_window is NULL");
                return;
        }
 
-       if (egl_window->rotation == rotation) {
+       if (!egl_window->driver_private) {
+               private = tizen_private_create();
+               if (!private) {
+                       WL_EGL_ERR("Failed to create tizen_private.");
+                       return;
+               }
+
+               egl_window->driver_private = (void *)private;
+       } else {
+               private = (struct tizen_private *)egl_window->driver_private;
+       }
+
+       if (private->rotation == rotation) {
                WL_EGL_LOG(2, "rotation(%d) egl_window->rotation(%d) already rotated",
-                                  rotation, egl_window->rotation);
+                                  rotation, private->rotation);
                return;
        }
 
-       egl_window->rotation = rotation;
+       private->rotation = rotation;
 
-       if (egl_window->rotate_callback)
-               egl_window->rotate_callback(egl_window, egl_window->driver_private);
+       if (private->rotate_callback)
+               private->rotate_callback(egl_window, egl_window->driver_private);
 }
 
 int
 wl_egl_window_tizen_get_capabilities(struct wl_egl_window *egl_window)
 {
+       struct tizen_private *private = NULL;
        int capabilities = WL_EGL_WINDOW_CAPABILITY_NONE;
+
        if (egl_window == NULL) {
                WL_EGL_ERR("egl_window is NULL");
-               return capabilities;
+               return -1;
        }
 
-       if (egl_window->get_rotation_capability)
-               capabilities = egl_window->get_rotation_capability(egl_window, egl_window->driver_private);
+       if (!egl_window->driver_private) {
+               private = tizen_private_create();
+               if (!private) {
+                       WL_EGL_ERR("Failed to create tizen_private.");
+                       return -1;
+               }
+
+               egl_window->driver_private = (void *)private;
+       } else {
+               private = (struct tizen_private *)egl_window->driver_private;
+       }
+
+       if (private->get_rotation_capability)
+               capabilities = private->get_rotation_capability(egl_window, egl_window->driver_private);
        else
                capabilities = WL_EGL_WINDOW_CAPABILITY_ROTATION_UNKNOWN;
 
@@ -90,77 +118,136 @@ void
 wl_egl_window_tizen_set_buffer_transform(struct wl_egl_window *egl_window,
                                                                                 int wl_output_transform)
 {
+       struct tizen_private *private = NULL;
        if (egl_window == NULL) {
                WL_EGL_ERR("egl_window is NULL");
                return;
        }
 
-       if (egl_window->transform == wl_output_transform) {
+       if (!egl_window->driver_private) {
+               private = tizen_private_create();
+               if (!private) {
+                       WL_EGL_ERR("Failed to create tizen_private.");
+                       return;
+               }
+
+               egl_window->driver_private = (void *)private;
+       } else {
+               private = (struct tizen_private *)egl_window->driver_private;
+       }
+
+       if (private->transform == wl_output_transform) {
                WL_EGL_LOG(2,
-                                  "wl_output_transform(%d) egl_window->transform(%d) already rotated",
-                                  wl_output_transform, egl_window->transform);
+                                  "wl_output_transform(%d) private->transform(%d) already rotated",
+                                  wl_output_transform, private->transform);
                return;
        }
 
-       egl_window->transform = wl_output_transform;
+       private->transform = wl_output_transform;
 }
 
 void
 wl_egl_window_tizen_set_frontbuffer_mode(struct wl_egl_window *egl_window,
                                                                                 int set)
 {
+       struct tizen_private *private = NULL;
        if (egl_window == NULL) {
                WL_EGL_ERR("egl_window is NULL");
                return;
        }
 
-       egl_window->frontbuffer_mode = set;
+       if (!egl_window->driver_private) {
+               private = tizen_private_create();
+               if (!private) {
+                       WL_EGL_ERR("Failed to create tizen_private.");
+                       return;
+               }
+
+               egl_window->driver_private = (void *)private;
+       } else {
+               private = (struct tizen_private *)egl_window->driver_private;
+       }
+
+       private->frontbuffer_mode = set;
 
-       if (egl_window->set_frontbuffer_callback)
-               egl_window->set_frontbuffer_callback(egl_window, egl_window->driver_private,
-                                                                                        set);
+       if (private->set_frontbuffer_callback)
+               private->set_frontbuffer_callback(egl_window, egl_window->driver_private,
+                                                                                 set);
 }
 
 void
 wl_egl_window_tizen_set_window_transform(struct wl_egl_window *egl_window,
                                                                                 int window_transform)
 {
+       struct tizen_private *private = NULL;
        if (egl_window == NULL) {
                WL_EGL_ERR("egl_window is NULL");
                return;
        }
 
-       if (egl_window->window_transform == window_transform) {
+       if (!egl_window->driver_private) {
+               private = tizen_private_create();
+               if (!private) {
+                       WL_EGL_ERR("Failed to create tizen_private.");
+                       return;
+               }
+
+               egl_window->driver_private = (void *)private;
+       } else {
+               private = (struct tizen_private *)egl_window->driver_private;
+       }
+
+       if (private->window_transform == window_transform) {
                WL_EGL_LOG(2,
                                   "window_transform(%d)  already rotated",
                                   window_transform);
                return;
        }
 
-       egl_window->window_transform = window_transform;
+       private->window_transform = window_transform;
 }
 
 unsigned int
 wl_egl_window_tizen_get_window_serial(struct wl_egl_window *egl_window)
 {
+       struct tizen_private *private = NULL;
        if (egl_window == NULL) {
                WL_EGL_ERR("egl_window is NULL");
                return 0;
        }
 
-       return egl_window->serial;
+       if (!egl_window->driver_private) {
+               private = tizen_private_create();
+               if (!private) {
+                       WL_EGL_ERR("Failed to create tizen_private.");
+                       return 0;
+               }
+
+               egl_window->driver_private = (void *)private;
+       } else {
+               private = (struct tizen_private *)egl_window->driver_private;
+       }
+
+       return private->serial;
 }
 
 void
 wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window,
                                                                          unsigned int serial)
 {
+       struct tizen_private *private = NULL;
        if (egl_window == NULL) {
                WL_EGL_ERR("egl_window is NULL");
                return;
        }
 
-       if (egl_window->set_window_serial_callback)
-               egl_window->set_window_serial_callback(egl_window, egl_window->driver_private,
-                                                                                          serial);
+       private = egl_window->driver_private;
+       if (private == NULL) {
+               WL_EGL_ERR("wl_egl_window(%p) dirver_private is NULL", egl_window);
+               return;
+       }
+
+       if (private->set_window_serial_callback)
+               private->set_window_serial_callback(egl_window, egl_window->driver_private,
+                                                                                       serial);
 }
\ No newline at end of file