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);
}
} 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
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.
tpl_handle_t window,
int *width,
int *height,
- tpl_format_t *format,
+ tbm_format *format,
int depth,
int a_size);
tpl_handle_t pixmap,
int *width,
int *height,
- tpl_format_t *format);
+ tbm_format *format);
void tpl_display_wait_native(tpl_display_t *display);
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;
}
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;
}
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);
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;
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;
}
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)
{
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);
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;
}
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;
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)
{
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);
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;
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;
}
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);
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;
__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;
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);
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)
{