2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Window Animation (Weston(Wayland) PlugIn)
37 #include <sys/types.h>
41 #include <weston/compositor.h>
43 #include <ilm/ilm_types.h>
44 #include <weston/weston-layout.h>
45 #include "ico_ivi_common_private.h"
46 #include "ico_window_mgr_private.h"
49 #define ANIMA_ZOOM 1 /* ZoomIn/ZoomOut */
50 #define ANIMA_FADE 2 /* FadeIn/FadeOut */
51 #define ANIMA_SLIDE_TORIGHT 11 /* SlideIn left to right/SlideOut right to left */
52 #define ANIMA_SLIDE_TOLEFT 12 /* SlideIn right to left/SlideOut left to right */
53 #define ANIMA_SLIDE_TOBOTTOM 13 /* SlideIn top to bottom/SlideOut bottom to top */
54 #define ANIMA_SLIDE_TOTOP 14 /* SlideIn bottom to top/SlideOut top to bottom */
55 #define ANIMA_WIPE_TORIGHT 21 /* WipeIn left to right/WipeOut right to left */
56 #define ANIMA_WIPE_TOLEFT 22 /* WipeIn right to left/WipeOut left to right */
57 #define ANIMA_WIPE_TOBOTTOM 23 /* WipeIn top to bottom/WipeOut bottom to top */
58 #define ANIMA_WIPE_TOTOP 24 /* WipeIn bottom to top/WipeOut top to bottom */
59 #define ANIMA_SWING_TORIGHT 31 /* SwingIn left to right/SwingOut right to left */
60 #define ANIMA_SWING_TOLEFT 32 /* SwingIn right to left/SwingOut left to right */
61 #define ANIMA_SWING_TOBOTTOM 33 /* SwingIn top to bottom/SwingOut bottom to top */
62 #define ANIMA_SWING_TOTOP 34 /* SwingIn bottom to top/SwingOut top to bottom */
64 /* Visible control at end of animation */
65 #define ANIMA_NOCONTROL_AT_END 0 /* no need surface show/hide at end of animation*/
66 #define ANIMA_SHOW_AT_END 1 /* surface show at end of animation */
67 #define ANIMA_HIDE_AT_END 2 /* surface hide at end of animation */
70 struct animation_data {
71 struct animation_data *next_free; /* free data list */
72 char transform_set; /* need transform reset at end */
73 char res[3]; /* (unused) */
74 struct weston_transform transform; /* transform matrix */
75 void (*end_function)(struct weston_animation *animation);
76 /* animation end function */
79 /* static valiables */
80 static struct weston_compositor *weston_ec; /* Weston compositor */
81 static char *default_animation; /* default animation name */
82 static int animation_fps; /* animation frame rate(frame/sec) */
83 static int animation_time; /* default animation time(ms) */
84 static int animation_count; /* current number of animations */
85 static struct animation_data *free_data; /* free data list */
87 /* support animation names */
88 static const struct _supprt_animaetions {
91 } supprt_animaetions[] = {
92 { "fade", ANIMA_FADE },
93 { "zoom", ANIMA_ZOOM },
94 { "slide", ANIMA_SLIDE_TOTOP },
95 { "slide.toleft", ANIMA_SLIDE_TOLEFT },
96 { "slide.toright", ANIMA_SLIDE_TORIGHT },
97 { "slide.totop", ANIMA_SLIDE_TOTOP },
98 { "slide.tobottom", ANIMA_SLIDE_TOBOTTOM },
99 { "wipe", ANIMA_WIPE_TOTOP },
100 { "wipe.toleft", ANIMA_WIPE_TOLEFT },
101 { "wipe.toright", ANIMA_WIPE_TORIGHT },
102 { "wipe.totop", ANIMA_WIPE_TOTOP },
103 { "wipe.tobottom", ANIMA_WIPE_TOBOTTOM },
104 { "swing", ANIMA_SWING_TOTOP },
105 { "swing.toleft", ANIMA_SWING_TOLEFT },
106 { "swing.toright", ANIMA_SWING_TORIGHT },
107 { "swing.totop", ANIMA_SWING_TOTOP },
108 { "swing.tobottom", ANIMA_SWING_TOBOTTOM },
112 /* static function */
113 /* slide animation */
114 static void animation_slide(struct weston_animation *animation,
115 struct weston_output *output, uint32_t msecs);
117 static void animation_wipe(struct weston_animation *animation,
118 struct weston_output *output, uint32_t msecs);
119 /* swing animation */
120 static void animation_swing(struct weston_animation *animation,
121 struct weston_output *output, uint32_t msecs);
122 /* swing animation end */
123 static void animation_swing_end(struct weston_animation *animation);
125 static void animation_fade(struct weston_animation *animation,
126 struct weston_output *output, uint32_t msecs);
127 /* fade animation end */
128 static void animation_fade_end(struct weston_animation *animation);
130 static void animation_zoom(struct weston_animation *animation,
131 struct weston_output *output, uint32_t msecs);
132 /* zoom animation end */
133 static void animation_zoom_end(struct weston_animation *animation);
134 /* continue animation */
135 static int animation_cont(struct weston_animation *animation,
136 struct weston_output *output, uint32_t msecs);
137 /* terminate animation */
138 static void animation_end(struct uifw_win_surface *usurf, const int disp);
140 /*--------------------------------------------------------------------------*/
142 * @brief ico_window_animation: Animation addin entry
144 * @param[in] op animation operation
145 * @param[in] data data
147 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMA success
148 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL success(no control)
149 * @retval ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA error(no animation)
151 /*--------------------------------------------------------------------------*/
153 ico_window_animation(const int op, void *data)
155 struct uifw_win_surface *usurf;
156 struct weston_output *output;
162 if (op == ICO_WINDOW_MGR_ANIMATION_NAME) {
163 /* convert animation name to animation type value */
164 for (idx = 0; supprt_animaetions[idx].animaid > 0; idx++) {
165 if (strcasecmp(supprt_animaetions[idx].name, (char *)data) == 0) {
166 uifw_trace("ico_window_animation: Type %s(%d)",
167 (char *)data, supprt_animaetions[idx].animaid);
168 return supprt_animaetions[idx].animaid;
171 uifw_warn("ico_window_animation: Unknown Type %s", (char *)data);
172 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
175 usurf = (struct uifw_win_surface *)data;
177 if (op == ICO_WINDOW_MGR_ANIMATION_DESTROY) {
178 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
179 (usurf->animation.animadata != NULL)) {
180 uifw_trace("ico_window_animation: Destroy %08x", usurf->surfaceid);
181 animation_end(usurf, 0);
183 return ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
186 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
188 if (op == ICO_WINDOW_MGR_ANIMATION_OPCANCEL) {
189 /* cancel animation */
190 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
191 (usurf->animation.animation.frame != NULL)) {
192 uifw_trace("ico_window_animation: cancel %s.%08x",
193 usurf->uclient->appid, usurf->surfaceid);
194 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 0);
196 animation_end(usurf, 1);
197 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
200 /* setup animation */
201 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
202 (usurf->animation.current > 95)) {
203 usurf->animation.animation.frame_counter = 1;
204 usurf->animation.current = 0;
205 usurf->animation.ahalf = 0;
206 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) {
207 wl_list_init(&usurf->animation.animation.link);
208 output = container_of(weston_ec->output_list.next,
209 struct weston_output, link);
210 wl_list_insert(output->animation_list.prev,
211 &usurf->animation.animation.link);
215 else if (((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) &&
216 ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
217 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS))) ||
218 ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) &&
219 ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
220 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)))) {
221 /* change ...In(ex.FadeIn) to ...Out(FadeOut) or ...Out to ...In */
222 nowsec = weston_compositor_get_time();
223 usurf->animation.current = 100 - usurf->animation.current;
224 if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE)||
225 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
226 usurf->animation.time = usurf->animation.hide_time;
229 usurf->animation.time = usurf->animation.show_time;
231 if (usurf->animation.time == 0) {
232 usurf->animation.time = animation_time;
234 ret = ((usurf->animation.current) * usurf->animation.time) / 100;
235 if (nowsec >= (uint32_t)ret) {
236 usurf->animation.starttime = nowsec - ret;
239 usurf->animation.starttime = ((long long)nowsec) + ((long long)0x100000000L)
242 usurf->animation.animation.frame_counter = 2;
245 /* set animation function */
246 if ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
247 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
248 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_SHOW;
249 animaid = usurf->animation.show_anima;
250 usurf->animation.anima = animaid;
251 uifw_trace("ico_window_animation: show(in) %s.%08x anima=%d",
252 usurf->uclient->appid, usurf->surfaceid, animaid);
253 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
255 else if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
256 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
257 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_HIDE;
258 animaid = usurf->animation.hide_anima;
259 usurf->animation.anima = animaid;
260 uifw_trace("ico_window_animation: hide(out) %s.%08x anima=%d",
261 usurf->uclient->appid, usurf->surfaceid, animaid);
262 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
263 usurf->animation.visible = ANIMA_HIDE_AT_END;
265 else if (op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
266 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_MOVE;
267 animaid = usurf->animation.move_anima;
268 usurf->animation.anima = animaid;
269 uifw_trace("ico_window_animation: move %s.%08x anima=%d",
270 usurf->uclient->appid, usurf->surfaceid, animaid);
271 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
273 else if (op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
274 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE;
275 animaid = usurf->animation.resize_anima;
276 usurf->animation.anima = animaid;
277 uifw_trace("ico_window_animation: resize %s.%08x anima=%d",
278 usurf->uclient->appid, usurf->surfaceid, animaid);
279 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
282 uifw_trace("ico_window_animation: Op=%d unknown", op);
283 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
285 if ((animaid == ANIMA_SLIDE_TOLEFT) || (animaid == ANIMA_SLIDE_TORIGHT) ||
286 (animaid == ANIMA_SLIDE_TOTOP) || (animaid == ANIMA_SLIDE_TOBOTTOM)) {
287 usurf->animation.animation.frame = animation_slide;
288 usurf->restrain_configure = 1;
289 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
291 else if ((animaid == ANIMA_WIPE_TOLEFT) || (animaid == ANIMA_WIPE_TORIGHT) ||
292 (animaid == ANIMA_WIPE_TOTOP) || (animaid == ANIMA_WIPE_TOBOTTOM)) {
293 usurf->animation.animation.frame = animation_wipe;
294 usurf->restrain_configure = 1;
295 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
297 else if ((animaid == ANIMA_SWING_TOLEFT) || (animaid == ANIMA_SWING_TORIGHT) ||
298 (animaid == ANIMA_SWING_TOTOP) || (animaid == ANIMA_SWING_TOBOTTOM)) {
299 usurf->animation.animation.frame = animation_swing;
300 usurf->restrain_configure = 1;
301 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
303 else if (animaid == ANIMA_FADE) {
304 usurf->animation.animation.frame = animation_fade;
305 usurf->restrain_configure = 1;
306 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
308 else if (animaid == ANIMA_ZOOM) {
309 usurf->animation.animation.frame = animation_zoom;
310 usurf->restrain_configure = 1;
311 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
315 usurf->animation.animation.frame = NULL;
316 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
317 usurf->restrain_configure = 0;
318 usurf->animation.anima = 0;
319 wl_list_remove(&usurf->animation.animation.link);
320 ret = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
322 usurf->animation.type = op;
323 #if PERFORMANCE_EVALUATIONS > 0
324 if (ret != ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) {
325 uifw_perf("SWAP_BUFFER Start Animation appid=%s surface=%08x anima=%d",
326 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
328 #endif /*PERFORMANCE_EVALUATIONS*/
330 weston_compositor_schedule_repaint(weston_ec);
334 /*--------------------------------------------------------------------------*/
336 * @brief animation_cont: continue animation
338 * @param[in] animation weston animation table
339 * @param[in] output weston output table
340 * @param[in] msecs current time stamp
341 * @return time has come
342 * @retval =0 time has come
343 * @retval >0 time has not yet come(return value is current parcent)
345 /*--------------------------------------------------------------------------*/
347 animation_cont(struct weston_animation *animation, struct weston_output *output,
350 struct uifw_win_surface *usurf;
354 nowsec = weston_compositor_get_time();
356 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
358 if (animation->frame_counter <= 1) {
359 /* first call, initialize */
360 animation->frame_counter = 1;
361 usurf->animation.starttime = nowsec;
362 usurf->animation.current = 1000;
363 if (! usurf->animation.animadata) {
365 usurf->animation.animadata = (void *)free_data;
366 free_data = free_data->next_free;
369 usurf->animation.animadata = (void *)malloc(sizeof(struct animation_data));
371 memset(usurf->animation.animadata, 0, sizeof(struct animation_data));
374 else if (! usurf->animation.animadata) {
375 animation_end(usurf, 0);
379 if (nowsec >= usurf->animation.starttime) {
380 nowsec = nowsec - usurf->animation.starttime; /* elapsed time(ms) */
383 nowsec = (uint32_t)(((long long)0x100000000L) +
384 ((long long)nowsec) - ((long long)usurf->animation.starttime));
386 switch (usurf->animation.state) {
387 case ICO_WINDOW_MGR_ANIMATION_STATE_SHOW:
388 usurf->animation.time = usurf->animation.show_time;
390 case ICO_WINDOW_MGR_ANIMATION_STATE_HIDE:
391 usurf->animation.time = usurf->animation.hide_time;
393 case ICO_WINDOW_MGR_ANIMATION_STATE_MOVE:
394 usurf->animation.time = usurf->animation.move_time;
397 usurf->animation.time = usurf->animation.resize_time;
400 if (usurf->animation.time == 0) {
401 usurf->animation.time = animation_time;
403 if (((output == NULL) && (msecs == 0)) || (nowsec >= ((uint32_t)usurf->animation.time))) {
407 par = (nowsec * 100 + usurf->animation.time / 2) / usurf->animation.time;
408 if (par < 2) par = 2;
411 (abs(usurf->animation.current - par) >=
412 (((1000 * 100) / animation_fps) / usurf->animation.time)) ||
413 ((animation_count > 1) && (par != usurf->animation.current))) {
414 usurf->animation.current = par;
420 /*--------------------------------------------------------------------------*/
422 * @brief animation_end: terminate animation
424 * @param[in] usurf UIFW surface table
425 * @param[in] disp display control(1)/no display(0)
428 /*--------------------------------------------------------------------------*/
430 animation_end(struct uifw_win_surface *usurf, const int disp)
432 struct animation_data *animadata;
433 struct weston_view *ev;
435 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
436 animadata = (struct animation_data *)usurf->animation.animadata;
438 if (animation_count > 0) {
441 ev = ico_ivi_get_primary_view(usurf);
444 if (animadata->end_function) {
445 (*animadata->end_function)(&usurf->animation.animation);
447 wl_list_remove(&usurf->animation.animation.link);
448 if (animadata->transform_set) {
449 wl_list_remove(&animadata->transform.link);
450 animadata->transform_set = 0;
452 weston_view_geometry_dirty(ev);
455 usurf->restrain_configure = 0;
456 if ((usurf->animation.visible == ANIMA_HIDE_AT_END) &&
457 (usurf->visible != 0)) {
459 weston_layout_surfaceSetVisibility(usurf->ivisurf, 0);
460 weston_layout_commitChanges();
461 weston_surface_damage(usurf->surface);
462 weston_view_geometry_dirty(ev);
464 if ((usurf->animation.visible == ANIMA_SHOW_AT_END) &&
465 (usurf->visible == 0)) {
467 weston_layout_surfaceSetVisibility(usurf->ivisurf, 1);
468 weston_layout_commitChanges();
469 weston_surface_damage(usurf->surface);
470 weston_view_geometry_dirty(ev);
473 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
474 if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE) {
475 switch(usurf->animation.type) {
476 case ICO_WINDOW_MGR_ANIMATION_OPHIDE:
477 case ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS:
478 usurf->animation.hide_anima = usurf->animation.next_anima;
480 case ICO_WINDOW_MGR_ANIMATION_OPSHOW:
481 case ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS:
482 usurf->animation.show_anima = usurf->animation.next_anima;
484 case ICO_WINDOW_MGR_ANIMATION_OPMOVE:
485 usurf->animation.move_anima = usurf->animation.next_anima;
487 case ICO_WINDOW_MGR_ANIMATION_OPRESIZE:
488 usurf->animation.resize_anima = usurf->animation.next_anima;
493 usurf->animation.next_anima = ICO_WINDOW_MGR_ANIMATION_NONE;
496 usurf->animation.animadata = NULL;
497 animadata->next_free = free_data;
498 free_data = animadata;
500 usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE;
501 #if PERFORMANCE_EVALUATIONS > 0
502 uifw_perf("SWAP_BUFFER End Animation appid=%s surface=%08x anima=%d",
503 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
504 #endif /*PERFORMANCE_EVALUATIONS*/
507 /*--------------------------------------------------------------------------*/
509 * @brief animation_slide: slide animation
511 * @param[in] animation weston animation table
512 * @param[in] outout weston output table
513 * @param[in] mseces current time(unused)
516 /*--------------------------------------------------------------------------*/
518 animation_slide(struct weston_animation *animation,
519 struct weston_output *output, uint32_t msecs)
521 struct uifw_win_surface *usurf;
522 struct weston_surface *es;
523 struct weston_view *ev;
529 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
531 par = animation_cont(animation, output, msecs);
533 /* continue animation */
535 weston_compositor_schedule_repaint(weston_ec);
539 ev = ico_ivi_get_primary_view(usurf);
540 par = usurf->animation.current;
542 uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d",
543 usurf->surfaceid, animation->frame_counter, par,
544 usurf->animation.anima, usurf->animation.state);
550 switch (usurf->animation.anima) {
551 case ANIMA_SLIDE_TORIGHT: /* slide in left to right */
552 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
553 /* slide in left to right */
554 x = 0 - usurf->animation.pos_width +
555 ((usurf->animation.pos_x + usurf->animation.pos_width) * par / 100);
558 /* slide out right to left */
559 x = 0 - usurf->animation.pos_width +
560 ((usurf->animation.pos_x + usurf->animation.pos_width) * (100 - par) / 100);
563 case ANIMA_SLIDE_TOLEFT: /* slide in right to left */
564 dwidth = usurf->node_tbl->disp_width;
565 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
566 /* slide in right to left */
567 x = usurf->animation.pos_x +
568 (dwidth - usurf->animation.pos_x) * (100 - par) / 100;
571 /* slide out left to right */
572 x = usurf->animation.pos_x + (dwidth - usurf->animation.pos_x) * par / 100;
575 case ANIMA_SLIDE_TOBOTTOM: /* slide in top to bottom */
576 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
577 /* slide in top to bottom */
578 y = 0 - usurf->animation.pos_height +
579 ((usurf->animation.pos_y + usurf->animation.pos_height) * par / 100);
582 /* slide out bottom to top */
583 y = 0 - usurf->animation.pos_height +
584 ((usurf->animation.pos_y + usurf->animation.pos_height) * (100 - par) / 100);
587 default: /*ANIMA_SLIDE_TOTOP*/ /* slide in bottom to top */
588 dheight = usurf->node_tbl->disp_height;
589 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
590 /* slide in bottom to top */
591 y = usurf->animation.pos_y +
592 (dheight - usurf->animation.pos_y) * (100 - par) / 100;
595 /* slide out top to bottom */
596 y = usurf->animation.pos_y + (dheight - usurf->animation.pos_y) * par / 100;
601 uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d)",
602 usurf->surfaceid, par, x, y, usurf->x, usurf->y);
603 ev->geometry.x = usurf->node_tbl->disp_x + x;
604 ev->geometry.y = usurf->node_tbl->disp_y + y;
605 if ((ev->output) && (es->buffer_ref.buffer) &&
606 (es->width > 0) && (es->height > 0)) {
607 weston_view_geometry_dirty(ev);
608 weston_surface_damage(es);
611 /* end of animation */
612 animation_end(usurf, 1);
613 uifw_trace("animation_slide: End of animation");
616 /* continue animation */
617 weston_compositor_schedule_repaint(weston_ec);
621 /*--------------------------------------------------------------------------*/
623 * @brief animation_wipe: wipe animation
625 * @param[in] animation weston animation table
626 * @param[in] outout weston output table
627 * @param[in] mseces current time(unused)
630 /*--------------------------------------------------------------------------*/
632 animation_wipe(struct weston_animation *animation,
633 struct weston_output *output, uint32_t msecs)
635 struct uifw_win_surface *usurf;
636 struct weston_surface *es;
637 struct weston_view *ev;
644 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
646 par = animation_cont(animation, output, msecs);
648 /* continue animation */
650 weston_compositor_schedule_repaint(weston_ec);
654 ev = ico_ivi_get_primary_view(usurf);
655 par = usurf->animation.current;
657 uifw_debug("animation_wipe: %08x count=%d %d%% anima=%d state=%d",
658 usurf->surfaceid, animation->frame_counter, par,
659 usurf->animation.anima, usurf->animation.state);
664 width = usurf->width;
665 height = usurf->width;
668 switch (usurf->animation.anima) {
669 case ANIMA_WIPE_TORIGHT: /* wipe in left to right */
670 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
671 /* wipe in left to right */
672 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
675 /* wipe out right to left */
676 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
678 if (width <= 0) width = 1;
680 case ANIMA_WIPE_TOLEFT: /* wipe in right to left */
681 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
682 /* wipe in right to left */
683 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
686 /* wipe out left to right */
687 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
689 if (width <= 0) width = 1;
690 x = x + (usurf->width - width);
692 case ANIMA_WIPE_TOBOTTOM: /* wipe in top to bottom */
693 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
694 /* wipe in top to bottom */
695 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
698 /* wipe out bottom to top */
699 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
701 if (height <= 0) height = 1;
703 default: /*ANIMA_WIPE_TOTOP*/ /* wipe in bottom to top */
704 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
705 /* wipe in bottom to top */
706 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
709 /* wipe out top to bottom */
710 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
712 if (height <= 0) height = 1;
713 y = y + (usurf->height - height);
718 ev->geometry.x = usurf->node_tbl->disp_x + x;
719 ev->geometry.y = usurf->node_tbl->disp_y + y;
722 if ((ev->output) && (es->buffer_ref.buffer)) {
723 weston_view_geometry_dirty(ev);
724 weston_surface_damage(es);
727 /* end of animation */
728 animation_end(usurf, 1);
729 uifw_trace("animation_wipe: End of animation");
732 /* continue animation */
733 weston_compositor_schedule_repaint(weston_ec);
737 /*--------------------------------------------------------------------------*/
739 * @brief animation_swing: swing animation
741 * @param[in] animation weston animation table
742 * @param[in] outout weston output table
743 * @param[in] mseces current time(unused)
746 /*--------------------------------------------------------------------------*/
748 animation_swing(struct weston_animation *animation,
749 struct weston_output *output, uint32_t msecs)
751 struct uifw_win_surface *usurf;
752 struct weston_surface *es;
753 struct weston_view *ev;
754 struct animation_data *animadata;
761 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
763 par = animation_cont(animation, output, msecs);
765 /* continue animation */
767 weston_compositor_schedule_repaint(weston_ec);
772 uifw_debug("animation_swing: %08x count=%d %d%% anima=%d state=%d",
773 usurf->surfaceid, animation->frame_counter, par,
774 usurf->animation.anima, usurf->animation.state);
776 animadata = (struct animation_data *)usurf->animation.animadata;
778 ev = ico_ivi_get_primary_view(usurf);
779 par = usurf->animation.current;
780 if (animation->frame_counter == 1) {
781 if (animadata->transform_set == 0) {
782 animadata->transform_set = 1;
783 weston_matrix_init(&animadata->transform.matrix);
784 wl_list_init(&animadata->transform.link);
785 wl_list_insert(&ev->geometry.transformation_list,
786 &animadata->transform.link);
788 animadata->end_function = animation_swing_end;
797 switch (usurf->animation.anima) {
798 case ANIMA_SWING_TORIGHT: /* swing in left to right */
799 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
800 /* swing in left to right */
801 scalex = ((float)par + 5.0f) / 105.0f;
804 /* swing out right to left */
805 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
807 if (scalex <= 0.0) scalex = 0.01;
809 case ANIMA_SWING_TOLEFT: /* seing in right to left */
810 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
811 /* swing in right to left */
812 scalex = ((float)par + 5.0f) / 105.0f;
815 /* swing out left to right */
816 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
818 if (scalex <= 0.0) scalex = 0.01;
819 x = x + (int)((float)usurf->width * (1.0f - scalex));
821 case ANIMA_SWING_TOBOTTOM: /* swing in top to bottom */
822 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
823 /* swing in top to bottom */
824 scaley = ((float)par + 5.0f) / 105.0f;
827 /* swing out bottom to top */
828 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
830 if (scaley <= 0.0) scaley = 0.01;
832 default: /*ANIMA_SWING*/ /* swing in bottom to top */
833 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
834 /* wipe in bottom to top */
835 scaley = ((float)par + 5.0f) / 105.0f;
838 /* wipe out top to bottom */
839 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
841 if (scaley <= 0.0) scaley = 0.01;
842 y = y + (int)((float)usurf->height * (1.0f - scaley));
847 ev->geometry.x = usurf->node_tbl->disp_x + x;
848 ev->geometry.y = usurf->node_tbl->disp_y + y;
849 weston_matrix_init(&animadata->transform.matrix);
850 weston_matrix_translate(&animadata->transform.matrix,
851 -0.5f * usurf->width, -0.5f * usurf->height, 0);
852 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
853 weston_matrix_translate(&animadata->transform.matrix,
854 0.5f * usurf->width, 0.5f * usurf->height, 0);
856 if ((ev->output) && (es->buffer_ref.buffer)) {
857 weston_view_geometry_dirty(ev);
858 weston_surface_damage(es);
861 /* end of animation */
862 animation_end(usurf, 1);
863 uifw_trace("animation_swing: End of animation");
866 /* continue animation */
867 weston_compositor_schedule_repaint(weston_ec);
871 /*--------------------------------------------------------------------------*/
873 * @brief animation_swing_end: swing animation end
875 * @param[in] animation weston animation table
878 /*--------------------------------------------------------------------------*/
880 animation_swing_end(struct weston_animation *animation)
882 struct uifw_win_surface *usurf;
883 struct weston_surface *es;
884 struct weston_view *ev;
886 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
887 if (usurf && usurf->surface) {
889 ev = ico_ivi_get_primary_view(usurf);
892 if ((ev->output) && (es->buffer_ref.buffer)) {
893 weston_surface_damage(es);
898 /*--------------------------------------------------------------------------*/
900 * @brief animation_fade: fade animation
902 * @param[in] animation weston animation table
903 * @param[in] outout weston output table
904 * @param[in] mseces current time(unused)
907 /*--------------------------------------------------------------------------*/
909 animation_fade(struct weston_animation *animation,
910 struct weston_output *output, uint32_t msecs)
912 struct uifw_win_surface *usurf;
913 struct animation_data *animadata;
914 struct weston_surface *es;
915 struct weston_view *ev;
918 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
920 par = animation_cont(animation, output, msecs);
922 /* continue animation */
924 weston_compositor_schedule_repaint(weston_ec);
929 animadata = (struct animation_data *)usurf->animation.animadata;
931 ev = ico_ivi_get_primary_view(usurf);
932 par = usurf->animation.current;
933 if (animation->frame_counter == 1) {
934 if (animadata->transform_set == 0) {
935 animadata->transform_set = 1;
936 weston_matrix_init(&animadata->transform.matrix);
937 wl_list_init(&animadata->transform.link);
938 wl_list_insert(&ev->geometry.transformation_list,
939 &animadata->transform.link);
941 animadata->end_function = animation_fade_end;
943 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
944 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
945 ico_window_mgr_set_weston_surface(usurf,
946 usurf->animation.pos_x, usurf->animation.pos_y,
947 usurf->animation.pos_width,
948 usurf->animation.pos_height);
952 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
954 ev->alpha = ((float)par) / 100.0f;
956 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
958 ev->alpha = 1.0f - (((float)par) / 100.0f);
961 /* fade move/resize */
962 if ((par >= 50) || (usurf->animation.ahalf)) {
963 ev->alpha = ((float)(par*2 - 100)) / 100.0f;
964 if (usurf->animation.ahalf == 0) {
965 uifw_trace("animation_fade: fade move chaneg to show");
966 usurf->animation.ahalf = 1;
968 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
969 usurf->width, usurf->height);
973 ev->alpha = 1.0f - (((float)(par*2)) / 100.0f);
976 if (ev->alpha < 0.0) ev->alpha = 0.0;
977 else if (ev->alpha > 1.0) ev->alpha = 1.0;
979 uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
980 usurf->surfaceid, animation->frame_counter, par,
981 ev->alpha, usurf->animation.anima, usurf->animation.state);
983 if ((ev->output) && (es->buffer_ref.buffer) &&
984 (es->width > 0) && (es->height > 0)) {
985 weston_surface_damage(es);
988 /* end of animation */
989 animation_end(usurf, 1);
990 uifw_trace("animation_fade: End of animation");
993 /* continue animation */
994 weston_compositor_schedule_repaint(weston_ec);
998 /*--------------------------------------------------------------------------*/
1000 * @brief animation_fade_end: fade animation end
1002 * @param[in] animation weston animation table
1005 /*--------------------------------------------------------------------------*/
1007 animation_fade_end(struct weston_animation *animation)
1009 struct uifw_win_surface *usurf;
1010 struct weston_surface *es;
1011 struct weston_view *ev;
1013 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1014 if (usurf && usurf->surface) {
1015 es = usurf->surface;
1016 ev = ico_ivi_get_primary_view(usurf);
1019 if ((ev->output) && (es->buffer_ref.buffer) &&
1020 (es->width > 0) && (es->height > 0)) {
1021 weston_surface_damage(es);
1026 /*--------------------------------------------------------------------------*/
1028 * @brief animation_zoom: zoom animation
1030 * @param[in] animation weston animation table
1031 * @param[in] outout weston output table
1032 * @param[in] mseces current time(unused)
1035 /*--------------------------------------------------------------------------*/
1037 animation_zoom(struct weston_animation *animation,
1038 struct weston_output *output, uint32_t msecs)
1040 struct uifw_win_surface *usurf;
1041 struct animation_data *animadata;
1042 struct weston_surface *es;
1043 struct weston_view *ev;
1045 float scalex, scaley;
1049 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1051 par = animation_cont(animation, output, msecs);
1053 /* continue animation */
1055 weston_compositor_schedule_repaint(weston_ec);
1060 animadata = (struct animation_data *)usurf->animation.animadata;
1061 es = usurf->surface;
1062 ev = ico_ivi_get_primary_view(usurf);
1063 par = usurf->animation.current;
1064 if (animation->frame_counter == 1) {
1065 if (animadata->transform_set == 0) {
1066 animadata->transform_set = 1;
1067 weston_matrix_init(&animadata->transform.matrix);
1068 wl_list_init(&animadata->transform.link);
1069 wl_list_insert(&ev->geometry.transformation_list,
1070 &animadata->transform.link);
1072 animadata->end_function = animation_zoom_end;
1074 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
1075 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1076 ico_window_mgr_set_weston_surface(usurf,
1077 usurf->animation.pos_x, usurf->animation.pos_y,
1078 usurf->animation.pos_width,
1079 usurf->animation.pos_height);
1083 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
1085 scalex = ((float)par + 5.0f) / 105.0f;
1088 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
1090 scalex = 1.0f - (((float)par + 5.0f) / 105.0f);
1094 /* zoom move/resize */
1095 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1096 usurf->width, usurf->height);
1097 fu = (float)usurf->width;
1098 fa = (float)usurf->animation.pos_width;
1099 fp = (100.0f - (float)par) / 100.0f;
1100 scalex = (fu - (fu - fa) * fp) / fu;
1101 fu = (float)usurf->height;
1102 fa = (float)usurf->animation.pos_height;
1103 scaley = (fu - (fu - fa) * fp) / fu;
1105 x = (((float)usurf->animation.pos_x) - ((float)usurf->x)) * fp + (float)usurf->x
1106 + (((float)usurf->width * scalex) - (float)usurf->width) / 2.0f;
1107 y = (((float)usurf->animation.pos_y) - ((float)usurf->y)) * fp + (float)usurf->y
1108 + (((float)usurf->height * scaley) - (float) usurf->height) / 2.0f;
1109 uifw_trace("animation_zoom: %08x %d%% x=%d/%d y=%d/%d",
1110 usurf->surfaceid, par, x, usurf->x, y, usurf->y);
1111 uifw_trace("animation_zoom: sx=%4.2f sy=%4.2f x=%d->%d y=%d->%d cur=%d,%d",
1112 scalex, scaley, usurf->animation.pos_x, usurf->x,
1113 usurf->animation.pos_y, usurf->y, x, y);
1114 ico_window_mgr_set_weston_surface(usurf, x, y, usurf->width, usurf->height);
1116 weston_matrix_init(&animadata->transform.matrix);
1117 weston_matrix_translate(&animadata->transform.matrix,
1118 -0.5f * usurf->width, -0.5f * usurf->height, 0);
1119 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
1120 weston_matrix_translate(&animadata->transform.matrix,
1121 0.5f * usurf->width, 0.5f * usurf->height, 0);
1123 uifw_trace("animation_zoom: %08x count=%d %d%% w=%d/%d h=%d/%d anima=%d state=%d",
1124 usurf->surfaceid, animation->frame_counter, par,
1125 (int)(usurf->width * scalex), usurf->width,
1126 (int)(usurf->height * scaley), usurf->height,
1127 usurf->animation.anima, usurf->animation.state);
1129 if ((ev->output) && (es->buffer_ref.buffer) &&
1130 (es->width > 0) && (es->height > 0)) {
1131 weston_view_geometry_dirty(ev);
1132 weston_surface_damage(es);
1135 /* end of animation */
1136 animation_end(usurf, 1);
1137 uifw_trace("animation_zoom: End of animation");
1140 /* continue animation */
1141 weston_compositor_schedule_repaint(weston_ec);
1145 /*--------------------------------------------------------------------------*/
1147 * @brief animation_zoom_end: zoom animation end
1149 * @param[in] animation weston animation table
1152 /*--------------------------------------------------------------------------*/
1154 animation_zoom_end(struct weston_animation *animation)
1156 struct uifw_win_surface *usurf;
1157 struct weston_surface *es;
1158 struct weston_view *ev;
1160 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1161 if (usurf && usurf->surface) {
1162 es = usurf->surface;
1163 ev = ico_ivi_get_primary_view(usurf);
1166 if ((ev->output) && (es->buffer_ref.buffer) &&
1167 (es->width > 0) && (es->height > 0)) {
1168 weston_surface_damage(es);
1173 /*--------------------------------------------------------------------------*/
1175 * @brief module_init: initialize ico_window_animation
1176 * this function called from ico_pluign_loader
1178 * @param[in] es weston compositor
1179 * @param[in] argc number of arguments(unused)
1180 * @param[in] argv argument list(unused)
1185 /*--------------------------------------------------------------------------*/
1187 module_init(struct weston_compositor *ec, int *argc, char *argv[])
1190 struct animation_data *animadata;
1192 uifw_info("ico_window_animation: Enter(module_init)");
1194 /* allocate animation datas */
1196 for (i = 0; i < 50; i++) {
1197 animadata = (struct animation_data *)malloc(sizeof(struct animation_data));
1199 uifw_error("ico_window_animation: No Memory(module_init)");
1202 animadata->next_free = free_data;
1203 free_data = animadata;
1207 default_animation = (char *)ico_ivi_default_animation_name();
1208 animation_time = ico_ivi_default_animation_time();
1209 animation_fps = ico_ivi_default_animation_fps();
1210 animation_count = 0;
1212 ico_window_mgr_set_hook_animation(ico_window_animation);
1214 uifw_info("ico_window_animation: Leave(module_init)");