tbm_module: add tbm_module_support_surface_data 00/260300/1
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 22 Jun 2021 02:24:29 +0000 (11:24 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 22 Jun 2021 02:24:29 +0000 (11:24 +0900)
This tells whether the module support surface_data.

Change-Id: I84bfa7849daad784feab9c2d7779adbe3bcea934

src/tbm_module.c
src/tbm_module.h

index 80abcc1..7b2fb74 100644 (file)
@@ -644,6 +644,41 @@ tbm_module_get_plane_data(tbm_module *module, int format, int plane_idx, uint32_
        return error;
 }
 
+int
+tbm_module_support_surface_data(tbm_module *module)
+{
+       tbm_error_e error = TBM_ERROR_NONE;
+       tbm_backend_surface_data *surface_data = NULL;
+
+       static int tbm_module_check_support_surface_data = 0;
+
+       TBM_RETURN_VAL_IF_FAIL(module, 0);
+
+       // check once support_surface_data or not.
+       if (tbm_module_check_support_surface_data) {
+               // return the value which already set.
+               return module->support_surface_data;
+       }
+
+       // check this only once
+       tbm_module_check_support_surface_data = 1;
+
+       if (module->type != TBM_MODULE_TYPE_HAL_TBM)
+               goto done;
+
+       // Assume that the hal-tbm supports the hal surface apis if tbm_module_alloc_surface_data succeed.
+       surface_data = tbm_module_alloc_surface_data(module, 10, 10, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT, &error);
+       if (!surface_data)
+               goto done;
+       free(surface_data);
+
+       module->support_surface_data = 1;
+
+done:
+       return module->support_surface_data;
+}
+
+
 tbm_backend_surface_data *
 tbm_module_alloc_surface_data(tbm_module *module, int width, int height, int format, int flags, tbm_error_e *error)
 {
index bccab4e..6d0b9a1 100644 (file)
@@ -52,6 +52,7 @@ typedef enum _tbm_module_type {
 
 typedef struct _tbm_module {
        tbm_module_type type;
+       int support_surface_data;
 
        void *module_data;                         /* backend module */
        tbm_bufmgr_backend   backend;              /* bufmgr backend (will be DEPRECATED) */
@@ -81,6 +82,7 @@ int                  tbm_module_get_capabilities(tbm_module *module, tbm_error_e
 tbm_error_e          tbm_module_bind_native_display(tbm_module *module, void *native_display);
 tbm_error_e          tbm_module_get_supported_formats(tbm_module *module, uint32_t **formats, uint32_t *num);
 tbm_error_e          tbm_module_get_plane_data(tbm_module *module, int format, int plane_idx, uint32_t w, uint32_t h, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx);
+int                  tbm_module_support_surface_data(tbm_module *module);
 
 tbm_backend_surface_data  *tbm_module_alloc_surface_data(tbm_module *module, int width, int height, int format, int flags, tbm_error_e *error);
 tbm_backend_surface_data  *tbm_module_import_surface_data(tbm_module *module, int width, int height, int format, tbm_surface_buffer_data *buffer_data, tbm_error_e *error);