e_comp_wl_tbm: add module func set/unset 46/245546/9
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 12 Oct 2020 06:41:24 +0000 (15:41 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Tue, 27 Oct 2020 08:05:17 +0000 (17:05 +0900)
add capturable_buffer_get func and
e_comp_wl_tbm_capturable_buffer_get api

Change-Id: I5b95351b514858e44d807513bbfe5f99a9ff2890

src/bin/Makefile.mk
src/bin/e_comp_wl_tbm.c
src/bin/e_comp_wl_tbm.h
src/bin/e_includes.h

index 94533e91a7b1776a395c8990e815759cb49cfb50..b8808235c8c22b9557a48dd47f33c8ecfa17d181 100644 (file)
@@ -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 \
index 144e5fb620f969ef8047c349dcdbe008711411f0..881a45fedfe1e2760d9ff59da619b2ed3b1dc058 100644 (file)
@@ -3,6 +3,8 @@
 #include <tbm_bufmgr.h>
 #include <tbm_surface_internal.h>
 
+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)
 {
index 9285ac3b7063fa135f8df55c985b0dac838e27ed..db762238a75b9898d0e738141400eb3653447382 100644 (file)
@@ -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 <tbm_surface.h>
 
+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
index d3f68cdfa5384dc25ce4c0a93a226929fbedcf28..25bd45daa3e970d17a84c1253d048ed50ce9f68d 100644 (file)
@@ -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"