Apply coding style 68/59868/1 accepted/tizen/wearable/20160307.020709 submit/tizen_wearable/20160304.133021
authorMun, Gwan-gyeong <kk.moon@samsung.com>
Fri, 19 Feb 2016 05:37:35 +0000 (14:37 +0900)
committerMun, Gwan-gyeong <kk.moon@samsung.com>
Fri, 19 Feb 2016 05:37:35 +0000 (14:37 +0900)
Change-Id: I5c3d76f1ba6fcabb98d3d472a9985eb7887ba86a

23 files changed:
src/tpl.c
src/tpl.h
src/tpl_display.c
src/tpl_gbm.c
src/tpl_internal.h
src/tpl_object.c
src/tpl_surface.c
src/tpl_tbm.c
src/tpl_utils.h
src/tpl_utils_hlist.c
src/tpl_utils_map.c
src/tpl_wayland.c
src/tpl_x11_common.c
src/tpl_x11_dri2.c
src/tpl_x11_dri3.c
src/tpl_x11_internal.h
src/wayland-egl/wayland-egl.c
tc/src/main.c
tc/src/tpl_test_buffer.c
tc/src/tpl_test_display.c
tc/src/tpl_test_object.c
tc/src/tpl_test_surface.c
tc/src/tpl_test_util.h

index c12b934..9946217 100644 (file)
--- a/src/tpl.c
+++ b/src/tpl.c
@@ -61,7 +61,7 @@ __tpl_util_clz(int val)
 }
 
 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;
 
@@ -75,7 +75,7 @@ __tpl_util_atomic_get(const tpl_util_atomic_uint * const atom)
 }
 
 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);
 
@@ -85,7 +85,7 @@ __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 )
+__tpl_util_atomic_inc(tpl_util_atomic_uint *const atom )
 {
        TPL_ASSERT(atom);
 
@@ -93,7 +93,7 @@ __tpl_util_atomic_inc(tpl_util_atomic_uint * const 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);
 
@@ -114,7 +114,7 @@ __tpl_runtime_find_display(tpl_backend_type_t type, tpl_handle_t native_display)
        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;
@@ -122,7 +122,7 @@ __tpl_runtime_find_display(tpl_backend_type_t type, tpl_handle_t native_display)
                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;
                }
@@ -166,7 +166,7 @@ __tpl_runtime_add_display(tpl_display_t *display)
        }
 
        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);
@@ -190,7 +190,7 @@ __tpl_runtime_remove_display(tpl_display_t *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);
@@ -216,7 +216,7 @@ __tpl_runtime_flush_all_display()
        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);
index 62004d2..b81f4ae 100644 (file)
--- a/src/tpl.h
+++ b/src/tpl.h
@@ -76,7 +76,7 @@ typedef unsigned int tpl_bool_t;
  * 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.
@@ -212,7 +212,8 @@ typedef enum {
  * @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.
@@ -223,7 +224,8 @@ int tpl_object_reference(tpl_object_t *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.
@@ -234,7 +236,8 @@ int tpl_object_unreference(tpl_object_t *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.
@@ -260,8 +263,9 @@ tpl_object_type_t tpl_object_get_type(tpl_object_t *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.
@@ -272,7 +276,8 @@ tpl_result_t tpl_object_set_user_data(tpl_object_t *object, void *key,
  *
  * @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.
@@ -297,7 +302,8 @@ tpl_display_create(tpl_backend_type_t type, tpl_handle_t native_dpy);
  * @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.
@@ -307,7 +313,8 @@ tpl_display_t * tpl_display_get(tpl_handle_t native_dpy);
  *
  * @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.
@@ -328,7 +335,8 @@ tpl_handle_t tpl_display_get_native_handle(tpl_display_t *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);
@@ -345,7 +353,8 @@ tpl_display_query_config(tpl_display_t *display, tpl_surface_type_t surface_type
  * @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.
@@ -368,7 +377,8 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
  *
  * @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.
@@ -378,7 +388,8 @@ tpl_display_t * tpl_surface_get_display(tpl_surface_t *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.
@@ -388,7 +399,8 @@ tpl_handle_t tpl_surface_get_native_handle(tpl_surface_t *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.
@@ -418,7 +430,8 @@ tpl_surface_get_size(tpl_surface_t *surface, int *width, int *height);
  *
  * @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.
@@ -440,7 +453,8 @@ tpl_bool_t tpl_surface_validate(tpl_surface_t *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.
@@ -506,7 +520,8 @@ tpl_surface_set_post_interval(tpl_surface_t *surface, int interval);
  *
  * @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.
index c933199..d61bc0f 100644 (file)
@@ -38,7 +38,7 @@ tpl_display_create(tpl_backend_type_t type, tpl_handle_t native_dpy)
 
        /* 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;
        }
@@ -94,7 +94,7 @@ tpl_display_get(tpl_handle_t native_dpy)
 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;
        }
@@ -103,27 +103,29 @@ tpl_display_get_native_handle(tpl_display_t *display)
 }
 
 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;
        }
@@ -142,7 +144,7 @@ tpl_display_get_native_window_info(tpl_display_t *display, tpl_handle_t window,
        }
 
        return display->backend.get_window_info(display, window, width, height,
-               format, depth, a_size);
+                                               format, depth, a_size);
 }
 
 tpl_result_t
@@ -158,7 +160,8 @@ tpl_display_get_native_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
 }
 
 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!");
index 6d38c75..ba52105 100644 (file)
@@ -57,7 +57,7 @@ static inline tpl_gbm_buffer_t *
 __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);
@@ -73,7 +73,7 @@ __tpl_gbm_set_gbm_buffer_to_tbm_surface(tbm_surface_h surface,
 
        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);
 }
 
@@ -136,12 +136,12 @@ __tpl_gbm_display_query_config(tpl_display_t *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 (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;
@@ -152,9 +152,9 @@ __tpl_gbm_display_query_config(tpl_display_t *display,
                }
                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;
@@ -175,7 +175,7 @@ __tpl_gbm_display_filter_config(tpl_display_t *display, int *visual_id,
        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;
        }
@@ -192,7 +192,8 @@ __tpl_gbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
        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;
@@ -211,7 +212,8 @@ __tpl_gbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
 {
        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;
@@ -231,7 +233,8 @@ __tpl_gbm_display_get_buffer_from_native_pixmap(tpl_handle_t pixmap)
 
        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;
@@ -257,26 +260,28 @@ __tpl_gbm_surface_init(tpl_surface_t *surface)
        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;
                }
@@ -324,7 +329,7 @@ __tpl_gbm_surface_enqueue_buffer(tpl_surface_t *surface,
 
        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);
@@ -340,7 +345,7 @@ __tpl_gbm_surface_enqueue_buffer(tpl_surface_t *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;
@@ -372,11 +377,11 @@ __tpl_gbm_surface_dequeue_buffer(tpl_surface_t *surface)
        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",
@@ -448,7 +453,8 @@ __tpl_display_init_backend_gbm(tpl_display_backend_t *backend)
        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
index 429040f..5b0fca4 100644 (file)
@@ -40,9 +40,9 @@ struct _tpl_display_backend {
        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);
@@ -139,7 +139,8 @@ void *__tpl_surface_get_backend_data(tpl_surface_t *surface);
 
 /* 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();
@@ -151,8 +152,10 @@ tpl_bool_t __tpl_display_choose_backend_tbm(tpl_handle_t native_dpy);
 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);
@@ -172,23 +175,24 @@ int __tpl_util_clz(int input);
  * @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 */
index d75af47..8e1991d 100644 (file)
@@ -11,14 +11,16 @@ __tpl_object_is_valid(tpl_object_t *object)
 }
 
 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);
 
index 3f19dd6..a17b592 100644 (file)
@@ -17,7 +17,8 @@ __tpl_surface_free(void *data)
 }
 
 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;
 
@@ -38,7 +39,7 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle, tpl_surface_type
        }
 
        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;
@@ -57,7 +58,7 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle, tpl_surface_type
        __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;
@@ -190,7 +191,7 @@ tpl_surface_dequeue_buffer(tpl_surface_t *surface)
 
        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);
index 65cbe6d..64477c8 100644 (file)
@@ -70,8 +70,8 @@ __tpl_tbm_display_query_config(tpl_display_t *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;
@@ -176,16 +176,16 @@ __tpl_tbm_surface_init(tpl_surface_t *surface)
 
        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);
@@ -193,8 +193,8 @@ __tpl_tbm_surface_init(tpl_surface_t *surface)
                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);
 
@@ -222,7 +222,7 @@ __tpl_tbm_surface_fini(tpl_surface_t *surface)
        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)
@@ -251,7 +251,7 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface,
        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;
        }
@@ -266,7 +266,7 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface,
        }
 
        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;
@@ -301,7 +301,8 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface)
        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;
                }
        }
@@ -344,7 +345,8 @@ __tpl_display_init_backend_tbm(tpl_display_backend_t *backend)
        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
index d5e5557..34912ee 100644 (file)
@@ -256,9 +256,9 @@ typedef union tpl_util_key tpl_util_key_t;
 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,
@@ -301,11 +301,14 @@ void tpl_util_map_init(tpl_util_map_t *map, int bucket_bits,
                       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);
 
@@ -637,7 +640,7 @@ tpl_list_pop_back(tpl_list_t *list, tpl_free_func_t func)
 }
 
 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;
@@ -666,15 +669,15 @@ __tpl_util_image_dump_bmp(const char * file, const void * data, int width,
                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) +
@@ -698,8 +701,8 @@ __tpl_util_image_dump_bmp(const char * file, const void * data, int width,
                        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;
@@ -735,14 +738,14 @@ __tpl_util_image_dump_png(const char *file, const void *data, int width,
                        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);
@@ -761,8 +764,8 @@ __tpl_util_image_dump_png(const char *file, const void *data, int width,
 
                                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;
@@ -801,7 +804,7 @@ __tpl_util_image_dump_png(const char *file, const void *data, int width,
 #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];
@@ -809,19 +812,19 @@ __tpl_util_image_dump(const char * func, const void * data, int type,
 
        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",
@@ -834,13 +837,13 @@ __tpl_util_image_dump(const char * func, const void * data, int type,
        }
 #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",
index bc3cfb2..791e26a 100644 (file)
@@ -24,8 +24,8 @@ __tpl_hlist_add_before(tpl_hlist_node_t *n, tpl_hlist_node_t *next);
 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;
@@ -113,7 +113,7 @@ __tpl_hlist_get_node(tpl_hlist_t *list, size_t key)
 
        for (pos = list->heads[hash].first; pos; pos = pos->next) {
                if (pos->key == key)
-               return pos;
+                       return pos;
        }
 
        return NULL;
@@ -147,7 +147,8 @@ __tpl_hashlist_create()
        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;
index f838570..f5454a4 100644 (file)
@@ -97,7 +97,7 @@ __pointer_hash(const tpl_util_key_t key, int key_length)
 
        return (int)_key;
 #else
-       #error "Not 32 or 64bit system"
+#error "Not 32 or 64bit system"
 #endif
 
        return 0;
@@ -132,21 +132,21 @@ void
 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
@@ -164,11 +164,11 @@ tpl_util_map_create(int bucket_bits, tpl_util_hash_func_t hash_func,
        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;
 }
@@ -177,21 +177,21 @@ tpl_util_map_t *
 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
index 935ec82..ccf0c70 100644 (file)
@@ -65,7 +65,7 @@ static TPL_INLINE tpl_wayland_buffer_t *
 __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);
@@ -75,14 +75,14 @@ __tpl_wayland_get_wayland_buffer_from_tbm_surface(tbm_surface_h surface)
 
 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);
 }
@@ -101,7 +101,7 @@ __tpl_wayland_display_is_wl_display(tpl_handle_t native_dpy)
        }
 
        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;
        }
 
@@ -148,7 +148,8 @@ __tpl_wayland_display_init(tpl_display_t *display)
                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;
@@ -181,7 +182,7 @@ __tpl_wayland_display_init(tpl_display_t *display)
                }
 
                wl_proxy_set_queue((struct wl_proxy *)wayland_display->wl_registry,
-                       wayland_display->wl_queue);
+                                  wayland_display->wl_queue);
        } else {
                goto free_wl_display;
        }
@@ -225,8 +226,8 @@ __tpl_wayland_display_query_config(tpl_display_t *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;
@@ -282,20 +283,22 @@ __tpl_wayland_display_get_window_info(tpl_display_t *display,
 }
 
 static void
-__cb_client_window_resize_callback(struct wl_egl_windowwl_egl_window,
-                                  voidprivate);
+__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;
@@ -307,7 +310,7 @@ __tpl_wayland_surface_init(tpl_surface_t *surface)
        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!");
@@ -319,7 +322,7 @@ __tpl_wayland_surface_init(tpl_surface_t *surface)
        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);
@@ -345,7 +348,8 @@ __tpl_wayland_surface_fini(tpl_surface_t *surface)
        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 */
@@ -353,9 +357,10 @@ __tpl_wayland_surface_fini(tpl_surface_t *surface)
                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);
@@ -387,9 +392,9 @@ __tpl_wayland_surface_enqueue_buffer(tpl_surface_t *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;
 
@@ -404,7 +409,7 @@ __tpl_wayland_surface_enqueue_buffer(tpl_surface_t *surface,
 
        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;
 
@@ -425,21 +430,21 @@ __tpl_wayland_surface_enqueue_buffer(tpl_surface_t *surface,
 
        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]);
                }
        }
 
@@ -450,7 +455,7 @@ __tpl_wayland_surface_enqueue_buffer(tpl_surface_t *surface,
                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);
 
@@ -466,7 +471,7 @@ __tpl_wayland_surface_validate(tpl_surface_t *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;
 
@@ -483,20 +488,20 @@ __tpl_wayland_surface_dequeue_buffer(tpl_surface_t *surface)
        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;
                }
@@ -505,18 +510,20 @@ __tpl_wayland_surface_dequeue_buffer(tpl_surface_t *surface)
 
        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);
@@ -524,7 +531,7 @@ __tpl_wayland_surface_dequeue_buffer(tpl_surface_t *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);
@@ -534,7 +541,7 @@ __tpl_wayland_surface_dequeue_buffer(tpl_surface_t *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);
 
@@ -562,7 +569,7 @@ __tpl_wayland_buffer_free(tpl_wayland_buffer_t *wayland_buffer)
 
        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);
 }
@@ -609,7 +616,8 @@ __tpl_surface_init_backend_wayland(tpl_surface_backend_t *backend)
 }
 
 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;
 
@@ -621,13 +629,13 @@ __cb_client_sync_callback(void *data, struct wl_callback *callback, uint32_t ser
        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().
@@ -638,8 +646,7 @@ __cb_client_frame_callback(void *data, struct wl_callback *callback, uint32_t ti
        wl_callback_destroy(callback);
 }
 
-static const struct wl_callback_listener frame_listener =
-{
+static const struct wl_callback_listener frame_listener = {
        __cb_client_frame_callback
 };
 
@@ -671,14 +678,16 @@ static const struct wl_buffer_listener buffer_release_listener = {
 };
 
 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;
 
@@ -688,8 +697,8 @@ __cb_client_window_resize_callback(struct wl_egl_window* wl_egl_window, void* pr
 
        /* 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);
index 8122ab1..00c2adb 100644 (file)
@@ -40,8 +40,7 @@ __tpl_x11_swap_str_to_swap_type(char *str, tpl_x11_swap_type_t *type)
 
        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:
@@ -53,7 +52,8 @@ __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)
 {
        tpl_list_node_t *node;
 
@@ -61,8 +61,7 @@ __tpl_x11_surface_buffer_cache_find(tpl_list_t         *buffer_cache, unsigned int name
 
        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);
@@ -77,7 +76,8 @@ __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_list_node_t *node;
 
@@ -85,14 +85,12 @@ __tpl_x11_surface_buffer_cache_remove(tpl_list_t *buffer_cache, unsigned int nam
 
        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;
@@ -103,13 +101,13 @@ __tpl_x11_surface_buffer_cache_remove(tpl_list_t *buffer_cache, unsigned int nam
 }
 
 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);
@@ -148,10 +146,8 @@ __tpl_x11_display_query_config(tpl_display_t *display,
        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;
@@ -159,8 +155,7 @@ __tpl_x11_display_query_config(tpl_display_t *display,
                        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];
 
@@ -174,8 +169,7 @@ __tpl_x11_display_query_config(tpl_display_t *display,
 
                                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;
 
@@ -189,19 +183,16 @@ __tpl_x11_display_query_config(tpl_display_t *display,
                        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;
 
@@ -220,42 +211,39 @@ __tpl_x11_display_query_config(tpl_display_t *display,
 }
 
 #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 XVisualInfotpl_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;
@@ -263,28 +251,27 @@ static XVisualInfo* tpl_find_visual( Display *dpy, xcb_visualid_t visual_id )
 
        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;
@@ -294,10 +281,8 @@ static int tpl_get_offset( unsigned long mask, int depth )
        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;
                }
@@ -307,100 +292,86 @@ static int tpl_get_offset( unsigned long mask, int depth )
        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;
@@ -409,7 +380,7 @@ static tpl_format_t tpl_offsets_to_color_buffer_format( int offset_r, int offset
 
 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;
@@ -420,18 +391,24 @@ __tpl_x11_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
        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;
@@ -444,7 +421,7 @@ __tpl_x11_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
 
 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;
@@ -457,16 +434,21 @@ __tpl_x11_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
        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;
@@ -505,8 +487,7 @@ __tpl_x11_buffer_fini(tpl_buffer_t *buffer)
 {
        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);
@@ -552,23 +533,22 @@ __tpl_x11_buffer_lock(tpl_buffer_t *buffer, tpl_lock_usage_t usage)
 
        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);
@@ -611,8 +591,7 @@ void __tpl_x11_display_wait_native(tpl_display_t *display)
        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);
        }
index ef6201c..59ad49a 100644 (file)
@@ -25,8 +25,7 @@
 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;
@@ -35,8 +34,7 @@ struct _tpl_x11_dri2_surface
 
 
 
-static tpl_x11_global_t        global =
-{
+static tpl_x11_global_t        global = {
        0,
        NULL,
        -1,
@@ -64,7 +62,7 @@ __tpl_x11_dri2_get_worker_display(void)
 
 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;
@@ -90,32 +88,24 @@ __tpl_x11_dri2_surface_post_internal(tpl_surface_t *surface, tpl_frame_t *frame,
        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];
@@ -124,13 +114,10 @@ __tpl_x11_dri2_surface_post_internal(tpl_surface_t *surface, tpl_frame_t *frame,
                        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);
                }
@@ -150,26 +137,23 @@ __tpl_x11_dri2_display_init(tpl_display_t *display)
 
        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;
@@ -182,8 +166,7 @@ __tpl_x11_dri2_display_init(tpl_display_t *display)
 
                /* 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;
                }
@@ -193,22 +176,19 @@ __tpl_x11_dri2_display_init(tpl_display_t *display)
 
                /* 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;
                }
@@ -219,8 +199,7 @@ __tpl_x11_dri2_display_init(tpl_display_t *display)
 
                /* DRI2 authentication. */
                xres = DRI2Authenticate(global.worker_display, root, magic);
-               if (True != xres)
-               {
+               if (True != xres) {
                        TPL_ERR("DRI2Authenciate failed!");
                        return TPL_FALSE;
                }
@@ -229,10 +208,10 @@ __tpl_x11_dri2_display_init(tpl_display_t *display)
 
                /* 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++;
@@ -252,8 +231,7 @@ __tpl_x11_dri2_display_fini(tpl_display_t *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);
@@ -277,23 +255,20 @@ __tpl_x11_dri2_surface_init(tpl_surface_t *surface)
 
        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;
        }
@@ -325,8 +300,7 @@ __tpl_x11_dri2_surface_fini(tpl_surface_t *surface)
        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)
@@ -356,21 +330,18 @@ __tpl_x11_surface_begin_frame(tpl_surface_t *surface)
 
        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);
                }
        }
@@ -395,10 +366,8 @@ __tpl_x11_surface_validate_frame(tpl_surface_t *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;
                }
@@ -419,22 +388,21 @@ __tpl_x11_surface_end_frame(tpl_surface_t *surface)
        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;
@@ -460,21 +428,19 @@ __tpl_x11_dri2_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
        /* 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. */
@@ -483,9 +449,7 @@ __tpl_x11_dri2_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
 #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);
@@ -494,8 +458,7 @@ __tpl_x11_dri2_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
        /* 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;
        }
@@ -503,10 +466,10 @@ __tpl_x11_dri2_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
        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;
        }
@@ -522,11 +485,10 @@ __tpl_x11_dri2_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
        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);
index e94bb87..f1e972d 100644 (file)
@@ -45,8 +45,7 @@ static int dri3_max_back = 0;/*max number of back buffer*/
 
 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;
@@ -55,21 +54,18 @@ struct _tpl_x11_dri3_surface
        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 */
@@ -87,20 +83,19 @@ typedef struct _dri3_buffer
        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;
 
@@ -129,14 +124,12 @@ typedef struct _dri3_drawable
        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,
@@ -163,18 +156,16 @@ dri3_open(Display *dpy, Window root, CARD32 provider)
        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;
@@ -209,25 +200,22 @@ dri3_display_init(Display *dpy)
        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;
@@ -235,11 +223,10 @@ dri3_display_init(Display *dpy)
        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;
@@ -265,28 +252,25 @@ dri3_create_drawable(Display *dpy, XID xDrawable)
 
        /* 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;
@@ -302,13 +286,12 @@ dri3_create_drawable(Display *dpy, XID xDrawable)
        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;
@@ -316,15 +299,15 @@ dri3_create_drawable(Display *dpy, XID xDrawable)
 
        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
@@ -342,19 +325,16 @@ dri3_destroy_drawable(Display *dpy, XID xDrawable)
 
        /* 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]);
                        }
@@ -394,8 +374,7 @@ dri3_update_drawable(void *loaderPrivate)
 
        /* 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;
@@ -416,25 +395,25 @@ dri3_update_drawable(void *loaderPrivate)
                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;
                }
@@ -455,20 +434,17 @@ dri3_update_drawable(void *loaderPrivate)
                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;
                        }
@@ -491,83 +467,73 @@ dri3_handle_present_event(dri3_drawable *priv, xcb_present_generic_event_t *ge)
        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)
 {
@@ -578,16 +544,14 @@ 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);
                }
@@ -606,23 +570,19 @@ dri3_wait_for_notify(xcb_connection_t *c, dri3_drawable *priv)
 
        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;
                }
@@ -646,10 +606,8 @@ dri3_find_back(xcb_connection_t *c, dri3_drawable *priv)
        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;
 
@@ -657,10 +615,9 @@ dri3_find_back(xcb_connection_t *c, dri3_drawable *priv)
                        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;
                        }
@@ -671,8 +628,7 @@ dri3_find_back(xcb_connection_t *c, dri3_drawable *priv)
                ev = xcb_wait_for_special_event(c, priv->special_event);
                TRACE_END();
 
-               if (!ev)
-               {
+               if (!ev) {
                        return -1;
                }
 
@@ -688,14 +644,14 @@ dri3_find_back(xcb_connection_t *c, dri3_drawable *priv)
  */
 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;
@@ -712,8 +668,7 @@ dri3_alloc_render_buffer(dri3_drawable *priv,
        /* 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;
        }
@@ -724,13 +679,12 @@ dri3_alloc_render_buffer(dri3_drawable *priv,
        /* 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;
@@ -761,13 +715,11 @@ dri3_alloc_render_buffer(dri3_drawable *priv,
        /* 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;
        }
@@ -804,8 +756,7 @@ dri3_free_render_buffer(dri3_drawable *pdraw, dri3_buffer *buffer)
 
        /* 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);
@@ -829,7 +780,7 @@ dri3_get_window_buffer(void *loaderPrivate, int cpp)
        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);
@@ -848,24 +799,21 @@ dri3_get_window_buffer(void *loaderPrivate, int cpp)
         * 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.*/
@@ -884,14 +832,13 @@ dri3_get_window_buffer(void *loaderPrivate, int cpp)
 
        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;
 }
@@ -900,7 +847,8 @@ dri3_get_window_buffer(void *loaderPrivate, int cpp)
 /* 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;
@@ -923,16 +871,14 @@ dri3_get_pixmap_buffer(void *loaderPrivate, Pixmap pixmap, int cpp)/*TODO:format
         */
        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;
@@ -962,8 +908,8 @@ dri3_get_pixmap_buffer(void *loaderPrivate, Pixmap pixmap, int cpp)/*TODO:format
        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);
@@ -973,7 +919,7 @@ no_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;
@@ -983,15 +929,13 @@ static dri3_buffer *dri3_get_buffers(XID drawable,  void *loaderPrivate,
 
        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;
@@ -999,12 +943,11 @@ static dri3_buffer *dri3_get_buffers(XID drawable,  void *loaderPrivate,
 
        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;
        }
@@ -1021,7 +964,8 @@ static dri3_buffer *dri3_get_buffers(XID drawable,  void *loaderPrivate,
  * 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;
@@ -1031,7 +975,7 @@ dri3_swap_buffers(Display *dpy, void *priv, tpl_buffer_t *frame_buffer, int inte
        xcb_connection_t *c;
        dri3_drawable   *pDrawable;
        dri3_buffer     *back = NULL;
-        int            i = 0;
+       int             i = 0;
 
        TPL_ASSERT(dpy);
        TPL_ASSERT(priv);
@@ -1039,11 +983,10 @@ dri3_swap_buffers(Display *dpy, void *priv, tpl_buffer_t *frame_buffer, int inte
 
        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;
        }
@@ -1051,16 +994,14 @@ dri3_swap_buffers(Display *dpy, void *priv, tpl_buffer_t *frame_buffer, int inte
        /* 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;
@@ -1078,26 +1019,26 @@ dri3_swap_buffers(Display *dpy, void *priv, tpl_buffer_t *frame_buffer, int inte
        ++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;
 
@@ -1118,14 +1059,13 @@ __tpl_x11_dri3_buffer_init(tpl_buffer_t *buffer)
 void
 __tpl_x11_dri3_buffer_fini(tpl_buffer_t *buffer)
 {
-       dri3_bufferback;
+       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);
@@ -1144,7 +1084,7 @@ __tpl_x11_dri3_buffer_map(tpl_buffer_t *buffer, int size)
        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);
@@ -1166,47 +1106,44 @@ __tpl_x11_dri3_buffer_lock(tpl_buffer_t *buffer, tpl_lock_usage_t usage)
 {
        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;
        }
@@ -1222,16 +1159,15 @@ __tpl_x11_dri3_buffer_unlock(tpl_buffer_t *buffer)
 
        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);
@@ -1264,17 +1200,15 @@ __tpl_x11_dri3_display_init(tpl_display_t *display)
 
        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;
@@ -1304,12 +1238,11 @@ __tpl_x11_dri3_display_init(tpl_display_t *display)
                        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;
@@ -1336,8 +1269,7 @@ __tpl_x11_dri3_display_fini(tpl_display_t *display)
        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);
@@ -1362,9 +1294,9 @@ __tpl_x11_dri3_surface_init(tpl_surface_t *surface)
 
        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;
        }
@@ -1378,17 +1310,14 @@ __tpl_x11_dri3_surface_init(tpl_surface_t *surface)
        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;
@@ -1407,10 +1336,9 @@ __tpl_x11_dri3_surface_fini(tpl_surface_t *surface)
        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);
 
 
@@ -1425,8 +1353,8 @@ __tpl_x11_dri3_surface_fini(tpl_surface_t *surface)
 
 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;
@@ -1441,54 +1369,43 @@ __tpl_x11_dri3_surface_post_internal(tpl_surface_t *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;
 
@@ -1516,13 +1433,11 @@ __tpl_x11_dri3_surface_begin_frame(tpl_surface_t *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_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);
                }
        }
@@ -1542,13 +1457,11 @@ __tpl_x11_dri3_surface_validate_frame(tpl_surface_t *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;
                }
@@ -1568,15 +1481,13 @@ __tpl_x11_dri3_surface_end_frame(tpl_surface_t *surface)
        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);
                }
        }
@@ -1587,7 +1498,8 @@ __tpl_x11_dri3_surface_end_frame(tpl_surface_t *surface)
 /* 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;
@@ -1602,8 +1514,7 @@ __tpl_x11_dri3_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
 
        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;
        }
 
@@ -1615,14 +1526,12 @@ __tpl_x11_dri3_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
 
        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. */
@@ -1637,25 +1546,22 @@ __tpl_x11_dri3_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
                }
        }
 
-       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;
        }
@@ -1664,10 +1570,9 @@ __tpl_x11_dri3_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
 
        /* 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;
        }
@@ -1686,11 +1591,10 @@ __tpl_x11_dri3_surface_get_buffer(tpl_surface_t *surface, tpl_bool_t *reset_buff
        __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;
@@ -1700,15 +1604,15 @@ done:
 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] */
 
@@ -1769,7 +1673,7 @@ __tpl_buffer_init_backend_x11_dri3(tpl_buffer_backend_t *backend)
        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] */
 }
index 5014326..fa14d04 100644 (file)
@@ -29,8 +29,7 @@
 
 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,
@@ -38,8 +37,7 @@ typedef enum
        TPL_X11_SWAP_TYPE_MAX
 } tpl_x11_swap_type_t;
 
-struct _tpl_x11_global
-{
+struct _tpl_x11_global {
        int             display_count;
 
        Display         *worker_display;
@@ -57,11 +55,14 @@ void
 __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
@@ -71,7 +72,7 @@ __tpl_x11_display_query_config(tpl_display_t *display,
                               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);
index acb35f7..0602209 100644 (file)
@@ -59,8 +59,7 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
                     int width, int height,
                     int dx, int dy)
 {
-       if (egl_window == NULL)
-       {
+       if (egl_window == NULL) {
                WL_EGL_ERR("egl_window is NULL");
                return;
        }
@@ -74,8 +73,8 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
                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 *
@@ -84,9 +83,8 @@ wl_egl_window_create(struct wl_surface *surface,
 {
        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;
        }
@@ -99,7 +97,7 @@ wl_egl_window_create(struct wl_surface *surface,
        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;
 }
@@ -107,8 +105,7 @@ wl_egl_window_create(struct wl_surface *surface,
 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;
        }
@@ -128,6 +125,6 @@ wl_egl_window_get_attached_size(struct wl_egl_window *egl_window,
                *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);
 }
index 7304391..241dca7 100644 (file)
@@ -13,8 +13,7 @@
 
 typedef struct _ProgOption ProgOption;
 
-typedef struct _ProgOption
-{
+typedef struct _ProgOption {
        int egl_r;
        int egl_g;
        int egl_b;
@@ -34,8 +33,7 @@ typedef struct _ProgOption
        bool show_names;
 };
 
-ProgOption g_option =
-{
+ProgOption g_option = {
        8, 8, 8, 8,
        24,
        0,
@@ -53,7 +51,7 @@ ProgOption g_option =
 /* 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, };
@@ -71,7 +69,7 @@ __LOG( const char* func, int line, const char* fmt, ... )
 }
 
 void
-__LOG_BEGIN( const charfunc )
+__LOG_BEGIN( const char *func )
 {
        char str[NUM_ERR_STR] = { (char)0, };
        sprintf( str, "[tpl_test][B] %s", func );
@@ -80,7 +78,7 @@ __LOG_BEGIN( const char* func )
 }
 
 void
-__LOG_END( const charfunc )
+__LOG_END( const char *func )
 {
        char str[NUM_ERR_STR] = { (char)0, };
        sprintf( str, "[tpl_test][E] %s", func );
@@ -89,7 +87,7 @@ __LOG_END( const char* func )
 }
 
 bool
-__tpl_test_log_display_msg( const charmsg )
+__tpl_test_log_display_msg( const char *msg )
 {
        fprintf( DEFAULT_LOG_STREAM, "%s\n", msg );
        fflush( DEFAULT_LOG_STREAM );
@@ -97,7 +95,7 @@ __tpl_test_log_display_msg( const char* msg )
 }
 
 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, };
@@ -117,20 +115,16 @@ __LOG_ERR( const char* func, int line, const char* fmt, ... )
 #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)
 {
-       TPLNativeWndthat = (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);*/
@@ -138,28 +132,32 @@ registry_handle_global(void *data, struct wl_registry *registry,uint32_t id, con
 }
 
 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;
@@ -168,8 +166,7 @@ shell_surface_handle_configure(void *data, struct wl_shell_surface * shell_surfa
 }
 
 
-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
@@ -177,34 +174,35 @@ const struct wl_shell_surface_listener shell_surface_listener_ =
 /* wayland native end */
 
 /* tpl_test related */
-TPLNativeWnd*
+TPLNativeWnd *
 tpl_test_native_wnd_create( void )
 {
-       TPLNativeWndwnd = 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;
 
@@ -215,9 +213,8 @@ tpl_test_native_wnd_initialize( TPLNativeWnd* wnd, int x, int y, int width, int
        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;
        }
@@ -234,15 +231,15 @@ tpl_test_native_wnd_initialize( TPLNativeWnd* wnd, int x, int y, int width, int
        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");
@@ -253,7 +250,7 @@ finish:
 }
 
 bool
-tpl_test_native_wnd_finalize( TPLNativeWndwnd )
+tpl_test_native_wnd_finalize( TPLNativeWnd *wnd )
 {
        bool res = false;
 
@@ -282,19 +279,17 @@ finish:
 }
 
 bool
-tpl_test_finalize( TPLNativeWndwnd )
+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;
@@ -304,7 +299,7 @@ finish:
 
 
 void
-tpl_test_native_wnd_release( TPLNativeWndwnd )
+tpl_test_native_wnd_release( TPLNativeWnd *wnd )
 {
        TPL_CHK_PARAM( !wnd );
 
@@ -345,93 +340,91 @@ print_usage( char *name )
        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;
                }
        }
 
@@ -440,11 +433,12 @@ check_option( int argc, char** argv )
 int tpl_test_log_level = 5;
 
 int
-main( int argc, char** argv )
+main( int argc, char **argv )
 {
-       TPLNativeWndwnd = 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;
@@ -454,30 +448,25 @@ main( int argc, char** argv )
        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++;
                }
@@ -487,51 +476,46 @@ main( int argc, char** argv )
        }
 
        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" );
        }
@@ -539,12 +523,11 @@ main( int argc, char** argv )
        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;
index 3c8e816..1c411dd 100644 (file)
@@ -4,17 +4,16 @@
 #include "tpl_test_util.h"
 
 
-bool tpl_buffer_map_unmap_test(TPLNativeWndwnd )
+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;
@@ -22,9 +21,9 @@ bool tpl_buffer_map_unmap_test(TPLNativeWnd* wnd )
 
        //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;
@@ -36,8 +35,7 @@ bool tpl_buffer_map_unmap_test(TPLNativeWnd* wnd )
        //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;
@@ -47,40 +45,39 @@ bool tpl_buffer_map_unmap_test(TPLNativeWnd* wnd )
        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(TPLNativeWndwnd )
+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;
@@ -88,9 +85,9 @@ bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
 
        //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;
@@ -102,8 +99,7 @@ bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
        //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;
@@ -111,9 +107,8 @@ bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
 
        //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;
@@ -121,9 +116,8 @@ bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
        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;
@@ -131,9 +125,8 @@ bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
        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;
@@ -141,9 +134,8 @@ bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
        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;
@@ -152,27 +144,26 @@ bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
 
 
 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(TPLNativeWndwnd )
+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;
@@ -180,9 +171,9 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
 
        //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;
@@ -194,8 +185,7 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
        //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;
@@ -204,8 +194,7 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
        //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;
@@ -214,8 +203,7 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
        //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;
@@ -224,8 +212,7 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
        //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;
@@ -234,8 +221,7 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
        //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;
@@ -244,8 +230,7 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
        //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;
@@ -254,8 +239,7 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
        //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;
@@ -263,8 +247,7 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
        //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;
@@ -272,27 +255,26 @@ bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
 
 
 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(TPLNativeWndwnd )
+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;
@@ -300,9 +282,9 @@ bool tpl_buffer_create_native_buffer_test(TPLNativeWnd* wnd )
 
        //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;
@@ -314,8 +296,7 @@ bool tpl_buffer_create_native_buffer_test(TPLNativeWnd* wnd )
        //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;
@@ -324,33 +305,31 @@ bool tpl_buffer_create_native_buffer_test(TPLNativeWnd* wnd )
        //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(TPLNativeWndwnd )
+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;
@@ -358,9 +337,9 @@ bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd )
 
        //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;
@@ -372,8 +351,7 @@ bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd )
        //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;
@@ -381,11 +359,11 @@ bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd )
 
        //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);
@@ -397,28 +375,28 @@ bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd )
        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(TPLNativeWndwnd )
+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;
@@ -426,21 +404,19 @@ bool tpl_buffer_stress_test(TPLNativeWnd* wnd )
 
        //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;
@@ -449,36 +425,35 @@ bool tpl_buffer_stress_test(TPLNativeWnd* wnd )
                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
index 9bbdff6..e7ccd88 100644 (file)
@@ -4,37 +4,35 @@
 #include "tpl_test_util.h"
 
 
-bool tpl_display_get_test (TPLNativeWndwnd)
+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(TPLNativeWndwnd)
+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;
@@ -42,9 +40,9 @@ bool tpl_display_bind_client_display_test(TPLNativeWnd* wnd)
 
        // 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;
@@ -52,41 +50,41 @@ bool tpl_display_bind_client_display_test(TPLNativeWnd* wnd)
 
        // 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 (TPLNativeWndwnd)
+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;
@@ -95,31 +93,29 @@ bool tpl_display_get_arg_test (TPLNativeWnd* wnd)
        //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 (TPLNativeWndwnd)
+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;
@@ -127,70 +123,66 @@ bool tpl_display_query_config_test (TPLNativeWnd* wnd)
        //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 (TPLNativeWndwnd)
+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;
@@ -199,26 +191,23 @@ bool tpl_display_filter_config_test (TPLNativeWnd* wnd)
        //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;
@@ -226,23 +215,22 @@ bool tpl_display_filter_config_test (TPLNativeWnd* wnd)
 
 
 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 (TPLNativeWndwnd)
+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;
@@ -250,8 +238,7 @@ bool tpl_display_abnormal_test (TPLNativeWnd* wnd)
 
        //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;
@@ -259,19 +246,20 @@ bool tpl_display_abnormal_test (TPLNativeWnd* wnd)
 
 
        //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;
 }
 
index e4a1776..1f6eb81 100644 (file)
@@ -4,17 +4,16 @@
 #include "tpl_test_util.h"
 
 
-bool tpl_object_get_type_test(TPLNativeWndwnd )
+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;
@@ -22,9 +21,9 @@ bool tpl_object_get_type_test(TPLNativeWnd* wnd )
 
        //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;
@@ -36,8 +35,7 @@ bool tpl_object_get_type_test(TPLNativeWnd* wnd )
        //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;
@@ -46,8 +44,7 @@ bool tpl_object_get_type_test(TPLNativeWnd* wnd )
        //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;
@@ -56,48 +53,46 @@ bool tpl_object_get_type_test(TPLNativeWnd* wnd )
        //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(TPLNativeWndwnd )
+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
-       voidget_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;
@@ -105,26 +100,25 @@ bool tpl_object_userdata_test(TPLNativeWnd* wnd )
 
 
 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(TPLNativeWndwnd )
+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;
@@ -136,8 +130,7 @@ bool tpl_object_reference_test(TPLNativeWnd* wnd )
        //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;
@@ -146,33 +139,32 @@ bool tpl_object_reference_test(TPLNativeWnd* wnd )
        //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(TPLNativeWndwnd )
+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);
@@ -180,10 +172,10 @@ bool tpl_object_abnormal_test(TPLNativeWnd* wnd )
 
 
 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;
 
 
index ac8a30f..bc6fd48 100644 (file)
 #include "tpl_test_util.h"
 
 
-bool tpl_surface_create_test(TPLNativeWndwnd)
+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(TPLNativeWndwnd)
+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(TPLNativeWndwnd)
+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;
@@ -128,26 +122,25 @@ bool tpl_surface_frame_test(TPLNativeWnd* wnd)
 
 
 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(TPLNativeWndwnd )
+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;
@@ -155,9 +148,9 @@ bool tpl_surface_get_buffer_test(TPLNativeWnd* wnd )
 
        //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;
@@ -169,8 +162,7 @@ bool tpl_surface_get_buffer_test(TPLNativeWnd* wnd )
        //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;
@@ -180,18 +172,17 @@ bool tpl_surface_get_buffer_test(TPLNativeWnd* wnd )
        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;
 
 
@@ -200,17 +191,16 @@ finish:
 
 
 
-bool tpl_surface_post_test(TPLNativeWndwnd )
+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;
@@ -218,9 +208,9 @@ bool tpl_surface_post_test(TPLNativeWnd* wnd )
 
        //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;
@@ -232,8 +222,7 @@ bool tpl_surface_post_test(TPLNativeWnd* wnd )
        //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;
@@ -243,21 +232,21 @@ bool tpl_surface_post_test(TPLNativeWnd* wnd )
        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!");
 
@@ -271,11 +260,10 @@ bool tpl_surface_post_test(TPLNativeWnd* wnd )
        //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
@@ -283,38 +271,36 @@ bool tpl_surface_post_test(TPLNativeWnd* wnd )
 
        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(TPLNativeWndwnd)
+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;
@@ -322,23 +308,26 @@ bool tpl_surface_abnormal_test(TPLNativeWnd* wnd)
 
        //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);
@@ -346,28 +335,27 @@ bool tpl_surface_abnormal_test(TPLNativeWnd* wnd)
        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(TPLNativeWndwnd )
+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;
@@ -375,9 +363,9 @@ bool tpl_surface_stress_test(TPLNativeWnd* wnd )
 
        //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;
@@ -389,28 +377,25 @@ bool tpl_surface_stress_test(TPLNativeWnd* wnd )
        //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;
@@ -419,19 +404,17 @@ bool tpl_surface_stress_test(TPLNativeWnd* wnd )
 
 
 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;
 
index b58f703..298300e 100644 (file)
@@ -28,16 +28,15 @@ extern "C" {
 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;
 
-       voidroot;
-       voidwnd;
+       void *root;
+       void *wnd;
        struct wl_surface *surface;
        struct wl_shell_surface *shell_surface;
        int x;
@@ -45,17 +44,16 @@ struct _TPLNativeWnd
        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;
@@ -80,65 +78,64 @@ 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 }
 
 };
@@ -158,7 +155,7 @@ static TPLTest tpl_test[] =
 #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 ints_time );
+void tpl_test_util_init_fps( long int *s_time );
 float tpl_test_util_get_fps( long int s_time, int frame );
 
 /*-----------------------------------------------------------------
@@ -172,8 +169,7 @@ 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];
@@ -202,11 +198,14 @@ struct _GfxUtilTimer
        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( ... ) { ; }
@@ -230,8 +229,8 @@ void                tpl_test_util_timer_end( GfxUtilTimer* timer, const char* func, int line,
 #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 charmsg );
+bool __LOG_ERR( const char *func, int line, const char *fmt, ... );
+bool __tpl_test_log_display_msg( const char *msg );
 
 
 
@@ -239,9 +238,9 @@ 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 charfunc );
-void __LOG_END( const charfunc );
+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( ... ) { ; }
@@ -293,13 +292,11 @@ void __LOG_END( const char* func );
 
 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,