Add enumeration for tpl result type. 64/59664/2
authorjoonbum.ko <joonbum.ko@samsung.com>
Wed, 17 Feb 2016 04:36:49 +0000 (13:36 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 17 Feb 2016 11:58:19 +0000 (20:58 +0900)
 - Enum
  TPL_ERROR_NONE : Successful
  TPL_ERROR_INVALID_PARAMETER : Error, Invalid parameter
  TPL_ERROR_INVALID_OPERATION : Error, Invalid operation

Change-Id: Idc7d9112ccb146b83aa7f96a0a49e3736f0957cf

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_wayland.c

index 2b2feef..59b5ed5 100644 (file)
--- a/src/tpl.c
+++ b/src/tpl.c
@@ -11,17 +11,20 @@ struct _tpl_runtime
 static tpl_runtime_t   *runtime = NULL;
 static pthread_mutex_t runtime_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_runtime_init()
 {
        if (runtime == NULL)
        {
                runtime = (tpl_runtime_t *) calloc(1, sizeof(tpl_runtime_t));
                if (runtime == NULL)
-                       return TPL_FALSE;
+               {
+                       TPL_ERR("Failed to allocate new tpl_runtime_t.");
+                       return TPL_ERROR_INVALID_OPERATION;
+               }
        }
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 static void __attribute__((destructor))
@@ -135,10 +138,10 @@ __tpl_runtime_find_display(tpl_backend_type_t type, tpl_handle_t native_display)
        return display;
 }
 
-tpl_bool_t
+tpl_result_t
 __tpl_runtime_add_display(tpl_display_t *display)
 {
-       tpl_bool_t ret;
+       tpl_result_t ret;
        tpl_handle_t handle;
        tpl_backend_type_t type;
 
@@ -150,28 +153,39 @@ __tpl_runtime_add_display(tpl_display_t *display)
        TPL_ASSERT(0 <= type && TPL_BACKEND_COUNT > type);
 
        if (0 != pthread_mutex_lock(&runtime_mutex))
-               return TPL_FALSE;
+       {
+               TPL_ERR("runtime_mutex pthread_mutex_lock filed.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
-       if (TPL_TRUE != __tpl_runtime_init())
-               return TPL_FALSE;
+       if (TPL_ERROR_NONE != __tpl_runtime_init())
+       {
+               TPL_ERR("__tpl_runtime_init() failed.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        if (NULL == runtime->displays[type])
        {
                runtime->displays[type] = __tpl_hashlist_create();
                if (NULL == runtime->displays[type])
-                       return TPL_FALSE;
+               {
+                       TPL_ERR("__tpl_hashlist_create failed.");
+                       return TPL_ERROR_INVALID_OPERATION;
+               }
        }
 
        ret = __tpl_hashlist_insert(runtime->displays[type], (size_t) handle, (void *) display);
-       if (TPL_TRUE != ret)
+       if (TPL_ERROR_NONE != ret)
        {
+               TPL_ERR("__tpl_hashlist_insert failed. list(%p), handle(%d), display(%p)",
+                               runtime->displays[type], handle, display);
                __tpl_hashlist_destroy(&runtime->displays[type]);
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_OPERATION;
        }
 
        pthread_mutex_unlock(&runtime_mutex);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 void
index 69c0eba..d8bd293 100644 (file)
--- a/src/tpl.h
+++ b/src/tpl.h
@@ -195,6 +195,17 @@ typedef enum
 } tpl_backend_type_t;
 
 /**
+ * Enumeration for TPL result type.
+ *
+ */
+typedef enum
+{
+       TPL_ERROR_NONE = 0, /* Successfull */
+       TPL_ERROR_INVALID_PARAMETER, /* Invalid parmeter */
+       TPL_ERROR_INVALID_OPERATION /* Invalid operation */
+} tpl_result_t;
+
+/**
  * Increase reference count of a TPL object.
  *
  * All TPL objects are reference-counted. They have reference count 1 on
@@ -254,7 +265,7 @@ tpl_object_type_t tpl_object_get_type(tpl_object_t *object);
  *
  * @see tpl_object_get_user_data()
  */
-tpl_bool_t tpl_object_set_user_data(tpl_object_t *object,
+tpl_result_t tpl_object_set_user_data(tpl_object_t *object,
                              void *key,
                              void *data,
                              tpl_free_func_t free_func);
@@ -321,9 +332,9 @@ tpl_handle_t tpl_display_get_native_handle(tpl_display_t *display);
  * @param depth_size Size of a pixel in bits (Color depth).
  * @param native_visual_id Pointer to receive native visual id.
  * @param is_slow Pointer to receive whether the given config is slow.
- * @return TPL_TRUE is the given config is supported, TPL_FALSE otherwise.
+ * @return TPL_ERROR_NONE is the given config is supported, TPL_ERROR otherwise.
  */
-tpl_bool_t tpl_display_query_config(tpl_display_t *display,
+tpl_result_t tpl_display_query_config(tpl_display_t *display,
                                    tpl_surface_type_t surface_type,
                                    int red_size,
                                    int green_size,
@@ -342,9 +353,9 @@ tpl_bool_t tpl_display_query_config(tpl_display_t *display,
  * @param display display to query pixel formats.
  * @param visual_id Pointer to receive native visual id.
  * @param alpha_size Size of the alpha component in bits.
- * @return TPL_TRUE if the given config has been modified, TPL_FALSE otherwise.
+ * @return TPL_ERROR_NONE if the given config has been modified, TPL_ERROR otherwise.
  */
-tpl_bool_t tpl_display_filter_config(tpl_display_t *display,
+tpl_result_t tpl_display_filter_config(tpl_display_t *display,
                                     int *visual_id,
                                     int alpha_size);
 
@@ -405,7 +416,7 @@ tpl_surface_type_t tpl_surface_get_type(tpl_surface_t *surface);
  * @param width pointer to receive width value.
  * @param height pointer to receive height value.
  */
-tpl_bool_t tpl_surface_get_size(tpl_surface_t *surface,
+tpl_result_t tpl_surface_get_size(tpl_surface_t *surface,
                          int *width,
                          int *height);
 
@@ -460,7 +471,7 @@ tbm_surface_h tpl_surface_dequeue_buffer(tpl_surface_t *surface);
  * @param tbm_surface buffer to post.
  *
  */
-tpl_bool_t tpl_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface);
+tpl_result_t tpl_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface);
 
 /**
  * Post a given tbm_surface with region of damage.
@@ -482,7 +493,7 @@ tpl_bool_t tpl_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_
  *
  * @see tpl_surface_enqueue_buffer()
  */
-tpl_bool_t tpl_surface_enqueue_buffer_with_damage(tpl_surface_t *surface,
+tpl_result_t tpl_surface_enqueue_buffer_with_damage(tpl_surface_t *surface,
                                                  tbm_surface_h tbm_surface,
                                                  int num_rects,
                                                  const int *rects);
@@ -499,8 +510,8 @@ tpl_bool_t tpl_surface_enqueue_buffer_with_damage(tpl_surface_t *surface,
  *
  * @see tpl_surface_get_post_interval()
  */
-tpl_bool_t tpl_surface_set_post_interval(tpl_surface_t *surface,
-                                  int interval);
+tpl_result_t tpl_surface_set_post_interval(tpl_surface_t *surface,
+                                          int interval);
 
 /**
  * Get frame interval of the given TPL surface.
@@ -520,9 +531,9 @@ int tpl_surface_get_post_interval(tpl_surface_t *surface);
  * @param width pointer to receive width of the window.
  * @param height pointer to receive height of the window.
  * @param format pointer to receive format of the window.
- * @return TPL_TRUE if the window is valid, TPL_FALSE otherwise.
+ * @return TPL_ERROR_NONE if the window is valid, TPL_ERROR otherwise.
  */
-tpl_bool_t tpl_display_get_native_window_info(tpl_display_t *display,
+tpl_result_t tpl_display_get_native_window_info(tpl_display_t *display,
                                              tpl_handle_t window,
                                              int *width,
                                              int *height,
@@ -538,9 +549,9 @@ tpl_bool_t tpl_display_get_native_window_info(tpl_display_t *display,
  * @param width pointer to receive width of the pixmap.
  * @param height pointer to receive height of the pixmap.
  * @param format pointer to receive format of the pixmap.
- * @return TPL_TRUE if the pixmap is valid, TPL_FALSE otherwise.
+ * @return TPL_ERROR_NONE if the pixmap is valid, TPL_ERROR otherwise.
  */
-tpl_bool_t tpl_display_get_native_pixmap_info(tpl_display_t *display,
+tpl_result_t tpl_display_get_native_pixmap_info(tpl_display_t *display,
                                              tpl_handle_t pixmap,
                                              int *width,
                                              int *height,
@@ -556,7 +567,4 @@ tpl_bool_t tpl_display_get_native_pixmap_info(tpl_display_t *display,
 tbm_surface_h tpl_display_get_buffer_from_native_pixmap(tpl_display_t *display,
                                                        tpl_handle_t pixmap);
 
-
-void tpl_display_wait_native(tpl_display_t *display);
-
 #endif /* TPL_H */
index 311f443..a62174d 100644 (file)
@@ -5,7 +5,7 @@ __tpl_display_fini(tpl_display_t *display)
 {
        TPL_ASSERT(display);
 
-       if (display->backend.fini)
+       if (display->backend.fini != NULL)
                display->backend.fini(display);
 
        __tpl_runtime_remove_display(display);
@@ -24,7 +24,7 @@ tpl_display_t *
 tpl_display_create(tpl_backend_type_t type, tpl_handle_t native_dpy)
 {
        tpl_display_t *display;
-       tpl_bool_t ret;
+       tpl_result_t ret;
 
        /* Search for an already connected display for the given native display. */
        display = __tpl_runtime_find_display(type, native_dpy);
@@ -52,7 +52,7 @@ tpl_display_create(tpl_backend_type_t type, tpl_handle_t native_dpy)
 
        /* Initialize object base class. */
        ret = __tpl_object_init(&display->base, TPL_OBJECT_DISPLAY, __tpl_display_free);
-       if (TPL_TRUE != ret)
+       if (TPL_ERROR_NONE != ret)
        {
                TPL_ERR("Failed to initialize display's base class!");
                free(display);
@@ -65,7 +65,7 @@ tpl_display_create(tpl_backend_type_t type, tpl_handle_t native_dpy)
        /* Initialize backend. */
        __tpl_display_init_backend(display, type);
 
-       if (!display->backend.init(display))
+       if (TPL_ERROR_NONE != display->backend.init(display))
        {
                TPL_ERR("Failed to initialize display's backend!");
                tpl_object_unreference((tpl_object_t *) display);
@@ -74,7 +74,7 @@ tpl_display_create(tpl_backend_type_t type, tpl_handle_t native_dpy)
 
        /* Add it to the runtime. */
        ret = __tpl_runtime_add_display(display);
-       if (TPL_TRUE != ret)
+       if (TPL_ERROR_NONE != ret)
        {
                TPL_ERR("Failed to add display to runtime list!");
                tpl_object_unreference((tpl_object_t *) display);
@@ -107,7 +107,7 @@ tpl_display_get_native_handle(tpl_display_t *display)
        return display->native_handle;
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_display_query_config(tpl_display_t *display,
                         tpl_surface_type_t surface_type,
                         int red_size,
@@ -121,45 +121,45 @@ tpl_display_query_config(tpl_display_t *display,
        if(NULL == display || TPL_TRUE != __tpl_object_is_valid(&display->base) || NULL == display->backend.query_config)
        {
                TPL_ERR("display is invalid!");
-               return TPL_FALSE;
+               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);
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_display_filter_config(tpl_display_t *display, int *visual_id, int alpha_size)
 {
        if(NULL == display || TPL_TRUE != __tpl_object_is_valid(&display->base) || NULL == display->backend.filter_config)
        {
                TPL_ERR("display is invalid!");
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        return display->backend.filter_config(display, visual_id, alpha_size);
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_display_get_native_window_info(tpl_display_t *display, tpl_handle_t window,
                           int *width, int *height, tbm_format *format, int depth, int a_size)
 {
        if (display->backend.get_window_info == NULL)
        {
                TPL_ERR("Backend for display has not been initialized!");
-                return TPL_FALSE;
+                return TPL_ERROR_INVALID_OPERATION;
        }
 
        return display->backend.get_window_info(display, window, width, height, format, depth, a_size);
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_display_get_native_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
                           int *width, int *height, tbm_format *format)
 {
         if (display->backend.get_pixmap_info == NULL)
        {
                TPL_ERR("Backend for display has not been initialized!");
-                return TPL_FALSE;
+                return TPL_ERROR_INVALID_OPERATION;
        }
 
        return display->backend.get_pixmap_info(display, pixmap, width, height, format);
index bad80c3..e2cf093 100644 (file)
@@ -92,7 +92,7 @@ __tpl_gbm_display_is_gbm_device(tpl_handle_t native_dpy)
        return TPL_FALSE;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_gbm_display_init(tpl_display_t *display)
 {
        tpl_gbm_display_t *gbm_display = NULL;
@@ -101,17 +101,17 @@ __tpl_gbm_display_init(tpl_display_t *display)
 
        /* Do not allow default display in gbm. */
        if (display->native_handle == NULL)
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
 
        gbm_display = (tpl_gbm_display_t *) calloc(1, sizeof(tpl_gbm_display_t));
        if (gbm_display == NULL)
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
 
        display->bufmgr_fd = dup(gbm_device_get_fd(display->native_handle));
        gbm_display->bufmgr = tbm_bufmgr_init(display->bufmgr_fd);
        display->backend.data = gbm_display;
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 static void
@@ -131,7 +131,7 @@ __tpl_gbm_display_fini(tpl_display_t *display)
        display->backend.data = NULL;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_gbm_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 color_depth, int *native_visual_id, tpl_bool_t *is_slow)
@@ -153,10 +153,10 @@ __tpl_gbm_display_query_config(tpl_display_t *display, tpl_surface_type_t surfac
                                if (native_visual_id != NULL) *native_visual_id = GBM_FORMAT_ARGB8888;
                        }
                        else
-                               return TPL_FALSE;
+                               return TPL_ERROR_INVALID_PARAMETER;
 
                        if (is_slow != NULL) *is_slow = TPL_FALSE;
-                       return TPL_TRUE;
+                       return TPL_ERROR_NONE;
                }
                if (alpha_size == 0)
                {
@@ -167,17 +167,17 @@ __tpl_gbm_display_query_config(tpl_display_t *display, tpl_surface_type_t surfac
                                if (native_visual_id != NULL) *native_visual_id = GBM_FORMAT_XRGB8888;
                        }
                        else
-                               return TPL_FALSE;
+                               return TPL_ERROR_INVALID_PARAMETER;
 
                        if (is_slow != NULL) *is_slow = TPL_FALSE;
-                       return TPL_TRUE;
+                       return TPL_ERROR_NONE;
                }
        }
 
-       return TPL_FALSE;
+       return TPL_ERROR_INVALID_PARAMETER;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_gbm_display_filter_config(tpl_display_t *display,
                                   int *visual_id, int alpha_size)
 {
@@ -186,13 +186,13 @@ __tpl_gbm_display_filter_config(tpl_display_t *display,
        if (visual_id != NULL && *visual_id == GBM_FORMAT_ARGB8888 && alpha_size == 0)
        {
                *visual_id = GBM_FORMAT_XRGB8888;
-               return TPL_TRUE;
+               return TPL_ERROR_NONE;
        }
 
-       return TPL_FALSE;
+       return TPL_ERROR_INVALID_PARAMETER;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_gbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
                                      int *width, int *height, tbm_format *format, int depth, int a_size)
 {
@@ -201,15 +201,20 @@ __tpl_gbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
 
        struct gbm_surface *gbm_surface = (struct gbm_surface *)window;
        tbm_surface_queue_h surf_queue = (tbm_surface_queue_h)gbm_tbm_get_surface_queue(gbm_surface);
+       if (surf_queue == NULL)
+       {
+               TPL_ERR("Failed to get tbm_surface_queue from gbm_surface.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        if (width != NULL) *width = tbm_surface_queue_get_width(surf_queue);
        if (height != NULL) *height = tbm_surface_queue_get_height(surf_queue);
        if (format != NULL) *format = tbm_surface_queue_get_format(surf_queue);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_gbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
                                      int *width, int *height, tbm_format *format)
 {
@@ -217,13 +222,16 @@ __tpl_gbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
 
        tbm_surface = wayland_tbm_server_get_surface(NULL, (struct wl_resource*)pixmap);
        if (tbm_surface == NULL)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Failed to get tbm_surface_h from native pixmap.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        if (width) *width = tbm_surface_get_width(tbm_surface);
        if (height) *height = tbm_surface_get_height(tbm_surface);
        if (format) *format = tbm_surface_get_format(tbm_surface);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 static tbm_surface_h
@@ -236,22 +244,25 @@ __tpl_gbm_display_get_buffer_from_native_pixmap(tpl_handle_t pixmap)
        tbm_surface = wayland_tbm_server_get_surface(NULL, (struct wl_resource*)pixmap);
        if (tbm_surface == NULL)
        {
-               TPL_ERR("Failed to get tbm surface from wayland_tbm.");
+               TPL_ERR("Failed to get tbm_surface_h from wayland_tbm.");
                return NULL;
        }
 
        return tbm_surface;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_gbm_surface_init(tpl_surface_t *surface)
 {
        tpl_gbm_surface_t *tpl_gbm_surface = NULL;
        TPL_ASSERT(surface);
 
        tpl_gbm_surface = (tpl_gbm_surface_t *) calloc(1, sizeof(tpl_gbm_surface_t));
-       if (NULL == tpl_gbm_surface)
-               return TPL_FALSE;
+       if (tpl_gbm_surface == NULL)
+       {
+               TPL_ERR("Failed to allocate new gbm backend surface.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        surface->backend.data = (void *)tpl_gbm_surface;
        tpl_gbm_surface->tbm_queue = NULL;
@@ -261,27 +272,38 @@ __tpl_gbm_surface_init(tpl_surface_t *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 == NULL)
+               {
+                       TPL_ERR("Failed to get tbm_surface_queue from gbm_surface.");
+                       goto error;
+               }
 
-               if (TPL_TRUE != __tpl_gbm_display_get_window_info(surface->display, surface->native_handle,
+               if (TPL_ERROR_NONE != __tpl_gbm_display_get_window_info(surface->display, surface->native_handle,
                                        &surface->width, &surface->height, NULL, 0, 0))
+               {
+                       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);
-               return TPL_TRUE;
+               return TPL_ERROR_NONE;
        }
        else if (surface->type == TPL_SURFACE_TYPE_PIXMAP)
        {
-               if (TPL_TRUE != __tpl_gbm_display_get_pixmap_info(surface->display, surface->native_handle,
+               if (TPL_ERROR_NONE != __tpl_gbm_display_get_pixmap_info(surface->display, surface->native_handle,
                                        &surface->width, &surface->height, NULL))
+               {
+                       TPL_ERR("Failed to get native pixmap info.");
                        goto error;
+               }
 
-               return TPL_TRUE;
+               return TPL_ERROR_NONE;
        }
 
 error:
        free(tpl_gbm_surface);
 
-       return TPL_FALSE;
+       return TPL_ERROR_INVALID_OPERATION;
 }
 
 static void
@@ -305,7 +327,7 @@ __tpl_gbm_surface_fini(tpl_surface_t *surface)
        surface->backend.data = NULL;
 }
 
-static void
+static tpl_result_t
 __tpl_gbm_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface,
                                 int num_rects, const int *rects)
 {
@@ -319,14 +341,28 @@ __tpl_gbm_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surfa
        TPL_LOG(3, "window(%p, %p)", surface, surface->native_handle);
 
        tpl_gbm_surface_t *gbm_surface = (tpl_gbm_surface_t*)surface->backend.data;
+       if (gbm_surface == NULL)
+       {
+               TPL_ERR("tpl_gbm_surface_t is invalid. tpl_surface_t(%p)", surface);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
 
        tbm_surface_internal_unref(tbm_surface);
 
-       if (gbm_surface->tbm_queue)
+       if (gbm_surface->tbm_queue == NULL)
        {
-               tbm_surface_queue_enqueue(gbm_surface->tbm_queue, tbm_surface);
-               TPL_LOG(6, "tbm_surface ENQUEUED!!");
+               TPL_ERR("tbm_surface_queue is invalid. tpl_gbm_surface_t(%p)", gbm_surface);
+               return TPL_ERROR_INVALID_PARAMETER;
        }
+
+       if (tbm_surface_queue_enqueue(gbm_surface->tbm_queue, tbm_surface) != 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;
+       }
+
+       return TPL_ERROR_NONE;
 }
 
 static tpl_bool_t
index 51b5daf..6df9739 100644 (file)
@@ -31,18 +31,18 @@ struct _tpl_display_backend
        tpl_backend_type_t      type;
        void                    *data;
 
-       tpl_bool_t              (*init)(tpl_display_t *display);
+       tpl_result_t            (*init)(tpl_display_t *display);
        void                    (*fini)(tpl_display_t *display);
 
-       tpl_bool_t              (*query_config)(tpl_display_t *display,
+       tpl_result_t            (*query_config)(tpl_display_t *display,
                                                tpl_surface_type_t surface_type, int red_bits,
                                                int green_bits, int blue_bits, int alpha_bits,
                                                int color_depth, int *native_visual_id, tpl_bool_t *is_slow);
-       tpl_bool_t              (*filter_config)(tpl_display_t *display, int *visual_id, int alpha_bits);
+       tpl_result_t            (*filter_config)(tpl_display_t *display, int *visual_id, int alpha_bits);
 
-       tpl_bool_t              (*get_window_info)(tpl_display_t *display, tpl_handle_t window,
+       tpl_result_t            (*get_window_info)(tpl_display_t *display, tpl_handle_t window,
                                                   int *width, int *height, tbm_format *format, int depth,int a_size);
-       tpl_bool_t              (*get_pixmap_info)(tpl_display_t *display, tpl_handle_t pixmap,
+       tpl_result_t            (*get_pixmap_info)(tpl_display_t *display, tpl_handle_t pixmap,
                                                   int *width, int *height, tbm_format *format);
 
        tbm_surface_h           (*get_buffer_from_native_pixmap)(tpl_handle_t pixmap);
@@ -53,13 +53,13 @@ struct _tpl_surface_backend
        tpl_backend_type_t      type;
        void                    *data;
 
-       tpl_bool_t      (*init)(tpl_surface_t *surface);
+       tpl_result_t    (*init)(tpl_surface_t *surface);
        void            (*fini)(tpl_surface_t *surface);
 
        tpl_bool_t      (*validate)(tpl_surface_t *surface);
 
        tbm_surface_h   (*dequeue_buffer)(tpl_surface_t *surface);
-       void            (*enqueue_buffer)(tpl_surface_t *surface, tbm_surface_h tbm_surface,
+       tpl_result_t    (*enqueue_buffer)(tpl_surface_t *surface, tbm_surface_h tbm_surface,
                                          int num_rects, const int *rects);
 };
 
@@ -107,7 +107,7 @@ struct _tpl_surface
 
 /** brief check wether a TPL object is valid
  * @param object the TPL object to check
- * @return TPL_TRUE on success, TPL_FALSE on error
+ * @return TPL_ERROR_NONE on success, TPL_ERROR on error
  */
 tpl_bool_t __tpl_object_is_valid(tpl_object_t *object);
 
@@ -115,22 +115,22 @@ tpl_bool_t __tpl_object_is_valid(tpl_object_t *object);
  * @param object the TPL object to initialize
  * @param type type of the TPL object
  * @param free_func customized deallocation routine for this TPL object
- * @return TPL_TRUE on success, TPL_FALSE on error
+ * @return TPL_ERROR_NONE on success, TPL_ERROR on error
  */
-tpl_bool_t __tpl_object_init(tpl_object_t *object, tpl_object_type_t type, tpl_free_func_t free_func);
+tpl_result_t __tpl_object_init(tpl_object_t *object, tpl_object_type_t type, tpl_free_func_t free_func);
 
 /** brief destroy a TPL object
  * @param object the TPL object to destroy
- * @return TPL_TRUE on success, TPL_FALSE on error
+ * @return TPL_ERROR_NONE on success, TPL_ERROR on error
  * @warning this function is automatically called when the reference count reaches 0, therefore it should not be expliclity called
  */
-tpl_bool_t __tpl_object_fini(tpl_object_t *object);
+tpl_result_t __tpl_object_fini(tpl_object_t *object);
 
 /** brief lock a TPL object
  * @param object the TPL object to lock
- * @return TPL_TRUE on success, TPL_FALSE on error
+ * @return TPL_ERROR_NONE on success, TPL_ERROR on error
  */
-tpl_bool_t __tpl_object_lock(tpl_object_t *object);
+tpl_result_t __tpl_object_lock(tpl_object_t *object);
 
 /** brief unlock a TPL object
  * @param object the TPL object to unlock
@@ -146,7 +146,7 @@ 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_bool_t                     __tpl_runtime_add_display(tpl_display_t *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();
 
@@ -196,7 +196,7 @@ unsigned int __tpl_util_atomic_dec(tpl_util_atomic_uint * const atom );
 /* Data structure functions */
 tpl_hlist_t * __tpl_hashlist_create();
 void __tpl_hashlist_destroy(tpl_hlist_t **list);
-tpl_bool_t __tpl_hashlist_insert(tpl_hlist_t *list, size_t key, void *data);
+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);
index 43a5443..33f756c 100644 (file)
@@ -10,7 +10,7 @@ __tpl_object_is_valid(tpl_object_t *object)
        return (0 != __tpl_util_atomic_get(&object->reference));
 }
 
-tpl_bool_t
+tpl_result_t
 __tpl_object_init(tpl_object_t *object, tpl_object_type_t type, tpl_free_func_t free_func)
 {
        TPL_ASSERT(object);
@@ -23,33 +23,41 @@ __tpl_object_init(tpl_object_t *object, tpl_object_type_t type, tpl_free_func_t
        __tpl_util_atomic_set(&object->reference, 1);
 
        if (0 != pthread_mutex_init(&object->mutex, NULL))
-               return TPL_FALSE;
+       {
+               TPL_ERR("tpl_object_t pthread_mutex_init failed.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
-tpl_bool_t
+tpl_result_t
 __tpl_object_fini(tpl_object_t *object)
 {
        TPL_ASSERT(object);
 
        if (0 != pthread_mutex_destroy(&object->mutex))
-               return TPL_FALSE;
+       {
+               TPL_ERR("tpl_object_t pthread_mutex_destroy failed.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        tpl_util_map_fini(&object->user_data_map);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
-tpl_bool_t
+tpl_result_t
 __tpl_object_lock(tpl_object_t *object)
 {
        TPL_ASSERT(object);
 
        if (0 != pthread_mutex_lock(&object->mutex))
-               return TPL_FALSE;
-
-       return TPL_TRUE;
+       {
+               TPL_ERR("tpl_object_t pthread_mutex_lock failed.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
+       return TPL_ERROR_NONE;
 }
 
 void
@@ -118,7 +126,7 @@ tpl_object_get_type(tpl_object_t *object)
        return object->type;
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_object_set_user_data(tpl_object_t *object, void *key, void *data, tpl_free_func_t free_func)
 {
        tpl_util_key_t _key;
@@ -126,7 +134,7 @@ tpl_object_set_user_data(tpl_object_t *object, void *key, void *data, tpl_free_f
        if (TPL_TRUE != __tpl_object_is_valid(object))
        {
                TPL_ERR("input object is invalid!");
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        __tpl_object_lock(object);
@@ -134,7 +142,7 @@ tpl_object_set_user_data(tpl_object_t *object, void *key, void *data, tpl_free_f
        tpl_util_map_set(&object->user_data_map, _key, data, free_func);
        __tpl_object_unlock(object);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 void *
index b18de35..a86cc6d 100644 (file)
@@ -12,7 +12,6 @@ static void
 __tpl_surface_free(void *data)
 {
        TPL_ASSERT(data);
-        TPL_LOG(9, "tpl_surface_t(%p)", data);
        __tpl_surface_fini((tpl_surface_t *) data);
        free(data);
 }
@@ -41,7 +40,7 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle, tpl_surface_type
                return NULL;
        }
 
-       if (TPL_TRUE != __tpl_object_init(&surface->base, TPL_OBJECT_SURFACE, __tpl_surface_free))
+       if (TPL_ERROR_NONE != __tpl_object_init(&surface->base, TPL_OBJECT_SURFACE, __tpl_surface_free))
        {
                TPL_ERR("Failed to initialize surface's base class!");
                free(surface);
@@ -60,7 +59,7 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle, tpl_surface_type
        /* Intialize backend. */
        __tpl_surface_init_backend(surface, display->backend.type);
 
-       if (NULL == surface->backend.init || TPL_TRUE != surface->backend.init(surface))
+       if (NULL == surface->backend.init || TPL_ERROR_NONE != surface->backend.init(surface))
        {
                TPL_ERR("Failed to initialize surface's backend!");
                tpl_object_unreference(&surface->base);
@@ -106,13 +105,13 @@ tpl_surface_get_type(tpl_surface_t *surface)
        return surface->type;
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_surface_get_size(tpl_surface_t *surface, int *width, int *height)
 {
        if (NULL == surface)
        {
                TPL_ERR("Surface is NULL!");
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        if (width)
@@ -121,7 +120,7 @@ tpl_surface_get_size(tpl_surface_t *surface, int *width, int *height)
        if (height)
                *height = surface->height;
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 
@@ -154,20 +153,20 @@ tpl_surface_validate(tpl_surface_t *surface)
        return was_valid;
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_surface_set_post_interval(tpl_surface_t *surface, int interval)
 {
        if (NULL == surface || TPL_SURFACE_TYPE_WINDOW != surface->type)
        {
                TPL_ERR("Invalid surface!");
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        TPL_OBJECT_LOCK(surface);
        surface->post_interval = interval;
        TPL_OBJECT_UNLOCK(surface);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 int
@@ -219,13 +218,15 @@ tpl_surface_dequeue_buffer(tpl_surface_t *surface)
        return tbm_surface;
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface)
 {
+       tpl_result_t ret = TPL_ERROR_INVALID_OPERATION;
+
        if (NULL == surface || TPL_SURFACE_TYPE_WINDOW != surface->type)
        {
                TPL_ERR("Invalid surface!");
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        TRACE_BEGIN("TPL:POST");
@@ -236,26 +237,28 @@ tpl_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface)
                TPL_OBJECT_UNLOCK(surface);
                TRACE_END();
                TPL_ERR("tbm surface is invalid.");
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        /* Call backend post */
-       surface->backend.enqueue_buffer(surface, tbm_surface, 0, NULL);
+       ret = surface->backend.enqueue_buffer(surface, tbm_surface, 0, NULL);
 
        TPL_OBJECT_UNLOCK(surface);
        TRACE_END();
 
-       return TPL_TRUE;
+       return ret;
 }
 
-tpl_bool_t
+tpl_result_t
 tpl_surface_enqueue_buffer_with_damage(tpl_surface_t *surface, tbm_surface_h tbm_surface,
                                       int num_rects, const int *rects)
 {
+       tpl_result_t ret = TPL_ERROR_INVALID_OPERATION;
+
        if (NULL == surface || TPL_SURFACE_TYPE_WINDOW != surface->type)
        {
                TPL_ERR("Invalid surface!");
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        TRACE_BEGIN("TPL:POST");
@@ -266,14 +269,14 @@ tpl_surface_enqueue_buffer_with_damage(tpl_surface_t *surface, tbm_surface_h tbm
                TPL_OBJECT_UNLOCK(surface);
                TRACE_END();
                TPL_ERR("tbm surface is invalid.");
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        /* Call backend post */
-       surface->backend.enqueue_buffer(surface, tbm_surface, num_rects, rects);
+       ret = surface->backend.enqueue_buffer(surface, tbm_surface, num_rects, rects);
 
        TPL_OBJECT_UNLOCK(surface);
        TRACE_END();
 
-       return TPL_TRUE;
+       return ret;
 }
index 479201a..6d81c01 100644 (file)
@@ -22,7 +22,7 @@ struct _tpl_tbm_surface
        int dummy;
 };
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_tbm_display_init(tpl_display_t *display)
 {
        tpl_tbm_display_t *tbm_display = NULL;
@@ -36,12 +36,15 @@ __tpl_tbm_display_init(tpl_display_t *display)
 
        tbm_display = (tpl_tbm_display_t *) calloc(1, sizeof(tpl_tbm_display_t));
        if (tbm_display == NULL)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Failed to allocate memory for new tpl_tbm_display_t.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        display->backend.data = tbm_display;
        display->bufmgr_fd = -1;
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 static void
@@ -61,7 +64,7 @@ __tpl_tbm_display_fini(tpl_display_t *display)
        tbm_bufmgr_deinit((tbm_bufmgr)display->native_handle);
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_tbm_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 color_depth, int *native_visual_id, tpl_bool_t *is_slow)
@@ -82,7 +85,7 @@ __tpl_tbm_display_query_config(tpl_display_t *display, tpl_surface_type_t surfac
                        if (is_slow != NULL)
                                *is_slow = TPL_FALSE;
 
-                       return TPL_TRUE;
+                       return TPL_ERROR_NONE;
                }
                if (alpha_size == 0)
                {
@@ -92,14 +95,14 @@ __tpl_tbm_display_query_config(tpl_display_t *display, tpl_surface_type_t surfac
                        if (is_slow != NULL)
                                *is_slow = TPL_FALSE;
 
-                       return TPL_TRUE;
+                       return TPL_ERROR_NONE;
                }
        }
 
-       return TPL_FALSE;
+       return TPL_ERROR_INVALID_PARAMETER;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_tbm_display_filter_config(tpl_display_t *display,
                                   int *visual_id, int alpha_size)
 {
@@ -108,13 +111,13 @@ __tpl_tbm_display_filter_config(tpl_display_t *display,
        if (visual_id != NULL && *visual_id == TBM_FORMAT_ARGB8888 && alpha_size == 0)
        {
                *visual_id = TBM_FORMAT_XRGB8888;
-               return TPL_TRUE;
+               return TPL_ERROR_NONE;
        }
 
-       return TPL_FALSE;
+       return TPL_ERROR_INVALID_PARAMETER;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_tbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
                                          int *width, int *height, tbm_format *format, int depth, int a_size)
 {
@@ -122,6 +125,11 @@ __tpl_tbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
        TPL_ASSERT(window);
 
        tbm_surface_queue_h surf_queue = (tbm_surface_queue_h)window;
+       if (surf_queue == NULL)
+       {
+               TPL_ERR("Native widow(%p) is invalid.", window);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
 
        if (width != NULL)
                *width = tbm_surface_queue_get_width(surf_queue);
@@ -130,10 +138,10 @@ __tpl_tbm_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
        if (format != NULL)
                *format = tbm_surface_queue_get_format(surf_queue);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_tbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
                                          int *width, int *height, tbm_format *format)
 {
@@ -141,7 +149,10 @@ __tpl_tbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
 
        tbm_surface = (tbm_surface_h)pixmap;
        if (tbm_surface == NULL)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Native pixmap(%p) is invalid.", pixmap);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
 
        if (width)
                *width = tbm_surface_get_width(tbm_surface);
@@ -150,7 +161,7 @@ __tpl_tbm_display_get_pixmap_info(tpl_display_t *display, tpl_handle_t pixmap,
        if (format)
                *format = tbm_surface_get_format(tbm_surface);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 static tbm_surface_h
@@ -166,7 +177,7 @@ __tpl_tbm_surface_queue_notify_cb(tbm_surface_queue_h surface_queue, void *data)
        /* Do something */
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_tbm_surface_init(tpl_surface_t *surface)
 {
        tpl_tbm_surface_t *tpl_tbm_surface = NULL;
@@ -174,39 +185,48 @@ __tpl_tbm_surface_init(tpl_surface_t *surface)
 
        tpl_tbm_surface = (tpl_tbm_surface_t *) calloc(1, sizeof(tpl_tbm_surface_t));
        if (NULL == tpl_tbm_surface)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Failed to allocate memory for new tpl_tbm_surface_t");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        surface->backend.data = (void *)tpl_tbm_surface;
 
        if (surface->type == TPL_SURFACE_TYPE_WINDOW)
        {
-               if (TPL_TRUE != __tpl_tbm_display_get_window_info(surface->display, surface->native_handle,
+               if (TPL_ERROR_NONE != __tpl_tbm_display_get_window_info(surface->display, surface->native_handle,
                                        &surface->width, &surface->height, NULL, 0, 0))
+               {
+                       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_LOG(3, "window(%p, %p) %dx%d", surface, surface->native_handle, surface->width, surface->height);
-               return TPL_TRUE;
+               return TPL_ERROR_NONE;
        }
        else if (surface->type == TPL_SURFACE_TYPE_PIXMAP)
        {
                if (TPL_TRUE != __tpl_tbm_display_get_pixmap_info(surface->display, surface->native_handle,
                                        &surface->width, &surface->height, NULL))
+               {
+                       TPL_ERR("Failed to get native pixmap(%p) info.", surface->native_handle);
                        goto error;
+               }
 
                tbm_surface_internal_ref((tbm_surface_h)surface->native_handle);
 
                TPL_LOG(3, "pixmap(%p, %p) %dx%d", surface, surface->native_handle, surface->width, surface->height);
-               return TPL_TRUE;
+               return TPL_ERROR_NONE;
        }
 
 error:
        free(tpl_tbm_surface);
        surface->backend.data = NULL;
 
-       return TPL_FALSE;
+       return TPL_ERROR_INVALID_OPERATION;
 }
 
 static void
@@ -230,7 +250,7 @@ __tpl_tbm_surface_fini(tpl_surface_t *surface)
        surface->backend.data = NULL;
 }
 
-static void
+static tpl_result_t
 __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface,
                                 int num_rects, const int *rects)
 {
@@ -245,19 +265,27 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surfa
 
        if (surface->type == TPL_SURFACE_TYPE_PIXMAP)
        {
-               TPL_WARN("Pixmap cannot post(%p, %p)",surface, surface->native_handle);
-               return;
+               TPL_ERR("Pixmap cannot post(%p, %p)",surface, surface->native_handle);
+               return TPL_ERROR_INVALID_PARAMETER;
        }
 
        TPL_LOG(3, "window(%p, %p)", surface, surface->native_handle);
 
        tbm_surface_queue_h tbm_queue = (tbm_surface_queue_h)surface->native_handle;
+       if (tbm_queue == NULL)
+       {
+               TPL_ERR("tbm_surface_queue is invalid.");
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
 
-       if (tbm_queue)
+       if (tbm_surface_queue_enqueue(tbm_queue, tbm_surface) != TBM_SURFACE_QUEUE_ERROR_NONE)
        {
-               tbm_surface_queue_enqueue(tbm_queue, tbm_surface);
-               TPL_LOG(6, "tbm_surface ENQUEUED!!");
+               TPL_ERR("tbm_surface_queue_enqueue failed. tbm_queue(%p) tbm_surface(%p)",
+                                                       tbm_queue, tbm_surface);
+               return TPL_ERROR_INVALID_OPERATION;
        }
+
+       return TPL_ERROR_NONE;
 }
 
 static tpl_bool_t
index 1bd9328..98aae4d 100644 (file)
@@ -686,12 +686,15 @@ __tpl_list_remove(tpl_list_node_t *node, tpl_free_func_t func)
        free(node);
 }
 
-static TPL_INLINE tpl_bool_t
+static TPL_INLINE tpl_result_t
 __tpl_list_insert(tpl_list_node_t *pos, void *data)
 {
        tpl_list_node_t *node = (tpl_list_node_t *)malloc(sizeof(tpl_list_node_t));
        if (NULL == node)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Failed to allocate new tpl_list_node_t.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        node->data = data;
        node->list = pos->list;
@@ -704,7 +707,7 @@ __tpl_list_insert(tpl_list_node_t *pos, void *data)
 
        pos->list->count++;
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 static TPL_INLINE void
@@ -795,7 +798,7 @@ __tpl_list_push_front(tpl_list_t *list, void *data)
        __tpl_list_insert(&list->head, data);
 }
 
-static TPL_INLINE tpl_bool_t
+static TPL_INLINE tpl_result_t
 __tpl_list_push_back(tpl_list_t *list, void *data)
 {
        TPL_ASSERT(list);
index e44a24e..d16a881 100644 (file)
@@ -118,7 +118,9 @@ tpl_hlist_node_t * __tpl_hlist_get_tail_node(tpl_hlist_t *list, size_t key)
        hash = CALC_HASH(key);
 
        if (__tpl_hlist_empty(&list->heads[hash]))
+       {
                return NULL;
+       }
 
        /* iterate until next node is NULL */
        for (pos = list->heads[hash].first; pos->next; pos = pos->next);
@@ -181,24 +183,30 @@ void __tpl_hashlist_destroy(tpl_hlist_t **list)
        *list = NULL;
 }
 
-tpl_bool_t __tpl_hashlist_insert(tpl_hlist_t *list, size_t key, void *data)
+tpl_result_t __tpl_hashlist_insert(tpl_hlist_t *list, size_t key, void *data)
 {
        size_t hash;
        tpl_hlist_node_t *prev_node;
        tpl_hlist_node_t *new_node;
 
        if (list == NULL)
-               return TPL_FALSE;
+               return TPL_ERROR_INVALID_PARAMETER;
 
        /* check if key already exists in the list */
        prev_node = __tpl_hlist_get_node(list, key);
        if (prev_node != NULL)
-               return TPL_FALSE;
+       {
+               TPL_ERR("key(%d) already exists in tpl_hlist_t(%p).", key, list);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
 
        /* create new node and assign given values */
        new_node = (tpl_hlist_node_t *) malloc(sizeof(tpl_hlist_node_t));
        if (new_node == NULL)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Failed to allocate new tpl_hlist_node_t.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        hash = CALC_HASH(key);
        __tpl_hlist_init_node(new_node);
@@ -208,7 +216,7 @@ tpl_bool_t __tpl_hashlist_insert(tpl_hlist_t *list, size_t key, void *data)
        /* add new node to head */
        __tpl_hlist_add_head(new_node, &list->heads[hash]);
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 void __tpl_hashlist_delete(tpl_hlist_t *list, size_t key)
index 70bc564..c7b7e57 100644 (file)
@@ -135,7 +135,7 @@ __tpl_wayland_display_roundtrip(tpl_display_t *display)
        return ret;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_wayland_display_init(tpl_display_t *display)
 {
        tpl_wayland_display_t *wayland_display = NULL;
@@ -144,11 +144,17 @@ __tpl_wayland_display_init(tpl_display_t *display)
 
        /* Do not allow default display in wayland. */
        if (display->native_handle == NULL)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Invalid native handle for display.");
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
 
        wayland_display = (tpl_wayland_display_t *) calloc(1, sizeof(tpl_wayland_display_t));
        if (wayland_display == NULL)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Failed to allocate memory for new tpl_wayland_display_t.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        display->backend.data = wayland_display;
        display->bufmgr_fd = -1;
@@ -157,7 +163,6 @@ __tpl_wayland_display_init(tpl_display_t *display)
        {
                struct wl_display *wl_dpy = (struct wl_display *)display->native_handle;
                wayland_display->wl_tbm_client = wayland_tbm_client_init((struct wl_display *) wl_dpy);
-
                if (wayland_display->wl_tbm_client == NULL)
                {
                        TPL_ERR("Wayland TBM initialization failed!");
@@ -166,18 +171,25 @@ __tpl_wayland_display_init(tpl_display_t *display)
 
                wayland_display->wl_queue = wl_display_create_queue(wl_dpy);
                if (NULL == wayland_display->wl_queue)
+               {
+                       TPL_ERR("Failed to create wl_queue with wl_dpy(%p).", wl_dpy);
                        goto free_wl_display;
+               }
 
                wayland_display->wl_registry = wl_display_get_registry(wl_dpy);
                if (NULL == wayland_display->wl_registry)
+               {
+                       TPL_ERR("Failed to get wl_registry with wl_dpy(%p).", wl_dpy);
                        goto destroy_queue;
+               }
 
                wl_proxy_set_queue((struct wl_proxy *)wayland_display->wl_registry, wayland_display->wl_queue);
        }
        else
                goto free_wl_display;
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
+
 destroy_queue:
        wl_event_queue_destroy(wayland_display->wl_queue);
 free_wl_display:
@@ -186,7 +198,7 @@ free_wl_display:
                free(wayland_display);
                display->backend.data = NULL;
        }
-       return TPL_FALSE;
+       return TPL_ERROR_INVALID_OPERATION;
 }
 
 static void
@@ -205,7 +217,7 @@ __tpl_wayland_display_fini(tpl_display_t *display)
        display->backend.data = NULL;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_wayland_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 color_depth, int *native_visual_id, tpl_bool_t *is_slow)
@@ -222,29 +234,29 @@ __tpl_wayland_display_query_config(tpl_display_t *display, tpl_surface_type_t su
                {
                        if (native_visual_id != NULL) *native_visual_id = TBM_FORMAT_ARGB8888;
                        if (is_slow != NULL) *is_slow = TPL_FALSE;
-                       return TPL_TRUE;
+                       return TPL_ERROR_NONE;
                }
                if (alpha_size == 0)
                {
                        if (native_visual_id != NULL) *native_visual_id = TBM_FORMAT_XRGB8888;
                        if (is_slow != NULL) *is_slow = TPL_FALSE;
-                       return TPL_TRUE;
+                       return TPL_ERROR_NONE;
                }
        }
 
-       return TPL_FALSE;
+       return TPL_ERROR_INVALID_PARAMETER;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_wayland_display_filter_config(tpl_display_t *display, int *visual_id, int alpha_size)
 {
        TPL_IGNORE(display);
        TPL_IGNORE(visual_id);
        TPL_IGNORE(alpha_size);
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
-static tpl_bool_t
+static tpl_result_t
 __tpl_wayland_display_get_window_info(tpl_display_t *display, tpl_handle_t window,
                int *width, int *height, tbm_format *format, int depth, int a_size)
 {
@@ -272,26 +284,28 @@ __tpl_wayland_display_get_window_info(tpl_display_t *display, tpl_handle_t windo
        if (width != NULL) *width = wl_egl_window->width;
        if (height != NULL) *height = wl_egl_window->height;
 
-       return TPL_TRUE;
+       return TPL_ERROR_NONE;
 }
 
 static void
 __cb_client_window_resize_callback(struct wl_egl_window* wl_egl_window, void* private);
 
-static tpl_bool_t
+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;
 
-
        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));
        if (NULL == wayland_surface)
-               return TPL_FALSE;
+       {
+               TPL_ERR("Failed to allocate memory for new tpl_wayland_surface_t.");
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        surface->backend.data = (void *)wayland_surface;
        wayland_surface->tbm_queue = NULL;
@@ -304,13 +318,12 @@ __tpl_wayland_surface_init(tpl_surface_t *surface)
                        wl_egl_window->height,
                        surface->format,
                        0);
-       TPL_LOG(9, "tbm_surface_queue_create!! || wl_egl_window(%p)| tbm_queue(%p)",
-                       wl_egl_window, wayland_surface->tbm_queue);
 
        if (wayland_surface->tbm_queue == NULL)
        {
                TPL_ERR("TBM surface queue creation failed!");
-               goto error;
+               free(wayland_surface);
+               return TPL_ERROR_INVALID_OPERATION;
        }
 
        surface->width = wl_egl_window->width;
@@ -320,12 +333,8 @@ __tpl_wayland_surface_init(tpl_surface_t *surface)
        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);
-       return TPL_TRUE;
 
-error:
-       free(wayland_surface);
-
-       return TPL_FALSE;
+       return TPL_ERROR_NONE;
 }
 
 static void
@@ -352,8 +361,6 @@ __tpl_wayland_surface_fini(tpl_surface_t *surface)
                TPL_ASSERT(wl_egl_window);
                /* TPL_ASSERT(wl_egl_window->surface); */ /* to be enabled once evas/gl patch is in place */
 
-               TPL_LOG(9, "tpl_surface_t(%p)| wl_egl_window(%p)| wayland_surface(%p)",
-                               surface, wl_egl_window, wayland_surface);
                wl_egl_window->private = NULL;
 
                /* Detach all pending buffers */
@@ -368,9 +375,6 @@ __tpl_wayland_surface_fini(tpl_surface_t *surface)
                wl_display_flush(surface->display->native_handle);
                __tpl_wayland_display_roundtrip(surface->display);
 
-               TPL_LOG(9, "tbm_surface_queue_destroy || wl_egl_window(%p)| tbm_queue(%p)",
-                               wl_egl_window, wayland_surface->tbm_queue);
-
                if (wayland_surface->current_buffer)
                        tbm_surface_internal_unref(wayland_surface->current_buffer);
 
@@ -382,7 +386,7 @@ __tpl_wayland_surface_fini(tpl_surface_t *surface)
        surface->backend.data = NULL;
 }
 
-static void
+static tpl_result_t
 __tpl_wayland_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface,
                                     int num_rects, const int *rects)
 {
@@ -409,19 +413,23 @@ __tpl_wayland_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_s
        wl_egl_window = (struct wl_egl_window *)surface->native_handle;
 
        tbm_surface_internal_unref(tbm_surface);
-       TPL_LOG(9, "tbm_surface(%p) ----------", tbm_surface);
 
        tsq_err = tbm_surface_queue_enqueue(wayland_surface->tbm_queue, tbm_surface);
        if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE)
+       {
                TPL_ERR("Failed to enqeueue tbm_surface. | tsq_err = %d", tsq_err);
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
        /* deprecated */
         tsq_err = tbm_surface_queue_acquire(wayland_surface->tbm_queue, &tbm_surface);
        if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE)
+       {
                TPL_ERR("Failed to acquire tbm_surface. | tsq_err = %d", tsq_err);
+               return TPL_ERROR_INVALID_OPERATION;
+       }
 
         tbm_surface_internal_ref(tbm_surface);
-       TPL_LOG(9, "tbm_surface(%p) ++++++++++",tbm_surface);
        wl_surface_attach(wl_egl_window->surface,
                        (void *)wayland_buffer->wl_proxy,
                        wl_egl_window->dx,
@@ -430,7 +438,6 @@ __tpl_wayland_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_s
        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,
@@ -459,6 +466,8 @@ __tpl_wayland_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_s
        wl_surface_commit(wl_egl_window->surface);
 
        wl_display_flush(surface->display->native_handle);
+
+       return TPL_ERROR_NONE;
 }
 
 static tpl_bool_t
@@ -479,7 +488,6 @@ static tbm_surface_h
 __tpl_wayland_surface_dequeue_buffer(tpl_surface_t *surface)
 {
        TPL_ASSERT(surface);
-       TPL_ASSERT(surface->native_handle);
        TPL_ASSERT(surface->backend.data);
        TPL_ASSERT(surface->display);
 
@@ -487,7 +495,6 @@ __tpl_wayland_surface_dequeue_buffer(tpl_surface_t *surface)
        tpl_wayland_buffer_t    *wayland_buffer = NULL;
        tpl_wayland_surface_t   *wayland_surface = (tpl_wayland_surface_t*)surface->backend.data;
        tpl_wayland_display_t   *wayland_display = (tpl_wayland_display_t*)surface->display->backend.data;
-       struct wl_egl_window    *wl_egl_window = (struct wl_egl_window *)surface->native_handle;
        struct wl_proxy         *wl_proxy = NULL;
        tbm_surface_queue_error_e tsq_err = 0;
 
@@ -514,7 +521,6 @@ __tpl_wayland_surface_dequeue_buffer(tpl_surface_t *surface)
 
        tbm_surface_internal_ref(tbm_surface);
 
-       TPL_LOG(9, "tbm_surface(%p) ++++++++++",tbm_surface);
        if ((wayland_buffer = __tpl_wayland_get_wayland_buffer_from_tbm_surface(tbm_surface)) != NULL)
        {
                return tbm_surface;
@@ -531,8 +537,6 @@ __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);
-       TPL_LOG(9, "wl_proxy(%p)CREATED| wl_egl_window(%p)| tbm_surface(%p)| wayland_surface(%p)",
-                       wl_proxy, wl_egl_window, tbm_surface, wayland_surface);
        if (wl_proxy == NULL)
        {
                TPL_ERR("Failed to create TBM client buffer!");
@@ -568,8 +572,6 @@ __tpl_wayland_buffer_free(tpl_wayland_buffer_t *wayland_buffer)
 
        wl_display_flush((struct wl_display *)wayland_buffer->display->native_handle);
 
-       TPL_LOG(9, "wl_proxy(%p) DESTROYED| wayland_surface(%p)| wayland_buffer(%p)",
-                       wayland_buffer->wl_proxy, wayland_buffer->wayland_surface, wayland_buffer);
        if (wayland_buffer->wl_proxy != NULL)
                wayland_tbm_client_destroy_buffer(wayland_display->wl_tbm_client, (void *)wayland_buffer->wl_proxy);
 
@@ -672,7 +674,6 @@ __cb_client_buffer_release_callback(void *data, struct wl_proxy *proxy)
 
                tbm_surface_internal_unref(tbm_surface);
 
-               TPL_LOG(9, "tbm_surface(%p) ----------",tbm_surface);
                tbm_surface_queue_release(wayland_surface->tbm_queue, tbm_surface);
        }
 }
@@ -702,14 +703,9 @@ __cb_client_window_resize_callback(struct wl_egl_window* wl_egl_window, void* pr
            width != tbm_surface_queue_get_width(wayland_surface->tbm_queue) ||
             height != tbm_surface_queue_get_height(wayland_surface->tbm_queue))
        {
-               TPL_LOG(9, "RESIZE!!|tpl_surface_t(%p)| wl_egl_window(%p)| wayland_surface(%p)",
-                               surface, wl_egl_window, wayland_surface);
                if (wayland_surface->current_buffer != NULL)
                        tbm_surface_internal_unref(wayland_surface->current_buffer);
 
                tbm_surface_queue_reset(wayland_surface->tbm_queue, width, height, format);
        }
-
-       TPL_LOG(9, "tpl_surface_t(%p)| wl_egl_window(%p)| wayland_surface(%p)",
-                       surface, wl_egl_window, wayland_surface);
 }