return TBM_SURFACE_ERROR_INVALID_OPERATION;
}
+#define MAX_BOS 4 // This value is came from bos[4] in struct _tbm_surface
+#define KEY_LEN 5 // "_XXXX"
+#define KEYS_LEN KEY_LEN * MAX_BOS
+
+static char *_tbm_surface_internal_get_keys(tbm_surface_h surface)
+{
+ char *keys, temp_key[KEY_LEN + 1];
+ struct _tbm_surface *surf;
+ int i, num_bos;
+ tbm_bo bo;
+
+ _tbm_surface_mutex_lock();
+
+ TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), NULL);
+
+ surf = (struct _tbm_surface *)surface;
+
+ num_bos = surf->num_bos;
+ if (num_bos > MAX_BOS)
+ num_bos = MAX_BOS;
+
+ keys = calloc(KEYS_LEN + 1, sizeof(char));
+ if (!keys) {
+ TBM_LOG_E("Failed to alloc memory");
+ _tbm_surface_mutex_unlock();
+ return NULL;
+ }
+
+ for (i = 0; i < num_bos; i++) {
+ memset(temp_key, 0x00, KEY_LEN + 1);
+ bo = surf->bos[i];
+ snprintf(temp_key, KEY_LEN, "_%d", tbm_bo_export(bo));
+ strncat(keys, temp_key, KEY_LEN);
+ }
+
+ _tbm_surface_mutex_unlock();
+
+ return keys;
+}
+
+static void _tbm_surface_internal_put_keys(char *keys)
+{
+ if (keys)
+ free(keys);
+}
+
void
tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type)
{
tbm_surface_info_s info;
tbm_bo_handle bo_handle;
const char *postfix;
+ char *keys;
int ret;
if (!g_dump_info)
else
postfix = dump_postfix[1];
+ keys = _tbm_surface_internal_get_keys(surface);
+ if (!keys) {
+ TBM_LOG_E("fail to get keys");
+ tbm_surface_unmap(surface);
+ return;
+ }
+
/* dump */
bo_handle = tbm_bo_map(buf_info->bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
if (!bo_handle.ptr) {
TBM_LOG_E("fail to map bo");
+ _tbm_surface_internal_put_keys(keys);
tbm_surface_unmap(surface);
return;
}
case TBM_FORMAT_ARGB8888:
case TBM_FORMAT_XRGB8888:
snprintf(buf_info->name, sizeof(buf_info->name),
- "%10.3f_%03d_%p-%s.%s",
+ "%10.3f_%03d%s_%p-%s.%s",
_tbm_surface_internal_get_time(),
- g_dump_info->count++, surface, type, postfix);
+ g_dump_info->count++, keys, surface, type, postfix);
if (scale_factor > 0.0) {
ret = _tbm_surface_internal_buffer_scale(info.planes[0].ptr,
if (ret != TBM_SURFACE_ERROR_NONE) {
TBM_LOG_E("fail to scale buffer");
tbm_bo_unmap(buf_info->bo);
+ _tbm_surface_internal_put_keys(keys);
tbm_surface_unmap(surface);
return;
}
case TBM_FORMAT_YVU420:
case TBM_FORMAT_YUV420:
snprintf(buf_info->name, sizeof(buf_info->name),
- "%10.3f_%03d-%s_%dx%d_%c%c%c%c.%s",
+ "%10.3f_%03d%s-%s_%dx%d_%c%c%c%c.%s",
_tbm_surface_internal_get_time(),
- g_dump_info->count++, type, info.planes[0].stride,
+ g_dump_info->count++, keys, type, info.planes[0].stride,
info.height, FOURCC_STR(info.format), postfix);
memcpy(bo_handle.ptr, info.planes[0].ptr, info.planes[0].stride * info.height);
bo_handle.ptr += info.planes[0].stride * info.height;
case TBM_FORMAT_NV12:
case TBM_FORMAT_NV21:
snprintf(buf_info->name, sizeof(buf_info->name),
- "%10.3f_%03d-%s_%dx%d_%c%c%c%c.%s",
+ "%10.3f_%03d%s-%s_%dx%d_%c%c%c%c.%s",
_tbm_surface_internal_get_time(),
- g_dump_info->count++, type, info.planes[0].stride,
+ g_dump_info->count++, keys, type, info.planes[0].stride,
info.height, FOURCC_STR(info.format), postfix);
memcpy(bo_handle.ptr, info.planes[0].ptr, info.planes[0].stride * info.height);
bo_handle.ptr += info.planes[0].stride * info.height;
case TBM_FORMAT_YUYV:
case TBM_FORMAT_UYVY:
snprintf(buf_info->name, sizeof(buf_info->name),
- "%10.3f_%03d-%s_%dx%d_%c%c%c%c.%s",
+ "%10.3f_%03d%s-%s_%dx%d_%c%c%c%c.%s",
_tbm_surface_internal_get_time(),
- g_dump_info->count++, type, info.planes[0].stride,
+ g_dump_info->count++, keys, type, info.planes[0].stride,
info.height, FOURCC_STR(info.format), postfix);
memcpy(bo_handle.ptr, info.planes[0].ptr, info.planes[0].stride * info.height);
break;
default:
TBM_LOG_E("can't copy %c%c%c%c buffer", FOURCC_STR(info.format));
tbm_bo_unmap(buf_info->bo);
+ _tbm_surface_internal_put_keys(keys);
tbm_surface_unmap(surface);
return;
}
tbm_bo_unmap(buf_info->bo);
+ _tbm_surface_internal_put_keys(keys);
+
tbm_surface_unmap(surface);
buf_info->dirty = 1;