X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftbm_module.c;h=16beb7f01911c6cf785f7cc694060a607711a8b1;hb=5d6f1d8855f0301ac781a5e66068344ed636a0b0;hp=652713d6d3402d94904a232c5d07c09dc124a33c;hpb=3afc2a7be0c0c7b8d6397643222ec36ed67fd6cb;p=platform%2Fcore%2Fuifw%2Flibtbm.git diff --git a/src/tbm_module.c b/src/tbm_module.c index 652713d..16beb7f 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -650,18 +650,16 @@ tbm_module_support_surface_data(tbm_module *module) tbm_error_e error = TBM_ERROR_NONE; tbm_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) { + if (module->check_surface_data) { // return the value which already set. return module->support_surface_data; } // check this only once - tbm_module_check_support_surface_data = 1; + module->check_surface_data = 1; if (module->type != TBM_MODULE_TYPE_HAL_TBM) goto done; @@ -703,8 +701,8 @@ tbm_module_alloc_surface_data(tbm_module *module, int width, int height, int for 0, (hal_tbm_error *)error); if (!surface_data->hal_surface) { - TBM_ERR("hal_tbm_bufmgr_alloc_surface failed."); - *error = TBM_ERROR_INVALID_OPERATION; + if (*error != TBM_ERROR_NOT_SUPPORTED) // do not print the error message when it is not supported. + TBM_ERR("hal_tbm_bufmgr_alloc_surface failed."); free(surface_data); return NULL; } @@ -823,7 +821,8 @@ tbm_module_alloc_bo_data_with_format(tbm_module *module, int format, int bo_idx, bo_data->hal_bo = hal_tbm_bufmgr_alloc_bo_with_format(module->hal_bufmgr, format, bo_idx, width, height, bpp, (hal_tbm_bo_memory_type)flags, (hal_tbm_error *)error); - TBM_GOTO_VAL_IF_FAIL(bo_data->hal_bo, failed); + if (!bo_data->hal_bo) + goto failed; break; /* LCOV_EXCL_START */ case TBM_MODULE_TYPE_TBM_BACKEND: @@ -835,11 +834,12 @@ tbm_module_alloc_bo_data_with_format(tbm_module *module, int format, int bo_idx, } bo_data->backend_bo_data = bufmgr_func->bufmgr_alloc_bo_with_format(module->bufmgr_data, format, bo_idx, width, height, flags, error); - TBM_GOTO_VAL_IF_FAIL(bo_data->backend_bo_data, failed); + if (!bo_data->backend_bo_data) + goto failed; break; case TBM_MODULE_TYPE_BUFMGR_BACKEND: TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5."); - TBM_ERR("error: not supported tbm_bufmgr_internal_alloc_bo_with_format."); + TBM_ERR("error: not supported tbm_module_alloc_bo_data_with_format."); *error = TBM_ERROR_NOT_SUPPORTED; goto failed; @@ -1037,7 +1037,7 @@ tbm_surface_data_get_plane_data(tbm_surface_data *surface_data, int plane_idx, u } tbm_bo_data ** -tbm_surface_data_get_bo_data_array(tbm_surface_data *surface_data, int *num_bos, tbm_error_e *error) +tbm_surface_data_get_bo_data_array(tbm_surface_data *surface_data, int *num_bos, int *memory_types, tbm_error_e *error) { tbm_bo_data **bo_data_array = NULL; hal_tbm_bo **hal_bos = NULL; @@ -1049,11 +1049,12 @@ tbm_surface_data_get_bo_data_array(tbm_surface_data *surface_data, int *num_bos, hal_bos = hal_tbm_surface_get_bos(surface_data->hal_surface, num_bos, (hal_tbm_error *)error); TBM_RETURN_VAL_IF_FAIL(hal_bos, NULL); - bo_data_array = calloc(*num_bos, sizeof(struct _tbm_bo_data)); - if (bo_data_array) { - TBM_ERR("memory allocation failed."); - *error = TBM_ERROR_OUT_OF_MEMORY; - return NULL; + bo_data_array = calloc(*num_bos, sizeof(tbm_bo_data *)); + TBM_RETURN_VAL_IF_FAIL(bo_data_array, NULL); + + for (i = 0; i < *num_bos; i++) { + bo_data_array[i] = calloc(*num_bos, sizeof(struct _tbm_bo_data)); + TBM_GOTO_VAL_SET_ERR_IF_FAIL(bo_data_array[i], failed, *error, TBM_ERROR_OUT_OF_MEMORY); } for (i = 0; i < *num_bos; i++) { @@ -1061,7 +1062,22 @@ tbm_surface_data_get_bo_data_array(tbm_surface_data *surface_data, int *num_bos, bo_data_array[i]->module = surface_data->module; } + // get memory_types(bo flags) + *memory_types = tbm_bo_data_get_memory_types(bo_data_array[0], error); + TBM_GOTO_VAL_IF_FAIL(*error == TBM_ERROR_NONE, failed); + return bo_data_array; + +/* LCOV_EXCL_START */ +failed: + for (i = 0; i < *num_bos; i++) { + if (bo_data_array[i]) + free(bo_data_array[i]); + } + free(bo_data_array); + + return NULL; +/* LCOV_EXCL_STOP */ } tbm_surface_buffer_data * @@ -1276,7 +1292,7 @@ tbm_bo_data_map(tbm_bo_data *bo_data, int device, int opt, tbm_error_e *error) tbm_backend_bo_func *bo_func = NULL; tbm_bufmgr_backend backend = NULL; tbm_bo_handle bo_handle = (tbm_bo_handle)NULL; - hal_tbm_bo_handle hbo_handle; + hal_tbm_bo_handle hbo_handle = (hal_tbm_bo_handle)NULL; TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER); TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data->module, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER);