-#include <PUI.h>
+//#include <PUI.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <PUI_backend.h>
-pui_backend_ani_func *ani_func = NULL;
-
-enum
+typedef enum
{
None,
Linear,
EaseOutQuart
} pui_effect_func;
-typedef struct _default_ani_data default_ani_data;
-struct _default_ani_data
+typedef struct _default_ani_info default_ani_info;
+struct _default_ani_info
{
pui_id id;
pui_ani_status status;
unsigned int num_key_frames;
double interval;
pui_effect_func effect_func;
-
- Eina_Bool (*frame_cb)(void *data);
-
-/*
- void *frame_cb_data;
- double expire;
- Ecore_Timer *frame_cb_timer;
-*/
};
-static void
-_start_frame(pui_ani_mgr *ani_mgr)
-{
- //TODO
-}
+pui_backend_ani_data *g_ani_data = NULL;
-static Eina_Bool
-_frame_cb(void *data)
+static pui_bool
+_frame_cb(void *data, int serial)
{
+ pui_ani_t *ani = (pui_ani_t *)data;
+
//TODO
+ (void) ani;
//_get_next_frame();
//pui_backend_ani_get_buffer();
//pui_backend_ani_update();
+
+ return (pui_bool)1;
}
pui_int_error
-get_ani_data_from_collection(default_ani_data *data, pui_id id)
+get_ani_info_from_ani_collection(default_ani_info *info, pui_id id)
{
pui_int_error e = PUI_INT_ERROR_NONE;
return e;
}
-pui_backend_ani_data *
-_ani_create(pui_ani_mgr *ani_mgr, pui_id id)
-{
- pui_int_error e = PUI_INT_ERROR_NONE;
- default_ani_data *data = (default_ani_data *)calloc(1, sizeof(default_ani_data));
-
- if (!data)
- {
- pui_err("Failed to allocate memory !\n");
- return NULL;
- }
-
- e = get_ani_data_from_collection(data, id);
-
- if (PUI_INT_ERROR_NONE != e)
- {
- pui_err("Failed to get ani data from collection !\n");
- goto err;
- }
-
- return (pui_backend_ani_data *)default_ani_data;
-
-err:
- if (data)
- free(data);
-
- return NULL;
-}
-
pui_error
-_ani_start(pui_ani_mgr *ani_mgr, int repeat)
+_ani_start(pui_ani_t *ani, int repeat)
{
pui_int_error e = PUI_INT_ERROR_NONE;
+ pui_backend_ani_data *ani_data = NULL;
- default_ani_data *data = (default_ani_data *)ani_mgr->ani_data;
+ ani_data = pui_backend_ani_get_ani_data(ani);
+ default_ani_info *info = (default_ani_info *)ani_data->ani_info;
//TODO
- //start_frame(ani_mgr);
- //pui_backend_ani_add_frame_cb(data->frame_cb);
+ (void) info;
+
+ pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STARTED);
+ pui_backend_ani_add_frame_cb(ani, _frame_cb, 0.1);
return e;
}
pui_error
-_ani_stop(pui_ani_mgr *ani_mgr)
+_ani_stop(pui_ani_t *ani)
{
pui_int_error e = PUI_INT_ERROR_NONE;
+ pui_backend_ani_data *ani_data = NULL;
- default_ani_data *data = (default_ani_data *)ani_mgr->ani_data;
+ ani_data = pui_backend_ani_get_ani_data(ani);
+ default_ani_info *info = (default_ani_info *)ani_data->ani_info;
//TODO
- //pui_backend_ani_remove_frame_cb(data->frame_cb);
+ (void) info;
+
+ pui_backend_ani_remove_frame_cb(ani);
+ pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
return e;
}
return e;
}
-pui_backend_ani_func *
-_get_ani_func(pui_id id)
+pui_backend_ani_data *
+_ani_create(pui_id id)
{
- if (ani_func)
- return ani_func;
+ pui_int_error e = PUI_INT_ERROR_NONE;
+
+ pui_backend_ani_data *ani_data = NULL;
+ pui_backend_ani_func *ani_func = NULL;
+
+ /* backend's animation specific info */
+ default_ani_info *ani_info = NULL;
+
+ //TODO : return NULL if the animation correspond to the given id dones't exist.
+ /* allocation of the structure of function pointers that will be called from pui_ani_control() */
ani_func = pui_backend_ani_alloc_ani_func();
if (!ani_func)
{
- pui_err("Failed to allocate memory !\n");
+ pui_err("Failed to allocate memory ! (pui backend ani func)\n");
return NULL;
}
- /* Assign each function pointer that corresponds to the given id */
- ani_func->ani_create = _ani_create;
+ /* Assign each function pointer that corresponds to the given id if needed. */
ani_func->ani_start = _ani_start;
ani_func->ani_stop = _ani_stop;
ani_func->reserved9 = NULL;
ani_func->reserved10 = NULL;
- return ani_func;
+ /* backend's animation specific info */
+ ani_info = (default_ani_info *)calloc(1, sizeof(default_ani_info));
+
+ if (!ani_info)
+ {
+ pui_err("Failed to allocate memory ! (backend's ani specific info)\n");
+ goto err;
+ }
+
+ /* fill animation info associate with the given id from animation collection */
+ e = get_ani_info_from_ani_collection(ani_info, id);
+
+ if (PUI_INT_ERROR_NONE != e)
+ {
+ pui_err("Failed to get ani info from animation collection !\n");
+ goto err;
+ }
+
+ /* allocate backend ani_data and return it to pui ani core */
+ ani_data = (pui_backend_ani_data *)calloc(1, sizeof(pui_backend_ani_data));
+
+ if (!ani_data)
+ {
+ pui_err("Failed to allocate memory for pui backend ani data !\n");
+ goto err;
+ }
+
+ ani_data->ani_func = ani_func;
+ ani_data->ani_info = (pui_backend_ani_info *)ani_info;
+
+ g_ani_data = ani_data;
+
+ return ani_data;
+
+err:
+ if (ani_func)
+ {
+ pui_backend_ani_free_ani_func(ani_func);
+ ani_func = NULL;
+ }
+
+ if (ani_info)
+ {
+ //TODO : free if anything needs to be done with ani_info
+
+ free(ani_info);
+ }
+
+ return NULL;
+}
+
+void
+_ani_destroy(pui_backend_ani_data *ani_data)
+{
+ if (!ani_data)
+ return;
+
+ pui_backend_ani_free_ani_func(ani_data->ani_func);
+
+ //TODO : free if anything needs to be done with ani_info
+ free(ani_data->ani_info);
+
+ ani_data->ani_func = NULL;
+ ani_data->ani_info = NULL;
+
+ g_ani_data = NULL;
}
static pui_backend_module_data *
return NULL;
}
+ backend_data->create_ani_collection = _create_ani_collection;
+ backend_data->ani_create = _ani_create;
+ backend_data->ani_destroy = _ani_destroy;
+
/* Allocate backend specific data if needed. Now it will be empty. */
backend_data->data = NULL;
- backend_data->create_ani_collection = _create_ani_collection;
- backend_data->is_ani_supported = _is_ani_supported;
- backend_data->get_ani_func = _get_ani_func;
-
return backend_data;
-
-err:
- if (backend_data)
- {
- if (backend_data->data)
- {
- free(backend_data->data);
- }
-
- free(backend_data);
- }
-
- return NULL;
}
static void
free(backend_data->data);
}
- if (backend_data->get_ani_func && ani_func)
+ if (g_ani_data)
{
- pui_backend_ani_free_ani_func(ani_func);
- ani_func = NULL;
+ if (g_ani_data->ani_func)
+ {
+ pui_backend_ani_free_ani_func(g_ani_data->ani_func);
+ g_ani_data->ani_func = NULL;
+ }
+
+ if (g_ani_data->ani_info)
+ {
+ //TODO : free if anything needs to be done with ani_info
+ free(g_ani_data->ani_info);
+ g_ani_data->ani_info = NULL;
+ }
}
- backend_data->get_ani_func = NULL;
backend_data->create_ani_collection = NULL;
- backend_data->is_ani_supported = NULL;
+ backend_data->ani_create = NULL;
+ backend_data->ani_destroy = NULL;
free(backend_data);
backend_data = NULL;
}
pui_backend_module pui_backend_module_info = {
- "tizen_ref_speaker",
+ "Tizen Reference Speaker Backend",
"Samsung",
PUI_BACKEND_SET_ABI_VERSION(1, 0),
pui_default_backend_init,