#define TBM_SURFACE_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
TBM_ERR("'%s' failed.\n", #cond);\
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);\
_tbm_surface_mutex_unlock();\
return;\
} \
#define TBM_SURFACE_RETURN_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
TBM_ERR("'%s' failed.\n", #cond);\
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);\
_tbm_surface_mutex_unlock();\
return val;\
} \
}
}
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
+
TBM_ERR("error: No valid tbm_surface(%p)\n", surface);
return 0;
TBM_RETURN_VAL_IF_FAIL(surf->info.format > 0, 0);
if (bufmgr->backend_module_data) {
- if (!bufmgr->bufmgr_func->bufmgr_get_plane_data)
+ if (!bufmgr->bufmgr_func->bufmgr_get_plane_data) {
+ _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
return 0;
+ }
error = bufmgr->bufmgr_func->bufmgr_get_plane_data(bufmgr->bufmgr_data, surf->info.format, plane_idx,
surf->info.width, surf->info.height, size, offset, pitch, bo_idx);
if (error != TBM_ERROR_NONE) {
/* LCOV_EXCL_START */
TBM_ERR("Fail to surface_get_plane_data. surface(%p) error(%d)\n", surface, error);
+ _tbm_set_last_result(error);
return 0;
/* LCOV_EXCL_STOP */
}
ret = 1;
} else {
- if (!bufmgr->backend->surface_get_plane_data)
+ if (!bufmgr->backend->surface_get_plane_data) {
+ _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
return 0;
+ }
ret = bufmgr->backend->surface_get_plane_data(surf->info.width,
surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx);
if (!ret) {
/* LCOV_EXCL_START */
TBM_ERR("Fail to surface_get_plane_data. surface(%p)\n", surface);
+ _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
return 0;
/* LCOV_EXCL_STOP */
}
int ret = 0;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
/* Return silently if surface is null. */
if (!surface) {
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
_tbm_surface_mutex_unlock();
return 0;
}
tbm_surface_internal_query_supported_formats(uint32_t **formats,
uint32_t *num)
{
- TBM_RETURN_VAL_IF_FAIL(formats, 0);
- TBM_RETURN_VAL_IF_FAIL(num, 0);
-
struct _tbm_bufmgr *bufmgr;
int ret = 0;
bool bufmgr_initialized = false;
tbm_error_e error;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(formats, 0);
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(num, 0);
if (!g_surface_bufmgr) {
_init_surface_bufmgr();
bufmgr = g_surface_bufmgr;
if (bufmgr->backend_module_data) {
- if (!bufmgr->bufmgr_func->bufmgr_get_supported_formats)
+ if (!bufmgr->bufmgr_func->bufmgr_get_supported_formats) {
+ _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
goto fail;
+ }
error = bufmgr->bufmgr_func->bufmgr_get_supported_formats(bufmgr->bufmgr_data, formats, num);
if (error != TBM_ERROR_NONE) {
}
ret = 1;
} else {
- if (!bufmgr->backend->surface_supported_format)
+ if (!bufmgr->backend->surface_supported_format) {
+ _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
goto fail;
+ }
ret = bufmgr->backend->surface_supported_format(formats, num);
if (!ret) {
/* LCOV_EXCL_START */
TBM_ERR("Fail to surface_supported_format.\n");
+ _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
goto fail;
/* LCOV_EXCL_START */
}
tbm_surface_internal_create_with_flags(int width, int height,
int format, int flags)
{
- TBM_RETURN_VAL_IF_FAIL(width > 0, NULL);
- TBM_RETURN_VAL_IF_FAIL(height > 0, NULL);
-
struct _tbm_bufmgr *bufmgr;
struct _tbm_surface *surf = NULL;
uint32_t size = 0;
tbm_error_e error;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(width > 0, NULL);
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(height > 0, NULL);
if (!g_surface_bufmgr) {
_init_surface_bufmgr();
if (!surf) {
/* LCOV_EXCL_START */
TBM_ERR("fail to alloc surf\n");
+ _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
goto alloc_surf_fail;
/* LCOV_EXCL_STOP */
}
bo = calloc(1, sizeof(struct _tbm_bo));
if (!bo) {
TBM_ERR("fail to alloc bo struct\n");
+ _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
goto alloc_bo_fail;
}
width, height, flags, &error);
if (!bo_data) {
TBM_ERR("fail to alloc bo priv. error(%d)\n", error);
+ _tbm_set_last_result(error);
free(bo);
pthread_mutex_unlock(&surf->bufmgr->lock);
goto alloc_bo_fail;
bo = calloc(1, sizeof(struct _tbm_bo));
if (!bo) {
TBM_ERR("fail to alloc bo struct\n");
+ _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
goto alloc_bo_fail;
}
bo_priv = bufmgr->backend->surface_bo_alloc(bo, width, height, format, flags, i);
if (!bo_priv) {
TBM_ERR("fail to alloc bo priv\n");
+ _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
free(bo);
pthread_mutex_unlock(&surf->bufmgr->lock);
goto alloc_bo_fail;
tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
tbm_bo *bos, int num)
{
- TBM_RETURN_VAL_IF_FAIL(bos, NULL);
- TBM_RETURN_VAL_IF_FAIL(info, NULL);
- TBM_RETURN_VAL_IF_FAIL(info->num_planes > 0, NULL);
- TBM_RETURN_VAL_IF_FAIL(num > 0, NULL);
- TBM_RETURN_VAL_IF_FAIL(num == 1 || info->num_planes == num, NULL);
-
struct _tbm_bufmgr *bufmgr;
struct _tbm_surface *surf = NULL;
int i;
bool bufmgr_initialized = false;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(bos, NULL);
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(info, NULL);
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(info->num_planes > 0, NULL);
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(num > 0, NULL);
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(num == 1 || info->num_planes == num, NULL);
if (!g_surface_bufmgr) {
_init_surface_bufmgr();
bufmgr = g_surface_bufmgr;
if (!TBM_BUFMGR_IS_VALID(bufmgr)) {
TBM_ERR("fail to validate the Bufmgr.\n");
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
goto check_valid_fail;
}
if (!surf) {
/* LCOV_EXCL_START */
TBM_ERR("fail to allocate struct _tbm_surface.\n");
+ _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
goto alloc_surf_fail;
/* LCOV_EXCL_STOP */
}
uint32_t size = 0, offset = 0, stride = 0;
int32_t bo_idx = 0;
- _tbm_surface_internal_query_plane_data(surf, i, &size, &offset, &stride, &bo_idx);
+ if (!_tbm_surface_internal_query_plane_data(surf, i, &size, &offset, &stride, &bo_idx)) {
+ TBM_ERR("fail to get plane_data. error(%s)\n", tbm_error_str(tbm_get_last_error()));
+ goto plane_data_fail;
+ }
surf->info.planes[i].size = size;
}
for (i = 0; i < num; i++) {
if (bos[i] == NULL) {
TBM_ERR("bos[%d] is null.\n", i);
+ _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
goto check_bo_fail;
}
/* LCOV_EXCL_START */
check_bo_fail:
+plane_data_fail:
bpp_fail:
for (i = 0; i < num; i++) {
if (surf->bos[i])
tbm_surface_internal_destroy(tbm_surface_h surface)
{
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_IF_FAIL(_tbm_surface_internal_is_valid(surface));
tbm_surface_internal_ref(tbm_surface_h surface)
{
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_IF_FAIL(_tbm_surface_internal_is_valid(surface));
tbm_surface_internal_unref(tbm_surface_h surface)
{
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_IF_FAIL(_tbm_surface_internal_is_valid(surface));
int num;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
surf = (struct _tbm_surface *)surface;
num = surf->num_bos;
+ if (!num)
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
+
TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) num_bos(%d)\n", surface, num);
_tbm_surface_mutex_unlock();
tbm_bo bo;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), NULL);
TBM_SURFACE_RETURN_VAL_IF_FAIL(bo_idx > -1, NULL);
unsigned int size;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
struct _tbm_surface *surf;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
TBM_SURFACE_RETURN_VAL_IF_FAIL(plane_idx > -1, 0);
if (plane_idx >= surf->info.num_planes) {
TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) plane_idx(%d)\n", surface, plane_idx);
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
_tbm_surface_mutex_unlock();
return 0;
}
int i, j;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
int i;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_IF_FAIL(_tbm_surface_internal_is_valid(surface));
unsigned int width;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
unsigned int height;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
tbm_format format;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
int bo_idx;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
TBM_SURFACE_RETURN_VAL_IF_FAIL(plane_idx > -1, 0);
tbm_user_data *data;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
data = user_data_lookup(&surface->user_data_list, key);
if (data) {
TBM_TRACE_SURFACE_INTERNAL("warning: user data already exist tbm_surface(%p) key(%lu)\n", surface, key);
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
_tbm_surface_mutex_unlock();
return 0;
}
tbm_user_data *old_data;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
old_data = user_data_lookup(&surface->user_data_list, key);
if (!old_data) {
TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) key(%lu)\n", surface, key);
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
_tbm_surface_mutex_unlock();
return 0;
}
tbm_user_data *old_data;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
if (!data) {
TBM_ERR("error: tbm_surface(%p) key(%lu)\n", surface, key);
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
_tbm_surface_mutex_unlock();
return 0;
}
old_data = user_data_lookup(&surface->user_data_list, key);
if (!old_data) {
TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) key(%lu)\n", surface, key);
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
_tbm_surface_mutex_unlock();
return 0;
}
tbm_user_data *old_data = (void *)0;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
old_data = user_data_lookup(&surface->user_data_list, key);
if (!old_data) {
TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) key(%lu)\n", surface, key);
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
_tbm_surface_mutex_unlock();
return 0;
}
tbm_surface_internal_set_debug_pid(tbm_surface_h surface, unsigned int pid)
{
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_IF_FAIL(_tbm_surface_internal_is_valid(surface));
tbm_surface_debug_data *debug_data = NULL;
debug_data = calloc(1, sizeof(tbm_surface_debug_data));
- if (!debug_data)
+ if (!debug_data) {
+ _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
+ TBM_ERR("fail to allocate the debug_data.");
return NULL;
+ }
if (key) debug_data->key = strdup(key);
if (value) debug_data->value = strdup(value);
tbm_bufmgr bufmgr = NULL;
_tbm_surface_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
TBM_SURFACE_RETURN_VAL_IF_FAIL(key, 0);