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;
pui_error_string
pui_error_to_string(pui_error e)
handle->visibility = 0;
handle->wl_tbm_client = wl_tbm_client;
handle->ani_handles = NULL;
+ handle->current_ani_h = NULL;
handle->backend_module_data = pui_module->backend_module_data;
handle->tbm_queue = wayland_tbm_client_create_surface_queue(handle->wl_tbm_client,
PUI_EVENT_ANI_PAUSED = ecore_event_type_new();
PUI_EVENT_ANI_READY_TO_START = ecore_event_type_new();
PUI_EVENT_ANI_READY_TO_RESUME = ecore_event_type_new();
- PUI_EVENT_ANI_FRAME_DONE = ecore_event_type_new();
- PUI_EVENT_ANI_BUFFER_RELEASED = ecore_event_type_new();
}
static void
PUI_EVENT_ANI_STOPPED,
PUI_EVENT_ANI_PAUSED,
PUI_EVENT_ANI_READY_TO_START,
- PUI_EVENT_ANI_READY_TO_RESUME,
- PUI_EVENT_ANI_FRAME_DONE,
- PUI_EVENT_ANI_BUFFER_RELEASED);
+ PUI_EVENT_ANI_READY_TO_RESUME);
PUI_EVENT_ANI_STARTED = -1;
PUI_EVENT_ANI_STOPPED = -1;
PUI_EVENT_ANI_PAUSED = -1;
PUI_EVENT_ANI_READY_TO_START = -1;
PUI_EVENT_ANI_READY_TO_RESUME = -1;
- PUI_EVENT_ANI_FRAME_DONE = -1;
- PUI_EVENT_ANI_BUFFER_RELEASED = -1;
}
int
ev = event;
- pui_info("Visibility change (window=0x%x, fully_obscured=%d)\n", ev->win, ev->fully_obscured);
+ pui_info("[pui_ani] Visibility change (window=0x%x, fully_obscured=%d)\n", ev->win, ev->fully_obscured);
/* check if this is needed */
ph->visibility = !(ev->fully_obscured);
if (ev->fully_obscured)
{
+ pui_info("ani->id=%s, ani->status=%d\n", ani->id, ani->status);
+
if (ani->status == PUI_ANI_STATUS_RUNNING)
{
- ani->status = PUI_ANI_STATUS_STOPPED;
-
+ 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));
if (!e)
return ECORE_CALLBACK_PASS_ON;
}
+ e->ani_h = ani_h;
e->win = ev->win;
- e->status = PUI_ANI_STATUS_FORCE_STOPPED;
+ e->status = ani->status;
- ecore_event_add(PUI_EVENT_ANI_STOPPED, e, NULL, ani_h);
- }
- }
- else
- {
- 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;
+ if (ani->status == PUI_ANI_STATUS_STOPPED)
+ {
+ ecore_event_add(PUI_EVENT_ANI_READY_TO_START, e, NULL, ani_h);
+ }
+ else if(ani->status == PUI_ANI_STATUS_PAUSED)
+ {
+ ecore_event_add(PUI_EVENT_ANI_READY_TO_RESUME, e, NULL, ani_h);
+ }
}
-
- e->win = ev->win;
- e->status = ani->status;
-
- if (ani->status == PUI_ANI_STATUS_STOPPED)
- ecore_event_add(PUI_EVENT_ANI_READY_TO_START, e, NULL, ani_h);
- else if(ani->status == PUI_ANI_STATUS_PAUSED)
- ecore_event_add(PUI_EVENT_ANI_READY_TO_RESUME, e, NULL, ani_h);
}
return ECORE_CALLBACK_PASS_ON;
ret = (Eina_Bool)ani->backend_frame_cb(ani, ++ani->serial);
- pui_ani_status_update(ani, PUI_ANI_STATUS_RUNNING);
+ if (!ret)
+ {
+ pui_err("Failed on backend's frame_cb !Frame_cb will be removed forcefuly !\n");
+ pui_ani_remove_frame_cb(ani);
+ }
+
+ pui_info("ret from ani->backend_frame_cb = %d, ani->status=%d\n", ret, ani->status);
+
+ if (ret && PUI_ANI_STATUS_STARTED == ani->status)
+ pui_ani_status_update(ani, PUI_ANI_STATUS_RUNNING);
return ret;
}
return 0;
}
+ pui_info("ani->id=%s, frame_interval=%.2f\n", ani->id, frame_interval);
+
+
+ if (frame_interval <= 0.0f)
+ {
+ pui_err("Invalid frame interval (%.2f) ! frame interval must be larger than 0.\n", frame_interval);
+ return 0;
+ }
+
ani->frame_cb = _pui_ani_frame_cb;
ani->backend_frame_cb = frame_cb;
ani->frame_interval = frame_interval;
if (!ani)
return;
+ pui_info("ani->id=%s\n", ani->id);
+
+
if (ani->frame_cb_timer)
{
ecore_timer_del(ani->frame_cb_timer);
void
pui_ani_status_update(pui_ani_t *ani, pui_ani_status status)
{
- //TODO : add PUI EVENT
+ int ev_type = -1;
+ pui_ani_h ani_h;
+ PUI_Event_Animation_Status *e = NULL;
+
+ if (!ani)
+ {
+ pui_err("Invalid pui ani !\n");
+ return;
+ }
+
+ if (ani->status == status)
+ 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;
+
+ pui_info("ani->id=%s, status=%d\n", ani->id, status);
+
+ switch (status)
+ {
+ case PUI_ANI_STATUS_STARTED:
+ ev_type = PUI_EVENT_ANI_STARTED;
+ break;
+
+ case PUI_ANI_STATUS_RUNNING:
+ break;
+
+ case PUI_ANI_STATUS_PAUSED:
+ ev_type = PUI_EVENT_ANI_PAUSED;
+ break;
+
+ case PUI_ANI_STATUS_STOPPED:
+ ev_type = PUI_EVENT_ANI_STOPPED;
+ break;
+
+ default:
+ pui_err("Unknown status !(ani status=%d, id=%s) !\n", status, ani->id);
+ return;
+ }
+
+ if (ev_type > 0)
+ {
+ ecore_event_add(ev_type, e, NULL, ani_h);
+ }
}
pui_ani_status
pui_error
pui_ani_control(pui_ani_h ani_h, pui_ani_cmd cmd, int repeat)
{
+ 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 (cmd < PUI_ANI_CMD_START || cmd >= PUI_ANI_CMD_LAST)
{
- pui_err("Invalid cmd ! (repeat=%d)\n", repeat);
+ pui_err("Invalid cmd ! (cmd=%d)\n", cmd);
return PUI_ERROR_INVALID_ANI_CMD;
}
return PUI_ERROR_INVALID_ANI_REPEAT;
}
- //TODO : check if there is any animation being played already
- //NOTE : the id of the animation being played can be different from ani_h->id
-
handle = ani_h->pui_handle;
ani = ani_h->ani;
if (cmd == PUI_ANI_CMD_START)
{
- ani_func->ani_start(ani, repeat);
+ if (handle->current_ani_h && handle->current_ani_h != ani_h)
+ {
+ pui_ani_t *current_ani = handle->current_ani_h->ani;
+
+ if (current_ani->status >= PUI_ANI_STATUS_STARTED &&
+ current_ani->status <= PUI_ANI_STATUS_RUNNING)
+ {
+ 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);
+
+ if (ei != PUI_INT_ERROR_NONE)
+ pui_info("Failed to stop running previous animation ! (id:%s)\n", current_ani->id);
+
+ current_ani = NULL;
+ handle->current_ani_h = NULL;
+ }
+ }
+
+ ei = ani_func->ani_start(ani, repeat);
+
+ if (ei != PUI_INT_ERROR_NONE)
+ {
+ 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);
+
+ return PUI_ERROR_INTERNAL;
+ }
+
+ handle->current_ani_h = ani_h;
}
else//cmd == PUI_ANI_CMD_STOP
{
- ani_func->ani_stop(ani);
+ ei = ani_func->ani_stop(ani);
+
+ if (ei != PUI_INT_ERROR_NONE)
+ {
+ pui_err("Failied on stopping animation ! (id:%s)\n", ani->id);
+
+ 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_NONE;
}
goto err;
}
- //TODO
-
return PUI_ERROR_NONE;
err: