Delete tpl_format_t and replace with tbm_format. 92/59292/1
authorjoonbum.ko <joonbum.ko@samsung.com>
Thu, 11 Feb 2016 00:39:33 +0000 (09:39 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Thu, 11 Feb 2016 00:39:33 +0000 (09:39 +0900)
Change-Id: Ia5925408225262af23781e4862a40edac2e38b01

src/tpl.c
src/tpl.h
src/tpl_gbm.c
src/tpl_internal.h
src/tpl_surface.c
src/tpl_tbm.c
src/tpl_wayland.c

index 903f439..3251324 100644 (file)
--- a/src/tpl.c
+++ b/src/tpl.c
@@ -328,14 +328,14 @@ __tpl_surface_init_backend(tpl_surface_t *surface, tpl_backend_type_t type)
 
 tpl_bool_t
 tpl_get_native_window_info(tpl_display_t *display, tpl_handle_t window,
-                          int *width, int *height, tpl_format_t *format, int depth, int a_size)
+                          int *width, int *height, tbm_format *format, int depth, int a_size)
 {
        return display->backend.get_window_info(display, window, width, height, format, depth, a_size);
 }
 
 tpl_bool_t
 tpl_get_native_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
-                          int *width, int *height, tpl_format_t *format)
+                          int *width, int *height, tbm_format *format)
 {
        return display->backend.get_pixmap_info(display, pixmap, width, height, format);
 }
index 07047a1..94ce400 100644 (file)
--- a/src/tpl.h
+++ b/src/tpl.h
@@ -156,47 +156,6 @@ typedef enum
 } tpl_surface_type_t;
 
 /**
- * Format types.
- *
- * TPL specifies several supportable formats. This can be used to specify the
- * format of a new surface. Each format explains its own depth, color sequence
- * and color bits. and they are enough attributes to convert to the other
- * formats (such as GPU drivers, Windowing systems, Buffer managers).
- *
- * @see tpl_surface_create()
- */
-typedef enum
-{
-       TPL_FORMAT_INVALID = 0,
-       TPL_FORMAT_NOT_YET_SPECIFIED = 1,
-       TPL_FORMAT_BGR565,
-       TPL_FORMAT_RGB565 = 16 + (0 << 8),
-       TPL_FORMAT_XBGR8888,
-       TPL_FORMAT_XRGB8888 = 32 + (0 << 8),
-       TPL_FORMAT_ABGR8888,
-       TPL_FORMAT_ARGB8888 = 32 + (1 << 8),
-       TPL_FORMAT_BGRA8888,
-       TPL_FORMAT_RGBA8888,
-       TPL_FORMAT_BGRX8888,
-       TPL_FORMAT_RGBX8888,
-       TPL_FORMAT_BGR888,
-       TPL_FORMAT_RGB888,
-       TPL_FORMAT_ABGR4444,
-       TPL_FORMAT_ARGB4444,
-       TPL_FORMAT_BGRA4444,
-       TPL_FORMAT_RGBA4444,
-       TPL_FORMAT_ABGR1555,
-       TPL_FORMAT_ARGB1555,
-       TPL_FORMAT_BGRA5551,
-       TPL_FORMAT_RGBA5551,
-       TPL_FORMAT_YUV420,
-       TPL_FORMAT_NV12,
-       TPL_FORMAT_NV21
-} tpl_format_t;
-
-#define TPL_FORMAT_GET_DEPTH(format) (int)((format) & 0xFF)
-
-/**
  * Lock usage types.
  *
  * TPL provides buffer locks which are used for synchronization. This usage
@@ -443,7 +402,7 @@ void tpl_display_flush(tpl_display_t *display);
 tpl_surface_t * tpl_surface_create(tpl_display_t *display,
                                   tpl_handle_t handle,
                                   tpl_surface_type_t type,
-                                  tpl_format_t format);
+                                  tbm_format format);
 
 /**
  * Get the TPL display where the given TPL surface was created from.
@@ -629,7 +588,7 @@ tpl_bool_t tpl_get_native_window_info(tpl_display_t *display,
                                      tpl_handle_t window,
                                      int *width,
                                      int *height,
-                                     tpl_format_t *format,
+                                     tbm_format *format,
                                      int depth,
                                      int a_size);
 
@@ -647,7 +606,7 @@ tpl_bool_t tpl_get_native_pixmap_info(tpl_display_t *display,
                                      tpl_handle_t pixmap,
                                      int *width,
                                      int *height,
-                                     tpl_format_t *format);
+                                     tbm_format *format);
 
 void tpl_display_wait_native(tpl_display_t *display);
 
index ef500ee..c9e382b 100644 (file)
@@ -160,8 +160,8 @@ __tpl_gbm_display_query_config(tpl_display_t *display, tpl_surface_type_t surfac
                if (alpha_size == 8)
                {
                        if (gbm_device_is_format_supported((struct gbm_device *)display->native_handle,
-                                                                                               GBM_FORMAT_ARGB8888,
-                                                                                               GBM_BO_USE_RENDERING) == 1)
+                                               GBM_FORMAT_ARGB8888,
+                                               GBM_BO_USE_RENDERING) == 1)
                        {
                                if (native_visual_id != NULL) *native_visual_id = GBM_FORMAT_ARGB8888;
                        }
@@ -174,8 +174,8 @@ __tpl_gbm_display_query_config(tpl_display_t *display, tpl_surface_type_t surfac
                if (alpha_size == 0)
                {
                        if (gbm_device_is_format_supported((struct gbm_device *)display->native_handle,
-                                                                                               GBM_FORMAT_XRGB8888,
-                                                                                               GBM_BO_USE_RENDERING) == 1)
+                                               GBM_FORMAT_XRGB8888,
+                                               GBM_BO_USE_RENDERING) == 1)
                        {
                                if (native_visual_id != NULL) *native_visual_id = GBM_FORMAT_XRGB8888;
                        }
@@ -207,7 +207,7 @@ __tpl_gbm_display_filter_config(tpl_display_t *display,
 
 static tpl_bool_t
 __tpl_gbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
-                                     int *width, int *height, tpl_format_t *format, int depth, int a_size)
+                                     int *width, int *height, tbm_format *format, int depth, int a_size)
 {
        TPL_ASSERT(display);
        TPL_ASSERT(window);
@@ -215,26 +215,16 @@ __tpl_gbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
        struct gbm_surface *gbm_surface = (struct gbm_surface *)window;
        tbm_surface_queue_h surf_queue = (tbm_surface_queue_h)gbm_tbm_get_surface_queue(gbm_surface);
 
-       if (format != NULL)
-       {
-               switch (tbm_surface_queue_get_format(surf_queue))
-               {
-                       case TBM_FORMAT_ARGB8888: *format = TPL_FORMAT_ARGB8888; break;
-                       case TBM_FORMAT_XRGB8888: *format = TPL_FORMAT_XRGB8888; break;
-                       case TBM_FORMAT_RGB565: *format = TPL_FORMAT_RGB565; break;
-                       default: *format = TPL_FORMAT_INVALID; break;
-               }
-       }
        if (width != NULL) *width = tbm_surface_queue_get_width(surf_queue);
        if (height != NULL) *height = tbm_surface_queue_get_height(surf_queue);
-       return TPL_TRUE;
+       if (format != NULL) *format = tbm_surface_queue_get_format(surf_queue);
 
-       return TPL_FALSE;
+       return TPL_TRUE;
 }
 
 static tpl_bool_t
 __tpl_gbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
-                                     int *width, int *height, tpl_format_t *format)
+                                     int *width, int *height, tbm_format *format)
 {
        tbm_surface_h   tbm_surface = NULL;
        int             tbm_format = -1;
@@ -245,19 +235,7 @@ __tpl_gbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
 
        if (width) *width = tbm_surface_get_width(tbm_surface);
        if (height) *height = tbm_surface_get_height(tbm_surface);
-       if (format)
-       {
-               tbm_format = tbm_surface_get_format(tbm_surface);
-               switch(tbm_format)
-               {
-                       case TBM_FORMAT_ARGB8888: *format = TPL_FORMAT_ARGB8888; break;
-                       case TBM_FORMAT_XRGB8888: *format = TPL_FORMAT_XRGB8888; break;
-                       case TBM_FORMAT_RGB565: *format = TPL_FORMAT_RGB565; break;
-                       default:
-                               *format = TPL_FORMAT_INVALID;
-                               return TPL_FALSE;
-               }
-       }
+       if (format) *format = tbm_surface_get_format(tbm_surface);
 
        return TPL_TRUE;
 }
@@ -361,46 +339,6 @@ __tpl_gbm_surface_validate(tpl_surface_t *surface)
        return TPL_TRUE;
 }
 
-static int
-__tpl_gbm_get_depth_from_format(tpl_format_t format)
-{
-       int depth = 0;
-
-       switch(format)
-       {
-               case TPL_FORMAT_BGR565:
-               case TPL_FORMAT_RGB565:
-               case TPL_FORMAT_ABGR4444:
-               case TPL_FORMAT_ARGB4444:
-               case TPL_FORMAT_BGRA4444:
-               case TPL_FORMAT_RGBA4444:
-               case TPL_FORMAT_ABGR1555:
-               case TPL_FORMAT_ARGB1555:
-               case TPL_FORMAT_BGRA5551:
-               case TPL_FORMAT_RGBA5551:
-                       depth = 16;
-                       break;
-               case TPL_FORMAT_ABGR8888:
-               case TPL_FORMAT_ARGB8888:
-               case TPL_FORMAT_BGRA8888:
-               case TPL_FORMAT_RGBA8888:
-               case TPL_FORMAT_XBGR8888:
-               case TPL_FORMAT_XRGB8888:
-               case TPL_FORMAT_BGRX8888:
-               case TPL_FORMAT_RGBX8888:
-                       depth = 32;
-                       break;
-               case TPL_FORMAT_BGR888:
-               case TPL_FORMAT_RGB888:
-                       depth = 24;
-                       break;
-               default:
-                       depth = 32;
-       }
-
-       return depth;
-}
-
 static tbm_surface_h
 __tpl_gbm_surface_create_buffer_from_gbm_surface(tpl_surface_t *surface, tpl_bool_t *reset_buffers)
 {
index fcc4d91..d003048 100644 (file)
@@ -42,9 +42,9 @@ struct _tpl_display_backend
        tpl_bool_t              (*filter_config)(tpl_display_t *display, int *visual_id, int alpha_bits);
 
        tpl_bool_t              (*get_window_info)(tpl_display_t *display, tpl_handle_t window,
-                                                  int *width, int *height, tpl_format_t *format, int depth,int a_size);
+                                                  int *width, int *height, tbm_format *format, int depth,int a_size);
        tpl_bool_t              (*get_pixmap_info)(tpl_display_t *display, tpl_handle_t pixmap,
-                                                  int *width, int *height, tpl_format_t *format);
+                                                  int *width, int *height, tbm_format *format);
 
        void                    (*flush)(tpl_display_t *display);
        void                    (*wait_native)(tpl_display_t *display);
@@ -100,7 +100,7 @@ struct _tpl_surface
        tpl_display_t                   *display;
        tpl_handle_t                    native_handle;
        tpl_surface_type_t              type;
-       tpl_format_t                    format;
+       tbm_format                      format;
        int                             width, height;
 
        int                             post_interval;
index 6a2460c..e89e29a 100644 (file)
@@ -20,7 +20,7 @@ __tpl_surface_free(void *data)
 }
 
 tpl_surface_t *
-tpl_surface_create(tpl_display_t *display, tpl_handle_t handle, tpl_surface_type_t type, tpl_format_t format)
+tpl_surface_create(tpl_display_t *display, tpl_handle_t handle, tpl_surface_type_t type, tbm_format format)
 {
        tpl_surface_t *surface;
 
index 24a15d0..3219cf1 100644 (file)
@@ -22,21 +22,6 @@ struct _tpl_tbm_surface
        int dummy;
 };
 
-static inline tpl_format_t
-__tpl_tbm_get_tpl_format(tbm_format format)
-{
-       tpl_format_t ret;
-       switch (format)
-       {
-               case TBM_FORMAT_ARGB8888: ret = TPL_FORMAT_ARGB8888; break;
-               case TBM_FORMAT_XRGB8888: ret = TPL_FORMAT_XRGB8888; break;
-               case TBM_FORMAT_RGB565: ret = TPL_FORMAT_RGB565; break;
-               default: ret = TPL_FORMAT_INVALID; break;
-       }
-
-       return ret;
-}
-
 static tpl_bool_t
 __tpl_tbm_display_init(tpl_display_t *display)
 {
@@ -131,7 +116,7 @@ __tpl_tbm_display_filter_config(tpl_display_t *display,
 
 static tpl_bool_t
 __tpl_tbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
-                                         int *width, int *height, tpl_format_t *format, int depth, int a_size)
+                                         int *width, int *height, tbm_format *format, int depth, int a_size)
 {
        TPL_ASSERT(display);
        TPL_ASSERT(window);
@@ -143,14 +128,14 @@ __tpl_tbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
        if (height != NULL)
                *height = tbm_surface_queue_get_height(surf_queue);
        if (format != NULL)
-               *format = __tpl_tbm_get_tpl_format(tbm_surface_queue_get_format(surf_queue));
+               *format = tbm_surface_queue_get_format(surf_queue);
 
        return TPL_TRUE;
 }
 
 static tpl_bool_t
 __tpl_tbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
-                                         int *width, int *height, tpl_format_t *format)
+                                         int *width, int *height, tbm_format *format)
 {
        tbm_surface_h   tbm_surface = NULL;
 
@@ -163,7 +148,7 @@ __tpl_tbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
        if (height)
                *height = tbm_surface_get_height(tbm_surface);
        if (format)
-               *format = __tpl_tbm_get_tpl_format(tbm_surface_get_format(tbm_surface));
+               *format = tbm_surface_get_format(tbm_surface);
 
        return TPL_TRUE;
 }
index 15cd708..d3f4bc7 100644 (file)
@@ -246,7 +246,7 @@ __tpl_wayland_display_filter_config(tpl_display_t *display, int *visual_id, int
 
 static tpl_bool_t
 __tpl_wayland_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
-               int *width, int *height, tpl_format_t *format, int depth, int a_size)
+               int *width, int *height, tbm_format *format, int depth, int a_size)
 {
        TPL_ASSERT(display);
        TPL_ASSERT(window);
@@ -264,9 +264,9 @@ __tpl_wayland_display_get_window_info(tpl_display_t *display, tpl_handle_t windo
                else
                {
                        if (a_size == 8)
-                               *format = TPL_FORMAT_ARGB8888;
+                               *format = TBM_FORMAT_ARGB8888;
                        else if (a_size == 0)
-                               *format = TPL_FORMAT_XRGB8888;
+                               *format = TBM_FORMAT_XRGB8888;
                }
        }
        if (width != NULL) *width = wl_egl_window->width;
@@ -290,7 +290,6 @@ static tpl_bool_t
 __tpl_wayland_surface_init(tpl_surface_t *surface)
 {
        tpl_wayland_surface_t *wayland_surface = NULL;
-       int tbm_format;
        struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)surface->native_handle;
 
 
@@ -307,24 +306,11 @@ __tpl_wayland_surface_init(tpl_surface_t *surface)
        wayland_surface->resized = TPL_FALSE;
        wayland_surface->current_buffer = NULL;
 
-       switch (surface->format)
-       {
-       case TPL_FORMAT_ARGB8888: tbm_format = TBM_FORMAT_ARGB8888;
-               break;
-       case TPL_FORMAT_XRGB8888: tbm_format = TBM_FORMAT_XRGB8888;
-               break;
-       case TPL_FORMAT_RGB565: tbm_format = TBM_FORMAT_RGB565;
-               break;
-       default:
-               TPL_ERR("Unsupported format found in surface!");
-               return TPL_FALSE;
-       }
-
        wayland_surface->tbm_queue = tbm_surface_queue_create(
                        CLIENT_QUEUE_SIZE,
                        wl_egl_window->width,
                        wl_egl_window->height,
-                       tbm_format,
+                       surface->format,
                        0);
        TPL_LOG(9, "tbm_surface_queue_create!! || wl_egl_window(%p)| tbm_queue(%p)",
                        wl_egl_window, wayland_surface->tbm_queue);
@@ -490,46 +476,6 @@ __tpl_wayland_surface_validate(tpl_surface_t *surface)
        return TPL_TRUE;
 }
 
-static int
-__tpl_wayland_get_depth_from_format(tpl_format_t format)
-{
-       int depth = 0;
-
-       switch(format)
-       {
-               case TPL_FORMAT_BGR565:
-               case TPL_FORMAT_RGB565:
-               case TPL_FORMAT_ABGR4444:
-               case TPL_FORMAT_ARGB4444:
-               case TPL_FORMAT_BGRA4444:
-               case TPL_FORMAT_RGBA4444:
-               case TPL_FORMAT_ABGR1555:
-               case TPL_FORMAT_ARGB1555:
-               case TPL_FORMAT_BGRA5551:
-               case TPL_FORMAT_RGBA5551:
-                       depth = 16;
-                       break;
-               case TPL_FORMAT_ABGR8888:
-               case TPL_FORMAT_ARGB8888:
-               case TPL_FORMAT_BGRA8888:
-               case TPL_FORMAT_RGBA8888:
-               case TPL_FORMAT_XBGR8888:
-               case TPL_FORMAT_XRGB8888:
-               case TPL_FORMAT_BGRX8888:
-               case TPL_FORMAT_RGBX8888:
-                       depth = 32;
-                       break;
-               case TPL_FORMAT_BGR888:
-               case TPL_FORMAT_RGB888:
-                       depth = 24;
-                       break;
-               default:
-                       depth = 32;
-       }
-
-       return depth;
-}
-
 static tbm_surface_h
 __tpl_wayland_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buffers)
 {