e_comp_wl_tbm: add egl_image_buffer_get func to E_Comp_wl_Tbm_Funcs 13/249413/1
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 11 Dec 2020 03:55:13 +0000 (12:55 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 11 Dec 2020 07:02:17 +0000 (16:02 +0900)
egl_image_buffer_get func has to provide the tbm_surface_h for making the egl_image.

Change-Id: Ibf2b2720b322e5183d16200296fe20f69747396e

src/bin/e_comp_wl_tbm.c
src/bin/e_comp_wl_tbm.h
src/bin/e_hwc_window_queue.c

index 881a45fedfe1e2760d9ff59da619b2ed3b1dc058..5371269d788ce30801bd9aa6233cb905e0c3d989 100644 (file)
@@ -33,6 +33,7 @@ e_comp_wl_tbm_module_func_set(const char *module_name, E_Comp_Wl_Tbm_Funcs *fn)
 
    _e_comp_wl_tbm_funcs->module_name = strdup(module_name);
    _e_comp_wl_tbm_funcs->capturable_buffer_get = fn->capturable_buffer_get;
+   _e_comp_wl_tbm_funcs->egl_image_buffer_get = fn->egl_image_buffer_get;
 
    return EINA_TRUE;
 }
@@ -69,6 +70,20 @@ e_comp_wl_tbm_capturable_buffer_get(tbm_surface_h tsurface)
    return tsurface;
 }
 
+EINTERN tbm_surface_h
+e_comp_wl_tbm_egl_image_buffer_get(int width, int height, tbm_format format)
+{
+   tbm_surface_h egl_image_buffer = NULL;
+
+   if (_e_comp_wl_tbm_funcs && _e_comp_wl_tbm_funcs->egl_image_buffer_get)
+     {
+        if (_e_comp_wl_tbm_funcs->egl_image_buffer_get(width, height, format, &egl_image_buffer))
+          return egl_image_buffer;
+     }
+
+   return NULL;
+}
+
 EINTERN Eina_Bool
 e_comp_wl_tbm_init(void)
 {
index db762238a75b9898d0e738141400eb3653447382..ba10399de253ac51c4b5036decfc32dafb16dc74 100644 (file)
@@ -13,7 +13,8 @@ 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);
+   Eina_Bool     (*capturable_buffer_get)(tbm_surface_h src_tsurface, tbm_surface_h *dst_tsurface);
+   Eina_Bool     (*egl_image_buffer_get)(int width, int height, tbm_format format, tbm_surface_h *egl_image_tsurface);
 };
 
 EINTERN Eina_Bool e_comp_wl_tbm_init(void);
@@ -30,5 +31,6 @@ 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);
+EINTERN tbm_surface_h e_comp_wl_tbm_egl_image_buffer_get(int width, int height, tbm_format format);
 # endif
 #endif
index a0c1fed2671e3f28c10bf71471574c9e9a020787..54d34075abc287af6aeea0b71522f2786419a3d3 100644 (file)
@@ -180,13 +180,18 @@ _backup_tsurface_create(tbm_surface_h tsurface)
         return NULL;
      }
 
-   new_tsurface = tbm_surface_create(src_info.width, src_info.height, src_info.format);
+   /* get the buffer from e20 module first, if no buffer from e20 module, then create the tbm_surface here. */
+   new_tsurface = e_comp_wl_tbm_egl_image_buffer_get(src_info.width, src_info.height, src_info.format);
    if (!new_tsurface)
      {
-        EHWQERR("fail to allocate the new_tsurface.", NULL, NULL, NULL);
-        tbm_surface_unmap(tsurface);
-        return NULL;
-     }
+        new_tsurface = tbm_surface_create(src_info.width, src_info.height, src_info.format);
+        if (!new_tsurface)
+          {
+             EHWQERR("fail to allocate the new_tsurface.", NULL, NULL, NULL);
+             tbm_surface_unmap(tsurface);
+             return NULL;
+          }
+   }
 
    ret = tbm_surface_map(new_tsurface, TBM_SURF_OPTION_WRITE, &dst_info);
    if (ret != TBM_SURFACE_ERROR_NONE)