From: Changyeon Lee Date: Mon, 12 Oct 2020 06:41:24 +0000 (+0900) Subject: e_comp_wl_tbm: add module func set/unset X-Git-Tag: submit/tizen/20201028.110311~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=991bdbce95030bdbb675ce2236f5dbb4bac69a21;p=platform%2Fupstream%2Fenlightenment.git e_comp_wl_tbm: add module func set/unset add capturable_buffer_get func and e_comp_wl_tbm_capturable_buffer_get api Change-Id: I5b95351b514858e44d807513bbfe5f99a9ff2890 --- diff --git a/src/bin/Makefile.mk b/src/bin/Makefile.mk index 94533e91a7..b8808235c8 100644 --- a/src/bin/Makefile.mk +++ b/src/bin/Makefile.mk @@ -99,14 +99,8 @@ src/bin/e_hwc_window.h \ src/bin/e_hwc_window_queue.h \ src/bin/e_explicit_sync.h \ src/bin/e_egl_sync.h \ -src/bin/e_info_server_input.h - -if HAVE_WAYLAND_TBM -ENLIGHTENMENTHEADERS += \ -src/bin/e_comp_wl_tbm.h -endif - -ENLIGHTENMENTHEADERS += \ +src/bin/e_info_server_input.h \ +src/bin/e_comp_wl_tbm.h \ src/bin/e_comp_wl_renderer.h \ src/bin/e_comp_wl_tizen_hwc.h \ src/bin/e_presentation_time.h \ @@ -225,14 +219,7 @@ src/bin/e_hwc_window_queue.c \ src/bin/e_explicit_sync.c \ src/bin/e_egl_sync.c \ src/bin/e_info_server_input.c \ -$(ENLIGHTENMENTHEADERS) - -if HAVE_WAYLAND_TBM -enlightenment_src += \ -src/bin/e_comp_wl_tbm.c -endif - -enlightenment_src += \ +src/bin/e_comp_wl_tbm.c \ src/bin/e_comp_wl_renderer.c \ src/bin/e_comp_wl_tizen_hwc.c \ src/bin/e_presentation_time.c \ diff --git a/src/bin/e_comp_wl_tbm.c b/src/bin/e_comp_wl_tbm.c index 144e5fb620..881a45fedf 100644 --- a/src/bin/e_comp_wl_tbm.c +++ b/src/bin/e_comp_wl_tbm.c @@ -3,6 +3,8 @@ #include #include +static E_Comp_Wl_Tbm_Funcs *_e_comp_wl_tbm_funcs = NULL; + static int _e_comp_wl_tbm_bind_wl_display(struct wayland_tbm_server *tbm_server, struct wl_display *display) { @@ -20,6 +22,53 @@ _e_comp_wl_tbm_bind_wl_display(struct wayland_tbm_server *tbm_server, struct wl_ return EINA_TRUE; } +E_API Eina_Bool +e_comp_wl_tbm_module_func_set(const char *module_name, E_Comp_Wl_Tbm_Funcs *fn) +{ + EINA_SAFETY_ON_FALSE_RETURN_VAL((_e_comp_wl_tbm_funcs == NULL), EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(fn, EINA_FALSE); + + _e_comp_wl_tbm_funcs = E_NEW(E_Comp_Wl_Tbm_Funcs, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(_e_comp_wl_tbm_funcs, EINA_FALSE); + + _e_comp_wl_tbm_funcs->module_name = strdup(module_name); + _e_comp_wl_tbm_funcs->capturable_buffer_get = fn->capturable_buffer_get; + + return EINA_TRUE; +} + +E_API Eina_Bool +e_comp_wl_tbm_module_func_unset(void) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(_e_comp_wl_tbm_funcs, EINA_FALSE); + + if (_e_comp_wl_tbm_funcs->module_name) + free(_e_comp_wl_tbm_funcs->module_name); + + E_FREE(_e_comp_wl_tbm_funcs); + _e_comp_wl_tbm_funcs = NULL; + + return EINA_TRUE; +} + +EINTERN tbm_surface_h +e_comp_wl_tbm_capturable_buffer_get(tbm_surface_h tsurface) +{ + tbm_surface_h capturable_buffer = NULL; + + EINA_SAFETY_ON_NULL_RETURN_VAL(tsurface, NULL); + + if (_e_comp_wl_tbm_funcs && _e_comp_wl_tbm_funcs->capturable_buffer_get) + { + if (_e_comp_wl_tbm_funcs->capturable_buffer_get(tsurface, &capturable_buffer)) + return capturable_buffer; + } + + tbm_surface_internal_ref(tsurface); + + return tsurface; +} + EINTERN Eina_Bool e_comp_wl_tbm_init(void) { diff --git a/src/bin/e_comp_wl_tbm.h b/src/bin/e_comp_wl_tbm.h index 9285ac3b70..db762238a7 100644 --- a/src/bin/e_comp_wl_tbm.h +++ b/src/bin/e_comp_wl_tbm.h @@ -1,11 +1,21 @@ #ifdef E_TYPEDEFS +typedef struct _E_Comp_Wl_Tbm_Funcs E_Comp_Wl_Tbm_Funcs; + #else # ifndef E_COMP_WL_TBM_H # define E_COMP_WL_TBM_H #include +struct _E_Comp_Wl_Tbm_Funcs +{ + char *module_name; + + /* reference count of dst_tsurface should be increased */ + Eina_Bool (*capturable_buffer_get)(tbm_surface_h src_tsurface, tbm_surface_h *dst_tsurface); +}; + EINTERN Eina_Bool e_comp_wl_tbm_init(void); EINTERN void e_comp_wl_tbm_shutdown(void); @@ -14,5 +24,11 @@ EINTERN void e_comp_wl_tbm_buffer_destroy(E_Comp_Wl_Buffer *buffer); EINTERN struct wl_resource *e_comp_wl_tbm_remote_buffer_get(struct wl_resource *wl_tbm, struct wl_resource *wl_buffer); EINTERN struct wl_resource *e_comp_wl_tbm_remote_buffer_get_with_tbm(struct wl_resource *wl_tbm, tbm_surface_h tbm_surface); + +E_API Eina_Bool e_comp_wl_tbm_module_func_set(const char *module_name, E_Comp_Wl_Tbm_Funcs *fn); +E_API Eina_Bool e_comp_wl_tbm_module_func_unset(void); + +/* reference count of returned tbm_surface should be decreased when not using it anymore */ +EINTERN tbm_surface_h e_comp_wl_tbm_capturable_buffer_get(tbm_surface_h tsurface); # endif #endif diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index d3f68cdfa5..25bd45daa3 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -64,9 +64,7 @@ #include "e_comp_wl_data.h" #include "e_comp_wl_input.h" #include "e_uuid_store.h" -#ifdef HAVE_WAYLAND_TBM -# include "e_comp_wl_tbm.h" -#endif +#include "e_comp_wl_tbm.h" #include "e_comp_wl_rsm.h" #include "e_comp_wl_screenshooter.h" #include "e_comp_wl_viewport.h"