}
int
-__tpl_util_atomic_get(const tpl_util_atomic_uint * const atom)
+__tpl_util_atomic_get(const tpl_util_atomic_uint *const atom)
{
unsigned int ret;
}
void
-__tpl_util_atomic_set(tpl_util_atomic_uint * const atom, unsigned int val)
+__tpl_util_atomic_set(tpl_util_atomic_uint *const atom, unsigned int val)
{
TPL_ASSERT(atom);
}
unsigned int
-__tpl_util_atomic_inc(tpl_util_atomic_uint * const atom )
+__tpl_util_atomic_inc(tpl_util_atomic_uint *const atom )
{
TPL_ASSERT(atom);
}
unsigned int
-__tpl_util_atomic_dec( tpl_util_atomic_uint * const atom )
+__tpl_util_atomic_dec( tpl_util_atomic_uint *const atom )
{
TPL_ASSERT(atom);
if (type != TPL_BACKEND_UNKNOWN) {
if (runtime->displays[type] != NULL) {
display = (tpl_display_t *) __tpl_hashlist_lookup(runtime->displays[type],
- (size_t) native_display);
+ (size_t) native_display);
}
} else {
int i;
for (i = 0; i < TPL_BACKEND_COUNT; i++) {
if (runtime->displays[i] != NULL) {
display = (tpl_display_t *) __tpl_hashlist_lookup(runtime->displays[i],
- (size_t) native_display);
+ (size_t) native_display);
}
if (display != NULL) break;
}
}
ret = __tpl_hashlist_insert(runtime->displays[type],
- (size_t) handle, (void *) display);
+ (size_t) handle, (void *) display);
if (TPL_ERROR_NONE != ret) {
TPL_ERR("__tpl_hashlist_insert failed. list(%p), handle(%d), display(%p)",
runtime->displays[type], handle, display);
if (type != TPL_BACKEND_UNKNOWN) {
if (runtime != NULL && runtime->displays[type] != NULL)
__tpl_hashlist_delete(runtime->displays[type],
- (size_t) handle);
+ (size_t) handle);
}
pthread_mutex_unlock(&runtime_mutex);
for (i = 0; i < TPL_BACKEND_COUNT; i++) {
if (runtime->displays[i] != NULL)
__tpl_hashlist_do_for_all_nodes(runtime->displays[i],
- __tpl_runtime_flush_cb);
+ __tpl_runtime_flush_cb);
}
pthread_mutex_unlock(&runtime_mutex);
* Represent a handle to a native object like pixmap, window, wl_display and
* etc.
*/
-typedef void * tpl_handle_t;
+typedef void *tpl_handle_t;
/**
* Structure containing function pointers to DDK's EGL layer.
* @see tpl_object_unreference()
* @see tpl_object_get_reference()
*/
-int tpl_object_reference(tpl_object_t *object);
+int
+tpl_object_reference(tpl_object_t *object);
/**
* Decrease reference count of a TPL object.
* @see tpl_object_reference()
* @see tpl_object_get_reference()
*/
-int tpl_object_unreference(tpl_object_t *object);
+int
+tpl_object_unreference(tpl_object_t *object);
/**
* Get reference count of a TPL object.
* @see tpl_object_reference()
* @see tpl_object_get_reference()
*/
-int tpl_object_get_reference(tpl_object_t *object);
+int
+tpl_object_get_reference(tpl_object_t *object);
/**
* Get the type of a TPL object.
*
* @see tpl_object_get_user_data()
*/
-tpl_result_t tpl_object_set_user_data(tpl_object_t *object, void *key,
- void *data, tpl_free_func_t free_func);
+tpl_result_t
+tpl_object_set_user_data(tpl_object_t *object, void *key,
+ void *data, tpl_free_func_t free_func);
/**
* Get registered user data of a TPL object.
*
* @see tpl_object_set_user_data()
*/
-void * tpl_object_get_user_data(tpl_object_t *object, void *key);
+void *
+tpl_object_get_user_data(tpl_object_t *object, void *key);
/**
* Create TPL display object for the given native display.
* @param native_dpy handle to the native display.
* @return pointer to the display on success, NULL on failure.
*/
-tpl_display_t * tpl_display_get(tpl_handle_t native_dpy);
+tpl_display_t *
+tpl_display_get(tpl_handle_t native_dpy);
/**
* Get the native display handle which the given TPL display is created for.
*
* @see tpl_display_get()
*/
-tpl_handle_t tpl_display_get_native_handle(tpl_display_t *display);
+tpl_handle_t
+tpl_display_get_native_handle(tpl_display_t *display);
/**
* Query supported pixel formats for the given TPL display.
* @return TPL_ERROR_NONE is the given config is supported, TPL_ERROR otherwise.
*/
tpl_result_t
-tpl_display_query_config(tpl_display_t *display, tpl_surface_type_t surface_type,
+tpl_display_query_config(tpl_display_t *display,
+ tpl_surface_type_t surface_type,
int red_size, int green_size, int blue_size,
int alpha_size, int depth_size, int *native_visual_id,
tpl_bool_t *is_slow);
* @return TPL_ERROR_NONE if the given config has been modified, TPL_ERROR otherwise.
*/
tpl_result_t
-tpl_display_filter_config(tpl_display_t *display, int *visual_id, int alpha_size);
+tpl_display_filter_config(tpl_display_t *display, int *visual_id,
+ int alpha_size);
/**
* Create a TPL surface for the given native surface.
*
* @see tpl_surface_create()
*/
-tpl_display_t * tpl_surface_get_display(tpl_surface_t *surface);
+tpl_display_t *
+tpl_surface_get_display(tpl_surface_t *surface);
/**
* Get the native surface handle of the given TPL surface.
*
* @see tpl_surface_create()
*/
-tpl_handle_t tpl_surface_get_native_handle(tpl_surface_t *surface);
+tpl_handle_t
+tpl_surface_get_native_handle(tpl_surface_t *surface);
/**
* Get the type of the given TPL surface.
*
* @see tpl_surface_create()
*/
-tpl_surface_type_t tpl_surface_get_type(tpl_surface_t *surface);
+tpl_surface_type_t
+tpl_surface_get_type(tpl_surface_t *surface);
/**
* Get the current size of the given TPL surface.
*
* @see tpl_surface_dequeue_buffer()
*/
-tpl_bool_t tpl_surface_validate(tpl_surface_t *surface);
+tpl_bool_t
+tpl_surface_validate(tpl_surface_t *surface);
/**
* Get the buffer of the current frame for the given TPL surface.
*
* @see tpl_surface_validate()
*/
-tbm_surface_h tpl_surface_dequeue_buffer(tpl_surface_t *surface);
+tbm_surface_h
+tpl_surface_dequeue_buffer(tpl_surface_t *surface);
/**
* Post a given tbm_surface.
*
* @see tpl_surface_set_post_interval()
*/
-int tpl_surface_get_post_interval(tpl_surface_t *surface);
+int
+tpl_surface_get_post_interval(tpl_surface_t *surface);
/**
* Query information on the given native window.
/* if still not found, then there's no compatible display */
if ((TPL_BACKEND_UNKNOWN == type) || (TPL_BACKEND_COUNT == type)
- || (TPL_BACKEND_MAX <= type)) {
+ || (TPL_BACKEND_MAX <= type)) {
TPL_ERR("Invalid backend type!");
return NULL;
}
tpl_handle_t
tpl_display_get_native_handle(tpl_display_t *display)
{
- if(!display || (__tpl_object_is_valid(&display->base) != TPL_TRUE)) {
+ if (!display || (__tpl_object_is_valid(&display->base) != TPL_TRUE)) {
TPL_ERR("display is invalid!");
return NULL;
}
}
tpl_result_t
-tpl_display_query_config(tpl_display_t *display, tpl_surface_type_t surface_type,
+tpl_display_query_config(tpl_display_t *display,
+ tpl_surface_type_t surface_type,
int red_size, int green_size, int blue_size,
int alpha_size, int depth_size, int *native_visual_id,
tpl_bool_t *is_slow)
{
if (!display || (__tpl_object_is_valid(&display->base) != TPL_TRUE)
- || (!display->backend.query_config)) {
+ || (!display->backend.query_config)) {
TPL_ERR("display is invalid!");
return TPL_ERROR_INVALID_PARAMETER;
}
return display->backend.query_config(display, surface_type, red_size,
- green_size, blue_size, alpha_size, depth_size,
- native_visual_id, is_slow);
+ green_size, blue_size, alpha_size, depth_size,
+ native_visual_id, is_slow);
}
tpl_result_t
-tpl_display_filter_config(tpl_display_t *display, int *visual_id, int alpha_size)
+tpl_display_filter_config(tpl_display_t *display, int *visual_id,
+ int alpha_size)
{
if (!display || (__tpl_object_is_valid(&display->base) != TPL_TRUE)
- || (!display->backend.filter_config)) {
+ || (!display->backend.filter_config)) {
TPL_ERR("display is invalid!");
return TPL_ERROR_INVALID_PARAMETER;
}
}
return display->backend.get_window_info(display, window, width, height,
- format, depth, a_size);
+ format, depth, a_size);
}
tpl_result_t
}
tbm_surface_h
-tpl_display_get_buffer_from_native_pixmap(tpl_display_t *display, tpl_handle_t pixmap)
+tpl_display_get_buffer_from_native_pixmap(tpl_display_t *display,
+ tpl_handle_t pixmap)
{
if (!display->backend.get_buffer_from_native_pixmap) {
TPL_ERR("Backend for display has not been initialized!");
__tpl_gbm_get_gbm_buffer_from_tbm_surface(tbm_surface_h surface)
{
tbm_bo bo;
- tpl_gbm_buffer_t *buf=NULL;
+ tpl_gbm_buffer_t *buf = NULL;
bo = tbm_surface_internal_get_bo(surface, 0);
tbm_bo_get_user_data(bo, KEY_TPL_GBM_BUFFER, (void **)&buf);
bo = tbm_surface_internal_get_bo(surface, 0);
tbm_bo_add_user_data(bo, KEY_TPL_GBM_BUFFER,
- (tbm_data_free)__tpl_gbm_buffer_free);
+ (tbm_data_free)__tpl_gbm_buffer_free);
tbm_bo_set_user_data(bo, KEY_TPL_GBM_BUFFER, buf);
}
TPL_ASSERT(display);
if ((surface_type == TPL_SURFACE_TYPE_WINDOW) && (red_size == 8)
- && (green_size == 8) && (blue_size == 8)
- && ((color_depth == 32) || (color_depth == 24))) {
+ && (green_size == 8) && (blue_size == 8)
+ && ((color_depth == 32) || (color_depth == 24))) {
if (alpha_size == 8) {
if (gbm_device_is_format_supported(
- (struct gbm_device *)display->native_handle,
- GBM_FORMAT_ARGB8888, GBM_BO_USE_RENDERING) == 1) {
+ (struct gbm_device *)display->native_handle,
+ GBM_FORMAT_ARGB8888, GBM_BO_USE_RENDERING) == 1) {
if (native_visual_id)
*native_visual_id = GBM_FORMAT_ARGB8888;
} else return TPL_ERROR_INVALID_PARAMETER;
}
if (alpha_size == 0) {
if (gbm_device_is_format_supported(
- (struct gbm_device *)display->native_handle,
- GBM_FORMAT_XRGB8888,
- GBM_BO_USE_RENDERING) == 1) {
+ (struct gbm_device *)display->native_handle,
+ GBM_FORMAT_XRGB8888,
+ GBM_BO_USE_RENDERING) == 1) {
if (native_visual_id)
*native_visual_id = GBM_FORMAT_XRGB8888;
} else return TPL_ERROR_INVALID_PARAMETER;
TPL_IGNORE(display);
if (visual_id != NULL && *visual_id == GBM_FORMAT_ARGB8888
- && alpha_size == 0) {
+ && alpha_size == 0) {
*visual_id = GBM_FORMAT_XRGB8888;
return TPL_ERROR_NONE;
}
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);
+ tbm_surface_queue_h surf_queue = (tbm_surface_queue_h)gbm_tbm_get_surface_queue(
+ gbm_surface);
if (!surf_queue) {
TPL_ERR("Failed to get tbm_surface_queue from gbm_surface.");
return TPL_ERROR_INVALID_OPERATION;
{
tbm_surface_h tbm_surface = NULL;
- tbm_surface = wayland_tbm_server_get_surface(NULL, (struct wl_resource*)pixmap);
+ tbm_surface = wayland_tbm_server_get_surface(NULL,
+ (struct wl_resource *)pixmap);
if (!tbm_surface) {
TPL_ERR("Failed to get tbm_surface_h from native pixmap.");
return TPL_ERROR_INVALID_OPERATION;
TPL_ASSERT(pixmap);
- tbm_surface = wayland_tbm_server_get_surface(NULL, (struct wl_resource*)pixmap);
+ tbm_surface = wayland_tbm_server_get_surface(NULL,
+ (struct wl_resource *)pixmap);
if (!tbm_surface) {
TPL_ERR("Failed to get tbm_surface_h from wayland_tbm.");
return NULL;
tpl_gbm_surface->current_buffer = NULL;
if (surface->type == TPL_SURFACE_TYPE_WINDOW) {
- struct gbm_surface *gbm_surface = (struct gbm_surface*)surface->native_handle;
- tpl_gbm_surface->tbm_queue = (tbm_surface_queue_h)gbm_tbm_get_surface_queue(gbm_surface);
+ struct gbm_surface *gbm_surface = (struct gbm_surface *)surface->native_handle;
+ tpl_gbm_surface->tbm_queue = (tbm_surface_queue_h)gbm_tbm_get_surface_queue(
+ gbm_surface);
if (!tpl_gbm_surface->tbm_queue) {
TPL_ERR("Failed to get tbm_surface_queue from gbm_surface.");
goto error;
}
if (__tpl_gbm_display_get_window_info(surface->display,
- surface->native_handle, &surface->width,
- &surface->height, NULL, 0, 0) != TPL_ERROR_NONE) {
+ surface->native_handle, &surface->width,
+ &surface->height, NULL, 0, 0) != TPL_ERROR_NONE) {
TPL_ERR("Failed to get native window info.");
goto error;
}
- TPL_LOG(3, "window(%p, %p) %dx%d", surface, surface->native_handle, surface->width, surface->height);
+ TPL_LOG(3, "window(%p, %p) %dx%d", surface, surface->native_handle,
+ surface->width, surface->height);
return TPL_ERROR_NONE;
} else if (surface->type == TPL_SURFACE_TYPE_PIXMAP) {
if (__tpl_gbm_display_get_pixmap_info(surface->display,
- surface->native_handle, &surface->width,
- &surface->height, NULL) != TPL_ERROR_NONE) {
+ surface->native_handle, &surface->width,
+ &surface->height, NULL) != TPL_ERROR_NONE) {
TPL_ERR("Failed to get native pixmap info.");
goto error;
}
TPL_LOG(3, "window(%p, %p)", surface, surface->native_handle);
- tpl_gbm_surface_t *gbm_surface = (tpl_gbm_surface_t*)surface->backend.data;
+ tpl_gbm_surface_t *gbm_surface = (tpl_gbm_surface_t *)surface->backend.data;
if (!gbm_surface) {
TPL_ERR("tpl_gbm_surface_t is invalid. tpl_surface_t(%p)",
surface);
}
if (tbm_surface_queue_enqueue(gbm_surface->tbm_queue, tbm_surface)
- != TBM_SURFACE_QUEUE_ERROR_NONE) {
+ != TBM_SURFACE_QUEUE_ERROR_NONE) {
TPL_ERR("tbm_surface_queue_enqueue failed. tbm_surface_queue(%p) tbm_surface(%p)",
gbm_surface->tbm_queue, tbm_surface);
return TPL_ERROR_INVALID_PARAMETER;
TPL_ASSERT(surface->display);
TPL_ASSERT(surface->display->native_handle);
- gbm_surface = (tpl_gbm_surface_t*)surface->backend.data;
+ gbm_surface = (tpl_gbm_surface_t *)surface->backend.data;
tsq_err = tbm_surface_queue_dequeue(gbm_surface->tbm_queue, &tbm_surface);
- if(!tbm_surface
- && tbm_surface_queue_can_dequeue(gbm_surface->tbm_queue, 1) == 1) {
+ if (!tbm_surface
+ && tbm_surface_queue_can_dequeue(gbm_surface->tbm_queue, 1) == 1) {
tsq_err = tbm_surface_queue_dequeue(gbm_surface->tbm_queue, &tbm_surface);
if (!tbm_surface) {
TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d",
backend->filter_config = __tpl_gbm_display_filter_config;
backend->get_window_info = __tpl_gbm_display_get_window_info;
backend->get_pixmap_info = __tpl_gbm_display_get_pixmap_info;
- backend->get_buffer_from_native_pixmap = __tpl_gbm_display_get_buffer_from_native_pixmap;
+ backend->get_buffer_from_native_pixmap =
+ __tpl_gbm_display_get_buffer_from_native_pixmap;
}
void
tpl_result_t (*filter_config)(tpl_display_t *display, int *visual_id,
int alpha_bits);
tpl_result_t (*get_window_info)(tpl_display_t *display,
- tpl_handle_t window, int *width,
+ tpl_handle_t window, int *width,
int *height, tbm_format *format,
- int depth,int a_size);
+ int depth, int a_size);
tpl_result_t (*get_pixmap_info)(tpl_display_t *display,
tpl_handle_t pixmap, int *width,
int *height, tbm_format *format);
/* Runtime functions. */
tpl_display_t *
-__tpl_runtime_find_display(tpl_backend_type_t type, tpl_handle_t native_display);
+__tpl_runtime_find_display(tpl_backend_type_t type,
+ tpl_handle_t native_display);
tpl_result_t __tpl_runtime_add_display(tpl_display_t *display);
void __tpl_runtime_remove_display(tpl_display_t *display);
void __tpl_runtime_flush_all_display();
tpl_bool_t __tpl_display_choose_backend_wayland(tpl_handle_t native_dpy);
tpl_bool_t __tpl_display_choose_backend_x11_dri2(tpl_handle_t native_dpy);
tpl_bool_t __tpl_display_choose_backend_x11_dri3(tpl_handle_t native_dpy);
-void __tpl_display_init_backend(tpl_display_t *display, tpl_backend_type_t type);
-void __tpl_surface_init_backend(tpl_surface_t *surface, tpl_backend_type_t type);
+void __tpl_display_init_backend(tpl_display_t *display,
+ tpl_backend_type_t type);
+void __tpl_surface_init_backend(tpl_surface_t *surface,
+ tpl_backend_type_t type);
void __tpl_display_init_backend_gbm(tpl_display_backend_t *backend);
void __tpl_display_init_backend_tbm(tpl_display_backend_t *backend);
void __tpl_display_init_backend_wayland(tpl_display_backend_t *backend);
* @param atom storage for the value to retrieve of
* @return value stored on success, 0 or error
*/
-int __tpl_util_atomic_get(const tpl_util_atomic_uint * const atom);
+int __tpl_util_atomic_get(const tpl_util_atomic_uint *const atom);
/** brief set the atomic variable's value
* @param atom storage for the value to set of
* @param val the value to set
* @return TPL_TRUE on succes, TPL_FALSE on error
*/
-void __tpl_util_atomic_set(tpl_util_atomic_uint * const atom, unsigned int val);
-unsigned int __tpl_util_atomic_inc(tpl_util_atomic_uint * const atom );
-unsigned int __tpl_util_atomic_dec(tpl_util_atomic_uint * const atom );
+void __tpl_util_atomic_set(tpl_util_atomic_uint *const atom, unsigned int val);
+unsigned int __tpl_util_atomic_inc(tpl_util_atomic_uint *const atom );
+unsigned int __tpl_util_atomic_dec(tpl_util_atomic_uint *const atom );
/* Data structure functions */
-tpl_hlist_t * __tpl_hashlist_create();
+tpl_hlist_t *__tpl_hashlist_create();
void __tpl_hashlist_destroy(tpl_hlist_t **list);
tpl_result_t __tpl_hashlist_insert(tpl_hlist_t *list, size_t key, void *data);
void __tpl_hashlist_delete(tpl_hlist_t *list, size_t key);
-void __tpl_hashlist_do_for_all_nodes(tpl_hlist_t *list, void (*cb_func)(void *));
-void * __tpl_hashlist_lookup(tpl_hlist_t *list, size_t key);
+void __tpl_hashlist_do_for_all_nodes(tpl_hlist_t *list,
+ void (*cb_func)(void *));
+void *__tpl_hashlist_lookup(tpl_hlist_t *list, size_t key);
#endif /* TPL_INTERNAL_H */
}
tpl_result_t
-__tpl_object_init(tpl_object_t *object, tpl_object_type_t type, tpl_free_func_t free_func)
+__tpl_object_init(tpl_object_t *object, tpl_object_type_t type,
+ tpl_free_func_t free_func)
{
TPL_ASSERT(object);
TPL_ASSERT(type >= 0 && type < TPL_OBJECT_MAX);
object->type = type;
object->free = free_func;
- tpl_util_map_pointer_init(&object->user_data_map, TPL_OBJECT_BUCKET_BITS, &object->buckets[0]);
+ tpl_util_map_pointer_init(&object->user_data_map, TPL_OBJECT_BUCKET_BITS,
+ &object->buckets[0]);
__tpl_util_atomic_set(&object->reference, 1);
}
tpl_surface_t *
-tpl_surface_create(tpl_display_t *display, tpl_handle_t handle, tpl_surface_type_t type, tbm_format format)
+tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
+ tpl_surface_type_t type, tbm_format format)
{
tpl_surface_t *surface;
}
if (__tpl_object_init(&surface->base, TPL_OBJECT_SURFACE,
- __tpl_surface_free) != TPL_ERROR_NONE) {
+ __tpl_surface_free) != TPL_ERROR_NONE) {
TPL_ERR("Failed to initialize surface's base class!");
free(surface);
return NULL;
__tpl_surface_init_backend(surface, display->backend.type);
if ((!surface->backend.init)
- || (surface->backend.init(surface) != TPL_ERROR_NONE)) {
+ || (surface->backend.init(surface) != TPL_ERROR_NONE)) {
TPL_ERR("Failed to initialize surface's backend!");
tpl_object_unreference(&surface->base);
return NULL;
tbm_surface = surface->backend.dequeue_buffer(surface);
- if(tbm_surface) {
+ if (tbm_surface) {
/* Update size of the surface. */
surface->width = tbm_surface_get_width(tbm_surface);
surface->height = tbm_surface_get_height(tbm_surface);
TPL_ASSERT(display);
if (surface_type == TPL_SURFACE_TYPE_WINDOW && red_size == 8
- && green_size == 8 && blue_size == 8
- && (color_depth == 32 || color_depth == 24)) {
+ && green_size == 8 && blue_size == 8
+ && (color_depth == 32 || color_depth == 24)) {
if (alpha_size == 8) {
if (native_visual_id)
*native_visual_id = TBM_FORMAT_ARGB8888;
if (surface->type == TPL_SURFACE_TYPE_WINDOW) {
if (__tpl_tbm_display_get_window_info(surface->display,
- surface->native_handle, &surface->width,
- &surface->height, NULL, 0, 0) != TPL_ERROR_NONE) {
+ surface->native_handle, &surface->width,
+ &surface->height, NULL, 0, 0) != TPL_ERROR_NONE) {
TPL_ERR("Failed to get native window(%p) info.",
surface->native_handle);
goto error;
}
tbm_surface_queue_set_destroy_cb((tbm_surface_queue_h)surface->native_handle,
- __tpl_tbm_surface_queue_notify_cb,
- surface);
+ __tpl_tbm_surface_queue_notify_cb,
+ surface);
TPL_LOG(3, "window(%p, %p) %dx%d", surface,
surface->native_handle, surface->width, surface->height);
return TPL_ERROR_NONE;
} else if (surface->type == TPL_SURFACE_TYPE_PIXMAP) {
if (__tpl_tbm_display_get_pixmap_info(surface->display,
- surface->native_handle, &surface->width,
- &surface->height, NULL) != TPL_TRUE) {
+ surface->native_handle, &surface->width,
+ &surface->height, NULL) != TPL_TRUE) {
TPL_ERR("Failed to get native pixmap(%p) info.",
surface->native_handle);
TPL_ASSERT(surface->display);
TPL_LOG(3, "%s(%p, %p)",
- ((surface->type == TPL_SURFACE_TYPE_WINDOW)?"window":"pixmap"),
+ ((surface->type == TPL_SURFACE_TYPE_WINDOW) ? "window" : "pixmap"),
surface, surface->native_handle);
if (surface->type == TPL_SURFACE_TYPE_PIXMAP)
tbm_surface_internal_unref(tbm_surface);
if (surface->type == TPL_SURFACE_TYPE_PIXMAP) {
- TPL_ERR("Pixmap cannot post(%p, %p)",surface,
+ TPL_ERR("Pixmap cannot post(%p, %p)", surface,
surface->native_handle);
return TPL_ERROR_INVALID_PARAMETER;
}
}
if (tbm_surface_queue_enqueue(tbm_queue, tbm_surface)
- != TBM_SURFACE_QUEUE_ERROR_NONE) {
+ != TBM_SURFACE_QUEUE_ERROR_NONE) {
TPL_ERR("tbm_surface_queue_enqueue failed. tbm_queue(%p) tbm_surface(%p)",
tbm_queue, tbm_surface);
return TPL_ERROR_INVALID_OPERATION;
if (!tbm_surface && tbm_surface_queue_can_dequeue(tbm_queue, 1) == 1) {
tsq_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surface);
if (!tbm_surface) {
- TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d",tsq_err);
+ TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d",
+ tsq_err);
return NULL;
}
}
backend->filter_config = __tpl_tbm_display_filter_config;
backend->get_window_info = __tpl_tbm_display_get_window_info;
backend->get_pixmap_info = __tpl_tbm_display_get_pixmap_info;
- backend->get_buffer_from_native_pixmap = __tpl_tbm_display_get_buffer_from_native_pixmap;
+ backend->get_buffer_from_native_pixmap =
+ __tpl_tbm_display_get_buffer_from_native_pixmap;
}
void
typedef int (*tpl_util_hash_func_t)(const tpl_util_key_t key, int key_length);
typedef int (*tpl_util_key_length_func_t)(const tpl_util_key_t key);
typedef int (*tpl_util_key_compare_func_t)(const tpl_util_key_t key0,
- int key0_length,
- const tpl_util_key_t key1,
- int key1_length);
+ int key0_length,
+ const tpl_util_key_t key1,
+ int key1_length);
enum _tpl_occurrence {
TPL_FIRST,
tpl_util_key_compare_func_t key_compare_func,
void *buckets);
-void tpl_util_map_int32_init(tpl_util_map_t *map, int bucket_bits, void *buckets);
+void tpl_util_map_int32_init(tpl_util_map_t *map, int bucket_bits,
+ void *buckets);
-void tpl_util_map_int64_init(tpl_util_map_t *map, int bucket_bits, void *buckets);
+void tpl_util_map_int64_init(tpl_util_map_t *map, int bucket_bits,
+ void *buckets);
-void tpl_util_map_pointer_init(tpl_util_map_t *map, int bucket_bits, void *buckets);
+void tpl_util_map_pointer_init(tpl_util_map_t *map, int bucket_bits,
+ void *buckets);
void tpl_util_map_fini(tpl_util_map_t *map);
}
static TPL_INLINE int
-__tpl_util_image_dump_bmp(const char * file, const void * data, int width,
+__tpl_util_image_dump_bmp(const char *file, const void *data, int width,
int height)
{
int i;
unsigned int ncolors;
unsigned int nimpcolors;
} bmp_dib_v3_header_t = { 0x28, 0, 0, 1, 24, 0, 0, 0, 0, 0, 0 };
- unsigned int * blocks;
+ unsigned int *blocks;
if (data == NULL) return -1;
if (width <= 0 || height <= 0) return -1;
- FILE * fp = NULL;
+ FILE *fp = NULL;
if ((fp = fopen (file, "wb")) == NULL) {
- printf("FILE ERROR:%s\t",strerror(errno));
+ printf("FILE ERROR:%s\t", strerror(errno));
return -2;
} else {
bmpfile_header.filesz = sizeof (bmpfile_magic) + sizeof (bmpfile_header) +
return -1;
}
- blocks = (unsigned int*)data;
- for (i=0; i<height * width; i++) {
+ blocks = (unsigned int *)data;
+ for (i = 0; i < height * width; i++) {
if (fwrite (&blocks[i], 3, 1, fp) < 0) {
fclose(fp);
return -1;
if (pPngInfo) {
png_init_io(pPngStruct, fp);
png_set_IHDR(pPngStruct,
- pPngInfo,
- width,
- height,
- PNG_DEPTH,
- PNG_COLOR_TYPE_RGBA,
- PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_DEFAULT,
- PNG_FILTER_TYPE_DEFAULT);
+ pPngInfo,
+ width,
+ height,
+ PNG_DEPTH,
+ PNG_COLOR_TYPE_RGBA,
+ PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_DEFAULT,
+ PNG_FILTER_TYPE_DEFAULT);
png_set_bgr(pPngStruct);
png_write_info(pPngStruct, pPngInfo);
for (; y < height; ++y) {
png_bytep row = png_malloc(pPngStruct,
- sizeof(png_byte) * width *
- pixel_size);
+ sizeof(png_byte) * width *
+ pixel_size);
if (!row) {
fclose(fp);
return res;
#endif
static TPL_INLINE void
-__tpl_util_image_dump(const char * func, const void * data, int type,
+__tpl_util_image_dump(const char *func, const void *data, int type,
int width, int height, int num)
{
char name[200];
if (mkdir (path_name, 0755) == -1) {
if (errno != EEXIST) {
- TPL_LOG(3,"Directory creation error!");
+ TPL_LOG(3, "Directory creation error!");
return;
}
}
if (type == 1) {
- snprintf(name, sizeof(name),"%s/[%d][%s][%d][%d][%04d].bmp",
- path_name, getpid(), func, width, height, num);
+ snprintf(name, sizeof(name), "%s/[%d][%s][%d][%d][%04d].bmp",
+ path_name, getpid(), func, width, height, num);
/*snprintf(name, sizeof(name), "[%d][%04d]", getpid(), num);*/
- switch(__tpl_util_image_dump_bmp(name, data, width, height)) {
+ switch (__tpl_util_image_dump_bmp(name, data, width, height)) {
case 0:
- TPL_LOG(6,"%s file is dumped\n", name);
+ TPL_LOG(6, "%s file is dumped\n", name);
break;
case -1:
TPL_LOG(6, "Dump failed..internal error (data = %p)(width = %d)(height = %d)\n",
}
#ifdef PNG_DUMP_ENABLE
else {
- snprintf(name, sizeof(name),"%s/[%d][%s][%d][%d][%04d].png",
- path_name, getpid(), func, width, height, num);
+ snprintf(name, sizeof(name), "%s/[%d][%s][%d][%d][%04d].png",
+ path_name, getpid(), func, width, height, num);
/*snprintf(name, sizeof(name), "[%d][%04d]", getpid(), num);*/
- switch(__tpl_util_image_dump_png(name, data, width, height)) {
+ switch (__tpl_util_image_dump_png(name, data, width, height)) {
case 0:
- TPL_LOG(6,"%s file is dumped\n", name);
+ TPL_LOG(6, "%s file is dumped\n", name);
break;
case -1:
TPL_LOG(6, "Dump failed..internal error (data = %p)(width = %d)(height = %d)\n",
static TPL_INLINE void
__tpl_hlist_add_behind(tpl_hlist_node_t *n, tpl_hlist_node_t *prev);
-tpl_hlist_node_t * __tpl_hlist_get_node(tpl_hlist_t *list, size_t key);
-tpl_hlist_node_t * __tpl_hlist_get_tail_node(tpl_hlist_t *list, size_t key);
+tpl_hlist_node_t *__tpl_hlist_get_node(tpl_hlist_t *list, size_t key);
+tpl_hlist_node_t *__tpl_hlist_get_tail_node(tpl_hlist_t *list, size_t key);
struct tpl_hlist {
tpl_hlist_head_t *heads;
for (pos = list->heads[hash].first; pos; pos = pos->next) {
if (pos->key == key)
- return pos;
+ return pos;
}
return NULL;
if (list == NULL)
return NULL;
- list->heads = (tpl_hlist_head_t *) malloc(sizeof(tpl_hlist_head_t) * NUM_OF_HEADS);
+ list->heads = (tpl_hlist_head_t *) malloc(sizeof(tpl_hlist_head_t) *
+ NUM_OF_HEADS);
if (list->heads == NULL) {
free(list);
return NULL;
return (int)_key;
#else
- #error "Not 32 or 64bit system"
+#error "Not 32 or 64bit system"
#endif
return 0;
tpl_util_map_int32_init(tpl_util_map_t *map, int bucket_bits, void *buckets)
{
tpl_util_map_init(map, bucket_bits, __int32_hash, NULL,
- __int32_key_compare, buckets);
+ __int32_key_compare, buckets);
}
void
tpl_util_map_int64_init(tpl_util_map_t *map, int bucket_bits, void *buckets)
{
tpl_util_map_init(map, bucket_bits, __int64_hash, NULL,
- __int64_key_compare, buckets);
+ __int64_key_compare, buckets);
}
void
tpl_util_map_pointer_init(tpl_util_map_t *map, int bucket_bits, void *buckets)
{
tpl_util_map_init(map, bucket_bits, __pointer_hash, NULL,
- __pointer_key_compare, buckets);
+ __pointer_key_compare, buckets);
}
void
int bucket_size = 1 << bucket_bits;
map = calloc(1,
- sizeof(tpl_util_map_t) + bucket_size * sizeof(tpl_util_map_entry_t *));
+ sizeof(tpl_util_map_t) + bucket_size * sizeof(tpl_util_map_entry_t *));
TPL_CHECK_ON_FALSE_RETURN_VAL(map, NULL);
tpl_util_map_init(map, bucket_bits, hash_func, key_length_func,
- key_compare_func, map + 1);
+ key_compare_func, map + 1);
return map;
}
tpl_util_map_int32_create(int bucket_bits)
{
return tpl_util_map_create(bucket_bits, __int32_hash, NULL,
- __int32_key_compare);
+ __int32_key_compare);
}
tpl_util_map_t *
tpl_util_map_int64_create(int bucket_bits)
{
return tpl_util_map_create(bucket_bits, __int64_hash, NULL,
- __int64_key_compare);
+ __int64_key_compare);
}
tpl_util_map_t *
tpl_util_map_pointer_create(int bucket_bits)
{
return tpl_util_map_create(bucket_bits, __pointer_hash, NULL,
- __pointer_key_compare);
+ __pointer_key_compare);
}
void
__tpl_wayland_get_wayland_buffer_from_tbm_surface(tbm_surface_h surface)
{
tbm_bo bo;
- tpl_wayland_buffer_t *buf=NULL;
+ tpl_wayland_buffer_t *buf = NULL;
bo = tbm_surface_internal_get_bo(surface, 0);
tbm_bo_get_user_data(bo, KEY_TPL_WAYLAND_BUFFER, (void **)&buf);
static TPL_INLINE void
__tpl_wayland_set_wayland_buffer_to_tbm_surface(tbm_surface_h surface,
- tpl_wayland_buffer_t *buf)
+ tpl_wayland_buffer_t *buf)
{
tbm_bo bo;
bo = tbm_surface_internal_get_bo(surface, 0);
tbm_bo_add_user_data(bo, KEY_TPL_WAYLAND_BUFFER,
- (tbm_data_free)__tpl_wayland_buffer_free);
+ (tbm_data_free)__tpl_wayland_buffer_free);
tbm_bo_set_user_data(bo, KEY_TPL_WAYLAND_BUFFER, buf);
}
}
if (strncmp(wl_egl_native_dpy->name, wl_display_interface.name,
- strlen(wl_display_interface.name)) == 0) {
+ strlen(wl_display_interface.name)) == 0) {
return TPL_TRUE;
}
return TPL_ERROR_INVALID_PARAMETER;
}
- wayland_display = (tpl_wayland_display_t *) calloc(1, sizeof(tpl_wayland_display_t));
+ wayland_display = (tpl_wayland_display_t *) calloc(1,
+ sizeof(tpl_wayland_display_t));
if (!wayland_display) {
TPL_ERR("Failed to allocate memory for new tpl_wayland_display_t.");
return TPL_ERROR_INVALID_OPERATION;
}
wl_proxy_set_queue((struct wl_proxy *)wayland_display->wl_registry,
- wayland_display->wl_queue);
+ wayland_display->wl_queue);
} else {
goto free_wl_display;
}
TPL_ASSERT(display);
if (surface_type == TPL_SURFACE_TYPE_WINDOW && red_size == 8 &&
- green_size == 8 && blue_size == 8 &&
- (color_depth == 32 || color_depth == 24)) {
+ green_size == 8 && blue_size == 8 &&
+ (color_depth == 32 || color_depth == 24)) {
if (alpha_size == 8) {
if (native_visual_id) *native_visual_id = TBM_FORMAT_ARGB8888;
}
static void
-__cb_client_window_resize_callback(struct wl_egl_window* wl_egl_window,
- void* private);
+__cb_client_window_resize_callback(struct wl_egl_window *wl_egl_window,
+ void *private);
static tpl_result_t
__tpl_wayland_surface_init(tpl_surface_t *surface)
{
tpl_wayland_surface_t *wayland_surface = NULL;
- struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)surface->native_handle;
+ struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)
+ surface->native_handle;
TPL_ASSERT(surface);
TPL_ASSERT(surface->type == TPL_SURFACE_TYPE_WINDOW);
TPL_ASSERT(surface->native_handle);
- wayland_surface = (tpl_wayland_surface_t *) calloc(1, sizeof(tpl_wayland_surface_t));
+ wayland_surface = (tpl_wayland_surface_t *) calloc(1,
+ sizeof(tpl_wayland_surface_t));
if (!wayland_surface) {
TPL_ERR("Failed to allocate memory for new tpl_wayland_surface_t.");
return TPL_ERROR_INVALID_OPERATION;
wayland_surface->current_buffer = NULL;
wayland_surface->tbm_queue = tbm_surface_queue_create(CLIENT_QUEUE_SIZE,
- wl_egl_window->width, wl_egl_window->height, surface->format, 0);
+ wl_egl_window->width, wl_egl_window->height, surface->format, 0);
if (!wayland_surface->tbm_queue) {
TPL_ERR("TBM surface queue creation failed!");
surface->height = wl_egl_window->height;
wl_egl_window->private = surface;
- wl_egl_window->resize_callback = (void*)__cb_client_window_resize_callback;
+ wl_egl_window->resize_callback = (void *)__cb_client_window_resize_callback;
TPL_LOG(3, "window(%p, %p) %dx%d", surface, surface->native_handle,
surface->width, surface->height);
TPL_LOG(3, "window(%p, %p)", surface, surface->native_handle);
if (surface->type == TPL_SURFACE_TYPE_WINDOW) {
- struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)surface->native_handle;
+ struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)
+ surface->native_handle;
TPL_ASSERT(wl_egl_window);
/* TPL_ASSERT(wl_egl_window->surface); */ /* to be enabled once evas/gl patch is in place */
wl_egl_window->private = NULL;
/* Detach all pending buffers */
- if (wl_egl_window->surface && /* if-statement to be removed once evas/gl patch is in place */
- wl_egl_window->width == wl_egl_window->attached_width &&
- wl_egl_window->height == wl_egl_window->attached_height) {
+ if (wl_egl_window->surface &&
+ /* if-statement to be removed once evas/gl patch is in place */
+ wl_egl_window->width == wl_egl_window->attached_width &&
+ wl_egl_window->height == wl_egl_window->attached_height) {
wl_surface_attach(wl_egl_window->surface, NULL, 0, 0);
wl_surface_commit(wl_egl_window->surface);
struct wl_egl_window *wl_egl_window = NULL;
tpl_wayland_display_t *wayland_display =
- (tpl_wayland_display_t*) surface->display->backend.data;
+ (tpl_wayland_display_t *) surface->display->backend.data;
tpl_wayland_surface_t *wayland_surface =
- (tpl_wayland_surface_t*) surface->backend.data;
+ (tpl_wayland_surface_t *) surface->backend.data;
tpl_wayland_buffer_t *wayland_buffer = NULL;
tbm_surface_queue_error_e tsq_err;
if (bo_handle.ptr)
TPL_IMAGE_DUMP(bo_handle.ptr, surface->width, surface->height,
- surface->dump_count++);
+ surface->dump_count++);
wl_egl_window = (struct wl_egl_window *)surface->native_handle;
tbm_surface_internal_ref(tbm_surface);
wl_surface_attach(wl_egl_window->surface, (void *)wayland_buffer->wl_proxy,
- wl_egl_window->dx, wl_egl_window->dy);
+ wl_egl_window->dx, wl_egl_window->dy);
wl_egl_window->attached_width = wl_egl_window->width;
wl_egl_window->attached_height = wl_egl_window->height;
if (num_rects < 1 || rects == NULL) {
wl_surface_damage(wl_egl_window->surface,
- wl_egl_window->dx, wl_egl_window->dy,
- wl_egl_window->width, wl_egl_window->height);
+ wl_egl_window->dx, wl_egl_window->dy,
+ wl_egl_window->width, wl_egl_window->height);
} else {
int i;
for (i = 0; i < num_rects; i++) {
wl_surface_damage(wl_egl_window->surface,
- rects[i * 4 + 0], rects[i * 4 + 1],
- rects[i * 4 + 2], rects[i * 4 + 3]);
+ rects[i * 4 + 0], rects[i * 4 + 1],
+ rects[i * 4 + 2], rects[i * 4 + 3]);
}
}
frame_callback = wl_surface_frame(wl_egl_window->surface);
wl_callback_add_listener(frame_callback, &frame_listener, tbm_surface);
wl_proxy_set_queue((struct wl_proxy *)frame_callback,
- wayland_display->wl_queue);
+ wayland_display->wl_queue);
}
wl_surface_commit(wl_egl_window->surface);
TPL_ASSERT(surface->backend.data);
tpl_wayland_surface_t *wayland_surface =
- (tpl_wayland_surface_t*)surface->backend.data;
+ (tpl_wayland_surface_t *)surface->backend.data;
if (wayland_surface->resized) return TPL_FALSE;
tbm_surface_h tbm_surface = NULL;
tpl_wayland_buffer_t *wayland_buffer = NULL;
tpl_wayland_surface_t *wayland_surface =
- (tpl_wayland_surface_t*)surface->backend.data;
+ (tpl_wayland_surface_t *)surface->backend.data;
tpl_wayland_display_t *wayland_display =
- (tpl_wayland_display_t*)surface->display->backend.data;
+ (tpl_wayland_display_t *)surface->display->backend.data;
struct wl_proxy *wl_proxy = NULL;
tbm_surface_queue_error_e tsq_err = 0;
if (wayland_surface->resized == TPL_TRUE) wayland_surface->resized = TPL_FALSE;
TPL_OBJECT_UNLOCK(surface);
- while(tbm_surface_queue_can_dequeue(
- wayland_surface->tbm_queue, 0) == 0) {
+ while (tbm_surface_queue_can_dequeue(
+ wayland_surface->tbm_queue, 0) == 0) {
/* Application sent all buffers to the server. Wait for server response. */
if (wl_display_dispatch_queue(surface->display->native_handle,
- wayland_display->wl_queue) == -1) {
+ wayland_display->wl_queue) == -1) {
TPL_OBJECT_LOCK(surface);
return NULL;
}
tsq_err = tbm_surface_queue_dequeue(wayland_surface->tbm_queue, &tbm_surface);
if (!tbm_surface) {
- TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d",tsq_err);
+ TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d",
+ tsq_err);
return NULL;
}
tbm_surface_internal_ref(tbm_surface);
if ((wayland_buffer =
- __tpl_wayland_get_wayland_buffer_from_tbm_surface(tbm_surface)) != NULL) {
+ __tpl_wayland_get_wayland_buffer_from_tbm_surface(tbm_surface)) != NULL) {
return tbm_surface;
}
- wayland_buffer = (tpl_wayland_buffer_t *) calloc(1, sizeof(tpl_wayland_buffer_t));
+ wayland_buffer = (tpl_wayland_buffer_t *) calloc(1,
+ sizeof(tpl_wayland_buffer_t));
if (!wayland_buffer) {
TPL_ERR("Mem alloc for wayland_buffer failed!");
tbm_surface_internal_unref(tbm_surface);
}
wl_proxy = (struct wl_proxy *)wayland_tbm_client_create_buffer(
- wayland_display->wl_tbm_client, tbm_surface);
+ wayland_display->wl_tbm_client, tbm_surface);
if (!wl_proxy) {
TPL_ERR("Failed to create TBM client buffer!");
tbm_surface_internal_unref(tbm_surface);
wl_proxy_set_queue(wl_proxy, wayland_display->wl_queue);
wl_buffer_add_listener((void *)wl_proxy, &buffer_release_listener,
- tbm_surface);
+ tbm_surface);
wl_display_flush((struct wl_display *)surface->display->native_handle);
if (wayland_buffer->wl_proxy)
wayland_tbm_client_destroy_buffer(wayland_display->wl_tbm_client,
- (void *)wayland_buffer->wl_proxy);
+ (void *)wayland_buffer->wl_proxy);
free(wayland_buffer);
}
}
static void
-__cb_client_sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+__cb_client_sync_callback(void *data, struct wl_callback *callback,
+ uint32_t serial)
{
int *done;
wl_callback_destroy(callback);
}
-static const struct wl_callback_listener sync_listener =
-{
+static const struct wl_callback_listener sync_listener = {
__cb_client_sync_callback
};
static void
-__cb_client_frame_callback(void *data, struct wl_callback *callback, uint32_t time)
+__cb_client_frame_callback(void *data, struct wl_callback *callback,
+ uint32_t time)
{
/* We moved the buffer reclaim logic to buffer_release_callback().
buffer_release_callback() is more suitable point to delete or reuse buffer instead of frame_callback().
wl_callback_destroy(callback);
}
-static const struct wl_callback_listener frame_listener =
-{
+static const struct wl_callback_listener frame_listener = {
__cb_client_frame_callback
};
};
static void
-__cb_client_window_resize_callback(struct wl_egl_window* wl_egl_window, void* private)
+__cb_client_window_resize_callback(struct wl_egl_window *wl_egl_window,
+ void *private)
{
TPL_ASSERT(private);
TPL_ASSERT(wl_egl_window);
int width, height, format;
- tpl_surface_t *surface = (tpl_surface_t*)private;
- tpl_wayland_surface_t *wayland_surface = (tpl_wayland_surface_t*)surface->backend.data;
+ tpl_surface_t *surface = (tpl_surface_t *)private;
+ tpl_wayland_surface_t *wayland_surface = (tpl_wayland_surface_t *)
+ surface->backend.data;
wayland_surface->resized = TPL_TRUE;
/* Check whether the surface was resized by wayland_egl */
if ((wayland_surface->resized == TPL_TRUE)
- || (width != tbm_surface_queue_get_width(wayland_surface->tbm_queue))
- || (height != tbm_surface_queue_get_height(wayland_surface->tbm_queue))) {
+ || (width != tbm_surface_queue_get_width(wayland_surface->tbm_queue))
+ || (height != tbm_surface_queue_get_height(wayland_surface->tbm_queue))) {
if (wayland_surface->current_buffer)
tbm_surface_internal_unref(wayland_surface->current_buffer);
swap_type = strtol(str, NULL, 0);
- switch (swap_type)
- {
+ switch (swap_type) {
case TPL_X11_SWAP_TYPE_SYNC:
case TPL_X11_SWAP_TYPE_ASYNC:
case TPL_X11_SWAP_TYPE_LAZY:
}
tpl_buffer_t *
-__tpl_x11_surface_buffer_cache_find(tpl_list_t *buffer_cache, unsigned int name)
+__tpl_x11_surface_buffer_cache_find(tpl_list_t *buffer_cache,
+ unsigned int name)
{
tpl_list_node_t *node;
node = __tpl_list_get_front_node(buffer_cache);
- while (node)
- {
+ while (node) {
tpl_buffer_t *buffer = (tpl_buffer_t *) __tpl_list_node_get_data(node);
TPL_ASSERT(buffer);
}
void
-__tpl_x11_surface_buffer_cache_remove(tpl_list_t *buffer_cache, unsigned int name)
+__tpl_x11_surface_buffer_cache_remove(tpl_list_t *buffer_cache,
+ unsigned int name)
{
tpl_list_node_t *node;
node = __tpl_list_get_front_node(buffer_cache);
- while (node)
- {
+ while (node) {
tpl_buffer_t *buffer = (tpl_buffer_t *) __tpl_list_node_get_data(node);
TPL_ASSERT(buffer);
- if (buffer->key == name)
- {
+ if (buffer->key == name) {
tpl_object_unreference(&buffer->base);
__tpl_list_remove(node, NULL);
return;
}
tpl_bool_t
-__tpl_x11_surface_buffer_cache_add(tpl_list_t *buffer_cache, tpl_buffer_t *buffer)
+__tpl_x11_surface_buffer_cache_add(tpl_list_t *buffer_cache,
+ tpl_buffer_t *buffer)
{
TPL_ASSERT(buffer_cache);
TPL_ASSERT(buffer);
- if (__tpl_list_get_count(buffer_cache) >= TPL_BUFFER_CACHE_MAX_ENTRIES)
- {
+ if (__tpl_list_get_count(buffer_cache) >= TPL_BUFFER_CACHE_MAX_ENTRIES) {
tpl_buffer_t *evict = __tpl_list_pop_front(buffer_cache, NULL);
TPL_ASSERT(evict);
native_display = (Display *)display->native_handle;
if (red_size != TPL_DONT_CARE || green_size != TPL_DONT_CARE ||
- blue_size != TPL_DONT_CARE || color_depth != TPL_DONT_CARE)
- {
- if (surface_type == TPL_SURFACE_TYPE_WINDOW)
- {
+ blue_size != TPL_DONT_CARE || color_depth != TPL_DONT_CARE) {
+ if (surface_type == TPL_SURFACE_TYPE_WINDOW) {
XVisualInfo *visual_formats;
int num_visual_formats;
int i;
visual_formats = XGetVisualInfo(native_display, 0, NULL,
&num_visual_formats);
TPL_ASSERT(visual_formats);
- for (i = 0; i < num_visual_formats; i++)
- {
+ for (i = 0; i < num_visual_formats; i++) {
int clz[3];
int col_size[3];
if ((red_size == TPL_DONT_CARE || col_size[0] == red_size) &&
(green_size == TPL_DONT_CARE || col_size[1] == green_size) &&
- (blue_size == TPL_DONT_CARE || col_size[2] == blue_size))
- {
+ (blue_size == TPL_DONT_CARE || col_size[2] == blue_size)) {
if (native_visual_id != NULL)
*native_visual_id = visual_formats[i].visualid;
visual_formats = NULL;
}
- if (surface_type == TPL_SURFACE_TYPE_PIXMAP)
- {
+ if (surface_type == TPL_SURFACE_TYPE_PIXMAP) {
XPixmapFormatValues *pixmap_formats;
int num_pixmap_formats;
int i;
pixmap_formats = XListPixmapFormats(native_display, &num_pixmap_formats);
TPL_ASSERT(pixmap_formats);
- for (i = 0; i < num_pixmap_formats; i++)
- {
+ for (i = 0; i < num_pixmap_formats; i++) {
if (color_depth == TPL_DONT_CARE ||
- pixmap_formats[i].depth == color_depth)
- {
+ pixmap_formats[i].depth == color_depth) {
if (is_slow != NULL)
*is_slow = TPL_FALSE;
}
#if 0
-static void tpl_handle_and_free_error( Display *dpy, xcb_generic_error_t *error, const char* request_string )
+static void tpl_handle_and_free_error( Display *dpy, xcb_generic_error_t *error,
+ const char *request_string )
{
char error_txt[256];
- if( error )
- {
- int len = sizeof(error_txt)/sizeof(error_txt[0]);
+ if ( error ) {
+ int len = sizeof(error_txt) / sizeof(error_txt[0]);
XGetErrorText( dpy, error->error_code, error_txt, len );
error_txt[ len - 1] = '\0';
- TPL_WARN("%s failed \"[%d]:%s\"", request_string, error->error_code, error_txt );
+ TPL_WARN("%s failed \"[%d]:%s\"", request_string, error->error_code,
+ error_txt );
free(error);
- }
- else
- {
+ } else {
TPL_WARN("%s failed \"Unknown error\"", request_string );
}
}
-static tpl_bool_t tpl_check_reply_for_error(Display *dpy, xcb_generic_reply_t *reply, xcb_generic_error_t *error,
+static tpl_bool_t tpl_check_reply_for_error(Display *dpy,
+ xcb_generic_reply_t *reply, xcb_generic_error_t *error,
const char *request_string)
{
tpl_bool_t retval = TPL_FALSE;
- if (error || reply == NULL)
- {
+ if (error || reply == NULL) {
tpl_handle_and_free_error( dpy, error, request_string );
- }
- else
- {
+ } else {
retval = TPL_TRUE;
}
return retval;
}
-static XVisualInfo* tpl_find_visual( Display *dpy, xcb_visualid_t visual_id )
+static XVisualInfo *tpl_find_visual( Display *dpy, xcb_visualid_t visual_id )
{
XVisualInfo *visual_info;
XVisualInfo visual_info_template;
visual_info_template.visualid = visual_id;
- visual_info = XGetVisualInfo(dpy, VisualIDMask, &visual_info_template, &matching_count);
+ visual_info = XGetVisualInfo(dpy, VisualIDMask, &visual_info_template,
+ &matching_count);
return visual_info;
}
-static int tpl_get_alpha_offset( int offset_r, int offset_g, int offset_b, int bpp )
+static int tpl_get_alpha_offset( int offset_r, int offset_g, int offset_b,
+ int bpp )
{
int ret = -1;
- TPL_CHECK_ON_FALSE_ASSERT_FAIL( bpp == 32, "alpha only supported for 32bits pixel formats");
+ TPL_CHECK_ON_FALSE_ASSERT_FAIL( bpp == 32,
+ "alpha only supported for 32bits pixel formats");
- if( offset_r != 0 && offset_g != 0 && offset_b != 0 )
- {
+ if ( offset_r != 0 && offset_g != 0 && offset_b != 0 ) {
ret = 0;
- }
- else if( offset_r != 24 && offset_g != 24 && offset_b != 24 )
- {
+ } else if ( offset_r != 24 && offset_g != 24 && offset_b != 24 ) {
ret = 24;
- }
- else
- {
- TPL_CHECK_ON_FALSE_ASSERT_FAIL(TPL_FALSE, "Alpha component has to be at either the offset 0 or 24");
+ } else {
+ TPL_CHECK_ON_FALSE_ASSERT_FAIL(TPL_FALSE,
+ "Alpha component has to be at either the offset 0 or 24");
}
return ret;
int res = -1;
int count;
- for (count = 0; count < depth; count++)
- {
- if (mask & 1)
- {
+ for (count = 0; count < depth; count++) {
+ if (mask & 1) {
res = count;
break;
}
return res;
}
/* Convert the given combination of offsets and bpp into a color buffer format */
-static tpl_format_t tpl_offsets_to_color_buffer_format( int offset_r, int offset_g, int offset_b, int offset_a, int bpp )
+static tpl_format_t tpl_offsets_to_color_buffer_format( int offset_r,
+ int offset_g, int offset_b, int offset_a, int bpp )
{
tpl_format_t retval = TPL_FORMAT_INVALID;
- if ( offset_b == 11 && offset_g == 5 && offset_r == 0 && offset_a == -1 && bpp == 16)
- {
+ if ( offset_b == 11 && offset_g == 5 && offset_r == 0 && offset_a == -1 &&
+ bpp == 16) {
retval = TPL_FORMAT_BGR565;
- }
- else if( offset_r == 11 && offset_g == 5 && offset_b == 0 && offset_a == -1 && bpp == 16)
- {
+ } else if ( offset_r == 11 && offset_g == 5 && offset_b == 0 &&
+ offset_a == -1 && bpp == 16) {
retval = TPL_FORMAT_RGB565;
}
- else if( offset_a == 24 && offset_b == 16 && offset_g == 8 && offset_r == 0 && bpp == 32)
- {
+ else if ( offset_a == 24 && offset_b == 16 && offset_g == 8 &&
+ offset_r == 0 && bpp == 32) {
retval = TPL_FORMAT_ABGR8888;
- }
- else if( offset_a == 24 && offset_r == 16 && offset_g == 8 && offset_b == 0 && bpp == 32)
- {
+ } else if ( offset_a == 24 && offset_r == 16 && offset_g == 8 &&
+ offset_b == 0 && bpp == 32) {
retval = TPL_FORMAT_ARGB8888;
- }
- else if( offset_b == 24 && offset_g == 16 && offset_r == 8 && offset_a == 0 && bpp == 32)
- {
+ } else if ( offset_b == 24 && offset_g == 16 && offset_r == 8 &&
+ offset_a == 0 && bpp == 32) {
retval = TPL_FORMAT_BGRA8888;
- }
- else if( offset_r == 24 && offset_g == 16 && offset_b == 8 && offset_a == 0 && bpp == 32)
- {
+ } else if ( offset_r == 24 && offset_g == 16 && offset_b == 8 &&
+ offset_a == 0 && bpp == 32) {
retval = TPL_FORMAT_RGBA8888;
}
- else if( offset_b == 16 && offset_g == 8 && offset_r == 0 && offset_a == -1 && bpp == 32)
- {
+ else if ( offset_b == 16 && offset_g == 8 && offset_r == 0 &&
+ offset_a == -1 && bpp == 32) {
retval = TPL_FORMAT_XBGR8888;
- }
- else if( offset_r == 16 && offset_g == 8 && offset_b == 0 && offset_a == -1 && bpp == 32)
- {
+ } else if ( offset_r == 16 && offset_g == 8 && offset_b == 0 &&
+ offset_a == -1 && bpp == 32) {
retval = TPL_FORMAT_XRGB8888;
- }
- else if( offset_b == 24 && offset_g == 16 && offset_r == 8 && offset_a == -1 && bpp == 32)
- {
+ } else if ( offset_b == 24 && offset_g == 16 && offset_r == 8 &&
+ offset_a == -1 && bpp == 32) {
retval = TPL_FORMAT_BGRX8888;
- }
- else if( offset_r == 24 && offset_g == 16 && offset_b == 8 && offset_a == -1 && bpp == 32)
- {
+ } else if ( offset_r == 24 && offset_g == 16 && offset_b == 8 &&
+ offset_a == -1 && bpp == 32) {
retval = TPL_FORMAT_RGBX8888;
}
- else if( offset_b == 16 && offset_g == 8 && offset_r == 0 && offset_a == -1 && bpp == 24)
- {
+ else if ( offset_b == 16 && offset_g == 8 && offset_r == 0 &&
+ offset_a == -1 && bpp == 24) {
retval = TPL_FORMAT_BGR888;
- }
- else if( offset_r == 16 && offset_g == 8 && offset_b == 0 && offset_a == -1 && bpp == 24)
- {
+ } else if ( offset_r == 16 && offset_g == 8 && offset_b == 0 &&
+ offset_a == -1 && bpp == 24) {
retval = TPL_FORMAT_RGB888;
}
- else if( offset_a == 12 && offset_b == 8 && offset_g == 4 && offset_r == 0 && bpp == 16)
- {
+ else if ( offset_a == 12 && offset_b == 8 && offset_g == 4 &&
+ offset_r == 0 && bpp == 16) {
retval = TPL_FORMAT_ABGR4444;
- }
- else if( offset_a == 12 && offset_r == 8 && offset_g == 4 && offset_b == 0 && bpp == 16)
- {
+ } else if ( offset_a == 12 && offset_r == 8 && offset_g == 4 &&
+ offset_b == 0 && bpp == 16) {
retval = TPL_FORMAT_ARGB4444;
- }
- else if( offset_b == 12 && offset_g == 8 && offset_r == 4 && offset_a == 0 && bpp == 16)
- {
+ } else if ( offset_b == 12 && offset_g == 8 && offset_r == 4 &&
+ offset_a == 0 && bpp == 16) {
retval = TPL_FORMAT_BGRA4444;
- }
- else if( offset_r == 12 && offset_g == 8 && offset_b == 4 && offset_a == 0 && bpp == 16)
- {
+ } else if ( offset_r == 12 && offset_g == 8 && offset_b == 4 &&
+ offset_a == 0 && bpp == 16) {
retval = TPL_FORMAT_RGBA4444;
}
- else if( offset_a == 15 && offset_b == 10 && offset_g == 5 && offset_r == 0 && bpp == 16)
- {
+ else if ( offset_a == 15 && offset_b == 10 && offset_g == 5 &&
+ offset_r == 0 && bpp == 16) {
retval = TPL_FORMAT_ABGR1555;
- }
- else if( offset_a == 15 && offset_r == 10 && offset_g == 5 && offset_b == 0 && bpp == 16)
- {
+ } else if ( offset_a == 15 && offset_r == 10 && offset_g == 5 &&
+ offset_b == 0 && bpp == 16) {
retval = TPL_FORMAT_ARGB1555;
- }
- else if( offset_b == 11 && offset_g == 6 && offset_r == 1 && offset_a == 0 && bpp == 16)
- {
+ } else if ( offset_b == 11 && offset_g == 6 && offset_r == 1 &&
+ offset_a == 0 && bpp == 16) {
retval = TPL_FORMAT_BGRA5551;
- }
- else if( offset_r == 11 && offset_g == 6 && offset_b == 1 && offset_a == 0 && bpp == 16)
- {
+ } else if ( offset_r == 11 && offset_g == 6 && offset_b == 1 &&
+ offset_a == 0 && bpp == 16) {
retval = TPL_FORMAT_RGBA5551;
}
- else
- {
+ else {
TPL_WARN("Format not supported: offset_r=%d, offset_g=%d, offset_b=%d, offset_a=%d, bpp=%d",
- offset_r, offset_g, offset_b, offset_a, bpp);
+ offset_r, offset_g, offset_b, offset_a, bpp);
}
return retval;
tpl_bool_t
__tpl_x11_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, tpl_format_t *format, int depth, int a_size)
{
Status x_res;
XWindowAttributes att;
TPL_ASSERT(display);
TPL_ASSERT(display->native_handle);
- x_res = XGetWindowAttributes((Display *)display->native_handle, (Window)window, &att);
-
- if (x_res != BadWindow)
- {
- if (format != NULL)
- {
- switch (att.depth)
- {
- case 32: *format = TPL_FORMAT_ARGB8888; break;
- case 24: *format = TPL_FORMAT_XRGB8888; break;
- case 16: *format = TPL_FORMAT_RGB565; break;
- default: *format = TPL_FORMAT_INVALID; break;
+ x_res = XGetWindowAttributes((Display *)display->native_handle, (Window)window,
+ &att);
+
+ if (x_res != BadWindow) {
+ if (format != NULL) {
+ switch (att.depth) {
+ case 32:
+ *format = TPL_FORMAT_ARGB8888;
+ break;
+ case 24:
+ *format = TPL_FORMAT_XRGB8888;
+ break;
+ case 16:
+ *format = TPL_FORMAT_RGB565;
+ break;
+ default:
+ *format = TPL_FORMAT_INVALID;
+ break;
}
}
if (width != NULL) *width = att.width;
tpl_bool_t
__tpl_x11_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
- int *width, int *height, tpl_format_t *format)
+ int *width, int *height, tpl_format_t *format)
{
Status x_res;
Window root = None;
x_res = XGetGeometry((Display *)display->native_handle, (Pixmap)pixmap, &root,
&x, &y, &w, &h, &bw, &d);
- if (x_res != BadDrawable)
- {
- if (format != NULL)
- {
- switch (d)
- {
- case 32: *format = TPL_FORMAT_ARGB8888; break;
- case 24: *format = TPL_FORMAT_XRGB8888; break;
- case 16: *format = TPL_FORMAT_RGB565; break;
- default: *format = TPL_FORMAT_INVALID; break;
+ if (x_res != BadDrawable) {
+ if (format != NULL) {
+ switch (d) {
+ case 32:
+ *format = TPL_FORMAT_ARGB8888;
+ break;
+ case 24:
+ *format = TPL_FORMAT_XRGB8888;
+ break;
+ case 16:
+ *format = TPL_FORMAT_RGB565;
+ break;
+ default:
+ *format = TPL_FORMAT_INVALID;
+ break;
}
}
if (width != NULL) *width = w;
{
TPL_ASSERT(buffer);
- if (buffer->backend.data)
- {
+ if (buffer->backend.data) {
tbm_bo_map((tbm_bo)buffer->backend.data, TBM_DEVICE_3D, TBM_OPTION_READ);
tbm_bo_unmap((tbm_bo)buffer->backend.data);
tbm_bo_unref((tbm_bo)buffer->backend.data);
TPL_OBJECT_UNLOCK(buffer);
- switch (usage)
- {
- case TPL_LOCK_USAGE_GPU_READ:
- handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_READ);
- break;
- case TPL_LOCK_USAGE_GPU_WRITE:
- handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_WRITE);
- break;
- case TPL_LOCK_USAGE_CPU_READ:
- handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
- break;
- case TPL_LOCK_USAGE_CPU_WRITE:
- handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
- break;
- default:
- TPL_ASSERT(TPL_FALSE);
- return TPL_FALSE;
+ switch (usage) {
+ case TPL_LOCK_USAGE_GPU_READ:
+ handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_READ);
+ break;
+ case TPL_LOCK_USAGE_GPU_WRITE:
+ handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_WRITE);
+ break;
+ case TPL_LOCK_USAGE_CPU_READ:
+ handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
+ break;
+ case TPL_LOCK_USAGE_CPU_WRITE:
+ handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+ break;
+ default:
+ TPL_ASSERT(TPL_FALSE);
+ return TPL_FALSE;
}
TPL_OBJECT_LOCK(buffer);
TPL_ASSERT(display);
xlib_display = (Display *) display->native_handle;
- if (xlib_display != NULL)
- {
+ if (xlib_display != NULL) {
/* Leave events in the queue since we only care they have arrived. */
XSync(xlib_display, 0);
}
typedef struct _tpl_x11_dri2_surface tpl_x11_dri2_surface_t;
-struct _tpl_x11_dri2_surface
-{
+struct _tpl_x11_dri2_surface {
int latest_post_interval;
XserverRegion damage;
tpl_list_t buffer_cache;
-static tpl_x11_global_t global =
-{
+static tpl_x11_global_t global = {
0,
NULL,
-1,
static void
__tpl_x11_dri2_surface_post_internal(tpl_surface_t *surface, tpl_frame_t *frame,
- tpl_bool_t is_worker)
+ tpl_bool_t is_worker)
{
Display *display;
Drawable drawable;
if (interval < 1)
interval = 1;
- if (interval != x11_surface->latest_post_interval)
- {
+ if (interval != x11_surface->latest_post_interval) {
DRI2SwapInterval(display, drawable, interval);
x11_surface->latest_post_interval = interval;
}
- if (__tpl_region_is_empty(&frame->damage))
- {
+ if (__tpl_region_is_empty(&frame->damage)) {
DRI2SwapBuffers(display, drawable, 0, 0, 0, &swap_count);
- }
- else
- {
+ } else {
int i;
- if (frame->damage.num_rects > TPL_STACK_XRECTANGLE_SIZE)
- {
+ if (frame->damage.num_rects > TPL_STACK_XRECTANGLE_SIZE) {
xrects = (XRectangle *) malloc(sizeof(XRectangle) *
- frame->damage.num_rects);
- }
- else
- {
+ frame->damage.num_rects);
+ } else {
xrects = &xrects_stack[0];
}
- for (i = 0; i < frame->damage.num_rects; i++)
- {
+ for (i = 0; i < frame->damage.num_rects; i++) {
const int *rects = &frame->damage.rects[i * 4];
xrects[i].x = rects[0];
xrects[i].height = rects[3];
}
- if (x11_surface->damage == None)
- {
+ if (x11_surface->damage == None) {
x11_surface->damage =
XFixesCreateRegion(display, xrects, frame->damage.num_rects);
- }
- else
- {
+ } else {
XFixesSetRegion(display, x11_surface->damage,
xrects, frame->damage.num_rects);
}
mutex = __tpl_x11_get_global_mutex();
- if (display->native_handle == NULL)
- {
+ if (display->native_handle == NULL) {
display->native_handle = XOpenDisplay(NULL);
- if (NULL == display->native_handle)
- {
+ if (NULL == display->native_handle) {
TPL_ERR("XOpenDisplay failed!");
return TPL_FALSE;
}
}
- display->xcb_connection = XGetXCBConnection( (Display*)display->native_handle );
- if( NULL == display->xcb_connection )
- {
+ display->xcb_connection = XGetXCBConnection( (Display *)
+ display->native_handle );
+ if ( NULL == display->xcb_connection ) {
TPL_WARN("XGetXCBConnection failed");
}
pthread_mutex_lock(&mutex);
- if (global.display_count == 0)
- {
+ if (global.display_count == 0) {
Bool xres = False;
char *drv = NULL;
char *dev = NULL;
/* Open a dummy display connection. */
global.worker_display = XOpenDisplay(NULL);
- if (NULL == global.worker_display)
- {
+ if (NULL == global.worker_display) {
TPL_ERR("XOpenDisplay failed!");
return TPL_FALSE;
}
/* Initialize DRI2. */
xres = DRI2QueryExtension(global.worker_display, &event_base, &error_base);
- if (True != xres)
- {
+ if (True != xres) {
TPL_ERR("DRI2QueryExtension failed!");
return TPL_FALSE;
}
xres = DRI2QueryVersion(global.worker_display, &major, &minor);
- if (True != xres)
- {
+ if (True != xres) {
TPL_ERR("DRI2QueryVersion failed!");
return TPL_FALSE;
}
xres = DRI2Connect(global.worker_display, root, &drv, &dev);
- if (True != xres)
- {
+ if (True != xres) {
TPL_ERR("DRI2Connect failed!");
return TPL_FALSE;
}
/* DRI2 authentication. */
xres = DRI2Authenticate(global.worker_display, root, magic);
- if (True != xres)
- {
+ if (True != xres) {
TPL_ERR("DRI2Authenciate failed!");
return TPL_FALSE;
}
/* Initialize swap type configuration. */
__tpl_x11_swap_str_to_swap_type(getenv(EGL_X11_WINDOW_SWAP_TYPE_ENV_NAME),
- &global.win_swap_type);
+ &global.win_swap_type);
__tpl_x11_swap_str_to_swap_type(getenv(EGL_X11_FB_SWAP_TYPE_ENV_NAME),
- &global.fb_swap_type);
+ &global.fb_swap_type);
}
global.display_count++;
pthread_mutex_lock(&mutex);
- if (--global.display_count == 0)
- {
+ if (--global.display_count == 0) {
tbm_bufmgr_deinit(global.bufmgr);
close(global.bufmgr_fd);
XCloseDisplay(global.worker_display);
TPL_ASSERT(surface);
- if (surface->type == TPL_SURFACE_TYPE_WINDOW)
- {
+ if (surface->type == TPL_SURFACE_TYPE_WINDOW) {
if (!__tpl_x11_display_get_window_info(surface->display, surface->native_handle,
- &surface->width, &surface->height, NULL,0,0))
+ &surface->width, &surface->height, NULL, 0, 0))
return TPL_FALSE;
- }
- else
- {
+ } else {
if (!__tpl_x11_display_get_pixmap_info(surface->display, surface->native_handle,
&surface->width, &surface->height, &format))
return TPL_FALSE;
}
- x11_surface = (tpl_x11_dri2_surface_t *) calloc(1, sizeof(tpl_x11_dri2_surface_t));
+ x11_surface = (tpl_x11_dri2_surface_t *) calloc(1,
+ sizeof(tpl_x11_dri2_surface_t));
- if (x11_surface == NULL)
- {
+ if (x11_surface == NULL) {
TPL_ERR("Failed to allocate memory for X11 surface!");
return TPL_FALSE;
}
drawable = (Drawable)surface->native_handle;
x11_surface = (tpl_x11_dri2_surface_t *)surface->backend.data;
- if (x11_surface)
- {
+ if (x11_surface) {
__tpl_x11_surface_buffer_cache_clear(&x11_surface->buffer_cache);
if (x11_surface->damage)
TPL_ASSERT(surface);
- if (surface->type != TPL_SURFACE_TYPE_WINDOW)
- {
+ if (surface->type != TPL_SURFACE_TYPE_WINDOW) {
TPL_ERR("Surface type is not of window type!");
return;
}
prev_frame = __tpl_surface_get_latest_frame(surface);
- if (prev_frame && prev_frame->state != TPL_FRAME_STATE_POSTED)
- {
+ if (prev_frame && prev_frame->state != TPL_FRAME_STATE_POSTED) {
if ((DRI2_BUFFER_IS_FB(prev_frame->buffer->backend.flags) &&
global.fb_swap_type == TPL_X11_SWAP_TYPE_SYNC) ||
(!DRI2_BUFFER_IS_FB(prev_frame->buffer->backend.flags) &&
- global.win_swap_type == TPL_X11_SWAP_TYPE_SYNC))
- {
+ global.win_swap_type == TPL_X11_SWAP_TYPE_SYNC)) {
__tpl_surface_wait_all_frames(surface);
}
}
if ((DRI2_BUFFER_IS_FB(surface->frame->buffer->backend.flags) &&
global.fb_swap_type == TPL_X11_SWAP_TYPE_LAZY) ||
(!DRI2_BUFFER_IS_FB(surface->frame->buffer->backend.flags) &&
- global.win_swap_type == TPL_X11_SWAP_TYPE_LAZY))
- {
- if (x11_surface->latest_render_target == surface->frame->buffer)
- {
+ global.win_swap_type == TPL_X11_SWAP_TYPE_LAZY)) {
+ if (x11_surface->latest_render_target == surface->frame->buffer) {
__tpl_surface_wait_all_frames(surface);
return TPL_FALSE;
}
frame = __tpl_surface_get_latest_frame(surface);
x11_surface = (tpl_x11_dri2_surface_t *) surface->backend.data;
- if (frame)
- {
+ if (frame) {
x11_surface->latest_render_target = frame->buffer;
if ((DRI2_BUFFER_IS_FB(frame->buffer->backend.flags) &&
global.fb_swap_type == TPL_X11_SWAP_TYPE_ASYNC) ||
(!DRI2_BUFFER_IS_FB(frame->buffer->backend.flags) &&
- global.win_swap_type == TPL_X11_SWAP_TYPE_ASYNC))
- {
+ global.win_swap_type == TPL_X11_SWAP_TYPE_ASYNC)) {
__tpl_x11_dri2_surface_post_internal(surface, frame, TPL_FALSE);
}
}
}
static tpl_buffer_t *
-__tpl_x11_dri2_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buffers)
+__tpl_x11_dri2_surface_get_buffer(tpl_surface_t *surface,
+ tpl_bool_t *reset_buffers)
{
tpl_buffer_t *buffer = NULL;
Display *display;
/* Get the current buffer via DRI2. */
dri2_buffers = DRI2GetBuffers(display, drawable,
&width, &height, attachments, 1, &num_buffers);
- if (dri2_buffers == NULL)
- {
+ if (dri2_buffers == NULL) {
TPL_ERR("DRI2GetBuffers failed!");
goto err_buffer;
}
- if (DRI2_BUFFER_IS_REUSED(dri2_buffers[0].flags))
- {
+ if (DRI2_BUFFER_IS_REUSED(dri2_buffers[0].flags)) {
/* Buffer is reused. So it should be in the buffer cache.
* However, sometimes we get a strange result of having reused flag for a newly
* received buffer. I don't know the meaning of such cases but just handle it. */
- buffer = __tpl_x11_surface_buffer_cache_find(&x11_surface->buffer_cache, dri2_buffers[0].name);
+ buffer = __tpl_x11_surface_buffer_cache_find(&x11_surface->buffer_cache,
+ dri2_buffers[0].name);
- if (buffer)
- {
+ if (buffer) {
/* Need to update buffer flag */
buffer->backend.flags = dri2_buffers[0].flags;
/* just update the buffer age. */
#endif
goto done;
}
- }
- else
- {
+ } else {
/* Buffer configuration of the server is changed. We have to reset all previsouly
* received buffers. */
__tpl_x11_surface_buffer_cache_clear(&x11_surface->buffer_cache);
/* Create a TBM buffer object for the buffer name. */
bo = tbm_bo_import(global.bufmgr, dri2_buffers[0].name);
- if (bo == NULL)
- {
+ if (bo == NULL) {
TPL_ERR("TBM bo import failed!");
goto done;
}
bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_3D);
/* Create tpl buffer. */
- buffer = __tpl_buffer_alloc(surface, (size_t) dri2_buffers[0].name, (int) bo_handle.u32,
+ buffer = __tpl_buffer_alloc(surface, (size_t) dri2_buffers[0].name,
+ (int) bo_handle.u32,
width, height, dri2_buffers[0].cpp * 8, dri2_buffers[0].pitch);
- if (NULL == buffer)
- {
+ if (NULL == buffer) {
TPL_ERR("TPL buffer alloc failed!");
goto err_buffer;
}
tpl_object_unreference(&buffer->base);
done:
- if (reset_buffers)
- {
+ if (reset_buffers) {
/* Users use this output value to check if they have to reset previous buffers. */
*reset_buffers = !DRI2_BUFFER_IS_REUSED(dri2_buffers[0].flags) ||
- width != surface->width || height != surface->height;
+ width != surface->width || height != surface->height;
}
XFree(dri2_buffers);
typedef struct _tpl_x11_dri3_surface tpl_x11_dri3_surface_t;
-struct _tpl_x11_dri3_surface
-{
+struct _tpl_x11_dri3_surface {
int latest_post_interval;
XserverRegion damage;
tpl_list_t buffer_cache;
void *drawable;
};
-enum dri3_buffer_type
-{
+enum dri3_buffer_type {
dri3_buffer_back = 0,
dri3_buffer_front = 1
};
-enum dri3_buffer_status
-{
- dri3_buffer_idle = 0,
- dri3_buffer_busy = 1,
- dri3_buffer_posted = 2
+enum dri3_buffer_status {
+ dri3_buffer_idle = 0,
+ dri3_buffer_busy = 1,
+ dri3_buffer_posted = 2
};
-typedef struct _dri3_buffer
-{
+typedef struct _dri3_buffer {
tbm_bo tbo;
uint32_t pixmap;
enum dri3_buffer_status status; /* Set on swap, cleared on IdleNotify */
uint32_t dma_buf_fd; /* fd of dma buffer */
/* [BEGIN: 20141125-xuelian.bai] Add old dma fd to save old fd
* before use new fd */
- /* 2015-04-08 joonbum.ko@samsung.com */
- /* Change old buffer name to old_bo_name from old_dma_fd */
+ /* 2015-04-08 joonbum.ko@samsung.com */
+ /* Change old buffer name to old_bo_name from old_dma_fd */
/* uint32_t old_dma_fd; */
- uint32_t old_bo_name;
+ uint32_t old_bo_name;
/* [END: 20141125-xuelian.bai] */
enum dri3_buffer_type buffer_type; /* back=0,front=1 */
- /* [BEGIN: 20140119-leiba.sun] Add support for buffer age */
- uint32_t buffer_age;
- /* [END:20150119-leiba.sun] */
+ /* [BEGIN: 20140119-leiba.sun] Add support for buffer age */
+ uint32_t buffer_age;
+ /* [END:20150119-leiba.sun] */
} dri3_buffer;
-typedef struct _dri3_drawable
-{
+typedef struct _dri3_drawable {
Display *dpy;
XID xDrawable;
xcb_special_event_t *special_event;
} dri3_drawable;
-typedef struct _dri3_drawable_node
-{
+typedef struct _dri3_drawable_node {
XID xDrawable;
dri3_drawable *drawable;
} dri3_drawable_node;
-static tpl_x11_global_t global =
-{
+static tpl_x11_global_t global = {
0,
NULL,
-1,
c = XGetXCBConnection(dpy);
cookie = xcb_dri3_open(c,
- root,
- provider);
+ root,
+ provider);
reply = xcb_dri3_open_reply(c, cookie, NULL);
- if (!reply)
- {
+ if (!reply) {
TPL_ERR("XCB DRI3 open failed!");
return -1;
}
- if (reply->nfd != 1)
- {
+ if (reply->nfd != 1) {
TPL_ERR("XCB DRI3 open reply failed!");
free(reply);
return -1;
xcb_prefetch_extension_data(c, &xcb_present_id);
extension = xcb_get_extension_data(c, &xcb_dri3_id);
- if (!(extension && extension->present))
- {
+ if (!(extension && extension->present)) {
TPL_ERR("XCB get extension failed!");
return TPL_FALSE;
}
extension = xcb_get_extension_data(c, &xcb_present_id);
- if (!(extension && extension->present))
- {
+ if (!(extension && extension->present)) {
TPL_ERR("XCB get extension failed!");
return TPL_FALSE;
}
dri3_cookie = xcb_dri3_query_version(c,
- XCB_DRI3_MAJOR_VERSION,
- XCB_DRI3_MINOR_VERSION);
+ XCB_DRI3_MAJOR_VERSION,
+ XCB_DRI3_MINOR_VERSION);
dri3_reply = xcb_dri3_query_version_reply(c, dri3_cookie, &error);
- if (!dri3_reply)
- {
+ if (!dri3_reply) {
TPL_ERR("XCB version query failed!");
free(error);
return TPL_FALSE;
free(dri3_reply);
present_cookie = xcb_present_query_version(c,
- XCB_PRESENT_MAJOR_VERSION,
- XCB_PRESENT_MINOR_VERSION);
+ XCB_PRESENT_MAJOR_VERSION,
+ XCB_PRESENT_MINOR_VERSION);
present_reply = xcb_present_query_version_reply(c, present_cookie, &error);
- if (!present_reply)
- {
+ if (!present_reply) {
TPL_ERR("Present version query failed!");
free(error);
return TPL_FALSE;
/* Check drawable list to find that if it has been created*/
node = __tpl_list_get_front_node(&dri3_drawable_list);
- while (node)
- {
- dri3_drawable_node *drawable = (dri3_drawable_node *) __tpl_list_node_get_data(node);
+ while (node) {
+ dri3_drawable_node *drawable = (dri3_drawable_node *) __tpl_list_node_get_data(
+ node);
- if (drawable->xDrawable == xDrawable)
- {
+ if (drawable->xDrawable == xDrawable) {
pdraw = drawable->drawable;
return (void *)pdraw;/* Reuse old drawable */
}
node = __tpl_list_node_next(node);
}
pdraw = calloc(1, sizeof(*pdraw));
- if (NULL == pdraw)
- {
+ if (NULL == pdraw) {
TPL_ERR("Failed to allocate memory!");
return NULL;
}
geom_cookie = xcb_get_geometry(c, xDrawable);
geom_reply = xcb_get_geometry_reply(c, geom_cookie, NULL);
- if (NULL == geom_reply)
- {
+ if (NULL == geom_reply) {
TPL_ERR("XCB get geometry failed!");
free(pdraw);
return NULL;
pdraw->dpy = global.worker_display;
pdraw->xDrawable = xDrawable;
- for (i = 0; i < dri3_max_back + 1;i++)
+ for (i = 0; i < dri3_max_back + 1; i++)
pdraw->buffers[i] = NULL;
/* Add new allocated drawable to drawable list */
drawable_node = calloc(1, sizeof(dri3_drawable_node));
- if (NULL == drawable_node)
- {
+ if (NULL == drawable_node) {
TPL_ERR("Failed to allocate memory for drawable node!");
free(pdraw);
return NULL;
drawable_node->drawable = pdraw;
drawable_node->xDrawable = xDrawable;
- if (TPL_TRUE != __tpl_list_push_back(&dri3_drawable_list, (void *)drawable_node))
- {
+ if (TPL_TRUE != __tpl_list_push_back(&dri3_drawable_list,
+ (void *)drawable_node)) {
TPL_ERR("List operation failed!");
free(pdraw);
free(drawable_node);
return NULL;
}
- return (void*)pdraw;
+ return (void *)pdraw;
}
static void
/* Remove drawable from list */
node = __tpl_list_get_front_node(&dri3_drawable_list);
- while (node)
- {
+ while (node) {
drawable = (dri3_drawable_node *) __tpl_list_node_get_data(node);
- if (drawable->xDrawable== xDrawable)
- {
+ if (drawable->xDrawable == xDrawable) {
pdraw = drawable->drawable;
if (!pdraw)
return;
- for (i = 0; i < dri3_max_back + 1; i++)
- {
+ for (i = 0; i < dri3_max_back + 1; i++) {
if (pdraw->buffers[i])
dri3_free_render_buffer(pdraw, pdraw->buffers[i]);
}
/* First time through, go get the current drawable geometry
*/ /*TODO*/
- if (priv->special_event == NULL)
- {
+ if (priv->special_event == NULL) {
xcb_get_geometry_cookie_t geom_cookie;
xcb_get_geometry_reply_t *geom_reply;
xcb_void_cookie_t cookie;
cookie = xcb_present_select_input_checked(c,
(priv->eid = xcb_generate_id(c)),
priv->xDrawable,
- XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY|
- XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY|
+ XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY |
+ XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY |
XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
- present_capabilities_cookie = xcb_present_query_capabilities(c, priv->xDrawable);
+ present_capabilities_cookie = xcb_present_query_capabilities(c,
+ priv->xDrawable);
/* Create an XCB event queue to hold present events outside of the usual
* application event queue
*/
priv->special_event = xcb_register_for_special_xge(c,
- &xcb_present_id,
- priv->eid,
- &priv->stamp);
+ &xcb_present_id,
+ priv->eid,
+ &priv->stamp);
geom_cookie = xcb_get_geometry(c, priv->xDrawable);
geom_reply = xcb_get_geometry_reply(c, geom_cookie, NULL);
- if (NULL == geom_reply)
- {
+ if (NULL == geom_reply) {
TPL_ERR("Failed to get geometry reply!");
return TPL_FALSE;
}
error = xcb_request_check(c, cookie);
present_capabilities_reply = xcb_present_query_capabilities_reply(c,
- present_capabilities_cookie,
- NULL);
+ present_capabilities_cookie,
+ NULL);
- if (present_capabilities_reply)
- {
+ if (present_capabilities_reply) {
priv->present_capabilities = present_capabilities_reply->capabilities;
free(present_capabilities_reply);
} else
priv->present_capabilities = 0;
- if (error)
- {
- if (error->error_code != BadWindow)
- {
+ if (error) {
+ if (error->error_code != BadWindow) {
free(error);
return TPL_FALSE;
}
TPL_ASSERT(priv);
TPL_ASSERT(ge);
- switch (ge->evtype)
- {
- case XCB_PRESENT_CONFIGURE_NOTIFY:
- {
- TRACE_BEGIN("DRI3:PRESENT_CONFIGURE_NOTIFY");
- xcb_present_configure_notify_event_t *ce = (void *) ge;
- priv->width = ce->width;
- priv->height = ce->height;
- TRACE_END();
- break;
- }
+ switch (ge->evtype) {
+ case XCB_PRESENT_CONFIGURE_NOTIFY: {
+ TRACE_BEGIN("DRI3:PRESENT_CONFIGURE_NOTIFY");
+ xcb_present_configure_notify_event_t *ce = (void *) ge;
+ priv->width = ce->width;
+ priv->height = ce->height;
+ TRACE_END();
+ break;
+ }
- case XCB_PRESENT_COMPLETE_NOTIFY:
- {
- TRACE_BEGIN("DRI3:PRESENT_COMPLETE_NOTIFY");
- xcb_present_complete_notify_event_t *ce = (void *) ge;
- /* Compute the processed SBC number from the received
- * 32-bit serial number merged with the upper 32-bits
- * of the sent 64-bit serial number while checking for
- * wrap
- */
- if (ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP)
- {
- priv->recv_sbc =
- (priv->send_sbc & 0xffffffff00000000LL) |
- ce->serial;
- if (priv->recv_sbc > priv->send_sbc)
- priv->recv_sbc -= 0x100000000;
- switch (ce->mode)
- {
- case XCB_PRESENT_COMPLETE_MODE_FLIP:
- priv->flipping = 1;
- break;
- case XCB_PRESENT_COMPLETE_MODE_COPY:
- priv->flipping = 0;
- break;
- }
- }
- else
- {
- priv->recv_msc_serial = ce->serial;
+ case XCB_PRESENT_COMPLETE_NOTIFY: {
+ TRACE_BEGIN("DRI3:PRESENT_COMPLETE_NOTIFY");
+ xcb_present_complete_notify_event_t *ce = (void *) ge;
+ /* Compute the processed SBC number from the received
+ * 32-bit serial number merged with the upper 32-bits
+ * of the sent 64-bit serial number while checking for
+ * wrap
+ */
+ if (ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP) {
+ priv->recv_sbc =
+ (priv->send_sbc & 0xffffffff00000000LL) |
+ ce->serial;
+ if (priv->recv_sbc > priv->send_sbc)
+ priv->recv_sbc -= 0x100000000;
+ switch (ce->mode) {
+ case XCB_PRESENT_COMPLETE_MODE_FLIP:
+ priv->flipping = 1;
+ break;
+ case XCB_PRESENT_COMPLETE_MODE_COPY:
+ priv->flipping = 0;
+ break;
}
-
- priv->ust = ce->ust;
- priv->msc = ce->msc;
- TRACE_END();
- break;
+ } else {
+ priv->recv_msc_serial = ce->serial;
}
- case XCB_PRESENT_EVENT_IDLE_NOTIFY:
- {
- xcb_present_idle_notify_event_t *ie = (void *) ge;
- uint32_t b;
-
- for (b = 0; b < sizeof (priv->buffers) / sizeof (priv->buffers[0]); b++)
- {
- dri3_buffer *buf = priv->buffers[b];
-
- if (buf && buf->pixmap == ie->pixmap)
- {
- TRACE_MARK("IDLE:%d",tbm_bo_export(priv->buffers[b]->tbo));
- buf->status = dri3_buffer_idle;
- break;
- }
+ priv->ust = ce->ust;
+ priv->msc = ce->msc;
+ TRACE_END();
+ break;
+ }
+
+ case XCB_PRESENT_EVENT_IDLE_NOTIFY: {
+ xcb_present_idle_notify_event_t *ie = (void *) ge;
+ uint32_t b;
+
+ for (b = 0; b < sizeof (priv->buffers) / sizeof (priv->buffers[0]); b++) {
+ dri3_buffer *buf = priv->buffers[b];
+
+ if (buf && buf->pixmap == ie->pixmap) {
+ TRACE_MARK("IDLE:%d", tbm_bo_export(priv->buffers[b]->tbo));
+ buf->status = dri3_buffer_idle;
+ break;
}
- break;
}
+ break;
+ }
}
free(ge);
- }
+}
- /******************************************************
- * dri3_flush_present_events
- *
- * Process any present events that have been received from the X server
- * called when get buffer or swap buffer
- ******************************************************/
+/******************************************************
+* dri3_flush_present_events
+*
+* Process any present events that have been received from the X server
+* called when get buffer or swap buffer
+******************************************************/
static void
dri3_flush_present_events(dri3_drawable *priv)
{
c = XGetXCBConnection(priv->dpy);
- TRACE_BEGIN("DRI3:FLUSH_PRESENT_EVENTS");
+ TRACE_BEGIN("DRI3:FLUSH_PRESENT_EVENTS");
/* Check to see if any configuration changes have occurred
* since we were last invoked
*/
- if (priv->special_event)
- {
+ if (priv->special_event) {
xcb_generic_event_t *ev;
- while ((ev = xcb_poll_for_special_event(c, priv->special_event)) != NULL)
- {
+ while ((ev = xcb_poll_for_special_event(c, priv->special_event)) != NULL) {
xcb_present_generic_event_t *ge = (void *) ev;
dri3_handle_present_event(priv, ge);
}
TRACE_BEGIN("TPL:DRI3:WAIT_FOR_NOTIFY");
- if (((uint32_t)priv->send_sbc) == 0)
- {
+ if (((uint32_t)priv->send_sbc) == 0) {
TRACE_END();
return TPL_TRUE;
}
- for (;;)
- {
- if( (uint32_t)priv->send_sbc <= (uint32_t)priv->recv_sbc )
- {
+ for (;;) {
+ if ( (uint32_t)priv->send_sbc <= (uint32_t)priv->recv_sbc ) {
TRACE_END();
return TPL_TRUE;
}
xcb_flush(c);
ev = xcb_wait_for_special_event(c, priv->special_event);
- if (!ev)
- {
+ if (!ev) {
TRACE_END();
return TPL_FALSE;
}
TPL_ASSERT(c);
TPL_ASSERT(priv);
- for (;;)
- {
- for (b = 0; b < dri3_max_back; b++)
- {
+ for (;;) {
+ for (b = 0; b < dri3_max_back; b++) {
int id = (b + priv->cur_back + 1) % dri3_max_back;
int pre_id = (id + dri3_max_back - 2) % dri3_max_back;
dri3_buffer *pre_buffer = priv->buffers[pre_id];
if (pre_buffer && pre_buffer->status != dri3_buffer_posted)
- pre_buffer->status = dri3_buffer_idle;
+ pre_buffer->status = dri3_buffer_idle;
- if (!buffer || buffer->status == dri3_buffer_idle)
- {
+ if (!buffer || buffer->status == dri3_buffer_idle) {
priv->cur_back = id;
return id;
}
ev = xcb_wait_for_special_event(c, priv->special_event);
TRACE_END();
- if (!ev)
- {
+ if (!ev) {
return -1;
}
*/
static dri3_buffer *
dri3_alloc_render_buffer(dri3_drawable *priv,
- int width, int height, int depth, int cpp)
+ int width, int height, int depth, int cpp)
{
Display *dpy;
Drawable draw;
dri3_buffer *buffer = NULL;
xcb_connection_t *c;
xcb_pixmap_t pixmap = 0;
- int buffer_fd;
+ int buffer_fd;
int size;
tbm_bo_handle handle;
xcb_void_cookie_t cookie;
/* Allocate the image from the driver
*/
buffer = calloc(1, sizeof (dri3_buffer));
- if (!buffer)
- {
+ if (!buffer) {
TPL_ERR("Failed to allocate buffer!");
goto no_buffer;
}
/* buffer->pitch = width*(cpp/8); */
/* Modify the calculation of pitch (strdie) */
- buffer->pitch = SIZE_ALIGN((width * cpp)>>3, ALIGNMENT_PITCH_ARGB);
+ buffer->pitch = SIZE_ALIGN((width * cpp) >> 3, ALIGNMENT_PITCH_ARGB);
- size = buffer->pitch*height;
+ size = buffer->pitch * height;
buffer->tbo = tbm_bo_alloc(priv->bufmgr, size, TBM_BO_DEFAULT);
- if (NULL == buffer->tbo)
- {
+ if (NULL == buffer->tbo) {
TPL_ERR("TBM bo alloc failed!");
free(buffer);
goto no_buffer;
/* buffer_fd is unuseful */
/* close(buffer_fd);*/
- if (error)
- {
+ if (error) {
TPL_ERR("No pixmap!");
goto no_pixmap;
}
- if (0 == pixmap)
- {
+ if (0 == pixmap) {
TPL_ERR("No pixmap!");
goto no_pixmap;
}
/* 2015-04-08 joonbum.ko@samsung.com */
/* if drawable type is pixmap, it requires only free buffer */
- if (!pdraw->is_pixmap)
- {
+ if (!pdraw->is_pixmap) {
if (buffer->own_pixmap)
xcb_free_pixmap(c, buffer->pixmap);
tbm_bo_unref(buffer->tbo);
dri3_drawable *priv = loaderPrivate;
xcb_connection_t *c;
dri3_buffer *backbuffer = NULL;
- int back_buf_id,reuse = 1;
+ int back_buf_id, reuse = 1;
uint32_t old_bo_name = 0;
TPL_ASSERT(priv);
* old one is the wrong size.
*/
if (!backbuffer || backbuffer->width != priv->width ||
- backbuffer->height != priv->height )
- {
+ backbuffer->height != priv->height ) {
dri3_buffer *new_buffer;
/* Allocate the new buffers
*/
TRACE_BEGIN("DDK:DRI3:ALLOCRENDERBUFFER");
new_buffer = dri3_alloc_render_buffer(priv,
- priv->width, priv->height, priv->depth, cpp);
+ priv->width, priv->height, priv->depth, cpp);
TRACE_END();
- if (!new_buffer)
- {
+ if (!new_buffer) {
TRACE_END();
return NULL;
}
- if (backbuffer)
- {
+ if (backbuffer) {
/* [BEGIN: 20141125-xuelian.bai] Size not match,this buffer
* must be removed from buffer cache, so we have to save
* dma_buf_fd of old buffer.*/
backbuffer->flags = DRI2_BUFFER_FB;
backbuffer->status = dri3_buffer_busy;
- if(reuse)
- {
+ if (reuse) {
backbuffer->flags |= DRI2_BUFFER_REUSED;
}
/* Return the requested buffer */
TRACE_END();
- TRACE_MARK("%d",tbm_bo_export(backbuffer->tbo));
+ TRACE_MARK("%d", tbm_bo_export(backbuffer->tbo));
return backbuffer;
}
/* modify internal flow of dri3_get_pixmap_buffer */
/* add 3rd argument for stride information */
static dri3_buffer *
-dri3_get_pixmap_buffer(void *loaderPrivate, Pixmap pixmap, int cpp)/*TODO:format*/
+dri3_get_pixmap_buffer(void *loaderPrivate, Pixmap pixmap,
+ int cpp)/*TODO:format*/
{
dri3_drawable *pdraw = loaderPrivate;
dri3_buffer *buffer = NULL;
*/
bp_cookie = xcb_dri3_buffer_from_pixmap(c, pixmap);
bp_reply = xcb_dri3_buffer_from_pixmap_reply(c, bp_cookie, NULL);
- if (!bp_reply)
- {
+ if (!bp_reply) {
goto no_image;
}
fds = xcb_dri3_buffer_from_pixmap_reply_fds(c, bp_reply);
- tbo = tbm_bo_import_fd(pdraw->bufmgr,(tbm_fd)(*fds));
+ tbo = tbm_bo_import_fd(pdraw->bufmgr, (tbm_fd)(*fds));
- if (!buffer)
- {
+ if (!buffer) {
buffer = calloc(1, sizeof (dri3_buffer));
if (!buffer)
goto no_buffer;
TRACE_END();
return buffer;
-/* 2015-04-09 joonbum.ko@samsung.com */
-/* change the lable order */
+ /* 2015-04-09 joonbum.ko@samsung.com */
+ /* change the lable order */
no_image:
if (buffer)
free(buffer);
}
static dri3_buffer *dri3_get_buffers(XID drawable, void *loaderPrivate,
- unsigned int *attachments, int cpp)
+ unsigned int *attachments, int cpp)
{
dri3_drawable *priv = loaderPrivate;
dri3_buffer *buffer = NULL;
TRACE_BEGIN("DDK:DRI3:GETBUFFERS");
- if (drawable != priv->xDrawable)
- {
+ if (drawable != priv->xDrawable) {
TPL_ERR("Drawable mismatch!");
TRACE_END();
return NULL;
}
- if (!dri3_update_drawable(loaderPrivate))
- {
+ if (!dri3_update_drawable(loaderPrivate)) {
TPL_ERR("Update drawable failed!");
TRACE_END();
return NULL;
if (*attachments == dri3_buffer_front)
buffer = dri3_get_pixmap_buffer(loaderPrivate,
- priv->xDrawable, cpp);
+ priv->xDrawable, cpp);
else
buffer = dri3_get_window_buffer(loaderPrivate, cpp);
- if (NULL == buffer)
- {
+ if (NULL == buffer) {
TPL_ERR("Get buffer failed!");
return NULL;
}
* if (region_t==0),swap whole frame, else swap with region
******************************************************/
static int64_t
-dri3_swap_buffers(Display *dpy, void *priv, tpl_buffer_t *frame_buffer, int interval, XID region_t)
+dri3_swap_buffers(Display *dpy, void *priv, tpl_buffer_t *frame_buffer,
+ int interval, XID region_t)
{
int64_t ret = -1;
xcb_connection_t *c;
dri3_drawable *pDrawable;
dri3_buffer *back = NULL;
- int i = 0;
+ int i = 0;
TPL_ASSERT(dpy);
TPL_ASSERT(priv);
c = XGetXCBConnection(dpy);
- pDrawable = (dri3_drawable*) priv;
- back = (dri3_buffer*) frame_buffer->backend.data;
+ pDrawable = (dri3_drawable *) priv;
+ back = (dri3_buffer *) frame_buffer->backend.data;
- if ((back == NULL)||(pDrawable == NULL)||(pDrawable->is_pixmap != 0))
- {
+ if ((back == NULL) || (pDrawable == NULL) || (pDrawable->is_pixmap != 0)) {
TRACE_END();
return ret;
}
/* Process any present events that have been received from the X
* server until receive complete notify.
*/
- if (!dri3_wait_for_notify(c, pDrawable))
- {
+ if (!dri3_wait_for_notify(c, pDrawable)) {
TRACE_END();
return ret;
}
- /* [BEGIN: 20140119-leiba.sun] Add support for buffer age
- * When swap buffer, increase buffer age of every back buffer */
- for(i = 0; i < dri3_max_back; i++)
- {
- if((pDrawable->buffers[i] != NULL)&&(pDrawable->buffers[i]->buffer_age > 0))
+ /* [BEGIN: 20140119-leiba.sun] Add support for buffer age
+ * When swap buffer, increase buffer age of every back buffer */
+ for (i = 0; i < dri3_max_back; i++) {
+ if ((pDrawable->buffers[i] != NULL) && (pDrawable->buffers[i]->buffer_age > 0))
pDrawable->buffers[i]->buffer_age++;
}
back->buffer_age = 1;
++pDrawable->send_sbc;
if (target_msc == 0)
target_msc = pDrawable->msc + pDrawable->swap_interval *
- (pDrawable->send_sbc - pDrawable->recv_sbc);
+ (pDrawable->send_sbc - pDrawable->recv_sbc);
back->last_swap = pDrawable->send_sbc;
TRACE_MARK("SWAP:%d", tbm_bo_export(back->tbo)) ;
xcb_present_pixmap(c,
- pDrawable->xDrawable, /* dst */
- back->pixmap, /* src */
- (uint32_t) pDrawable->send_sbc,
- 0, /* valid */
- region_t, /* update */
- 0, /* x_off */
- 0, /* y_off */
- None, /* target_crtc */
- None,
- 0,
- XCB_PRESENT_OPTION_NONE,
- /*target_msc*/0,
- divisor,
- remainder, 0, NULL);
+ pDrawable->xDrawable, /* dst */
+ back->pixmap, /* src */
+ (uint32_t) pDrawable->send_sbc,
+ 0, /* valid */
+ region_t, /* update */
+ 0, /* x_off */
+ 0, /* y_off */
+ None, /* target_crtc */
+ None,
+ 0,
+ XCB_PRESENT_OPTION_NONE,
+ /*target_msc*/0,
+ divisor,
+ remainder, 0, NULL);
ret = (int64_t) pDrawable->send_sbc;
void
__tpl_x11_dri3_buffer_fini(tpl_buffer_t *buffer)
{
- dri3_buffer* back;
+ dri3_buffer *back;
TPL_ASSERT(buffer);
- back = (dri3_buffer*)buffer->backend.data;
+ back = (dri3_buffer *)buffer->backend.data;
- if (back)
- {
+ if (back) {
tbm_bo bo = back->tbo;
tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_READ);
tbm_bo_unmap(bo);
TPL_ASSERT(buffer);
TPL_IGNORE(size);
- bo = ((dri3_buffer*)buffer->backend.data)->tbo;
+ bo = ((dri3_buffer *)buffer->backend.data)->tbo;
TPL_ASSERT(bo);
handle = tbm_bo_get_handle(bo, TBM_DEVICE_CPU);
{
tbm_bo bo;
tbm_bo_handle handle;
- dri3_buffer* back;
+ dri3_buffer *back;
TPL_ASSERT(buffer);
TPL_ASSERT(buffer->backend.data);
- back = (dri3_buffer*) buffer->backend.data;
+ back = (dri3_buffer *) buffer->backend.data;
bo = back->tbo;
- if (NULL == bo)
- {
+ if (NULL == bo) {
TPL_ERR("bo is NULL!");
return TPL_FALSE;
}
- TRACE_BEGIN("TPL:BUFFERLOCK:%d",tbm_bo_export(bo));
+ TRACE_BEGIN("TPL:BUFFERLOCK:%d", tbm_bo_export(bo));
TPL_OBJECT_UNLOCK(buffer);
- switch (usage)
- {
- case TPL_LOCK_USAGE_GPU_READ:
- handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_READ);
- break;
- case TPL_LOCK_USAGE_GPU_WRITE:
- handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_WRITE);
- break;
- case TPL_LOCK_USAGE_CPU_READ:
- handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
- break;
- case TPL_LOCK_USAGE_CPU_WRITE:
- handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
- break;
- default:
- TPL_ASSERT(TPL_FALSE);
- return TPL_FALSE;
+ switch (usage) {
+ case TPL_LOCK_USAGE_GPU_READ:
+ handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_READ);
+ break;
+ case TPL_LOCK_USAGE_GPU_WRITE:
+ handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_WRITE);
+ break;
+ case TPL_LOCK_USAGE_CPU_READ:
+ handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
+ break;
+ case TPL_LOCK_USAGE_CPU_WRITE:
+ handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+ break;
+ default:
+ TPL_ASSERT(TPL_FALSE);
+ return TPL_FALSE;
}
TPL_OBJECT_LOCK(buffer);
- if (handle.u32 != 0 || handle.ptr != NULL)
- {
+ if (handle.u32 != 0 || handle.ptr != NULL) {
TRACE_END();
return TPL_FALSE;
}
TPL_ASSERT(buffer);
- back = (dri3_buffer*) buffer->backend.data;
+ back = (dri3_buffer *) buffer->backend.data;
bo = back->tbo;
- if (NULL == bo)
- {
+ if (NULL == bo) {
TPL_ERR("bo is NULL!");
return;
}
- TRACE_BEGIN("TPL:BUFFERUNLOCK:%d",tbm_bo_export(back->tbo));
+ TRACE_BEGIN("TPL:BUFFERUNLOCK:%d", tbm_bo_export(back->tbo));
TPL_OBJECT_UNLOCK(buffer);
tbm_bo_unmap(bo);
TPL_ASSERT(display);
- XInitThreads();
- if (display->native_handle == NULL)
- {
+ XInitThreads();
+ if (display->native_handle == NULL) {
display->native_handle = XOpenDisplay(NULL);
TPL_ASSERT(display->native_handle != NULL);
}
pthread_mutex_lock(&mutex);
- if (global.display_count == 0)
- {
+ if (global.display_count == 0) {
tpl_bool_t xres = TPL_FALSE;
Window root = 0;
drm_magic_t magic;
const char *backend_env = NULL;
int count = 0;
backend_env = getenv("MALI_EGL_DRI3_BUF_NUM");
- /* 2015-05-13 joonbum.ko@samsung.com */
- /* Change the value of dri3_max_back 5 to 3 */
+ /* 2015-05-13 joonbum.ko@samsung.com */
+ /* Change the value of dri3_max_back 5 to 3 */
if (!backend_env || strlen(backend_env) == 0)
dri3_max_back = 3; /* Default value is 3*/
- else
- {
+ else {
count = atoi(backend_env);
if (count == 1)/* one buffer doesn't work,min is 2 */
dri3_max_back = 2;
TPL_IGNORE(display);
pthread_mutex_lock(&mutex);
- if (--global.display_count == 0)
- {
+ if (--global.display_count == 0) {
tbm_bufmgr_deinit(global.bufmgr);
close(global.bufmgr_fd);
XCloseDisplay(global.worker_display);
TPL_ASSERT(surface);
- x11_surface = (tpl_x11_dri3_surface_t *)calloc(1, sizeof(tpl_x11_dri3_surface_t));
- if (x11_surface == NULL)
- {
+ x11_surface = (tpl_x11_dri3_surface_t *)calloc(1,
+ sizeof(tpl_x11_dri3_surface_t));
+ if (x11_surface == NULL) {
TPL_ERR("Failed to allocate buffer!");
return TPL_FALSE;
}
x11_surface->drawable = dri3_create_drawable(display, drawable);
surface->backend.data = (void *)x11_surface;
- if (surface->type == TPL_SURFACE_TYPE_WINDOW)
- {
+ if (surface->type == TPL_SURFACE_TYPE_WINDOW) {
__tpl_x11_display_get_window_info(surface->display,
- surface->native_handle,
- &surface->width, &surface->height, NULL, 0, 0);
- }
- else
- {
+ surface->native_handle,
+ &surface->width, &surface->height, NULL, 0, 0);
+ } else {
__tpl_x11_display_get_pixmap_info(surface->display,
- surface->native_handle,
- &surface->width, &surface->height, NULL);
+ surface->native_handle,
+ &surface->width, &surface->height, NULL);
}
return TPL_TRUE;
display = (Display *) surface->display->native_handle;
x11_surface = (tpl_x11_dri3_surface_t *) surface->backend.data;
- dri3_destroy_drawable(display, (XID)surface->native_handle);
+ dri3_destroy_drawable(display, (XID)surface->native_handle);
- if (x11_surface)
- {
+ if (x11_surface) {
__tpl_x11_surface_buffer_cache_clear(&x11_surface->buffer_cache);
static void
__tpl_x11_dri3_surface_post_internal(tpl_surface_t *surface,
- tpl_frame_t *frame,
- tpl_bool_t is_worker)
+ tpl_frame_t *frame,
+ tpl_bool_t is_worker)
{
Display *display = NULL;
tpl_x11_dri3_surface_t *x11_surface;
display = __tpl_x11_dri3_get_worker_display();
- if (frame->interval != x11_surface->latest_post_interval)
- {
+ if (frame->interval != x11_surface->latest_post_interval) {
x11_surface->latest_post_interval = frame->interval;/*FIXME:set interval?*/
}
- if (__tpl_region_is_empty(&frame->damage))
- {
- dri3_swap_buffers(display, x11_surface->drawable, frame->buffer, 0,0);
- }
- else
- {
+ if (__tpl_region_is_empty(&frame->damage)) {
+ dri3_swap_buffers(display, x11_surface->drawable, frame->buffer, 0, 0);
+ } else {
int i;
- if (frame->damage.num_rects > TPL_STACK_XRECTANGLE_SIZE)
- {
+ if (frame->damage.num_rects > TPL_STACK_XRECTANGLE_SIZE) {
xrects = (XRectangle *)malloc(sizeof(XRectangle) *
- frame->damage.num_rects);
- }
- else
- {
+ frame->damage.num_rects);
+ } else {
xrects = &xrects_stack[0];
}
- for (i = 0; i < frame->damage.num_rects; i++)
- {
+ for (i = 0; i < frame->damage.num_rects; i++) {
const int *rects = &frame->damage.rects[i * 4];
xrects[i].x = rects[0];
xrects[i].y = frame->buffer->height - rects[1] -
- rects[3];
+ rects[3];
xrects[i].width = rects[2];
xrects[i].height = rects[3];
}
- if (x11_surface->damage == None)
- {
+ if (x11_surface->damage == None) {
x11_surface->damage =
- XFixesCreateRegion(display, xrects,
- frame->damage.num_rects);
- }
- else
- {
+ XFixesCreateRegion(display, xrects,
+ frame->damage.num_rects);
+ } else {
XFixesSetRegion(display, x11_surface->damage,
xrects, frame->damage.num_rects);
}
dri3_swap_buffers(display, x11_surface->drawable, frame->buffer, 0,
- x11_surface->damage);
+ x11_surface->damage);
}
frame->state = TPL_FRAME_STATE_POSTED;
prev_frame = __tpl_surface_get_latest_frame(surface);
- if (prev_frame && prev_frame->state != TPL_FRAME_STATE_POSTED)
- {
+ if (prev_frame && prev_frame->state != TPL_FRAME_STATE_POSTED) {
if ((DRI2_BUFFER_IS_FB(prev_frame->buffer->backend.flags) &&
global.fb_swap_type == TPL_X11_SWAP_TYPE_SYNC) ||
(!DRI2_BUFFER_IS_FB(prev_frame->buffer->backend.flags) &&
- global.win_swap_type == TPL_X11_SWAP_TYPE_SYNC))
- {
+ global.win_swap_type == TPL_X11_SWAP_TYPE_SYNC)) {
__tpl_surface_wait_all_frames(surface);
}
}
prev_frame = __tpl_surface_get_latest_frame(surface);
- if (prev_frame && prev_frame->state != TPL_FRAME_STATE_POSTED)
- {
+ if (prev_frame && prev_frame->state != TPL_FRAME_STATE_POSTED) {
if ((DRI2_BUFFER_IS_FB(prev_frame->buffer->backend.flags) &&
- global.fb_swap_type == TPL_X11_SWAP_TYPE_LAZY) ||
- (!DRI2_BUFFER_IS_FB(prev_frame->buffer->backend.flags) &&
- global.win_swap_type == TPL_X11_SWAP_TYPE_LAZY))
- {
+ global.fb_swap_type == TPL_X11_SWAP_TYPE_LAZY) ||
+ (!DRI2_BUFFER_IS_FB(prev_frame->buffer->backend.flags) &&
+ global.win_swap_type == TPL_X11_SWAP_TYPE_LAZY)) {
__tpl_surface_wait_all_frames(surface);
return TPL_TRUE;
}
frame = __tpl_surface_get_latest_frame(surface);
x11_surface = (tpl_x11_dri3_surface_t *) surface->backend.data;
- if (frame)
- {
+ if (frame) {
x11_surface->latest_render_target = frame->buffer;
if ((DRI2_BUFFER_IS_FB(frame->buffer->backend.flags) &&
- global.fb_swap_type == TPL_X11_SWAP_TYPE_ASYNC) ||
- (!DRI2_BUFFER_IS_FB(frame->buffer->backend.flags) &&
- global.win_swap_type == TPL_X11_SWAP_TYPE_ASYNC))
- {
+ global.fb_swap_type == TPL_X11_SWAP_TYPE_ASYNC) ||
+ (!DRI2_BUFFER_IS_FB(frame->buffer->backend.flags) &&
+ global.win_swap_type == TPL_X11_SWAP_TYPE_ASYNC)) {
__tpl_x11_dri3_surface_post_internal(surface, frame, TPL_FALSE);
}
}
/* 2015-04-08 joonbum.ko@samsung.com */
/* change the key value of tpl_buffer_t from dma_buf_fd to tbo name */
static tpl_buffer_t *
-__tpl_x11_dri3_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buffers)
+__tpl_x11_dri3_surface_get_buffer(tpl_surface_t *surface,
+ tpl_bool_t *reset_buffers)
{
Drawable drawable;
dri3_buffer *buffer = NULL;
x11_surface = (tpl_x11_dri3_surface_t *)surface->backend.data;
- if (surface->type == TPL_SURFACE_TYPE_PIXMAP)
- {
+ if (surface->type == TPL_SURFACE_TYPE_PIXMAP) {
attachments[0] = dri3_buffer_front;
}
buffer = dri3_get_buffers(drawable, x11_surface->drawable, attachments, cpp);
- if (DRI2_BUFFER_IS_REUSED(buffer->flags))
- {
+ if (DRI2_BUFFER_IS_REUSED(buffer->flags)) {
tpl_buffer = __tpl_x11_surface_buffer_cache_find(
- &x11_surface->buffer_cache,
- tbm_bo_export(buffer->tbo));
+ &x11_surface->buffer_cache,
+ tbm_bo_export(buffer->tbo));
- if (tpl_buffer)
- {
+ if (tpl_buffer) {
/* If the buffer name is reused and there's a cache
* entry for that name, just update the buffer age
* and return. */
}
}
- if (!tpl_buffer)
- {
+ if (!tpl_buffer) {
/* Remove the buffer from the cache. */
- __tpl_x11_surface_buffer_cache_remove(
- &x11_surface->buffer_cache,
- tbm_bo_export(buffer->tbo));
- if(buffer->old_bo_name != 0)
- {
+ __tpl_x11_surface_buffer_cache_remove(
+ &x11_surface->buffer_cache,
+ tbm_bo_export(buffer->tbo));
+ if (buffer->old_bo_name != 0) {
__tpl_x11_surface_buffer_cache_remove(
- &x11_surface->buffer_cache,
- buffer->old_bo_name);
+ &x11_surface->buffer_cache,
+ buffer->old_bo_name);
buffer->old_bo_name = 0;
}
}
bo = buffer->tbo;
- if (bo == NULL)
- {
+ if (bo == NULL) {
TPL_ERR("bo is NULL!");
goto done;
}
/* Create tpl buffer. */
tpl_buffer = __tpl_buffer_alloc(surface, (size_t) tbm_bo_export(buffer->tbo),
- (int)bo_handle.u32,
- buffer->width, buffer->height, buffer->cpp * 8, buffer->pitch);
- if (NULL == tpl_buffer)
- {
+ (int)bo_handle.u32,
+ buffer->width, buffer->height, buffer->cpp * 8, buffer->pitch);
+ if (NULL == tpl_buffer) {
TPL_ERR("TPL buffer alloc failed!");
goto done;
}
__tpl_x11_surface_buffer_cache_add(&x11_surface->buffer_cache, tpl_buffer);
tpl_object_unreference(&tpl_buffer->base);
done:
- if (reset_buffers)
- {
+ if (reset_buffers) {
/* Users use this output value to check if they have to reset previous buffers. */
*reset_buffers = !DRI2_BUFFER_IS_REUSED(buffer->flags) ||
- buffer->width != surface->width || buffer->height != surface->height;
+ buffer->width != surface->width || buffer->height != surface->height;
}
return tpl_buffer;
int
__tpl_x11_dri3_get_buffer_age(tpl_buffer_t *buffer)
{
- dri3_buffer *back;
+ dri3_buffer *back;
TPL_ASSERT(buffer);
- back = (dri3_buffer*) buffer->backend.data;
+ back = (dri3_buffer *) buffer->backend.data;
- TPL_ASSERT(back);
+ TPL_ASSERT(back);
- return back->buffer_age;
+ return back->buffer_age;
}
/* [END:20150119-leiba.sun] */
backend->unmap = __tpl_x11_dri3_buffer_unmap;
backend->lock = __tpl_x11_dri3_buffer_lock;
backend->unlock = __tpl_x11_dri3_buffer_unlock;
- /* [BEGIN: 20140119-leiba.sun] Add support for buffer age */
- backend->get_buffer_age = __tpl_x11_dri3_get_buffer_age;
- /* [END:20150119-leiba.sun] */
+ /* [BEGIN: 20140119-leiba.sun] Add support for buffer age */
+ backend->get_buffer_age = __tpl_x11_dri3_get_buffer_age;
+ /* [END:20150119-leiba.sun] */
}
typedef struct _tpl_x11_global tpl_x11_global_t;
-typedef enum
-{
+typedef enum {
TPL_X11_SWAP_TYPE_ERROR = -1,
TPL_X11_SWAP_TYPE_SYNC = 0,
TPL_X11_SWAP_TYPE_ASYNC,
TPL_X11_SWAP_TYPE_MAX
} tpl_x11_swap_type_t;
-struct _tpl_x11_global
-{
+struct _tpl_x11_global {
int display_count;
Display *worker_display;
__tpl_x11_swap_str_to_swap_type(char *str, tpl_x11_swap_type_t *type);
tpl_buffer_t *
-__tpl_x11_surface_buffer_cache_find(tpl_list_t *buffer_cache, unsigned int name);
+__tpl_x11_surface_buffer_cache_find(tpl_list_t *buffer_cache,
+ unsigned int name);
void
-__tpl_x11_surface_buffer_cache_remove(tpl_list_t *buffer_cache, unsigned int name);
+__tpl_x11_surface_buffer_cache_remove(tpl_list_t *buffer_cache,
+ unsigned int name);
tpl_bool_t
-__tpl_x11_surface_buffer_cache_add(tpl_list_t *buffer_cache, tpl_buffer_t *buffer);
+__tpl_x11_surface_buffer_cache_add(tpl_list_t *buffer_cache,
+ tpl_buffer_t *buffer);
void
__tpl_x11_surface_buffer_cache_clear(tpl_list_t *buffer_cache);
tpl_bool_t
int color_depth, int *native_visual_id, tpl_bool_t *is_slow);
tpl_bool_t
__tpl_x11_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, tpl_format_t *format, int depth, int a_size);
tpl_bool_t
__tpl_x11_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
int *width, int *height, tpl_format_t *format);
int width, int height,
int dx, int dy)
{
- if (egl_window == NULL)
- {
+ if (egl_window == NULL) {
WL_EGL_ERR("egl_window is NULL");
return;
}
egl_window->resize_callback(egl_window, egl_window->private);
WL_EGL_LOG(2, "egl_win:%10p WxH:%dx%d dx:%d dy:%d rsz_cb:%10p",
- egl_window, egl_window->width, egl_window->height,
- egl_window->dx, egl_window->dy, egl_window->resize_callback);
+ egl_window, egl_window->width, egl_window->height,
+ egl_window->dx, egl_window->dy, egl_window->resize_callback);
}
WL_EGL_EXPORT struct wl_egl_window *
{
struct wl_egl_window *egl_window;
- egl_window = malloc(sizeof *egl_window);
- if (!egl_window)
- {
+ egl_window = malloc(sizeof * egl_window);
+ if (!egl_window) {
WL_EGL_ERR("failed to allocate memory for egl_window");
return NULL;
}
egl_window->attached_height = 0;
WL_EGL_LOG(2, "surf:%10p WxH:%dx%d egl_win:%10p priv:%10p",
- surface, width, height, egl_window, egl_window->private);
+ surface, width, height, egl_window, egl_window->private);
return egl_window;
}
WL_EGL_EXPORT void
wl_egl_window_destroy(struct wl_egl_window *egl_window)
{
- if(egl_window == NULL)
- {
+ if (egl_window == NULL) {
WL_EGL_ERR("egl_window is NULL");
return;
}
*height = egl_window->attached_height;
WL_EGL_LOG(2, "egl_win:%10p w:%10p h:%10p att_w:%d att_h:%d",
- egl_window, width, height, egl_window->attached_width,
- egl_window->attached_height);
+ egl_window, width, height, egl_window->attached_width,
+ egl_window->attached_height);
}
typedef struct _ProgOption ProgOption;
-typedef struct _ProgOption
-{
+typedef struct _ProgOption {
int egl_r;
int egl_g;
int egl_b;
bool show_names;
};
-ProgOption g_option =
-{
+ProgOption g_option = {
8, 8, 8, 8,
24,
0,
/* log related */
#ifdef TPL_ENABLE_LOG
bool
-__LOG( const char* func, int line, const char* fmt, ... )
+__LOG( const char *func, int line, const char *fmt, ... )
{
char buff[NUM_ERR_STR] = { (char)0, };
char str[NUM_ERR_STR] = { (char)0, };
}
void
-__LOG_BEGIN( const char* func )
+__LOG_BEGIN( const char *func )
{
char str[NUM_ERR_STR] = { (char)0, };
sprintf( str, "[tpl_test][B] %s", func );
}
void
-__LOG_END( const char* func )
+__LOG_END( const char *func )
{
char str[NUM_ERR_STR] = { (char)0, };
sprintf( str, "[tpl_test][E] %s", func );
}
bool
-__tpl_test_log_display_msg( const char* msg )
+__tpl_test_log_display_msg( const char *msg )
{
fprintf( DEFAULT_LOG_STREAM, "%s\n", msg );
fflush( DEFAULT_LOG_STREAM );
}
bool
-__LOG_ERR( const char* func, int line, const char* fmt, ... )
+__LOG_ERR( const char *func, int line, const char *fmt, ... )
{
char buff[NUM_ERR_STR] = { (char)0, };
char str[NUM_ERR_STR] = { (char)0, };
#endif /* TPL_ENABLE_LOG */
/* wayland native related */
-registry_handle_global(void *data, struct wl_registry *registry,uint32_t id, const char *interface,uint32_t version)
+registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
+ const char *interface, uint32_t version)
{
- TPLNativeWnd* that = (TPLNativeWnd *)(data);
+ TPLNativeWnd *that = (TPLNativeWnd *)(data);
- if (strcmp(interface, "wl_compositor") == 0)
- {
- that->compositor = wl_registry_bind(registry,id, &wl_compositor_interface, 1);
- }
- else if (strcmp(interface, "wl_shell") == 0)
- {
- that->shell = wl_registry_bind(registry,id, &wl_shell_interface, 1);
- }
- else if (strcmp(interface, "wl_output") == 0)
- {
+ if (strcmp(interface, "wl_compositor") == 0) {
+ that->compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1);
+ } else if (strcmp(interface, "wl_shell") == 0) {
+ that->shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
+ } else if (strcmp(interface, "wl_output") == 0) {
/*struct my_output *my_output = new struct my_output;
memset(my_output, 0, sizeof(*my_output));
my_output->output = wl_registry_bind(registry,id, &wl_output_interface, 2);*/
}
void
-registry_handle_global_remove(void * data,struct wl_registry * registry,uint32_t name)
+registry_handle_global_remove(void *data, struct wl_registry *registry,
+ uint32_t name)
{
}
-const struct wl_registry_listener registry_listener_ =
-{
+const struct wl_registry_listener registry_listener_ = {
registry_handle_global,
registry_handle_global_remove
};
-shell_surface_handle_ping(void * data, struct wl_shell_surface *shell_surface,uint32_t serial)
+shell_surface_handle_ping(void *data, struct wl_shell_surface *shell_surface,
+ uint32_t serial)
{
wl_shell_surface_pong(shell_surface, serial);
}
void
-shell_surface_handle_popup_done(void * data,struct wl_shell_surface * shell_surface)
+shell_surface_handle_popup_done(void *data,
+ struct wl_shell_surface *shell_surface)
{
}
void
-shell_surface_handle_configure(void *data, struct wl_shell_surface * shell_surface,uint32_t edges, int32_t width, int32_t height)
+shell_surface_handle_configure(void *data,
+ struct wl_shell_surface *shell_surface, uint32_t edges, int32_t width,
+ int32_t height)
{
TPLNativeWnd *that = (TPLNativeWnd *)(data);
that->width = width;
}
-const struct wl_shell_surface_listener shell_surface_listener_ =
-{
+const struct wl_shell_surface_listener shell_surface_listener_ = {
shell_surface_handle_ping,
shell_surface_handle_configure,
shell_surface_handle_popup_done
/* wayland native end */
/* tpl_test related */
-TPLNativeWnd*
+TPLNativeWnd *
tpl_test_native_wnd_create( void )
{
- TPLNativeWnd* wnd = NULL;
+ TPLNativeWnd *wnd = NULL;
TPL_RSM_MALLOC( wnd, TPLNativeWnd );
//wnd->dpy = (NativeDisplayType)NULL;
- wnd->dpy = (void*)NULL;
+ wnd->dpy = (void *)NULL;
wnd->screen = 0;
//wnd->root = (NativeWindowType)NULL;
- wnd->root = (void*)NULL;
+ wnd->root = (void *)NULL;
//wnd->wnd = (NativeWindowType)NULL;
- wnd->wnd = (void*)NULL;
+ wnd->wnd = (void *)NULL;
wnd->x = 0;
wnd->y = 0;
wnd->width = 0;
wnd->height = 0;
wnd->depth = 0;
- tpl_display_t * tpl_display = NULL;
- tpl_surface_t * tpl_surf = NULL;
- tpl_buffer_t * tpl_buf = NULL;
+ tpl_display_t *tpl_display = NULL;
+ tpl_surface_t *tpl_surf = NULL;
+ tpl_buffer_t *tpl_buf = NULL;
finish:
return wnd;
}
bool
-tpl_test_native_wnd_initialize( TPLNativeWnd* wnd, int x, int y, int width, int height )
+tpl_test_native_wnd_initialize( TPLNativeWnd *wnd, int x, int y, int width,
+ int height )
{
bool res = false;
TPL_CHK_PARAM( height <= 0 );
//wnd->dpy = (NativeDisplayType)wl_display_connect(NULL);
- wnd->dpy = (void*)wl_display_connect(NULL);
- if( !wnd->dpy )
- {
+ wnd->dpy = (void *)wl_display_connect(NULL);
+ if ( !wnd->dpy ) {
__log_err( "wl_display_connect() is failed.");
return res;
}
wnd->height = height;
wnd->depth = 32;
- wnd->surface= wl_compositor_create_surface(wnd->compositor);
- wnd->wnd = wl_egl_window_create(wnd->surface,wnd->width, wnd->height);
+ wnd->surface = wl_compositor_create_surface(wnd->compositor);
+ wnd->wnd = wl_egl_window_create(wnd->surface, wnd->width, wnd->height);
- wnd->shell_surface = wl_shell_get_shell_surface(wnd->shell,wnd->surface);
+ wnd->shell_surface = wl_shell_get_shell_surface(wnd->shell, wnd->surface);
wl_shell_surface_set_toplevel(wnd->shell_surface);
- if (wnd->shell_surface)
- {
- wl_shell_surface_add_listener(wnd->shell_surface,&shell_surface_listener_, wnd);
+ if (wnd->shell_surface) {
+ wl_shell_surface_add_listener(wnd->shell_surface, &shell_surface_listener_,
+ wnd);
}
wl_shell_surface_set_title(wnd->shell_surface, "tpl_testtest");
}
bool
-tpl_test_native_wnd_finalize( TPLNativeWnd* wnd )
+tpl_test_native_wnd_finalize( TPLNativeWnd *wnd )
{
bool res = false;
}
bool
-tpl_test_finalize( TPLNativeWnd* wnd )
+tpl_test_finalize( TPLNativeWnd *wnd )
{
bool res = true;
TPL_CHK_PARAM( !wnd );
- if(NULL != wnd->tpl_display)
- {
- tpl_object_unreference((tpl_object_t*)wnd->tpl_display);
+ if (NULL != wnd->tpl_display) {
+ tpl_object_unreference((tpl_object_t *)wnd->tpl_display);
}
- if(NULL != wnd->tpl_surf)
- {
- tpl_object_unreference((tpl_object_t*)wnd->tpl_surf);
+ if (NULL != wnd->tpl_surf) {
+ tpl_object_unreference((tpl_object_t *)wnd->tpl_surf);
}
res = true;
void
-tpl_test_native_wnd_release( TPLNativeWnd* wnd )
+tpl_test_native_wnd_release( TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
fprintf( stderr, "\n" );
fprintf( stderr, "Options:\n" );
- fprintf( stderr, " -w Set width size of the window default: %d\n", g_option.wnd_w );
- fprintf( stderr, " -h Set height size of the window default: %d\n", g_option.wnd_h );
-
- fprintf( stderr, " -t Specify the test case number default: %d\n", g_option.tc_num );
- fprintf( stderr, " -a Run all test cases default: %s\n", g_option.all ? "true" : "false" );
- fprintf( stderr, " -l Show TC name default: %s\n", g_option.show_names ? "true" : "false" );
+ fprintf( stderr, " -w Set width size of the window default: %d\n",
+ g_option.wnd_w );
+ fprintf( stderr, " -h Set height size of the window default: %d\n",
+ g_option.wnd_h );
+
+ fprintf( stderr, " -t Specify the test case number default: %d\n",
+ g_option.tc_num );
+ fprintf( stderr, " -a Run all test cases default: %s\n",
+ g_option.all ? "true" : "false" );
+ fprintf( stderr, " -l Show TC name default: %s\n",
+ g_option.show_names ? "true" : "false" );
fprintf( stderr, "\n" );
exit( 1 );
}
static void
-check_option( int argc, char** argv )
+check_option( int argc, char **argv )
{
int c;
- char* opt_str = NULL;
-
- while( (c = getopt(argc, argv, "alc:d:s:p:x:y:w:h:f:t:F:i:")) != EOF )
- {
- switch( c )
- {
- case 'c':
- opt_str = optarg;
- if( strcmp(opt_str, "888") == 0 )
- {
- g_option.egl_r = 8;
- g_option.egl_g = 8;
- g_option.egl_b = 8;
- g_option.egl_a = 0;
- }
- else if( strcmp(opt_str, "8888") == 0 )
- {
- g_option.egl_r = 8;
- g_option.egl_g = 8;
- g_option.egl_b = 8;
- g_option.egl_a = 8;
- }
- else if( strcmp(opt_str, "565") == 0 )
- {
- g_option.egl_r = 5;
- g_option.egl_g = 6;
- g_option.egl_b = 5;
- g_option.egl_a = 0;
- }
- break;
- case 'd':
- g_option.egl_d = atol( optarg );
- break;
- case 's':
- g_option.egl_s = atol( optarg );
- break;
- case 'p':
- g_option.egl_preserved = atol( optarg );
- break;
- case 'i':
- g_option.egl_swap_interval = atol( optarg );
- break;
- case 'x':
- g_option.wnd_x = atol( optarg );
- break;
- case 'y':
- g_option.wnd_y = atol( optarg );
- break;
- case 'w':
- g_option.wnd_w = atol( optarg );
- break;
- case 'h':
- g_option.wnd_h = atol( optarg );
- break;
- case 'f':
- g_option.frames = atol( optarg );
- break;
- case 't':
- g_option.tc_num = atol( optarg );
- g_option.all = false;
- break;
- case 'F':
- g_option.fps = atol( optarg );
- break;
- case 'a':
- g_option.all = true;
- break;
- case 'l':
- g_option.show_names = true;
- break;
- default:
- print_usage( argv[0] );
- break;
+ char *opt_str = NULL;
+
+ while ( (c = getopt(argc, argv, "alc:d:s:p:x:y:w:h:f:t:F:i:")) != EOF ) {
+ switch ( c ) {
+ case 'c':
+ opt_str = optarg;
+ if ( strcmp(opt_str, "888") == 0 ) {
+ g_option.egl_r = 8;
+ g_option.egl_g = 8;
+ g_option.egl_b = 8;
+ g_option.egl_a = 0;
+ } else if ( strcmp(opt_str, "8888") == 0 ) {
+ g_option.egl_r = 8;
+ g_option.egl_g = 8;
+ g_option.egl_b = 8;
+ g_option.egl_a = 8;
+ } else if ( strcmp(opt_str, "565") == 0 ) {
+ g_option.egl_r = 5;
+ g_option.egl_g = 6;
+ g_option.egl_b = 5;
+ g_option.egl_a = 0;
+ }
+ break;
+ case 'd':
+ g_option.egl_d = atol( optarg );
+ break;
+ case 's':
+ g_option.egl_s = atol( optarg );
+ break;
+ case 'p':
+ g_option.egl_preserved = atol( optarg );
+ break;
+ case 'i':
+ g_option.egl_swap_interval = atol( optarg );
+ break;
+ case 'x':
+ g_option.wnd_x = atol( optarg );
+ break;
+ case 'y':
+ g_option.wnd_y = atol( optarg );
+ break;
+ case 'w':
+ g_option.wnd_w = atol( optarg );
+ break;
+ case 'h':
+ g_option.wnd_h = atol( optarg );
+ break;
+ case 'f':
+ g_option.frames = atol( optarg );
+ break;
+ case 't':
+ g_option.tc_num = atol( optarg );
+ g_option.all = false;
+ break;
+ case 'F':
+ g_option.fps = atol( optarg );
+ break;
+ case 'a':
+ g_option.all = true;
+ break;
+ case 'l':
+ g_option.show_names = true;
+ break;
+ default:
+ print_usage( argv[0] );
+ break;
}
}
int tpl_test_log_level = 5;
int
-main( int argc, char** argv )
+main( int argc, char **argv )
{
- TPLNativeWnd* wnd = NULL;
+ TPLNativeWnd *wnd = NULL;
bool res = false;
- int i = 0;int k=0;
+ int i = 0;
+ int k = 0;
int total_num_test = ( sizeof(tpl_test) / sizeof(TPLTest) ) - 1;
int tc_num = 0;
char *log_env;
check_option( argc, argv );
log_env = getenv("TPL_TEST_LOG_LEVEL");
- if (log_env != NULL)
- {
+ if (log_env != NULL) {
tpl_test_log_level = atoi(log_env);
}
- LOG("INFO",LOG_LEVEL_LOW,"tpl_test_log_level = %d",tpl_test_log_level);
+ LOG("INFO", LOG_LEVEL_LOW, "tpl_test_log_level = %d", tpl_test_log_level);
env = getenv("TEST_SLEEP");
- if (env && !strcmp(env,"yes"))
- {
- while(k<20)
- {
- usleep(1000*1000);
- printf("sleep %d\n",k++);
+ if (env && !strcmp(env, "yes")) {
+ while (k < 20) {
+ usleep(1000 * 1000);
+ printf("sleep %d\n", k++);
}
}
- if( g_option.show_names )
- {
+ if ( g_option.show_names ) {
printf( "-------------------------------------------------\n" );
printf( " number of test cass: %d \n", total_num_test );
printf( "-------------------------------------------------\n" );
- while( tpl_test[i].name )
- {
+ while ( tpl_test[i].name ) {
printf( " [%2d] %s\n", i, tpl_test[i].name );
i++;
}
}
wnd = tpl_test_native_wnd_create();
- if( !wnd ) goto finish;
+ if ( !wnd ) goto finish;
res = tpl_test_native_wnd_initialize( wnd,
- g_option.wnd_x,
- g_option.wnd_y,
- g_option.wnd_w,
- g_option.wnd_h );
- if( !res ) goto finish;
+ g_option.wnd_x,
+ g_option.wnd_y,
+ g_option.wnd_w,
+ g_option.wnd_h );
+ if ( !res ) goto finish;
printf( "-------------------tpl test begin!!!-----------------------------------\n");
- if( g_option.all )
- {
+ if ( g_option.all ) {
i = 0;
- while( tpl_test[i].name )
- {
+ while ( tpl_test[i].name ) {
printf( "[%4d] %-50s", i, tpl_test[i].name );
- if( tpl_test[i].run )
- {
- if(true == tpl_test[i].run( wnd ))
+ if ( tpl_test[i].run ) {
+ if (true == tpl_test[i].run( wnd ))
printf("[PASS]\n");
else
printf("[FAIL]\n");
}
i++;
}
- }
- else
- {
+ } else {
tc_num = g_option.tc_num;
- if( tc_num < 0 || tc_num > total_num_test-1 ) goto finish;
+ if ( tc_num < 0 || tc_num > total_num_test - 1 ) goto finish;
//printf( "----------------------------------------------\n\n" );
- if( tpl_test[tc_num].name ) printf( "[%4d] %-50s", tc_num, tpl_test[tc_num].name );
+ if ( tpl_test[tc_num].name ) printf( "[%4d] %-50s", tc_num,
+ tpl_test[tc_num].name );
else printf( "[%4d] No test name\n", tc_num );
- if( tpl_test[tc_num].run )
- {
- if(true == tpl_test[tc_num].run( wnd ))
- printf("[PASS]\n");
- else
- printf("[FAIL]\n");
+ if ( tpl_test[tc_num].run ) {
+ if (true == tpl_test[tc_num].run( wnd ))
+ printf("[PASS]\n");
+ else
+ printf("[FAIL]\n");
}
//printf( "\n----------------------------------------------\n\n" );
}
printf("-------------------tpl test end!!!-------------------------------------\n");
finish:
- if( wnd )
- {
- tpl_test_native_wnd_finalize( wnd );
- tpl_test_native_wnd_release( wnd );
- tpl_test_finalize( wnd );
- }
+ if ( wnd ) {
+ tpl_test_native_wnd_finalize( wnd );
+ tpl_test_native_wnd_release( wnd );
+ tpl_test_finalize( wnd );
+ }
return 0;
#include "tpl_test_util.h"
-bool tpl_buffer_map_unmap_test(TPLNativeWnd* wnd )
+bool tpl_buffer_map_unmap_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
void *ptr = NULL;
//int size = tpl_buf->width * tpl_buf->height * tpl_buf->depth;
int size = wnd->width * wnd->height ;
- LOG("INFO", LOG_LEVEL_LOW ,"width=%d,height=%d,size=%d\n",wnd->width , wnd->height , size);
+ LOG("INFO", LOG_LEVEL_LOW , "width=%d,height=%d,size=%d\n", wnd->width ,
+ wnd->height , size);
ptr = tpl_buffer_map(wnd->tpl_buf, size);
- if (ptr == NULL)
- {
+ if (ptr == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map");
ret = false;
goto finish;
}
//5.buffer unmap
- tpl_buffer_unmap(wnd->tpl_buf,ptr,size);
+ tpl_buffer_unmap(wnd->tpl_buf, ptr, size);
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
+bool tpl_buffer_lock_unlock_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
//5.buffer lock
tpl_bool_t result = false;
- result = tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_GPU_READ);
- if(result == true)
- {
+ result = tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_GPU_READ);
+ if (result == true) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");
ret = false;
goto finish;
tpl_buffer_unlock(wnd->tpl_buf);
//TPL_LOCK_USAGE_GPU_WRITE
- result = tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_GPU_WRITE);
- if(result == true)
- {
+ result = tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_GPU_WRITE);
+ if (result == true) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");
ret = false;
goto finish;
tpl_buffer_unlock(wnd->tpl_buf);
//TPL_LOCK_USAGE_CPU_READ
- result = tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_CPU_READ);
- if(result == true)
- {
+ result = tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_CPU_READ);
+ if (result == true) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");
ret = false;
goto finish;
tpl_buffer_unlock(wnd->tpl_buf);
//TPL_LOCK_USAGE_CPU_WRITE
- result = tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_CPU_WRITE);
- if(result == true)
- {
+ result = tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_CPU_WRITE);
+ if (result == true) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");
ret = false;
goto finish;
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
+bool tpl_buffer_get_arg_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
//tpl_buffer_get_key
unsigned int key = 0;
key = tpl_buffer_get_key(wnd->tpl_buf);
- if (key == 0)
- {
+ if (key == 0) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_key");
ret = false;
goto finish;
//tpl_buffer_get_fd
int fd = -1;
fd = tpl_buffer_get_fd(wnd->tpl_buf);
- if (fd == -1)
- {
+ if (fd == -1) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_fd");
ret = false;
goto finish;
//tpl_buffer_get_age
int age = -1;
age = tpl_buffer_get_age(wnd->tpl_buf);
- if (age == 0)
- {
+ if (age == 0) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_age");
ret = false;
goto finish;
//tpl_buffer_get_surface
tpl_surface_t *test_surf = NULL;
test_surf = tpl_buffer_get_surface(wnd->tpl_buf);
- if (test_surf == NULL)
- {
+ if (test_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_surface");
ret = false;
goto finish;
//tpl_buffer_get_size
int width = 0, heigh = 0;
tpl_buffer_get_size(wnd->tpl_buf, &width, &heigh);
- if ((width == 0)||(heigh == 0))
- {
+ if ((width == 0) || (heigh == 0)) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_size");
ret = false;
goto finish;
//tpl_buffer_get_depth
int depth = 0;
depth = tpl_buffer_get_depth(wnd->tpl_buf);
- if (depth == 0)
- {
+ if (depth == 0) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_depth");
ret = false;
goto finish;
//tpl_buffer_get_pitch
int pitch = 0;
pitch = tpl_buffer_get_fd(wnd->tpl_buf);
- if (pitch == 0)
- {
+ if (pitch == 0) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_fd");
ret = false;
goto finish;
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_buffer_create_native_buffer_test(TPLNativeWnd* wnd )
+bool tpl_buffer_create_native_buffer_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
//create native buffer
void *native_buffer = NULL;
native_buffer = tpl_buffer_create_native_buffer(wnd->tpl_buf);
- if (native_buffer == NULL)
- {
+ if (native_buffer == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_create_native_buffer");
ret = false;
goto finish;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd )
+bool tpl_buffer_abnormal_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
//abnormal test
- tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_INVALID);
- int test_width = 0,test_heigh = 0;
+ tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_INVALID);
+ int test_width = 0, test_heigh = 0;
tpl_buffer_map(NULL, 0);
- tpl_buffer_unmap(NULL,NULL,0);
- tpl_buffer_lock(NULL,TPL_LOCK_USAGE_INVALID);
+ tpl_buffer_unmap(NULL, NULL, 0);
+ tpl_buffer_lock(NULL, TPL_LOCK_USAGE_INVALID);
tpl_buffer_unlock(NULL);
tpl_buffer_get_key(NULL);
tpl_buffer_get_fd(NULL);
tpl_buffer_create_native_buffer(NULL);
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_buffer_stress_test(TPLNativeWnd* wnd )
+bool tpl_buffer_stress_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- int index = 0;int size = 0;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ int index = 0;
+ int size = 0;
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display _get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
}
- tpl_buffer_t *buf_array[STRESS_NUM]={0};
- for(index = 0;index<STRESS_NUM;index++)
- {
+ tpl_buffer_t *buf_array[STRESS_NUM] = {0};
+ for (index = 0; index < STRESS_NUM; index++) {
tpl_surface_begin_frame(wnd->tpl_surf);
buf_array[index] = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (buf_array[index] == NULL)
- {
+ if (buf_array[index] == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
void *ptr = NULL;
size = wnd->width * wnd->height ;
ptr = tpl_buffer_map(buf_array[index], size);
- if (ptr == NULL)
- {
+ if (ptr == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map");
ret = false;
goto finish;
}
//6.write
- int *p = NULL;int j=0;
- for(j = 0; j <size;j++)
- {
- p = (int*) ptr;
- if(index%2 == 0)
- *(p+j) = 0xFF00;
+ int *p = NULL;
+ int j = 0;
+ for (j = 0; j < size; j++) {
+ p = (int *) ptr;
+ if (index % 2 == 0)
+ *(p + j) = 0xFF00;
else
- *(p+j) = 0x00FF;
+ *(p + j) = 0x00FF;
}
tpl_surface_end_frame(wnd->tpl_surf);
tpl_surface_post(wnd->tpl_surf);
- usleep(500*1000);//0.5s
+ usleep(500 * 1000); //0.5s
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
- }
+}
#endif
#include "tpl_test_util.h"
-bool tpl_display_get_test (TPLNativeWnd* wnd)
+bool tpl_display_get_test (TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
}
- finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+finish:
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_display_bind_client_display_test(TPLNativeWnd* wnd)
+bool tpl_display_bind_client_display_test(TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---", __func__);
bool ret = true;
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
// bind display handle
tpl_bool_t result = false;
- result = tpl_display_bind_client_display_handle(wnd->tpl_display,(tpl_handle_t)wnd->dpy);
- if(result == false)
- {
+ result = tpl_display_bind_client_display_handle(wnd->tpl_display,
+ (tpl_handle_t)wnd->dpy);
+ if (result == false) {
LOG("ERRO", LOG_LEVEL_HIGH , " failed:tpl_display_bind_client_display_handle");
ret = false;
goto finish;
// unbind display handle
result = false;
- result = tpl_display_unbind_client_display_handle(wnd->tpl_display,(tpl_handle_t)wnd->dpy);
- if(result == false)
- {
- LOG("ERRO", LOG_LEVEL_HIGH , " failed:tpl_display_unbind_client_display_handle");
+ result = tpl_display_unbind_client_display_handle(wnd->tpl_display,
+ (tpl_handle_t)wnd->dpy);
+ if (result == false) {
+ LOG("ERRO", LOG_LEVEL_HIGH ,
+ " failed:tpl_display_unbind_client_display_handle");
ret = false;
goto finish;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_display_get_arg_test (TPLNativeWnd* wnd)
+bool tpl_display_get_arg_test (TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
}
//tpl_display_get_backend_type
- tpl_backend_type_t backend_type = tpl_display_get_backend_type(wnd->tpl_display);
- if(backend_type != TPL_BACKEND_WAYLAND)
- {
+ tpl_backend_type_t backend_type = tpl_display_get_backend_type(
+ wnd->tpl_display);
+ if (backend_type != TPL_BACKEND_WAYLAND) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_backend_type");
ret = false;
goto finish;
//tpl_display_get_native_handle
tpl_handle_t test_handle = NULL;
test_handle = tpl_display_get_native_handle(wnd->tpl_display);
- if(test_handle == NULL)
- {
+ if (test_handle == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_native_handle");
ret = false;
goto finish;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_display_query_config_test (TPLNativeWnd* wnd)
+bool tpl_display_query_config_test (TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//query config
tpl_bool_t result = false;
result = tpl_display_query_config(wnd->tpl_display,
- TPL_SURFACE_TYPE_WINDOW,
- 8,
- 8,
- 8,
- 8,
- 32,
- NULL,
- NULL);
- if(result == false )
- {
+ TPL_SURFACE_TYPE_WINDOW,
+ 8,
+ 8,
+ 8,
+ 8,
+ 32,
+ NULL,
+ NULL);
+ if (result == false ) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");
ret = false;
goto finish;
}
result = tpl_display_query_config(wnd->tpl_display,
- TPL_SURFACE_TYPE_WINDOW,
- 8,
- 8,
- 8,
- 8,
- 24,
- NULL,
- NULL);
- if(result == false )
- {
+ TPL_SURFACE_TYPE_WINDOW,
+ 8,
+ 8,
+ 8,
+ 8,
+ 24,
+ NULL,
+ NULL);
+ if (result == false ) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");
ret = false;
goto finish;
}
result = tpl_display_query_config(wnd->tpl_display,
- TPL_SURFACE_TYPE_WINDOW,
- 0,
- 8,
- 8,
- 8,
- 24,
- NULL,
- NULL);
- if(result != false )//unmatched case
- {
+ TPL_SURFACE_TYPE_WINDOW,
+ 0,
+ 8,
+ 8,
+ 8,
+ 24,
+ NULL,
+ NULL);
+ if (result != false ) { //unmatched case
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");
ret = false;
goto finish;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_display_filter_config_test (TPLNativeWnd* wnd)
+bool tpl_display_filter_config_test (TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//filt config
tpl_bool_t result = false;
int test_visual_id = GBM_FORMAT_ARGB8888;
- result = tpl_display_filter_config(wnd->tpl_display,&test_visual_id,0);
- if(result == false )
- {
+ result = tpl_display_filter_config(wnd->tpl_display, &test_visual_id, 0);
+ if (result == false ) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");
ret = false;
goto finish;
}
//filt config, unmatched case
- result = tpl_display_filter_config(wnd->tpl_display,&test_visual_id,8);
- if(result != false )
- {
+ result = tpl_display_filter_config(wnd->tpl_display, &test_visual_id, 8);
+ if (result != false ) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");
ret = false;
goto finish;
}
test_visual_id = GBM_FORMAT_XRGB8888;
- result = tpl_display_filter_config(wnd->tpl_display,&test_visual_id,0);
- if(result != false )
- {
+ result = tpl_display_filter_config(wnd->tpl_display, &test_visual_id, 0);
+ if (result != false ) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");
ret = false;
goto finish;
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_display_abnormal_test (TPLNativeWnd* wnd)
+bool tpl_display_abnormal_test (TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//abnormal test
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, NULL);
- if(wnd->tpl_display != NULL)
- {
+ if (wnd->tpl_display != NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:tpl_display_get");
ret = false;
goto finish;
//abnormal test
- tpl_display_bind_client_display_handle(NULL,NULL);
- tpl_display_unbind_client_display_handle(NULL,NULL);
+ tpl_display_bind_client_display_handle(NULL, NULL);
+ tpl_display_unbind_client_display_handle(NULL, NULL);
tpl_display_get_backend_type(NULL);
tpl_display_get_native_handle(NULL);
- tpl_display_filter_config(NULL,NULL,0);
- tpl_display_query_config(NULL,TPL_SURFACE_TYPE_PIXMAP,0,8,8,8,24,NULL,NULL);
+ tpl_display_filter_config(NULL, NULL, 0);
+ tpl_display_query_config(NULL, TPL_SURFACE_TYPE_PIXMAP, 0, 8, 8, 8, 24, NULL,
+ NULL);
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
#include "tpl_test_util.h"
-bool tpl_object_get_type_test(TPLNativeWnd* wnd )
+bool tpl_object_get_type_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
//tpl_object_get_type:DISPLAY
int obj_type = -1;
obj_type = tpl_object_get_type((tpl_object_t *)wnd->tpl_display);
- if (obj_type != TPL_OBJECT_DISPLAY)
- {
+ if (obj_type != TPL_OBJECT_DISPLAY) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type");
ret = false;
goto finish;
//tpl_object_get_type:SURFACE
obj_type = -1;
obj_type = tpl_object_get_type((tpl_object_t *)wnd->tpl_surf);
- if (obj_type != TPL_OBJECT_SURFACE)
- {
+ if (obj_type != TPL_OBJECT_SURFACE) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type");
ret = false;
goto finish;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_object_userdata_test(TPLNativeWnd* wnd )
+bool tpl_object_userdata_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
}
//2. set userdate
- tpl_object_set_user_data((tpl_object_t *)wnd->tpl_display,(void *)wnd->dpy,NULL);
+ tpl_object_set_user_data((tpl_object_t *)wnd->tpl_display, (void *)wnd->dpy,
+ NULL);
//3.get userdate
- void* get_dpy = NULL;
+ void *get_dpy = NULL;
get_dpy = (void *)tpl_object_get_user_data((tpl_object_t *)wnd->tpl_display);
- if(get_dpy == NULL)
- {
+ if (get_dpy == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_user_data");
ret = false;
goto finish;
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_object_reference_test(TPLNativeWnd* wnd )
+bool tpl_object_reference_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//3.tpl_object_get_reference
int ref_count = -1;
ref_count = tpl_object_get_reference((tpl_object_t *)wnd->tpl_display);
- if(ref_count == -1)
- {
+ if (ref_count == -1) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_reference");
ret = false;
goto finish;
//4.tpl_object_unreference
int unref_count = -1;
unref_count = tpl_object_unreference((tpl_object_t *)wnd->tpl_display);
- if(unref_count != ref_count-1)
- {
+ if (unref_count != ref_count - 1) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_unreference");
ret = false;
goto finish;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_object_abnormal_test(TPLNativeWnd* wnd )
+bool tpl_object_abnormal_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//abnormal test
tpl_object_get_type(NULL);
- tpl_object_set_user_data(NULL,NULL,NULL);
+ tpl_object_set_user_data(NULL, NULL, NULL);
tpl_object_get_user_data(NULL);
tpl_object_reference(NULL);
tpl_object_get_reference(NULL);
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
#include "tpl_test_util.h"
-bool tpl_surface_create_test(TPLNativeWnd* wnd)
+bool tpl_surface_create_test(TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_display = NULL;
//1.tpl_display_get
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
}
//2.tpl_surface_create
tpl_surface_t *tpl_surf = NULL;
- tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(tpl_surf == NULL)
- {
+ tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_surface_get_arg_test(TPLNativeWnd* wnd)
+bool tpl_surface_get_arg_test(TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_display = NULL;
//1.tpl_display_get
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
}
//2.tpl_surface_create
tpl_surface_t *tpl_surf = NULL;
- tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(tpl_surf == NULL)
- {
+ tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
}
//tpl_surface_get_display test
- tpl_display_t* test_dpy = tpl_surface_get_display(tpl_surf);
- if(test_dpy == NULL)
- {
+ tpl_display_t *test_dpy = tpl_surface_get_display(tpl_surf);
+ if (test_dpy == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_display");
ret = false;
goto finish;
}
//tpl_surface_get_native_handle
tpl_handle_t test_handle = tpl_surface_get_native_handle(tpl_surf);
- if(test_handle == NULL)
- {
+ if (test_handle == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_native_handle");
ret = false;
goto finish;
}
//tpl_surface_get_type test
tpl_surface_type_t test_type = tpl_surface_get_type(tpl_surf);
- if(test_type != TPL_SURFACE_TYPE_WINDOW)
- {
+ if (test_type != TPL_SURFACE_TYPE_WINDOW) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_type");
ret = false;
goto finish;
}
- finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+finish:
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_surface_frame_test(TPLNativeWnd* wnd)
+bool tpl_surface_frame_test(TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_display = NULL;
//1.tpl_display_get
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
}
//2.tpl_surface_create
tpl_surface_t *tpl_surf = NULL;
- tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(tpl_surf == NULL)
- {
+ tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_surface_get_buffer_test(TPLNativeWnd* wnd )
+bool tpl_surface_get_buffer_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
tpl_surface_t *tpl_surf = NULL;
- tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(tpl_surf == NULL)
- {
+ tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
tpl_buffer_t *tpl_buf_r = NULL;
tpl_bool_t reset;
tpl_buf_r = tpl_surface_get_buffer(tpl_surf, &reset);
- if (tpl_buf_r == NULL)
- {
+ if (tpl_buf_r == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
-bool tpl_surface_post_test(TPLNativeWnd* wnd )
+bool tpl_surface_post_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
tpl_surface_t *tpl_surf = NULL;
- tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(tpl_surf == NULL)
- {
+ tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
void *ptr = NULL;
//int size = tpl_buf->width * tpl_buf->height * tpl_buf->depth;
int size = wnd->width * wnd->height ;
- LOG("INFO", LOG_LEVEL_LOW ,"width=%d,height=%d,size=%d",wnd->width , wnd->height , size);
+ LOG("INFO", LOG_LEVEL_LOW , "width=%d,height=%d,size=%d", wnd->width ,
+ wnd->height , size);
ptr = tpl_buffer_map(wnd->tpl_buf, size);
- if (ptr == NULL)
- {
+ if (ptr == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map");
ret = false;
goto finish;
}
//6.write
- int *p = NULL;int j=0;
- for(j = 0; j <size;j++)
- {
- p = (int*) ptr;
- *(p+j) = 0xFF00;
+ int *p = NULL;
+ int j = 0;
+ for (j = 0; j < size; j++) {
+ p = (int *) ptr;
+ *(p + j) = 0xFF00;
}
LOG("INFO", LOG_LEVEL_LOW , "succ:write completed!");
//9. get post interval;
int interval_get = tpl_surface_get_post_interval(tpl_surf);
- if(interval_get!=interval_set)
- {
- LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_post_interval");
- ret = false;
- goto finish;
+ if (interval_get != interval_set) {
+ LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_post_interval");
+ ret = false;
+ goto finish;
}
//10.post
LOG("INFO", LOG_LEVEL_LOW , "After posted!!!");
- int k=1;
- while(k<=10)
- {
- usleep(1000*1000);
- LOG("INFO", LOG_LEVEL_LOW , "sleep %d ...",k);
+ int k = 1;
+ while (k <= 10) {
+ usleep(1000 * 1000);
+ LOG("INFO", LOG_LEVEL_LOW , "sleep %d ...", k);
//printf("%d ",k);
k++;
}
finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_surface_abnormal_test(TPLNativeWnd* wnd)
+bool tpl_surface_abnormal_test(TPLNativeWnd *wnd)
{
TPL_CHK_PARAM( !wnd );
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
bool ret = true;
wnd->tpl_surf = NULL;
//1.tpl_display_get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//abnormal test
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(NULL, NULL, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, 10, TPL_FORMAT_ARGB8888);
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_INVALID);
- /* if(tpl_surf != NULL)
+ wnd->tpl_surf = tpl_surface_create(NULL, NULL, TPL_SURFACE_TYPE_WINDOW,
+ TPL_FORMAT_ARGB8888);
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, 10,
+ TPL_FORMAT_ARGB8888);
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_INVALID);
+ /* if(tpl_surf != NULL)
{
LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:%s",__func__);
ret = false;
goto finish;
}
- */
+ */
//abnormal test
int width = 0, height = 0;
tpl_surface_get_display(NULL);
tpl_surface_get_native_handle(NULL);
tpl_surface_get_type(NULL);
- tpl_surface_get_size(NULL,&width,&height);
- tpl_surface_get_buffer(NULL,NULL);
+ tpl_surface_get_size(NULL, &width, &height);
+ tpl_surface_get_buffer(NULL, NULL);
tpl_surface_set_post_interval(NULL, 2);
tpl_surface_get_post_interval(NULL);
tpl_surface_post(NULL);
tpl_surface_validate_frame(NULL);
tpl_surface_end_frame(NULL);
- finish:
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+finish:
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
}
-bool tpl_surface_stress_test(TPLNativeWnd* wnd )
+bool tpl_surface_stress_test(TPLNativeWnd *wnd )
{
TPL_CHK_PARAM( !wnd );
bool ret = true;
int index = 0;
- LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+ LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__);
//1.tpl_display _get
wnd->tpl_display = NULL;
wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
- if(wnd->tpl_display == NULL)
- {
+ if (wnd->tpl_display == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
ret = false;
goto finish;
//2.tpl_surface_create
wnd->tpl_surf = NULL;
- wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd,
+ TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
//4.get buffer
wnd->tpl_buf = NULL;
wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (wnd->tpl_buf == NULL)
- {
+ if (wnd->tpl_buf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
}
- tpl_buffer_t *surf_array[STRESS_NUM]={0};
- tpl_buffer_t *buf_array[STRESS_NUM]={0};
- for(index = 0;index<STRESS_NUM;index++)
- {
- surf_array[index] = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
- if(wnd->tpl_surf == NULL)
- {
+ tpl_buffer_t *surf_array[STRESS_NUM] = {0};
+ tpl_buffer_t *buf_array[STRESS_NUM] = {0};
+ for (index = 0; index < STRESS_NUM; index++) {
+ surf_array[index] = tpl_surface_create(wnd->tpl_display ,
+ (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+ if (wnd->tpl_surf == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
ret = false;
goto finish;
}
buf_array[index] = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
- if (buf_array[index] == NULL)
- {
+ if (buf_array[index] == NULL) {
LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
ret = false;
goto finish;
finish:
- for(index = 0;index<STRESS_NUM;index++)
- {
- if (surf_array[index] != NULL)
- {
- tpl_object_unreference((tpl_object_t*)surf_array[index]);
+ for (index = 0; index < STRESS_NUM; index++) {
+ if (surf_array[index] != NULL) {
+ tpl_object_unreference((tpl_object_t *)surf_array[index]);
surf_array[index] = NULL;
}
}
- if(true == ret)
- LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+ if (true == ret)
+ LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__);
else
- LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+ LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__);
return ret;
typedef struct _TPLNativeWnd TPLNativeWnd;
-struct _TPLNativeWnd
-{
- void* dpy;
+struct _TPLNativeWnd {
+ void *dpy;
struct wl_registry *registry;
struct wl_compositor *compositor;
struct wl_shell *shell;
int screen;
- void* root;
- void* wnd;
+ void *root;
+ void *wnd;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
int x;
int width;
int height;
int depth;
- tpl_display_t * tpl_display;
- tpl_surface_t * tpl_surf;
- tpl_buffer_t * tpl_buf;
+ tpl_display_t *tpl_display;
+ tpl_surface_t *tpl_surf;
+ tpl_buffer_t *tpl_buf;
};
typedef struct _TPLTest TPLTest;
-struct _TPLTest
-{
- char* name;
- bool (*run) (TPLNativeWnd*);
+struct _TPLTest {
+ char *name;
+ bool (*run) (TPLNativeWnd *);
};
extern int tpl_test_log_level;
/* for tpl test */
-bool tpl_buffer_map_unmap_test(TPLNativeWnd* wnd );
-bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd );
-bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd );
-bool tpl_buffer_create_native_buffer_test(TPLNativeWnd* wnd );
-
-bool tpl_display_get_test (TPLNativeWnd* wnd);
-bool tpl_display_bind_client_display_test(TPLNativeWnd* wnd);
-bool tpl_display_get_arg_test (TPLNativeWnd* wnd);
-bool tpl_display_query_config_test (TPLNativeWnd* wnd);
-bool tpl_display_filter_config_test (TPLNativeWnd* wnd);
-
-bool tpl_object_get_type_test(TPLNativeWnd* wnd );
-bool tpl_object_userdata_test(TPLNativeWnd* wnd );
-bool tpl_object_reference_test(TPLNativeWnd* wnd );
-
-bool tpl_surface_create_test(TPLNativeWnd* wnd);
-bool tpl_surface_get_arg_test(TPLNativeWnd* wnd);
-bool tpl_surface_frame_test(TPLNativeWnd* wnd);
-bool tpl_surface_get_buffer_test(TPLNativeWnd* wnd );
-bool tpl_surface_post_test(TPLNativeWnd* wnd );
-
-bool tpl_surface_abnormal_test(TPLNativeWnd* wnd);
-bool tpl_object_abnormal_test(TPLNativeWnd* wnd);
-bool tpl_display_abnormal_test(TPLNativeWnd* wnd);
-bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd);
-
-bool tpl_surface_stress_test(TPLNativeWnd* wnd );
-bool tpl_buffer_stress_test(TPLNativeWnd* wnd );
-
-static TPLTest tpl_test[] =
-{
+bool tpl_buffer_map_unmap_test(TPLNativeWnd *wnd );
+bool tpl_buffer_lock_unlock_test(TPLNativeWnd *wnd );
+bool tpl_buffer_get_arg_test(TPLNativeWnd *wnd );
+bool tpl_buffer_create_native_buffer_test(TPLNativeWnd *wnd );
+
+bool tpl_display_get_test (TPLNativeWnd *wnd);
+bool tpl_display_bind_client_display_test(TPLNativeWnd *wnd);
+bool tpl_display_get_arg_test (TPLNativeWnd *wnd);
+bool tpl_display_query_config_test (TPLNativeWnd *wnd);
+bool tpl_display_filter_config_test (TPLNativeWnd *wnd);
+
+bool tpl_object_get_type_test(TPLNativeWnd *wnd );
+bool tpl_object_userdata_test(TPLNativeWnd *wnd );
+bool tpl_object_reference_test(TPLNativeWnd *wnd );
+
+bool tpl_surface_create_test(TPLNativeWnd *wnd);
+bool tpl_surface_get_arg_test(TPLNativeWnd *wnd);
+bool tpl_surface_frame_test(TPLNativeWnd *wnd);
+bool tpl_surface_get_buffer_test(TPLNativeWnd *wnd );
+bool tpl_surface_post_test(TPLNativeWnd *wnd );
+
+bool tpl_surface_abnormal_test(TPLNativeWnd *wnd);
+bool tpl_object_abnormal_test(TPLNativeWnd *wnd);
+bool tpl_display_abnormal_test(TPLNativeWnd *wnd);
+bool tpl_buffer_abnormal_test(TPLNativeWnd *wnd);
+
+bool tpl_surface_stress_test(TPLNativeWnd *wnd );
+bool tpl_buffer_stress_test(TPLNativeWnd *wnd );
+
+static TPLTest tpl_test[] = {
{ "Check TPL buffer map and unmap", tpl_buffer_map_unmap_test },
{ "Check TPL buffer lock and unlock", tpl_buffer_lock_unlock_test },
{ "Check TPL buffer get args", tpl_buffer_get_arg_test },
- { "TPL buffer create native buffer test",tpl_buffer_create_native_buffer_test },
- { "TPL buffer stress test",tpl_buffer_stress_test },
+ { "TPL buffer create native buffer test", tpl_buffer_create_native_buffer_test },
+ { "TPL buffer stress test", tpl_buffer_stress_test },
- { "TPL display get test",tpl_display_get_test },
+ { "TPL display get test", tpl_display_get_test },
//{ "Check TPL display bind client display",tpl_display_bind_client_display_test },/*5*/
- { "Check TPL display get args",tpl_display_get_arg_test },
- { "TPL display query config test",tpl_display_query_config_test },
- { "TPL display filter config test",tpl_display_filter_config_test },
+ { "Check TPL display get args", tpl_display_get_arg_test },
+ { "TPL display query config test", tpl_display_query_config_test },
+ { "TPL display filter config test", tpl_display_filter_config_test },
- { "Check TPL object get types",tpl_object_get_type_test },
- { "Check TPL object set and get userdate",tpl_object_userdata_test },
- { "Check TPL object reference and unreference",tpl_object_reference_test },
+ { "Check TPL object get types", tpl_object_get_type_test },
+ { "Check TPL object set and get userdate", tpl_object_userdata_test },
+ { "Check TPL object reference and unreference", tpl_object_reference_test },
- { "Check TPL surface create",tpl_surface_create_test },
- { "Check TPL surface get args",tpl_surface_get_arg_test },
+ { "Check TPL surface create", tpl_surface_create_test },
+ { "Check TPL surface get args", tpl_surface_get_arg_test },
{ "Check TPL surface frame operation" , tpl_surface_frame_test },
- { "TPL surface get buffer test",tpl_surface_get_buffer_test },/*15*/
- { "TPL surface post test",tpl_surface_post_test },
- { "TPL surface stress test",tpl_surface_stress_test },
-/*
- { "TPL surface abnormal test",tpl_surface_abnormal_test },
- { "TPL object abnormal test",tpl_object_abnormal_test },
- { "TPL display abnormal test",tpl_display_abnormal_test },
- { "TPL buffer abnormal test",tpl_buffer_abnormal_test },
-*/
+ { "TPL surface get buffer test", tpl_surface_get_buffer_test }, /*15*/
+ { "TPL surface post test", tpl_surface_post_test },
+ { "TPL surface stress test", tpl_surface_stress_test },
+ /*
+ { "TPL surface abnormal test",tpl_surface_abnormal_test },
+ { "TPL object abnormal test",tpl_object_abnormal_test },
+ { "TPL display abnormal test",tpl_display_abnormal_test },
+ { "TPL buffer abnormal test",tpl_buffer_abnormal_test },
+ */
{ NULL, NULL }
};
#define __USEC_TO_SEC( usec ) ((float)(usec) * 1.0e-6f)
#define __MSEC_TO_SEC( usec ) ((float)(usec) * 1.0e-3f)
long int tpl_test_util_get_systime( void );
-void tpl_test_util_init_fps( long int* s_time );
+void tpl_test_util_init_fps( long int *s_time );
float tpl_test_util_get_fps( long int s_time, int frame );
/*-----------------------------------------------------------------
typedef struct _GfxUtilTimer GfxUtilTimer;
#define USE_GETTIME 1
-struct _GfxUtilTimer
-{
+struct _GfxUtilTimer {
bool is_begin;
bool is_measured;
char func[1024];
tpl_test_util_timer_end( &__timer, __func__, __LINE__, msg );
void tpl_test_util_timer_list_display( void );
-void tpl_test_util_timer_release( GfxUtilTimer* timer );
-GfxUtilTimer* tpl_test_util_timer_copy( GfxUtilTimer* src, const char* func, int line, const char* msg );
+void tpl_test_util_timer_release( GfxUtilTimer *timer );
+GfxUtilTimer *tpl_test_util_timer_copy( GfxUtilTimer *src, const char *func,
+ int line, const char *msg );
void tpl_test_util_timer_list_clear( void );
-void tpl_test_util_timer_begin( GfxUtilTimer* timer, const char* func, int line, const char* msg );
-void tpl_test_util_timer_end( GfxUtilTimer* timer, const char* func, int line, const char* msg );
+void tpl_test_util_timer_begin( GfxUtilTimer *timer, const char *func,
+ int line, const char *msg );
+void tpl_test_util_timer_end( GfxUtilTimer *timer, const char *func, int line,
+ const char *msg );
#else
# define __TPL_TIMER_GLOBAL_BEGIN( ... ) { ; }
# define __TPL_TIMER_GLOBAL_END( ... ) { ; }
#define DEFAULT_LOG_STREAM stderr
#define __log_err(fmt, args...) __LOG_ERR(__func__, __LINE__, fmt, ##args)
-bool __LOG_ERR( const char* func, int line, const char* fmt, ... );
-bool __tpl_test_log_display_msg( const char* msg );
+bool __LOG_ERR( const char *func, int line, const char *fmt, ... );
+bool __tpl_test_log_display_msg( const char *msg );
# define __log(fmt, args...) __LOG(__func__, __LINE__, fmt, ##args)
# define __log_begin( ... ) __LOG_BEGIN(__func__);
# define __log_end( ... ) __LOG_END(__func__);
-bool __LOG( const char* func, int line, const char* fmt, ... );
-void __LOG_BEGIN( const char* func );
-void __LOG_END( const char* func );
+bool __LOG( const char *func, int line, const char *fmt, ... );
+void __LOG_BEGIN( const char *func );
+void __LOG_END( const char *func );
#else
# define __log( ... ) { ; }
# define __log_begin( ... ) { ; }
typedef struct _GfxMatrix GfxMatrix_t;
-struct _GfxMatrix
-{
+struct _GfxMatrix {
//GLfloat m[4][4];
};
-typedef enum
-{
+typedef enum {
TPL_TEX_COLOR_BLACK,
TPL_TEX_COLOR_WHITE,
TPL_TEX_COLOR_GREY,