#include "PUI.h"
#include <Eina.h>
-static int KEY_WL_BUFFER = 0xabcdbeaf;
-static int KEY_CLIENT = 0xdcbabeaf;
-
-static Eina_Bool
-_cb_visibility_change(void *data, int type EINA_UNUSED, void *event)
+pui_int_error
+_pui_ani_error_to_int_error(pui_error e)
{
- pui_ani_h ani_h = (pui_ani_h)data;
- pui_ani_t *ani = ani_h->ani;
- pui_h ph = ani_h->pui_handle;
+ pui_int_error ei;
- Ecore_Wl2_Event_Window_Visibility_Change *ev;
- PUI_Event_Animation_Status *e = NULL;
-
- ev = event;
+ switch (e)
+ {
+ case PUI_ERROR_NONE:
+ ei = PUI_INT_ERROR_NONE;
+ break;
- /* check if this is needed */
- ph->visibility = !(ev->fully_obscured);
+ case PUI_ERROR_INVALID_HANDLE:
+ ei = PUI_INT_ERROR_INVALID_HANDLE;
+ break;
- if (ev->fully_obscured)
- {
- if (ani->status == PUI_ANI_STATUS_RUNNING)
- {
- pui_info("animation(%s) will be stopped as it lost its priority !\n", ani->id);
+ case PUI_ERROR_INVALID_SURFACE:
+ ei = PUI_INT_ERROR_INVALID_SURFACE;
+ break;
- pui_ani_control(ani_h, PUI_ANI_CMD_STOP, 0);
- }
- }
- else
- {
- if (ani->status == PUI_ANI_STATUS_STOPPED || ani->status == PUI_ANI_STATUS_PAUSED)
- {
- e = (PUI_Event_Animation_Status *)calloc(1, sizeof(PUI_Event_Animation_Status));
+ case PUI_ERROR_INVALID_BUFFER:
+ ei = PUI_INT_ERROR_INVALID_BUFFER;
+ break;
- if (!e)
- {
- pui_err("Failed to allocate memory for PUI Event !\n");
- return ECORE_CALLBACK_PASS_ON;
- }
-
- e->ani_h = ani_h;
- e->win = ev->win;
- e->status = ani->status;
-
- if (ani->status == PUI_ANI_STATUS_STOPPED)
- {
- pui_info("[Event added][ani id:%s] PUI_EVENT_ANI_READY_TO_START event has been added.\n", ani_h->id);
- ecore_event_add(PUI_EVENT_ANI_READY_TO_START, e, NULL, ani_h);
- }
- else if(ani->status == PUI_ANI_STATUS_PAUSED)
- {
- pui_info("[Event added][ani id:%s] PUI_EVENT_ANI_READY_TO_RESUME event has been added.\n", ani_h->id);
- ecore_event_add(PUI_EVENT_ANI_READY_TO_RESUME, e, NULL, ani_h);
- }
- }
+ default:
+ ei = PUI_INT_ERROR_UNKNOWN;
+ break;
}
- return ECORE_CALLBACK_PASS_ON;
+ return ei;
}
static void
return;
}
-static void
-_buffer_release(void *data, struct wl_buffer *buffer)
-{
- tbm_surface_h surface = (tbm_surface_h)data;
- pui_h handle;
-
- tbm_surface_internal_get_user_data(surface, (unsigned long)&KEY_CLIENT, (void **)&handle);
- tbm_surface_queue_release(handle->tbm_queue, surface);
-
- pui_info("[UPDATE] release wl_buffer:%p, surface:%p\n", buffer, surface);
-}
-
-static const struct wl_buffer_listener buffer_listener = {
- _buffer_release
-};
-
pui_ani_control_buffer *
-pui_ani_get_buffer(pui_ani_h ani_h)
+pui_ani_get_last_buffer(pui_ani_h ani_h)
{
pui_h handle = NULL;
- tbm_surface_error_e ret;
- tbm_surface_h surface;
pui_ani_control_buffer *buffer = NULL;
- if (!ani_h)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
{
- pui_err("Invalid pui ani handle !\n");
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return NULL;
}
handle = ani_h->pui_handle;
+ buffer = pui_display_get_last_buffer(handle);
- if (!handle)
- {
- pui_err("Error : PUI_INT_ERROR_INVALID_HANDLE\n");
- return NULL;
- }
-
- if (handle->current_surface)
- {
- pui_warn("Current_surface is not used !\n");
- }
-
- if (!tbm_surface_queue_can_dequeue(handle->tbm_queue, 0))
- {
- pui_err("[UPDATE] Cannot dequeue (error : PUI_ERROR_INTERNAL)\n");
- return NULL;
- }
+ return buffer;
+}
- ret = tbm_surface_queue_dequeue(handle->tbm_queue, &surface);
+pui_ani_control_buffer *
+pui_ani_get_buffer(pui_ani_h ani_h)
+{
+ pui_h handle = NULL;
+ pui_ani_control_buffer *buffer = NULL;
- if (ret != TBM_SURFACE_ERROR_NONE)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
{
- pui_err("[UPDATE] dequeue err:%d\n", ret);
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return NULL;
}
- tbm_surface_map(surface, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &handle->current_sinfo);
-
- handle->current_surface = surface;
- buffer = (pui_ani_control_buffer *)&(handle->current_sinfo.planes[0]);
+ handle = ani_h->pui_handle;
+ buffer = pui_display_get_buffer(handle);
return buffer;
}
pui_int_error
pui_ani_set_buffer(pui_ani_h ani_h, pui_ani_control_buffer *buffer)
{
+ pui_error e = PUI_ERROR_NONE;
pui_h handle = NULL;
- if (!ani_h)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
{
- pui_err("Invalid ani handle !\n");
- return PUI_INT_ERROR_INVALID_HANDLE;
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
+ return PUI_ERROR_INVALID_HANDLE;
}
handle = ani_h->pui_handle;
- if (!handle)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
{
- pui_err("Error : PUI_INT_ERROR_INVALID_HANDLE\n");
- return PUI_INT_ERROR_INVALID_HANDLE;
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return PUI_ERROR_INVALID_HANDLE;
}
- if (!handle->current_surface)
- {
- pui_err("Current_surface is not valid !\n");
- return PUI_INT_ERROR_INVALID_SURFACE;
- }
+ e = pui_display_set_buffer(handle, buffer);
- if (!buffer || !buffer->ptr || !buffer->size)
- return PUI_INT_ERROR_INVALID_BUFFER;
-
- handle->is_buffer_set = 1;
-
- return PUI_INT_ERROR_NONE;
+ return _pui_ani_error_to_int_error(e);
}
pui_int_error
pui_ani_update(pui_ani_h ani_h)
{
- tbm_surface_h surface;
- tbm_surface_error_e ret;
- struct wl_buffer *wl_buffer = NULL;
-
+ pui_error e = PUI_ERROR_NONE;
pui_h handle = NULL;
if (!ani_h)
}
handle = ani_h->pui_handle;
+ e = pui_display_update(handle);
- if (!handle)
- {
- pui_err("Error : PUI_INT_ERROR_INVALID_HANDLE\n");
- return PUI_INT_ERROR_INVALID_HANDLE;
- }
-
- if (!handle->current_surface)
- return PUI_INT_ERROR_INVALID_SURFACE;
-
- if (!handle->is_buffer_set)
- {
- pui_err("Buffer is not set !\n");
- return PUI_INT_ERROR_INVALID_BUFFER;
- }
-
- surface = handle->current_surface;
- handle->current_surface = NULL;
-
- tbm_surface_unmap(surface);
-
- ret = tbm_surface_queue_enqueue(handle->tbm_queue, surface);
-
- if (ret != TBM_SURFACE_ERROR_NONE)
- {
- pui_err("[UPDATE] enqueue err:%d\n", ret);
- return PUI_INT_ERROR_INVALID_SURFACE;
- }
-
- ret = tbm_surface_queue_acquire(handle->tbm_queue, &surface);
-
- if (ret != TBM_SURFACE_ERROR_NONE)
- {
- pui_err("[UPDATE] acquire err:%d\n", ret);
- return PUI_INT_ERROR_INVALID_SURFACE;
- }
-
- if (!tbm_surface_internal_get_user_data(surface, (unsigned long)&KEY_WL_BUFFER, (void **)&wl_buffer)) {
- wl_buffer = wayland_tbm_client_create_buffer(handle->wl_tbm_client, surface);
-
- if (!wl_buffer)
- {
- pui_err("[UPDATE] failed to create wl_buffer tbm_surface:%p\n", surface);
- return PUI_INT_ERROR_INVALID_BUFFER;
- }
-
- wl_buffer_add_listener(wl_buffer, &buffer_listener, surface);
-
- tbm_surface_internal_add_user_data(surface, (unsigned long)&KEY_WL_BUFFER, NULL);
- tbm_surface_internal_set_user_data(surface, (unsigned long)&KEY_WL_BUFFER, wl_buffer);
- tbm_surface_internal_add_user_data(surface, (unsigned long)&KEY_CLIENT, NULL);
- tbm_surface_internal_set_user_data(surface, (unsigned long)&KEY_CLIENT, handle);
- }
-
- if (!wl_buffer)
- {
- pui_err("[UPDATE] dequeue err:%d\n", ret);
- return PUI_INT_ERROR_INVALID_BUFFER;
- }
-
- ecore_wl2_window_buffer_attach(handle->win, wl_buffer, 0, 0, 0);
- ecore_wl2_window_damage(handle->win, NULL, 0);
- ecore_wl2_window_commit(handle->win, EINA_TRUE);
-
- pui_info("[UPDATE] commit wl_buffer:%p, surface:%p\n", wl_buffer, surface);
-
- handle->is_buffer_set = 0;
-
- return PUI_INT_ERROR_NONE;
-}
-
-static void
-_pui_ani_event_handlers_init(pui_ani_h ani_h)
-{
- Ecore_Event_Handler *h = NULL;
-
- if (!ani_h)
- {
- pui_err("Invalid handle !\n");
- return;
- }
-
- if (!ani_h->ecore_event_hdls)
- ani_h->ecore_event_hdls = eina_array_new(1);
-
- h = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE, _cb_visibility_change, ani_h);
- eina_array_push(ani_h->ecore_event_hdls, h);
-
-}
-
-static void
-_pui_ani_event_handlers_shutdown(pui_ani_h ani_h)
-{
- if (!ani_h)
- {
- pui_err("Invalid handle !\n");
- return;
- }
-
- if (ani_h->ecore_event_hdls)
- {
- while (eina_array_count(ani_h->ecore_event_hdls))
- ecore_event_handler_del(eina_array_pop(ani_h->ecore_event_hdls));
-
- eina_array_free(ani_h->ecore_event_hdls);
- ani_h->ecore_event_hdls = NULL;
- }
+ return _pui_ani_error_to_int_error(e);
}
static Eina_Bool
_pui_ani_frame_cb(void *data)
{
Eina_Bool ret;
-
pui_ani_t *ani = (pui_ani_t *)data;
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid pui ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return ECORE_CALLBACK_CANCEL;
}
if (ret && PUI_ANI_STATUS_STARTED == ani->status)
pui_ani_status_update(ani, PUI_ANI_STATUS_RUNNING);
- return EINA_TRUE;
+ return ECORE_CALLBACK_RENEW;
}
pui_bool
{
Ecore_Timer *timer = NULL;
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid put ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return 0;
}
void
pui_ani_remove_frame_cb(pui_ani_t *ani)
{
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid put ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return;
}
pui_id
pui_ani_get_id(pui_ani_h ani_h)
{
- if (!ani_h || !ani_h->ani)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return NULL;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani_h->ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani_h->ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return NULL;
+ }
return ani_h->ani->id;
}
pui_ani_cmd
pui_ani_get_cmd(pui_ani_h ani_h)
{
- if (!ani_h || !ani_h->ani)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
+ return PUI_ANI_CMD_NONE;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani_h->ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani_h->ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return PUI_ANI_CMD_NONE;
+ }
return ani_h->ani->cmd;
}
int
pui_ani_get_repeat(pui_ani_h ani_h)
{
- if (!ani_h || !ani_h->ani)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return 0;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani_h->ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani_h->ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return 0;
+ }
return ani_h->ani->repeat;
}
pui_backend_ani_data *
pui_ani_get_ani_data(pui_ani_t *ani)
{
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return NULL;
+ }
return ani->ani_data;
}
pui_ani_h ani_h;
PUI_Event_Animation_Status *e = NULL;
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid pui ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return;
}
ani_h = ani->ani_h;
- e = (PUI_Event_Animation_Status *)calloc(1, sizeof(PUI_Event_Animation_Status));
-
- if (!e)
- {
- pui_err("Failed to allocate memory for PUI Event !\n");
- return;
- }
-
ani->status = status;
- e->ani_h = ani_h;
- e->win = ecore_wl2_window_id_get(ani_h->pui_handle->win);
- e->status = status;
switch (status)
{
if (ev_type > 0)
{
+ e = (PUI_Event_Animation_Status *)calloc(1, sizeof(PUI_Event_Animation_Status));
+
+ if (!e)
+ {
+ pui_err("Failed to allocate memory for PUI Event !\n");
+ return;
+ }
+
+ e->ani_h = ani_h;
+ e->win = ecore_wl2_window_id_get(ani_h->pui_handle->win);
+ e->status = status;
+
ecore_event_add(ev_type, e, NULL, ani_h);
}
}
{
pui_ani_status status = PUI_ANI_STATUS_UNKNOWN;
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid pui ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return status;
}
return ani->status;
}
-pui_error
-pui_ani_control(pui_ani_h ani_h, pui_ani_cmd cmd, int repeat)
+static pui_error
+_pui_ani_control_with_force(pui_ani_h ani_h, pui_ani_cmd cmd, int repeat, pui_bool force)
{
pui_int_error ei = PUI_INT_ERROR_NONE;
pui_ani_t *ani = NULL;
pui_h handle = NULL;
pui_backend_ani_func *ani_func = NULL;
- if (!ani_h)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return PUI_ERROR_INVALID_ANI_HANDLE;
+ }
if (cmd < PUI_ANI_CMD_START || cmd >= PUI_ANI_CMD_LAST)
{
handle = ani_h->pui_handle;
ani = ani_h->ani;
- if (!ani || !ani->ani_data)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
+ {
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return PUI_ERROR_INTERNAL;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return PUI_ERROR_INTERNAL;
+ }
+
+ if (!ani->ani_data)
{
- pui_err("Invalid ani or ani_data !\n");
+ pui_err("Invalid ani_data !\n");
return PUI_ERROR_INTERNAL;
}
if (cmd == PUI_ANI_CMD_START)
{
+ if (handle->manual_render)
+ {
+ pui_err("Manual render has been set ! Unable to start animation.\n");
+ return PUI_ERROR_MANUAL_RENDER_ENABLED;
+ }
+
if (handle->current_ani_h && handle->current_ani_h != ani_h)
{
pui_ani_t *current_ani = handle->current_ani_h->ani;
{
pui_info("current_ani id=%s, status=%d\n", current_ani->id, current_ani->status);
- ei = pui_ani_control(handle->current_ani_h, PUI_ANI_CMD_STOP, 0);
+ ei = _pui_ani_control_with_force(handle->current_ani_h, PUI_ANI_CMD_STOP, 0, force);
if (ei != PUI_INT_ERROR_NONE)
pui_info("Failed to stop running previous animation ! (id:%s)\n", current_ani->id);
pui_err("Error on starting animation ! (id:%s, repeat:%d, status=%d))\n", ani->id, repeat, ani->status);
if (ani->status != PUI_ANI_STATUS_RUNNING)
- pui_ani_control(ani_h, PUI_ANI_CMD_STOP, 0);
+ _pui_ani_control_with_force(ani_h, PUI_ANI_CMD_STOP, 0, 0);
return PUI_ERROR_INTERNAL;
}
}
else//cmd == PUI_ANI_CMD_STOP
{
- ei = ani_func->ani_stop(ani);
+ ei = ani_func->ani_stop(ani, force);
+
+ if (ani->frame_cb_timer)
+ pui_ani_remove_frame_cb(ani);
if (ei != PUI_INT_ERROR_NONE)
{
if (ani->status != PUI_ANI_STATUS_STOPPED)
pui_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
- if (ani->frame_cb_timer)
- pui_ani_remove_frame_cb(ani);
-
return PUI_ERROR_INTERNAL;
}
return PUI_ERROR_INTERNAL;
}
+pui_error
+pui_ani_control(pui_ani_h ani_h, pui_ani_cmd cmd, int repeat)
+{
+ return _pui_ani_control_with_force(ani_h, cmd, repeat, 0);
+}
+
+static Eina_Bool
+_cb_visibility_change(void *data, int type EINA_UNUSED, void *event)
+{
+ pui_ani_h ani_h = (pui_ani_h)data;
+ pui_ani_t *ani = ani_h->ani;
+ pui_h ph = ani_h->pui_handle;
+
+ Ecore_Wl2_Event_Window_Visibility_Change *ev;
+ PUI_Event_Animation_Status *e = NULL;
+
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ if (!PUI_MAGIC_CHECK(ph, PUI_MAGIC_PUI_H))
+ {
+ PUI_MAGIC_FAIL(ph, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ ev = event;
+
+ /* check if this is needed */
+ ph->visibility = !(ev->fully_obscured);
+
+ if (ev->fully_obscured)
+ {
+ if (ani->status == PUI_ANI_STATUS_RUNNING)
+ {
+ pui_info("animation(%s) will be stopped as it lost its priority !\n", ani->id);
+
+ _pui_ani_control_with_force(ani_h, PUI_ANI_CMD_STOP, 0, 1);
+ }
+ }
+ else
+ {
+ if (ani->status == PUI_ANI_STATUS_PAUSED)
+ {
+ e = (PUI_Event_Animation_Status *)calloc(1, sizeof(PUI_Event_Animation_Status));
+
+ if (!e)
+ {
+ pui_err("Failed to allocate memory for PUI Event !\n");
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ e->ani_h = ani_h;
+ e->win = ev->win;
+ e->status = ani->status;
+
+ if(ani->status == PUI_ANI_STATUS_PAUSED)
+ {
+ pui_info("[Event added][ani id:%s] PUI_EVENT_ANI_READY_TO_RESUME event has been added.\n", ani_h->id);
+ ecore_event_add(PUI_EVENT_ANI_READY_TO_RESUME, e, NULL, ani_h);
+ }
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static void
+_pui_ani_event_handlers_init(pui_ani_h ani_h)
+{
+ Ecore_Event_Handler *h = NULL;
+
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
+ return;
+ }
+
+ if (!ani_h->ecore_event_hdls)
+ ani_h->ecore_event_hdls = eina_array_new(1);
+
+ h = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE, _cb_visibility_change, ani_h);
+ eina_array_push(ani_h->ecore_event_hdls, h);
+
+}
+
+static void
+_pui_ani_event_handlers_shutdown(pui_ani_h ani_h)
+{
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
+ return;
+ }
+
+ if (ani_h->ecore_event_hdls)
+ {
+ while (eina_array_count(ani_h->ecore_event_hdls))
+ ecore_event_handler_del(eina_array_pop(ani_h->ecore_event_hdls));
+
+ eina_array_free(ani_h->ecore_event_hdls);
+ ani_h->ecore_event_hdls = NULL;
+ }
+}
+
pui_ani_h
pui_ani_create(pui_h handle, pui_id id)
{
pui_ani_t *ani = NULL;
pui_backend_ani_data *ani_data = NULL;
- if (!handle || !handle->backend_module_data)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
+ {
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return NULL;
+ }
+
+ if (!handle->backend_module_data)
{
- pui_err("Invalid pui handle or backend module data !\n");
+ pui_err("Invalid backend module data !\n");
return NULL;
}
ani_h->pui_handle = handle;
ani_h->ecore_event_hdls = NULL;
+ PUI_MAGIC_SET(ani_h, PUI_MAGIC_ANI_H);
+
_pui_ani_event_handlers_init(ani_h);
ani = (pui_ani_t *)calloc(1, sizeof(pui_ani_t));
handle->ani_handles = eina_list_append(handle->ani_handles, ani_h);
+ PUI_MAGIC_SET(ani, PUI_MAGIC_ANI_T);
+
return ani_h;
err:
}
if (ani_h)
+ {
+ PUI_MAGIC_SET(ani_h, PUI_MAGIC_NONE);
free(ani_h);
+ }
return NULL;
}
pui_ani_t *ani = NULL;
pui_backend_module_data *backend_module_data = NULL;
- if (!ani_h || !ani_h->pui_handle)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return;
+ }
handle = ani_h->pui_handle;
ani = ani_h->ani;
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
+ {
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return;
+ }
+
/* stop the animation being played already if any */
if (ani->status == PUI_ANI_STATUS_STARTED || ani->status == PUI_ANI_STATUS_RUNNING)
pui_ani_control(ani_h, PUI_ANI_CMD_STOP, 0);
ani->frame_cb_timer = NULL;
}
+ PUI_MAGIC_SET(ani_h->ani, PUI_MAGIC_NONE);
free(ani_h->ani);
_pui_ani_event_handlers_shutdown(ani_h);
handle->ani_handles = eina_list_remove(handle->ani_handles, ani_h);
+ PUI_MAGIC_SET(ani_h, PUI_MAGIC_NONE);
+
free(ani_h->id);
free(ani_h);
}