map/unmap for dump 89/62489/1
authorBoram Park <boram1288.park@samsung.com>
Wed, 16 Mar 2016 08:12:33 +0000 (17:12 +0900)
committerBoram Park <boram1288.park@samsung.com>
Wed, 16 Mar 2016 10:03:13 +0000 (19:03 +0900)
Change-Id: Ib91a52e7c3dbb95db719da201efe8a0d34a3d999

src/tdm_helper.c

index dd57986..d4a0937 100644 (file)
@@ -110,13 +110,14 @@ EXTERN void
 tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
 {
        tbm_surface_info_s info;
-       int len;
+       int len, ret;
        const char *prefix;
 
        TDM_RETURN_IF_FAIL(buffer != NULL);
        TDM_RETURN_IF_FAIL(file != NULL);
 
-       tbm_surface_get_info(buffer, &info);
+       ret = tbm_surface_map(buffer, TBM_DEVICE_CPU, &info);
+       TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
 
        len = strnlen(file, 1024);
        if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888)
@@ -126,6 +127,7 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
 
        if (strncmp(file + (len - 3), prefix, 3)) {
                TDM_ERR("can't dump to '%s' file", file + (len - 3));
+               tbm_surface_unmap(buffer);
                return;
        }
 
@@ -163,8 +165,11 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
                break;
        default:
                TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR (info.format));
+               tbm_surface_unmap(buffer);
                return;
        }
 
+       tbm_surface_unmap(buffer);
+
        TDM_INFO("dump %s", file);
 }