tbm_surface_internal: remove padding area of buffer in capture 09/226709/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Wed, 26 Feb 2020 10:10:57 +0000 (19:10 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 5 Mar 2020 04:26:38 +0000 (13:26 +0900)
Change-Id: Ia042ab4b9a6f6bc8f761ce1b589799826e512af4

src/tbm_surface_internal.c

index 50ae206..493f507 100644 (file)
@@ -1767,7 +1767,7 @@ _tbm_surface_internal_dump_file_raw(const char *file, void *data1, int size1,
 }
 
 static void
-_tbm_surface_internal_dump_file_png(const char *file, const void *data, int width, int height, int format)
+_tbm_surface_internal_dump_file_png(const char *file, const void *data, int width, int height, int stride, int format)
 {
        unsigned int *blocks = (unsigned int *)data;
        FILE *fp;
@@ -1856,7 +1856,7 @@ _tbm_surface_internal_dump_file_png(const char *file, const void *data, int widt
                row_pointers[y] = (png_bytep)row;
 
                for (x = 0; x < width; ++x) {
-                       unsigned int curBlock = blocks[y * width + x];
+                       unsigned int curBlock = blocks[(y * (stride >> 2)) + x];
 
                        if (pixel_size == 3) { // XRGB8888
                                row[x * pixel_size] = (curBlock & 0xFF);
@@ -2027,12 +2027,16 @@ tbm_surface_internal_dump_end(void)
                        case TBM_FORMAT_ARGB8888:
                                _tbm_surface_internal_dump_file_png(file, bo_handle.ptr,
                                                        buf_info->info.planes[0].stride >> 2,
-                                                       buf_info->info.height, TBM_FORMAT_ARGB8888);
+                                                       buf_info->info.height,
+                                                       buf_info->info.planes[0].stride,
+                                                       TBM_FORMAT_ARGB8888);
                                break;
                        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, TBM_FORMAT_XRGB8888);
+                                                       buf_info->info.height,
+                                                       buf_info->info.planes[0].stride,
+                                                       TBM_FORMAT_XRGB8888);
                                break;
                        case TBM_FORMAT_YVU420:
                        case TBM_FORMAT_YUV420:
@@ -2067,7 +2071,8 @@ tbm_surface_internal_dump_end(void)
                } else if (buf_info->dirty_shm)
                        _tbm_surface_internal_dump_file_png(file, bo_handle.ptr,
                                                        buf_info->shm_stride >> 2,
-                                                       buf_info->shm_h, 0);
+                                                       buf_info->shm_h,
+                                                       buf_info->shm_stride, 0);
 
                tbm_bo_unmap(buf_info->bo);
                tbm_bo_unref(buf_info->bo);
@@ -2503,13 +2508,17 @@ tbm_surface_internal_capture_buffer(tbm_surface_h surface, const char *path, con
        switch (info.format) {
        case TBM_FORMAT_ARGB8888:
                _tbm_surface_internal_dump_file_png(file, info.planes[0].ptr,
-                                                       info.planes[0].stride >> 2,
-                                                       info.height, TBM_FORMAT_ARGB8888);
+                                                       info.width,
+                                                       info.height,
+                                                       info.planes[0].stride,
+                                                       TBM_FORMAT_ARGB8888);
                break;
        case TBM_FORMAT_XRGB8888:
                _tbm_surface_internal_dump_file_png(file, info.planes[0].ptr,
-                                                       info.planes[0].stride >> 2,
-                                                       info.height, TBM_FORMAT_XRGB8888);
+                                                       info.width,
+                                                       info.height,
+                                                       info.planes[0].stride,
+                                                       TBM_FORMAT_XRGB8888);
                break;
        case TBM_FORMAT_YVU420:
        case TBM_FORMAT_YUV420:
@@ -2572,7 +2581,7 @@ tbm_surface_internal_capture_shm_buffer(void *ptr, int w, int h, int stride,
                return 0;
        }
 
-       _tbm_surface_internal_dump_file_png(file, ptr, w, h, 0);
+       _tbm_surface_internal_dump_file_png(file, ptr, w, h, stride, 0);
 
        TBM_TRACE_SURFACE_INTERNAL("Capture %s \n", file);