tbm_bufmgr: add tbm_bufmgr_internal_alloc_bo and use it
[platform/core/uifw/libtbm.git] / src / tbm_bufmgr.c
index b20523a..48dca8e 100644 (file)
@@ -912,6 +912,40 @@ tbm_bufmgr_internal_find_bo(tbm_bufmgr bufmgr, tbm_bo bo)
        return NULL;
 }
 
+tbm_bo
+tbm_bufmgr_internal_alloc_bo(tbm_bufmgr bufmgr, int size, int flags, tbm_error_e *error)
+{
+       tbm_bo bo;
+       tbm_backend_bo_data *bo_data;
+
+       _tbm_bufmgr_check_bo_cnt(bufmgr);
+
+       bo = calloc(1, sizeof(struct _tbm_bo));
+       if (!bo) {
+               /* LCOV_EXCL_START */
+               TBM_ERR("memory allocationc failed.");
+               *error = TBM_ERROR_OUT_OF_MEMORY;
+               return NULL;
+               /* LCOV_EXCL_STOP */
+       }
+
+       bo_data = tbm_module_bufmgr_bo_alloc(bufmgr->module, bo, size, flags, error);
+       if (!bo_data) {
+               /* LCOV_EXCL_START */
+               TBM_ERR("tbm_module_bufmgr_bo_alloc failed. size:%d flags:%s error:%d", size, _tbm_flag_to_str(flags), *error);
+               free(bo);
+               return NULL;
+               /* LCOV_EXCL_STOP */
+       }
+       bo->bo_data = bo_data;
+       bo->priv = (void *)bo_data; // TODO: this will be DEPRECATED.
+
+       _tbm_bufmgr_initialize_bo(bufmgr, bo, flags);
+
+       return bo;
+}
+
+
 /* LCOV_EXCL_START */
 
 tbm_bo