diff options
author | Junkyeong Kim <jk0430.kim@samsung.com> | 2016-05-16 12:36:01 +0900 |
---|---|---|
committer | Junkyeong Kim <jk0430.kim@samsung.com> | 2016-05-16 16:23:31 +0900 |
commit | 9badccfefed3346631c9017cd44e041e63e98de9 (patch) | |
tree | 2ab12d7bc0fb07736d9fb3c80ad3d070b82d685a | |
parent | afbfef586e8a3ffd54f43c919cb5651c0d9d27cb (diff) | |
download | libtbm-9badccfefed3346631c9017cd44e041e63e98de9.tar.gz libtbm-9badccfefed3346631c9017cd44e041e63e98de9.tar.bz2 libtbm-9badccfefed3346631c9017cd44e041e63e98de9.zip |
add shm buffer dump APIsubmit/tizen/20160516.074649accepted/tizen/wearable/20160517.032227accepted/tizen/tv/20160517.032133accepted/tizen/mobile/20160517.032125accepted/tizen/ivi/20160517.032145accepted/tizen/common/20160517.173839
Change-Id: Ib47f3a727c9694c1230a2b4dee452efdb8de6e77
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
-rw-r--r-- | src/tbm_surface_internal.c | 77 | ||||
-rw-r--r-- | src/tbm_surface_internal.h | 14 |
2 files changed, 88 insertions, 3 deletions
diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index f1a94b3..4f79c10 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -1153,6 +1153,9 @@ struct _tbm_surface_dump_buf_info tbm_bo bo; int size; int dirty; + int dirty_shm; + int shm_stride; + int shm_h; char name[1024]; tbm_surface_info_s info; @@ -1368,8 +1371,9 @@ tbm_surface_internal_dump_end(void) /* make files */ if (!LIST_IS_EMPTY(&g_dump_info->surface_list)) { LIST_FOR_EACH_ENTRY_SAFE(buf_info, tmp, &g_dump_info->surface_list, link) { + char file[2048]; + if (buf_info->dirty) { - char file[2048]; void *ptr1 = NULL; void *ptr2 = NULL; @@ -1384,7 +1388,7 @@ tbm_surface_internal_dump_end(void) case TBM_FORMAT_ARGB8888: case TBM_FORMAT_XRGB8888: _tbm_surface_internal_dump_file_png(file, bo_handle.ptr, - buf_info->info.planes[0].stride >> 2, buf_info->info.height); + buf_info->info.planes[0].stride >> 2, buf_info->info.height); break; case TBM_FORMAT_YVU420: case TBM_FORMAT_YUV420: @@ -1419,6 +1423,18 @@ tbm_surface_internal_dump_end(void) } tbm_bo_unmap(buf_info->bo); + } else if (buf_info->dirty_shm) { + bo_handle = tbm_bo_map(buf_info->bo, TBM_DEVICE_CPU, TBM_OPTION_READ); + if (bo_handle.ptr == NULL) + continue; + + snprintf(file, sizeof(file), "%s/%s", g_dump_info->path, buf_info->name); + TBM_LOG("Dump File.. %s generated.\n", file); + + _tbm_surface_internal_dump_file_png(file, bo_handle.ptr, + buf_info->shm_stride >> 2, buf_info->shm_h); + + tbm_bo_unmap(buf_info->bo); } } } @@ -1528,6 +1544,63 @@ tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type) tbm_surface_unmap(surface); buf_info->dirty = 1; + buf_info->dirty_shm = 0; + + if (g_dump_info->count == 1000) + g_dump_info->count = 0; + + g_dump_info->link = next_link; + + TBM_LOG("Dump %s \n", buf_info->name); +} + +void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int stride, const char *type) +{ + TBM_RETURN_IF_FAIL(ptr != NULL); + TBM_RETURN_IF_FAIL(w > 0); + TBM_RETURN_IF_FAIL(h > 0); + TBM_RETURN_IF_FAIL(stride > 0); + TBM_RETURN_IF_FAIL(type != NULL); + + tbm_surface_dump_buf_info *buf_info; + struct list_head *next_link; + tbm_bo_handle bo_handle; + + if (!g_dump_info) + return; + + next_link = g_dump_info->link->next; + TBM_RETURN_IF_FAIL(next_link != NULL); + + if (next_link == &g_dump_info->surface_list) { + next_link = next_link->next; + TBM_RETURN_IF_FAIL(next_link != NULL); + } + + buf_info = LIST_ENTRY(tbm_surface_dump_buf_info, next_link, link); + TBM_RETURN_IF_FAIL(buf_info != NULL); + + if (stride * h > buf_info->size) { + TBM_LOG("Dump skip. shm buffer over created buffer size(%d, %d)\n", stride * h, buf_info->size); + return; + } + + /* dump */ + bo_handle = tbm_bo_map(buf_info->bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE); + TBM_RETURN_IF_FAIL(bo_handle.ptr != NULL); + memset(bo_handle.ptr, 0x00, buf_info->size); + memset(&buf_info->info, 0x00, sizeof(tbm_surface_info_s)); + + + snprintf(buf_info->name, sizeof(buf_info->name), "%03d-%s.%s", g_dump_info->count++, type, dump_postfix[0]); + memcpy(bo_handle.ptr, ptr, stride * h); + + tbm_bo_unmap(buf_info->bo); + + buf_info->dirty = 0; + buf_info->dirty_shm = 1; + buf_info->shm_stride = stride; + buf_info->shm_h = h; if (g_dump_info->count == 1000) g_dump_info->count = 0; diff --git a/src/tbm_surface_internal.h b/src/tbm_surface_internal.h index fbda74a..6240494 100644 --- a/src/tbm_surface_internal.h +++ b/src/tbm_surface_internal.h @@ -430,11 +430,23 @@ void tbm_surface_internal_dump_end(void); * The filename extension should be "png" for TBM_FORMAT_ARGB8888 and TBM_FORMAT_XRGB8888 * or "yuv" for YUV formats. * @param[in] surface : a tbm surface - * @param[in] type : a string used by a file name. + * @param[in] type : a string used by a file name */ void tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type); /** + * @brief Dump a shared memory buffer + * @details + * This function supports shared memory buffer dump. + * @param[in] ptr : a pointer of dump buffer + * @param[in] w : a width of dump buffer + * @param[in] h : a height of dump buffer + * @param[in] stride : a stride of dump buffer + * @param[in] type : a string used by a file name + */ +void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int stride, const char *type); + +/** * @brief check valid tbm surface. * @since_tizen 3.0 * @param[in] surface : the tbm surface. |