PUI: collect animations when pui is loaded
[platform/core/uifw/libpui.git] / src / PUI.c
index c5e8a94..744c834 100644 (file)
--- a/src/PUI.c
+++ b/src/PUI.c
@@ -1,41 +1,31 @@
-#include "PUI.h"
 #include "PUI_internal.h"
 #include "PUI_backend.h"
+#include "PUI.h"
+
+#include <wayland-tbm-client.h>
+#include <tbm_surface_internal.h>
+#include <stdio.h>
+#include <dlfcn.h>
 
 #ifndef PUI_MODULE_DIR
 #define PUI_MODULE_DIR "/usr/lib"
 #endif
 
-#define pui_err(msg, ...)                                                                              \
-       do {                                                                                                            \
-               fprintf(stderr, "[ERROR][%s] " msg, __FUNCTION__, ##__VA_ARGS__);       \
-       } while(0)
-
-#define pui_warn(msg, ...)                                                                             \
-               do {                                                                                                    \
-                       fprintf(stderr, "[WARNING][%s] " msg, __FUNCTION__, ##__VA_ARGS__);     \
-               } while(0)
-
-#define pui_info(msg, ...)                                                                             \
-       do {                                                                                                            \
-               fprintf(stdout, "[INFO][%s] " msg, __FUNCTION__, ##__VA_ARGS__);        \
-       } while(0)
-
 static int _pui_init_count = 0;
-static pui_module_data *pui_module = NUJLL;
+static pui_module_data *pui_module = NULL;
 
-EAPI int PUI_EVENT_ANI_STARTED = 0;
-EAPI int PUI_EVENT_ANI_STOPPED = 0;
-EAPI int PUI_EVENT_ANI_PAUSED = 0;
-EAPI int PUI_EVENT_ANI_READY_TO_START = 0;
-EAPI int PUI_EVENT_ANI_READY_TO_RESUME = 0;
-EAPI int PUI_EVENT_ANI_FRAME_DONE = 0;
-EAPI int PUI_EVENT_ANI_BUFFER_RELEASED = 0;
+int PUI_EVENT_ANI_STARTED = 0;
+int PUI_EVENT_ANI_STOPPED = 0;
+int PUI_EVENT_ANI_PAUSED = 0;
+int PUI_EVENT_ANI_READY_TO_START = 0;
+int PUI_EVENT_ANI_READY_TO_RESUME = 0;
+int PUI_EVENT_ANI_FRAME_DONE = 0;
+int PUI_EVENT_ANI_BUFFER_RELEASED = 0;
 
-const pui_error_string
+pui_error_string
 pui_error_to_string(pui_error e)
 {
-       const pui_error_string str = NULL;
+       pui_error_string str = NULL;
 
        switch (e)
        {
@@ -51,10 +41,6 @@ pui_error_to_string(pui_error e)
                        str = "PUI_Invalid_Animation_Command";
                        break;
 
-               case PUI_ERROR_INVALID_ANI_OPT:
-                       str = "PUI_Invalid_Animation_Option";
-                       break;
-
                case PUI_ERROR_INTERNAL:
                        str = "PUI_Internal_Error";
                        break;
@@ -66,29 +52,16 @@ pui_error_to_string(pui_error e)
        return str;
 }
 
-static void
-_pui_cb_frame(Ecore_Wl2_Window *win, uint32_t timestamp EINA_UNUSED, void *data)
-{
-       pui_h handle = (pui_h) data;
-
-       TRACE("Frame done ! (window=%p)\n", win);
-
-       // TODO
-
-       return;
-}
-
 pui_h
 pui_create(Ecore_Wl2_Window *win)
 {
        pui_h handle = NULL;
-       Ecore_Wl2_display *ewd = ecore_wl2_window_display_get(win);
+       Ecore_Wl2_Display *ewd = ecore_wl2_window_display_get(win);
        struct wayland_tbm_client *wl_tbm_client = NULL;
-       Ecore_Wl2_Frame_Cb_Handle *frame_cb = NULL;
 
        if (!win || !ewd)
        {
-               pui_err("Invalid window or display !");
+               pui_err("Invalid window or display !\n");
                return NULL;
        }
 
@@ -96,7 +69,7 @@ pui_create(Ecore_Wl2_Window *win)
 
        if (!wl_tbm_client)
        {
-               pui_err("Failed to init wayland_tbm_client !");
+               pui_err("Failed to init wayland_tbm_client !\n");
                return NULL;
        }
 
@@ -133,7 +106,7 @@ err:
 void
 pui_destroy(pui_h handle)
 {
-       pui_ani_h *ani_h = NULL;
+       pui_ani_h ani_h = NULL;
 
        if (!handle)
                return;
@@ -147,7 +120,6 @@ pui_destroy(pui_h handle)
        if (handle->tbm_queue)
        {
                tbm_surface_queue_destroy(handle->tbm_queue);
-               handle->tbm_queue = NULL;
        }
 
        if (handle->wl_tbm_client)
@@ -159,9 +131,9 @@ pui_destroy(pui_h handle)
        free(handle);
 }
 
-#define PREFIX_LIB    "libpui_"
+#define PREFIX_LIB    "libpui-"
 #define SUFFIX_LIB    ".so"
-#define DEFAULT_LIB   PREFIX_LIB"default"SUFFIX_LIB
+#define DEFAULT_LIB   PREFIX_LIB"default-backend"SUFFIX_LIB
 
 static void
 _pui_load_backend_module(void)
@@ -197,11 +169,11 @@ _pui_load_backend_module(void)
        backend_module_minor = PUI_BACKEND_GET_ABI_MINOR(backend_module_info->abi_version);
 
        if (backend_module_major > pui_backend_major) {
-               TBM_ERR("PUI backend module ABI major ver(%d) is newer than the PUI's ver(%d)\n",
+               pui_err("PUI backend module ABI major ver(%d) is newer than the PUI's ver(%d)\n",
                        backend_module_major, pui_backend_major);
                goto err;
        } else if (backend_module_minor > pui_backend_minor) {
-               TBM_ERR("PUI backend module ABI minor ver(%d) is newer than the PUI's ver(%d)\n",
+               pui_err("PUI backend module ABI minor ver(%d) is newer than the PUI's ver(%d)\n",
                        backend_module_minor, pui_backend_minor);
                goto err;
        }
@@ -227,8 +199,8 @@ _pui_load_backend_module(void)
        return;
 
 err:
-       if (backend_module_info)
-               backend_module_info->backend_deinit
+       if (backend_module_info && backend_module_info->backend_init)
+               backend_module_info->backend_deinit(backend_module_data);
 
        if (module_info)
                dlclose(module_info);
@@ -257,9 +229,27 @@ _pui_unload_backend_module(void)
 }
 
 static void
+_pui_load_backend_collect_animations(void)
+{
+       pui_int_error ret;
+
+       if (!pui_module || !pui_module->backend_module_data) {
+               pui_err("pui module data is not loaded\n");
+               return;
+       }
+
+       ret = pui_module->backend_module_data->create_ani_collection();
+       if (ret != PUI_INT_ERROR_NONE) {
+               pui_err("Failed to collect animations data (%s)\n",
+                       pui_error_to_string(ret));
+       }
+}
+
+static void
 _pui_load(void)
 {
        _pui_load_backend_module();
+       _pui_load_backend_collect_animations();
 }
 
 static void