int bDebug;
#endif
+#ifdef TRACE
+int bTrace;
+#endif
+
#ifdef HAVE_DLOG
int bDlog;
#endif
tbm_last_error = err;
}
+char * tbm_flag_to_str(int f) {
+ static char str[255];
+ int c = 0;
+ if (f == TBM_BO_DEFAULT)
+ snprintf(str, 255, "DEFAULT\n");
+ else {
+ if (f & TBM_BO_SCANOUT)
+ c = snprintf(&str[c], 255, "SCANOUT,");
+ if (f & TBM_BO_NONCACHABLE)
+ c = snprintf(&str[c], 255, "NONCACHABLE,");
+ if (f & TBM_BO_WC)
+ c = snprintf(&str[c], 255, "WC");
+ }
+ return str;
+}
+
/* LCOV_EXCL_START */
static int last_chk_bo_cnt = 0;
static void
bDebug = 0;
}
#endif
+
+#ifdef TRACE
+ env = getenv("TBM_TRACE");
+ if (env) {
+ bTrace = atoi(env);
+ TBM_LOG_D("TBM_TRACE=%s\n", env);
+ } else {
+ bTrace = 0;
+ }
+#endif
/* LCOV_EXCL_STOP */
/* initialize buffer manager */
if (gBufMgr) {
gBufMgr->ref_count++;
-
- DBG("bufmgr:%p ref: fd=%d, ref_count:%d\n",
- gBufMgr, gBufMgr->fd, gBufMgr->ref_count);
+ TBM_TRACE("reuse tbm_bufmgr(%p) ref_count(%d) fd(%d)\n", gBufMgr, gBufMgr->ref_count, gBufMgr->fd);
pthread_mutex_unlock(&gLock);
return gBufMgr;
}
gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr));
if (!gBufMgr) {
_tbm_set_last_result(TBM_BO_ERROR_HEAP_ALLOC_FAILED);
+ TBM_TRACE("error: fail to alloc bufmgr fd(%d)\n", fd);
pthread_mutex_unlock(&gLock);
return NULL;
}
/* LCOV_EXCL_START */
_tbm_set_last_result(TBM_BO_ERROR_LOAD_MODULE_FAILED);
TBM_LOG_E("error : Fail to load bufmgr backend\n");
-
free(gBufMgr);
gBufMgr = NULL;
pthread_mutex_unlock(&gLock);
DBG("BUFMGR_LOCK_TYPE=%s\n",
env ? env : "default:once");
+ TBM_TRACE("create tbm_bufmgr(%p) ref_count(%d) fd(%d)\n", gBufMgr, gBufMgr->ref_count, fd);
+
/* intialize bo_list */
LIST_INITHEAD(&gBufMgr->bo_list);
bufmgr->ref_count--;
if (bufmgr->ref_count > 0) {
- DBG("tizen bufmgr destroy: bufmgr:%p, ref_count:%d\n",
- bufmgr, bufmgr->ref_count);
+ TBM_TRACE("reduce a ref_count(%d) of tbm_bufmgr(%p)\n", bufmgr->ref_count, bufmgr);
pthread_mutex_unlock(&gLock);
return;
}
pthread_mutex_destroy(&bufmgr->lock);
- DBG("tizen bufmgr destroy: bufmgr:%p\n",
- bufmgr);
+ TBM_TRACE("destroy tbm_bufmgr(%p)\n", bufmgr);
dlclose(bufmgr->module_data);
size = bufmgr->backend->bo_size(bo);
+ TBM_TRACE("bo(%p) size(%d)\n", bo, size);
+
pthread_mutex_unlock(&bufmgr->lock);
return size;
_tbm_bo_ref(bo);
+ TBM_TRACE("bo(%p) ref_cnt(%d)\n", bo, bo->ref_cnt);
+
pthread_mutex_unlock(&bufmgr->lock);
return bo;
pthread_mutex_lock(&bufmgr->lock);
+ TBM_TRACE("bo(%p) ref_cnt(%d)\n", bo, bo->ref_cnt - 1);
+
_tbm_bo_unref(bo);
pthread_mutex_unlock(&bufmgr->lock);
bo = calloc(1, sizeof(struct _tbm_bo));
if (!bo) {
+ TBM_TRACE("error: fail to create of tbm_bo size(%d) flag(%s)\n", size, tbm_flag_to_str(flags));
_tbm_set_last_result(TBM_BO_ERROR_HEAP_ALLOC_FAILED);
return NULL;
}
bo_priv = bufmgr->backend->bo_alloc(bo, size, flags);
if (!bo_priv) {
+ TBM_TRACE("error: fail to create of tbm_bo size(%d) flag(%s)\n", size, tbm_flag_to_str(flags));
_tbm_set_last_result(TBM_BO_ERROR_BO_ALLOC_FAILED);
free(bo);
pthread_mutex_unlock(&bufmgr->lock);
bo->flags = flags;
bo->priv = bo_priv;
+ TBM_TRACE("bo(%p) size(%d) refcnt(%d), flag(%s)\n", bo, size, bo->ref_cnt, tbm_flag_to_str(bo->flags));
+
LIST_INITHEAD(&bo->user_data_list);
LIST_ADD(&bo->item_link, &bufmgr->bo_list);
bo = calloc(1, sizeof(struct _tbm_bo));
if (!bo) {
+ TBM_TRACE("error: fail to import of tbm_bo by key(%d)\n", key);
pthread_mutex_unlock(&bufmgr->lock);
return NULL;
}
bo_priv = bufmgr->backend->bo_import(bo, key);
if (!bo_priv) {
+ TBM_TRACE("error: fail to import of tbm_bo by key(%d)\n", key);
_tbm_set_last_result(TBM_BO_ERROR_IMPORT_FAILED);
free(bo);
pthread_mutex_unlock(&bufmgr->lock);
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
if (bo2->priv == bo_priv) {
- DBG("find bo(%p, ref:%d key:%d) in list\n",
- bo2, bo2->ref_cnt, key);
-
+ TBM_TRACE("find bo(%p) ref(%d) key(%d) flag(%s) in list\n",
+ bo2, bo2->ref_cnt, key, tbm_flag_to_str(bo2->flags));
bo2->ref_cnt++;
free(bo);
pthread_mutex_unlock(&bufmgr->lock);
else
bo->flags = TBM_BO_DEFAULT;
+ TBM_TRACE("import new bo(%p) ref(%d) key(%d) flag(%s) in list\n",
+ bo, bo->ref_cnt, key, tbm_flag_to_str(bo->flags));
+
LIST_INITHEAD(&bo->user_data_list);
LIST_ADD(&bo->item_link, &bufmgr->bo_list);
bo = calloc(1, sizeof(struct _tbm_bo));
if (!bo) {
+ TBM_TRACE("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
pthread_mutex_unlock(&bufmgr->lock);
return NULL;
}
bo_priv = bufmgr->backend->bo_import_fd(bo, fd);
if (!bo_priv) {
+ TBM_TRACE("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
_tbm_set_last_result(TBM_BO_ERROR_IMPORT_FD_FAILED);
free(bo);
pthread_mutex_unlock(&bufmgr->lock);
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
if (bo2->priv == bo_priv) {
- DBG("find bo(%p, ref:%d, fd:%d) in list\n",
- bo2, bo2->ref_cnt, fd);
-
+ TBM_TRACE("find bo(%p) ref(%d) fd(%d) flag(%s) in list\n",
+ bo2, bo2->ref_cnt, fd, tbm_flag_to_str(bo2->flags));
bo2->ref_cnt++;
free(bo);
pthread_mutex_unlock(&bufmgr->lock);
else
bo->flags = TBM_BO_DEFAULT;
+ TBM_TRACE("import bo(%p) ref(%d) fd(%d) flag(%s)in list\n",
+ bo, bo->ref_cnt, fd, tbm_flag_to_str(bo->flags));
+
LIST_INITHEAD(&bo->user_data_list);
LIST_ADD(&bo->item_link, &bufmgr->bo_list);
bufmgr = bo->bufmgr;
pthread_mutex_lock(&bufmgr->lock);
+
ret = bufmgr->backend->bo_export(bo);
if (!ret) {
_tbm_set_last_result(TBM_BO_ERROR_EXPORT_FAILED);
+ TBM_TRACE("error: bo(%p) tbm_key(%d)\n", bo, ret);
pthread_mutex_unlock(&bufmgr->lock);
return ret;
}
+
+ TBM_TRACE("bo(%p) tbm_key(%d)\n", bo, ret);
+
pthread_mutex_unlock(&bufmgr->lock);
return ret;
bufmgr = bo->bufmgr;
pthread_mutex_lock(&bufmgr->lock);
+
ret = bufmgr->backend->bo_export_fd(bo);
if (ret < 0) {
_tbm_set_last_result(TBM_BO_ERROR_EXPORT_FD_FAILED);
+ TBM_TRACE("error: bo(%p) tbm_fd(%d)\n", bo, ret);
pthread_mutex_unlock(&bufmgr->lock);
return ret;
}
+
+ TBM_TRACE("bo(%p) tbm_fd(%d)\n", bo, ret);
+
pthread_mutex_unlock(&bufmgr->lock);
return ret;
bufmgr = bo->bufmgr;
pthread_mutex_lock(&bufmgr->lock);
+
bo_handle = bufmgr->backend->bo_get_handle(bo, device);
if (bo_handle.ptr == NULL) {
_tbm_set_last_result(TBM_BO_ERROR_GET_HANDLE_FAILED);
+ TBM_TRACE("error: bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
pthread_mutex_unlock(&bufmgr->lock);
return (tbm_bo_handle) NULL;
}
+
+ TBM_TRACE("bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
+
pthread_mutex_unlock(&bufmgr->lock);
return bo_handle;
if (!_tbm_bo_lock(bo, device, opt)) {
_tbm_set_last_result(TBM_BO_ERROR_LOCK_FAILED);
- TBM_LOG_E("error fail to lock bo:%p)\n",
- bo);
+ TBM_TRACE("error: fail to lock bo:%p)\n", bo);
pthread_mutex_unlock(&bufmgr->lock);
return (tbm_bo_handle) NULL;
}
bo_handle = bufmgr->backend->bo_map(bo, device, opt);
if (bo_handle.ptr == NULL) {
_tbm_set_last_result(TBM_BO_ERROR_MAP_FAILED);
- TBM_LOG_E("error fail to map bo:%p\n",
- bo);
-
+ TBM_TRACE("error: fail to map bo:%p\n", bo);
_tbm_bo_unlock(bo);
pthread_mutex_unlock(&bufmgr->lock);
return (tbm_bo_handle) NULL;
/* increase the map_count */
bo->map_cnt++;
+ TBM_TRACE("bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
+
pthread_mutex_unlock(&bufmgr->lock);
return bo_handle;
ret = bufmgr->backend->bo_unmap(bo);
if (!ret) {
-
+ TBM_TRACE("error: bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
_tbm_set_last_result(TBM_BO_ERROR_UNMAP_FAILED);
pthread_mutex_unlock(&bufmgr->lock);
return ret;
/* decrease the map_count */
bo->map_cnt--;
+ TBM_TRACE("bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
+
_tbm_bo_unlock(bo);
pthread_mutex_unlock(&bufmgr->lock);
pthread_mutex_lock(&bo1->bufmgr->lock);
+ TBM_TRACE("before: bo1(%p) bo2(%p)\n", bo1, bo2);
+
if (bo1->bufmgr->backend->bo_size(bo1) != bo2->bufmgr->backend->bo_size(bo2)) {
_tbm_set_last_result(TBM_BO_ERROR_SWAP_FAILED);
- pthread_mutex_unlock(&bo1->bufmgr->lock);
+ TBM_TRACE("error: bo1(%p) bo2(%p)\n", bo1, bo2);
+ pthread_mutex_unlock(&bo1->bufmgr->lock);
return 0;
}
+ TBM_TRACE("after: bo1(%p) bo2(%p)\n", bo1, bo2);
+
temp = bo1->priv;
bo1->priv = bo2->priv;
bo2->priv = temp;
bufmgr = bo->bufmgr;
- if (bufmgr->lock_type == LOCK_TRY_NEVER)
+ if (bufmgr->lock_type == LOCK_TRY_NEVER) {
+ TBM_TRACE("bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
return 0;
+ }
pthread_mutex_lock(&bufmgr->lock);
+
if (bo->lock_cnt > 0) {
+ TBM_TRACE("error: bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
pthread_mutex_unlock(&bufmgr->lock);
return 1;
}
+ TBM_TRACE("bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
pthread_mutex_unlock(&bufmgr->lock);
return 0;
/* check if the data according to the key exist if so, return false. */
data = user_data_lookup(&bo->user_data_list, key);
if (data) {
- TBM_LOG_W("waring user data already exist. key:%ld\n",
- key);
+ TBM_TRACE("warning: user data already exist key(%ld)\n", key);
return 0;
}
data = user_data_create(key, data_free_func);
- if (!data)
+ if (!data) {
+ TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
return 0;
+ }
+
+ TBM_TRACE("bo(%p) key(%lu) data(%p)\n", bo, key, data->data);
LIST_ADD(&data->item_link, &bo->user_data_list);
tbm_user_data *old_data;
- if (LIST_IS_EMPTY(&bo->user_data_list))
+ if (LIST_IS_EMPTY(&bo->user_data_list)) {
+ TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
return 0;
+ }
old_data = user_data_lookup(&bo->user_data_list, key);
- if (!old_data)
+ if (!old_data) {
+ TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
return 0;
+ }
if (old_data->data && old_data->free_func)
old_data->free_func(old_data->data);
old_data->data = data;
+ TBM_TRACE("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
+
return 1;
}
tbm_user_data *old_data;
- if (!data || LIST_IS_EMPTY(&bo->user_data_list))
+ if (!data || LIST_IS_EMPTY(&bo->user_data_list)) {
+ TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
return 0;
+ }
old_data = user_data_lookup(&bo->user_data_list, key);
if (!old_data) {
+ TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
*data = NULL;
return 0;
}
*data = old_data->data;
+ TBM_TRACE("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
+
return 1;
}
tbm_user_data *old_data = (void *)0;
- if (LIST_IS_EMPTY(&bo->user_data_list))
+ if (LIST_IS_EMPTY(&bo->user_data_list)) {
+ TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
return 0;
+ }
old_data = user_data_lookup(&bo->user_data_list, key);
- if (!old_data)
+ if (!old_data) {
+ TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
return 0;
+ }
+
+ TBM_TRACE("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
user_data_delete(old_data);
if (bufmgr->backend->bo_import_fd && bufmgr->backend->bo_export_fd)
capability |= TBM_BUFMGR_CAPABILITY_SHARE_FD;
+ TBM_TRACE("tbm_bufmgr(%p) capability(%d)\n", bufmgr, capability);
+
return capability;
}
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
+ TBM_TRACE("bo(%p)\n", bo);
+
return bo->flags;
}
void
tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
{
+#ifdef TRACE
TBM_LOG_D("bufmgr=%p onoff=%d\n", bufmgr, onoff);
- TBM_LOG_D("Not implemented yet.\n");
+ bTrace = onoff;
+#endif
}
/* internal function */
pthread_mutex_lock(&bufmgr->lock);
if (!bufmgr->backend->bufmgr_bind_native_display) {
+ TBM_TRACE("error: tbm_bufmgr(%p) NativeDisplay(%p)\n", bufmgr, NativeDisplay);
pthread_mutex_unlock(&bufmgr->lock);
return 1;
}
ret = bufmgr->backend->bufmgr_bind_native_display(bufmgr, NativeDisplay);
if (!ret) {
+ TBM_TRACE("error: tbm_bufmgr(%p) NativeDisplay(%p)\n", bufmgr, NativeDisplay);
pthread_mutex_unlock(&bufmgr->lock);
return 0;
}
+ TBM_TRACE("tbm_bufmgr(%p) NativeDisplay(%p)\n", bufmgr, NativeDisplay);
+
pthread_mutex_unlock(&bufmgr->lock);
return 1;
#define DBG_LOCK(...)
#endif /* DEBUG */
+#define TRACE
+#ifdef TRACE
+extern int bTrace;
+#endif /* TRACE */
+
#ifdef HAVE_DLOG
#include <dlog.h>
fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__);\
} \
}
+
+#ifdef TRACE
+#define TBM_TRACE(fmt, ...) {\
+ if (bDlog) {\
+ if (bTrace&0x1) LOGE("[TBM:TRACE] " fmt, ##__VA_ARGS__);\
+ } \
+ else {\
+ if (bTrace&0x1) fprintf(stderr, "[TBM:TRACE(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
+ } \
+}
+#else
+#define TBM_TRACE(fmt, ...)
+#endif /* TRACE */
+
#else
#define TBM_LOG_D(fmt, ...) fprintf(stderr, "[TBM:D(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
#define TBM_LOG_I(fmt, ...) fprintf(stderr, "[TBM:I(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
#define TBM_LOG_W(fmt, ...) fprintf(stderr, "[TBM:W(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
#define TBM_LOG_E(fmt, ...) fprintf(stderr, "[TBM:E(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
#define TBM_DEBUG(fmt, ...) fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
+#ifdef TRACE
+#define TBM_TRACE(fmt, ...) { if (bTrace&0x1) fprintf(stderr, "[TBM:TRACE(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__); }
+#else
+#define TBM_TRACE(fmt, ...)
+#endif /* TRACE */
#endif /* HAVE_DLOG */
/* check condition */
int
tbm_surface_query_formats(uint32_t **formats, uint32_t *num)
{
+ TBM_TRACE("\n");
+
if (!tbm_surface_internal_query_supported_formats(formats, num))
return TBM_SURFACE_ERROR_INVALID_OPERATION;
tbm_surface_h
tbm_surface_create(int width, int height, tbm_format format)
{
+ TBM_TRACE("width(%d) height(%d)\n", width, height);
+
if (!(width > 0) || !(height > 0)) {
#ifdef HAVE_CAPI_0_1_1
set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER);
int
tbm_surface_destroy(tbm_surface_h surface)
{
+ TBM_TRACE("tbm_surface(%p)\n", surface);
+
if (!tbm_surface_internal_is_valid(surface))
return TBM_SURFACE_ERROR_INVALID_PARAMETER;
int
tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info)
{
+ TBM_TRACE("tbm_surface(%p)\n", surface);
+
TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
int
tbm_surface_unmap(tbm_surface_h surface)
{
+ TBM_TRACE("tbm_surface(%p)\n", surface);
+
TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
tbm_surface_internal_unmap(surface);
int
tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info)
{
+ TBM_TRACE("tbm_surface(%p)\n", surface);
+
TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
int
tbm_surface_get_width(tbm_surface_h surface)
{
+ TBM_TRACE("tbm_surface(%p)\n", surface);
+
TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
return tbm_surface_internal_get_width(surface);
int
tbm_surface_get_height(tbm_surface_h surface)
{
+ TBM_TRACE("tbm_surface(%p)\n", surface);
+
TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
return tbm_surface_internal_get_height(surface);
tbm_format
tbm_surface_get_format(tbm_surface_h surface)
{
+ TBM_TRACE("tbm_surface(%p)\n", surface);
+
if (!tbm_surface_internal_is_valid(surface)) {
#ifdef HAVE_CAPI_0_1_1
set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER);
{
tbm_surface_h old_data = NULL, tmp = NULL;
- if (surface == NULL || g_surface_bufmgr == NULL)
+ if (surface == NULL || g_surface_bufmgr == NULL) {
+ TBM_TRACE("error: tbm_surface(%p)\n", surface);
return 0;
+ }
if (!LIST_IS_EMPTY(&g_surface_bufmgr->surf_list)) {
LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &g_surface_bufmgr->surf_list, item_link) {
- if (old_data == surface)
+ if (old_data == surface) {
+ TBM_TRACE("tbm_surface(%p)\n", surface);
return 1;
+ }
}
}
+ TBM_TRACE("error: tbm_surface(%p)\n", surface);
return 0;
}
mgr = g_surface_bufmgr;
if (!mgr->backend->surface_supported_format) {
+ TBM_TRACE("error: tbm_bufmgr(%p)\n", g_surface_bufmgr);
_tbm_surface_mutex_unlock();
return 0;
}
ret = mgr->backend->surface_supported_format(formats, num);
+ TBM_TRACE("tbm_bufmgr(%p) format num(%d)\n", g_surface_bufmgr, *num);
+
_tbm_surface_mutex_unlock();
return ret;
break;
}
+ TBM_TRACE("tbm_format(%s) num_planes(%d)\n", _tbm_surface_internal_format_to_str(format), num_planes);
+
return num_planes;
}
int
tbm_surface_internal_get_bpp(tbm_format format)
{
+
int bpp = 0;
switch (format) {
break;
}
+ TBM_TRACE("tbm_format(%s) bpp(%d)\n", _tbm_surface_internal_format_to_str(format), bpp);
+
return bpp;
}
mgr = g_surface_bufmgr;
if (!TBM_BUFMGR_IS_VALID(mgr)) {
+ TBM_TRACE("error: width(%d) height(%d) format(%s) flags(%d)\n",
+ width, height, _tbm_surface_internal_format_to_str(format), flags);
_tbm_surface_mutex_unlock();
return NULL;
}
surf = calloc(1, sizeof(struct _tbm_surface));
if (!surf) {
+ TBM_TRACE("error: width(%d) height(%d) format(%s) flags(%d)\n",
+ width, height, _tbm_surface_internal_format_to_str(format), flags);
_tbm_surface_mutex_unlock();
return NULL;
}
}
+ TBM_TRACE("width(%d) height(%d) format(%s) flags(%d) tbm_surface(%p)\n", width, height,
+ _tbm_surface_internal_format_to_str(format), flags, surf);
+
LIST_INITHEAD(&surf->user_data_list);
LIST_ADD(&surf->item_link, &mgr->surf_list);
return surf;
alloc_fail:
+
+ TBM_TRACE("error: width(%d) height(%d) format(%s) flags(%d)\n",
+ width, height, _tbm_surface_internal_format_to_str(format), flags);
+
for (j = 0; j < i; j++) {
if (surf->bos[j])
tbm_bo_unref(surf->bos[j]);
mgr = g_surface_bufmgr;
if (!TBM_BUFMGR_IS_VALID(mgr)) {
+ TBM_TRACE("error: width(%d) height(%d) format(%s) bo_num(%d)\n",
+ info->width, info->height, _tbm_surface_internal_format_to_str(info->format), num);
_tbm_surface_mutex_unlock();
return NULL;
}
surf = calloc(1, sizeof(struct _tbm_surface));
if (!surf) {
+ TBM_TRACE("error: width(%d) height(%d) format(%s) bo_num(%d)\n",
+ info->width, info->height, _tbm_surface_internal_format_to_str(info->format), num);
_tbm_surface_mutex_unlock();
return NULL;
}
_tbm_bo_set_surface(bos[i], surf);
}
+ TBM_TRACE("tbm_surface(%p) width(%d) height(%d) format(%s) bo_num(%d)\n", surf,
+ info->width, info->height, _tbm_surface_internal_format_to_str(info->format), num);
+
LIST_INITHEAD(&surf->user_data_list);
LIST_ADD(&surf->item_link, &mgr->surf_list);
return surf;
bail1:
+ TBM_TRACE("error: width(%d) height(%d) format(%s) bo_num(%d)\n",
+ info->width, info->height, _tbm_surface_internal_format_to_str(info->format), num);
for (i = 0; i < num; i++) {
if (surf->bos[i]) {
tbm_bo_unref(surf->bos[i]);
surface->refcnt--;
if (surface->refcnt > 0) {
+ TBM_TRACE("reduce a refcnt(%d) of tbm_surface(%p)\n", surface->refcnt, surface);
_tbm_surface_mutex_unlock();
return;
}
+ TBM_TRACE("destroy tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
+
if (surface->refcnt == 0)
_tbm_surface_internal_destroy(surface);
surface->refcnt++;
+ TBM_TRACE("tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
+
_tbm_surface_mutex_unlock();
}
surface->refcnt--;
if (surface->refcnt > 0) {
+ TBM_TRACE("reduce a refcnt(%d) of tbm_surface(%p)\n", surface->refcnt, surface);
_tbm_surface_mutex_unlock();
return;
}
+ TBM_TRACE("destroy tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
+
if (surface->refcnt == 0)
_tbm_surface_internal_destroy(surface);
surf = (struct _tbm_surface *)surface;
num = surf->num_bos;
+ TBM_TRACE("tbm_surface(%p) num_bos(%d)\n", surface, num);
+
_tbm_surface_mutex_unlock();
return num;
surf = (struct _tbm_surface *)surface;
bo = surf->bos[bo_idx];
+ TBM_TRACE("tbm_surface(%p) bo_idx(%d) tbm_bo(%p)\n", surface, bo_idx, bo);
+
_tbm_surface_mutex_unlock();
return bo;
surf = (struct _tbm_surface *)surface;
size = surf->info.size;
+ TBM_TRACE("tbm_surface(%p) size(%d)\n", surface, size);
+
_tbm_surface_mutex_unlock();
return size;
surf = (struct _tbm_surface *)surface;
if (plane_idx >= surf->info.num_planes) {
+ TBM_TRACE("error: tbm_surface(%p) plane_idx(%d)\n", surface, plane_idx);
_tbm_surface_mutex_unlock();
return 0;
}
if (pitch)
*pitch = surf->info.planes[plane_idx].stride;
+ TBM_TRACE("tbm_surface(%p) plane_idx(%d) size(%d) offset(%d) pitch(%d)\n", surface, plane_idx,
+ surf->info.planes[plane_idx].size, surf->info.planes[plane_idx].offset,
+ surf->info.planes[plane_idx].stride);
+
_tbm_surface_mutex_unlock();
return 1;
for (j = 0; j < i; j++)
tbm_bo_unmap(surf->bos[j]);
+ TBM_TRACE("error: tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
_tbm_surface_mutex_unlock();
return 0;
}
surf->info.planes[i].offset;
}
+ TBM_TRACE("tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
+
_tbm_surface_mutex_unlock();
return 1;
for (i = 0; i < surf->num_bos; i++)
tbm_bo_unmap(surf->bos[i]);
+ TBM_TRACE("tbm_surface(%p)\n", surface);
+
_tbm_surface_mutex_unlock();
}
surf = (struct _tbm_surface *)surface;
width = surf->info.width;
+ TBM_TRACE("tbm_surface(%p) width(%d)\n", surface, width);
+
_tbm_surface_mutex_unlock();
return width;
surf = (struct _tbm_surface *)surface;
height = surf->info.height;
+ TBM_TRACE("tbm_surface(%p) height(%d)\n", surface, height);
+
_tbm_surface_mutex_unlock();
return height;
surf = (struct _tbm_surface *)surface;
format = surf->info.format;
+ TBM_TRACE("tbm_surface(%p) format(%s)\n", surface, _tbm_surface_internal_format_to_str(format));
+
_tbm_surface_mutex_unlock();
return format;
surf = (struct _tbm_surface *)surface;
bo_idx = surf->planes_bo_idx[plane_idx];
+ TBM_TRACE("tbm_surface(%p) plane_idx(%d) bo_idx(%d)\n", surface, plane_idx, bo_idx);
+
_tbm_surface_mutex_unlock();
return bo_idx;
/* check if the data according to the key exist if so, return false. */
data = user_data_lookup(&surface->user_data_list, key);
if (data) {
- TBM_LOG_W("waring user data already exist. key:%ld\n", key);
+ TBM_TRACE("warning: user data already exist tbm_surface(%p) key(%lu)\n", surface, key);
return 0;
}
data = user_data_create(key, data_free_func);
- if (!data)
+ if (!data) {
+ TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
return 0;
+ }
+
+ TBM_TRACE("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, data);
LIST_ADD(&data->item_link, &surface->user_data_list);
tbm_user_data *old_data;
- if (LIST_IS_EMPTY(&surface->user_data_list))
+ if (LIST_IS_EMPTY(&surface->user_data_list)) {
+ TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
return 0;
+ }
old_data = user_data_lookup(&surface->user_data_list, key);
- if (!old_data)
+ if (!old_data) {
+ TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
return 0;
+ }
if (old_data->data && old_data->free_func)
old_data->free_func(old_data->data);
old_data->data = data;
+ TBM_TRACE("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
+
return 1;
}
tbm_user_data *old_data;
- if (!data || LIST_IS_EMPTY(&surface->user_data_list))
+ if (!data || LIST_IS_EMPTY(&surface->user_data_list)) {
+ TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
return 0;
+ }
old_data = user_data_lookup(&surface->user_data_list, key);
if (!old_data) {
+ TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
*data = NULL;
return 0;
}
*data = old_data->data;
+ TBM_TRACE("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
+
return 1;
}
tbm_user_data *old_data = (void *)0;
- if (LIST_IS_EMPTY(&surface->user_data_list))
+ if (LIST_IS_EMPTY(&surface->user_data_list)) {
+ TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
return 0;
+ }
old_data = user_data_lookup(&surface->user_data_list, key);
- if (!old_data)
+ if (!old_data) {
+ TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
return 0;
+ }
+
+ TBM_TRACE("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
user_data_delete(old_data);
#define TBM_QUEUE_DEBUG 0
+#ifdef TRACE
+#define TBM_QUEUE_TRACE(fmt, ...) { if (bTrace&0x1) fprintf(stderr, "[TBM:TRACE(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__); }
+#else
+#define TBM_QUEUE_TRACE(fmt, ...)
+#endif /* TRACE */
+
#if TBM_QUEUE_DEBUG
-#define TBM_QUEUE_TRACE(fmt, ...) fprintf(stderr, "[TBM(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
#define TBM_LOCK() TBM_LOG_D("[LOCK] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
#define TBM_UNLOCK() TBM_LOG_D("[UNLOCK] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
#else
-#define TBM_QUEUE_TRACE(fmt, ...)
#define TBM_LOCK()
#define TBM_UNLOCK()
#endif