Add function for supporting tbm surface multiple bo 80/43780/1 accepted/tizen/mobile/20150715.003248 accepted/tizen/tv/20150715.003255 accepted/tizen/wearable/20150715.003304 submit/tizen/20150714.075906
authorChangyeon Lee <cyeon.lee@samsung.com>
Fri, 10 Jul 2015 05:23:25 +0000 (14:23 +0900)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Mon, 13 Jul 2015 12:06:01 +0000 (21:06 +0900)
Change-Id: Id054e0f4d5b05f9d43d902bdebab86e36459bedb
Signed-off-by: Changyeon Lee <cyeon.lee@samsung.com>
src/tbm_bufmgr_emulator.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index e8b111f..a9c28c7
@@ -285,11 +285,12 @@ static int tbm_bufmgr_emulator_bo_get_global_key(tbm_bo bo)
     return sfc->gem.name;
 }
 
-static int tbm_bufmgr_emulator_surface_get_plane_data(tbm_surface_h surface, int width, int height, tbm_format format, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch)
+static int tbm_bufmgr_emulator_surface_get_plane_data(tbm_surface_h surface, int width, int height, tbm_format format, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx)
 {
     *size = 0;
     *offset = 0;
     *pitch = 0;
+    *bo_idx = 0;
 
     switch(format) {
     case TBM_FORMAT_XRGB8888:
@@ -297,16 +298,19 @@ static int tbm_bufmgr_emulator_surface_get_plane_data(tbm_surface_h surface, int
         *size = width * height * 4;
         *offset = 0;
         *pitch = width * 4;
+        *bo_idx = 0;
         return 1;
     case TBM_FORMAT_NV21:
         if (plane_idx == 0) {
             *size = width * height;
             *offset = 0;
             *pitch = width;
+            *bo_idx = 0;
         } else if (plane_idx == 1) {
             *size = width * (height >> 1);
             *offset = width * height;
             *pitch = width;
+            *bo_idx = 0;
         } else {
             return 0;
         }
@@ -316,10 +320,12 @@ static int tbm_bufmgr_emulator_surface_get_plane_data(tbm_surface_h surface, int
             *size = width * height;
             *offset = 0;
             *pitch = width;
+            *bo_idx = 0;
         } else if (plane_idx == 1) {
             *size = width * height;
             *offset = width * height;
             *pitch = width;
+            *bo_idx = 0;
         } else {
             return 0;
         }
@@ -329,14 +335,17 @@ static int tbm_bufmgr_emulator_surface_get_plane_data(tbm_surface_h surface, int
             *size = width * height;
             *offset = 0;
             *pitch = width;
+            *bo_idx = 0;
         } else if (plane_idx == 1) {
             *size = (width * height) >> 2;
             *offset = width * height;
             *pitch = width >> 1 ;
+            *bo_idx = 0;
         } else if (plane_idx == 2) {
             *size = (width * height) >> 2;
             *offset = (width * height) + (width  * height >> 2);
             *pitch = width >> 1;
+            *bo_idx = 0;
         } else {
             return 0;
         }
@@ -371,6 +380,27 @@ static int tbm_bufmgr_emulator_surface_get_size(tbm_surface_h surface, int width
     return (width * height * bpp) >> 3;
 }
 
+static int tbm_bufmgr_emulator_surface_get_num_bos (tbm_format format)
+{
+    int num = 0;
+
+    switch(format) {
+    case TBM_FORMAT_XRGB8888:
+    case TBM_FORMAT_ARGB8888:
+    /* NV21 : Y/CrCb 4:2:0 */
+    /* YUV420 : YUV 4:2:0 */
+    case TBM_FORMAT_NV21:
+    case TBM_FORMAT_YUV420:
+    /* NV61 : Y/CrCb 4:2:2 */
+    case TBM_FORMAT_NV61:
+        num = 1;
+        break;
+    default:
+        return 0;
+    }
+    return num;
+}
+
 static int tbm_bufmgr_emulator_surface_supported_format(uint32_t **formats, uint32_t *num)
 {
     uint32_t *color_formats;
@@ -447,6 +477,7 @@ int tbm_bufmgr_emulator_init(tbm_bufmgr bufmgr, int fd)
     backend->surface_get_plane_data = tbm_bufmgr_emulator_surface_get_plane_data;
     backend->surface_get_size = tbm_bufmgr_emulator_surface_get_size;
     backend->surface_supported_format = tbm_bufmgr_emulator_surface_supported_format;
+    backend->surface_get_num_bos = tbm_bufmgr_emulator_surface_get_num_bos;
 
     if (!tbm_backend_init(bufmgr, backend)) {
         TBM_EMULATOR_LOG_ERROR("tbm_backend_init failed");