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 "ico_ivi_common_private.h"
44 #include "ico_ivi_shell_private.h"
45 #include "ico_window_mgr_private.h"
48 #define ANIMA_ZOOM 1 /* ZoomIn/ZoomOut */
49 #define ANIMA_FADE 2 /* FadeIn/FadeOut */
50 #define ANIMA_SLIDE_TORIGHT 11 /* SlideIn left to right/SlideOut right to left */
51 #define ANIMA_SLIDE_TOLEFT 12 /* SlideIn right to left/SlideOut left to right */
52 #define ANIMA_SLIDE_TOBOTTOM 13 /* SlideIn top to bottom/SlideOut bottom to top */
53 #define ANIMA_SLIDE_TOTOP 14 /* SlideIn bottom to top/SlideOut top to bottom */
54 #define ANIMA_WIPE_TORIGHT 21 /* WipeIn left to right/WipeOut right to left */
55 #define ANIMA_WIPE_TOLEFT 22 /* WipeIn right to left/WipeOut left to right */
56 #define ANIMA_WIPE_TOBOTTOM 23 /* WipeIn top to bottom/WipeOut bottom to top */
57 #define ANIMA_WIPE_TOTOP 24 /* WipeIn bottom to top/WipeOut top to bottom */
58 #define ANIMA_SWING_TORIGHT 31 /* SwingIn left to right/SwingOut right to left */
59 #define ANIMA_SWING_TOLEFT 32 /* SwingIn right to left/SwingOut left to right */
60 #define ANIMA_SWING_TOBOTTOM 33 /* SwingIn top to bottom/SwingOut bottom to top */
61 #define ANIMA_SWING_TOTOP 34 /* SwingIn bottom to top/SwingOut top to bottom */
63 /* Visible control at end of animation */
64 #define ANIMA_NOCONTROL_AT_END 0 /* no need surface show/hide at end of animation*/
65 #define ANIMA_SHOW_AT_END 1 /* surface show at end of animation */
66 #define ANIMA_HIDE_AT_END 2 /* surface hide at end of animation */
69 struct animation_data {
70 struct animation_data *next_free; /* free data list */
71 char transform_set; /* need transform reset at end */
72 char res[3]; /* (unused) */
73 struct weston_transform transform; /* transform matrix */
74 void (*end_function)(struct weston_animation *animation);
75 /* animation end function */
78 /* static valiables */
79 static struct weston_compositor *weston_ec; /* Weston compositor */
80 static char *default_animation; /* default animation name */
81 static int animation_fps; /* animation frame rate(frame/sec) */
82 static int animation_time; /* default animation time(ms) */
83 static int animation_count; /* current number of animations */
84 static struct animation_data *free_data; /* free data list */
86 /* support animation names */
87 static const struct _supprt_animaetions {
90 } supprt_animaetions[] = {
91 { "fade", ANIMA_FADE },
92 { "zoom", ANIMA_ZOOM },
93 { "slide", ANIMA_SLIDE_TOTOP },
94 { "slide.toleft", ANIMA_SLIDE_TOLEFT },
95 { "slide.toright", ANIMA_SLIDE_TORIGHT },
96 { "slide.totop", ANIMA_SLIDE_TOTOP },
97 { "slide.tobottom", ANIMA_SLIDE_TOBOTTOM },
98 { "wipe", ANIMA_WIPE_TOTOP },
99 { "wipe.toleft", ANIMA_WIPE_TOLEFT },
100 { "wipe.toright", ANIMA_WIPE_TORIGHT },
101 { "wipe.totop", ANIMA_WIPE_TOTOP },
102 { "wipe.tobottom", ANIMA_WIPE_TOBOTTOM },
103 { "swing", ANIMA_SWING_TOTOP },
104 { "swing.toleft", ANIMA_SWING_TOLEFT },
105 { "swing.toright", ANIMA_SWING_TORIGHT },
106 { "swing.totop", ANIMA_SWING_TOTOP },
107 { "swing.tobottom", ANIMA_SWING_TOBOTTOM },
111 /* static function */
112 /* slide animation */
113 static void animation_slide(struct weston_animation *animation,
114 struct weston_output *output, uint32_t msecs);
116 static void animation_wipe(struct weston_animation *animation,
117 struct weston_output *output, uint32_t msecs);
118 /* swing animation */
119 static void animation_swing(struct weston_animation *animation,
120 struct weston_output *output, uint32_t msecs);
121 /* swing animation end */
122 static void animation_swing_end(struct weston_animation *animation);
124 static void animation_fade(struct weston_animation *animation,
125 struct weston_output *output, uint32_t msecs);
126 /* fade animation end */
127 static void animation_fade_end(struct weston_animation *animation);
129 static void animation_zoom(struct weston_animation *animation,
130 struct weston_output *output, uint32_t msecs);
131 /* zoom animation end */
132 static void animation_zoom_end(struct weston_animation *animation);
133 /* continue animation */
134 static int animation_cont(struct weston_animation *animation,
135 struct weston_output *output, uint32_t msecs);
136 /* terminate animation */
137 static void animation_end(struct uifw_win_surface *usurf, const int disp);
139 /*--------------------------------------------------------------------------*/
141 * @brief ico_window_animation: Animation addin entry
143 * @param[in] op animation operation
144 * @param[in] data data
146 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMA success
147 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL success(no control)
148 * @retval ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA error(no animation)
150 /*--------------------------------------------------------------------------*/
152 ico_window_animation(const int op, void *data)
154 struct uifw_win_surface *usurf;
155 struct weston_output *output;
161 if (op == ICO_WINDOW_MGR_ANIMATION_NAME) {
162 /* convert animation name to animation type value */
163 for (idx = 0; supprt_animaetions[idx].animaid > 0; idx++) {
164 if (strcasecmp(supprt_animaetions[idx].name, (char *)data) == 0) {
165 uifw_trace("ico_window_animation: Type %s(%d)",
166 (char *)data, supprt_animaetions[idx].animaid);
167 return supprt_animaetions[idx].animaid;
170 uifw_warn("ico_window_animation: Unknown Type %s", (char *)data);
171 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
174 usurf = (struct uifw_win_surface *)data;
176 if (op == ICO_WINDOW_MGR_ANIMATION_DESTROY) {
177 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
178 (usurf->animation.animadata != NULL)) {
179 uifw_trace("ico_window_animation: Destroy %08x", usurf->surfaceid);
180 animation_end(usurf, 0);
182 return ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
185 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
187 if (op == ICO_WINDOW_MGR_ANIMATION_OPCANCEL) {
188 /* cancel animation */
189 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
190 (usurf->animation.animation.frame != NULL)) {
191 uifw_trace("ico_window_animation: cancel %s.%08x",
192 usurf->uclient->appid, usurf->surfaceid);
193 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 0);
195 animation_end(usurf, 1);
196 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
199 /* setup animation */
200 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
201 (usurf->animation.current > 95)) {
202 usurf->animation.animation.frame_counter = 1;
203 usurf->animation.current = 0;
204 usurf->animation.ahalf = 0;
205 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) {
206 wl_list_init(&usurf->animation.animation.link);
207 output = container_of(weston_ec->output_list.next,
208 struct weston_output, link);
209 wl_list_insert(output->animation_list.prev,
210 &usurf->animation.animation.link);
214 else if (((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) &&
215 ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
216 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS))) ||
217 ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) &&
218 ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
219 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)))) {
220 /* change ...In(ex.FadeIn) to ...Out(FadeOut) or ...Out to ...In */
221 nowsec = weston_compositor_get_time();
222 usurf->animation.current = 100 - usurf->animation.current;
223 if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE)||
224 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
225 usurf->animation.time = usurf->animation.hide_time;
228 usurf->animation.time = usurf->animation.show_time;
230 if (usurf->animation.time == 0) {
231 usurf->animation.time = animation_time;
233 ret = ((usurf->animation.current) * usurf->animation.time) / 100;
234 if (nowsec >= (uint32_t)ret) {
235 usurf->animation.starttime = nowsec - ret;
238 usurf->animation.starttime = ((long long)nowsec) + ((long long)0x100000000L)
241 usurf->animation.animation.frame_counter = 2;
244 /* set animation function */
245 if ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
246 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
247 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_SHOW;
248 animaid = usurf->animation.show_anima;
249 usurf->animation.anima = animaid;
250 uifw_trace("ico_window_animation: show(in) %s.%08x anima=%d",
251 usurf->uclient->appid, usurf->surfaceid, animaid);
252 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
254 else if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
255 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
256 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_HIDE;
257 animaid = usurf->animation.hide_anima;
258 usurf->animation.anima = animaid;
259 uifw_trace("ico_window_animation: hide(out) %s.%08x anima=%d",
260 usurf->uclient->appid, usurf->surfaceid, animaid);
261 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
262 usurf->animation.visible = ANIMA_HIDE_AT_END;
264 else if (op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
265 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_MOVE;
266 animaid = usurf->animation.move_anima;
267 usurf->animation.anima = animaid;
268 uifw_trace("ico_window_animation: move %s.%08x anima=%d",
269 usurf->uclient->appid, usurf->surfaceid, animaid);
270 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
272 else if (op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
273 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE;
274 animaid = usurf->animation.resize_anima;
275 usurf->animation.anima = animaid;
276 uifw_trace("ico_window_animation: resize %s.%08x anima=%d",
277 usurf->uclient->appid, usurf->surfaceid, animaid);
278 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
281 uifw_trace("ico_window_animation: Op=%d unknown", op);
282 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
284 if ((animaid == ANIMA_SLIDE_TOLEFT) || (animaid == ANIMA_SLIDE_TORIGHT) ||
285 (animaid == ANIMA_SLIDE_TOTOP) || (animaid == ANIMA_SLIDE_TOBOTTOM)) {
286 usurf->animation.animation.frame = animation_slide;
287 usurf->restrain_configure = 1;
288 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
290 else if ((animaid == ANIMA_WIPE_TOLEFT) || (animaid == ANIMA_WIPE_TORIGHT) ||
291 (animaid == ANIMA_WIPE_TOTOP) || (animaid == ANIMA_WIPE_TOBOTTOM)) {
292 usurf->animation.animation.frame = animation_wipe;
293 usurf->restrain_configure = 1;
294 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
296 else if ((animaid == ANIMA_SWING_TOLEFT) || (animaid == ANIMA_SWING_TORIGHT) ||
297 (animaid == ANIMA_SWING_TOTOP) || (animaid == ANIMA_SWING_TOBOTTOM)) {
298 usurf->animation.animation.frame = animation_swing;
299 usurf->restrain_configure = 1;
300 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
302 else if (animaid == ANIMA_FADE) {
303 usurf->animation.animation.frame = animation_fade;
304 usurf->restrain_configure = 1;
305 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
307 else if (animaid == ANIMA_ZOOM) {
308 usurf->animation.animation.frame = animation_zoom;
309 usurf->restrain_configure = 1;
310 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
314 usurf->animation.animation.frame = NULL;
315 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
316 usurf->restrain_configure = 0;
317 usurf->animation.anima = 0;
318 wl_list_remove(&usurf->animation.animation.link);
319 ret = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
321 usurf->animation.type = op;
322 #if PERFORMANCE_EVALUATIONS > 0
323 if (ret != ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) {
324 uifw_perf("SWAP_BUFFER Start Animation appid=%s surface=%08x anima=%d",
325 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
327 #endif /*PERFORMANCE_EVALUATIONS*/
329 weston_compositor_schedule_repaint(weston_ec);
333 /*--------------------------------------------------------------------------*/
335 * @brief animation_cont: continue animation
337 * @param[in] animation weston animation table
338 * @param[in] output weston output table
339 * @param[in] msecs current time stamp
340 * @return time has come
341 * @retval =0 time has come
342 * @retval >0 time has not yet come(return value is current parcent)
344 /*--------------------------------------------------------------------------*/
346 animation_cont(struct weston_animation *animation, struct weston_output *output,
349 struct uifw_win_surface *usurf;
353 nowsec = weston_compositor_get_time();
355 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
357 if (animation->frame_counter <= 1) {
358 /* first call, initialize */
359 animation->frame_counter = 1;
360 usurf->animation.starttime = nowsec;
361 usurf->animation.current = 1000;
362 if (! usurf->animation.animadata) {
364 usurf->animation.animadata = (void *)free_data;
365 free_data = free_data->next_free;
368 usurf->animation.animadata = (void *)malloc(sizeof(struct animation_data));
370 memset(usurf->animation.animadata, 0, sizeof(struct animation_data));
373 else if (! usurf->animation.animadata) {
374 animation_end(usurf, 0);
378 if (nowsec >= usurf->animation.starttime) {
379 nowsec = nowsec - usurf->animation.starttime; /* elapsed time(ms) */
382 nowsec = (uint32_t)(((long long)0x100000000L) +
383 ((long long)nowsec) - ((long long)usurf->animation.starttime));
385 switch (usurf->animation.state) {
386 case ICO_WINDOW_MGR_ANIMATION_STATE_SHOW:
387 usurf->animation.time = usurf->animation.show_time;
389 case ICO_WINDOW_MGR_ANIMATION_STATE_HIDE:
390 usurf->animation.time = usurf->animation.hide_time;
392 case ICO_WINDOW_MGR_ANIMATION_STATE_MOVE:
393 usurf->animation.time = usurf->animation.move_time;
396 usurf->animation.time = usurf->animation.resize_time;
399 if (usurf->animation.time == 0) {
400 usurf->animation.time = animation_time;
402 if (((output == NULL) && (msecs == 0)) || (nowsec >= ((uint32_t)usurf->animation.time))) {
406 par = (nowsec * 100 + usurf->animation.time / 2) / usurf->animation.time;
407 if (par < 2) par = 2;
410 (abs(usurf->animation.current - par) >=
411 (((1000 * 100) / animation_fps) / usurf->animation.time)) ||
412 ((animation_count > 1) && (par != usurf->animation.current))) {
413 usurf->animation.current = par;
419 /*--------------------------------------------------------------------------*/
421 * @brief animation_end: terminate animation
423 * @param[in] usurf UIFW surface table
424 * @param[in] disp display control(1)/no display(0)
427 /*--------------------------------------------------------------------------*/
429 animation_end(struct uifw_win_surface *usurf, const int disp)
431 struct animation_data *animadata;
432 struct weston_view *ev;
434 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
435 animadata = (struct animation_data *)usurf->animation.animadata;
437 if (animation_count > 0) {
440 ev = ico_ivi_get_primary_view(usurf);
443 if (animadata->end_function) {
444 (*animadata->end_function)(&usurf->animation.animation);
446 wl_list_remove(&usurf->animation.animation.link);
447 if (animadata->transform_set) {
448 wl_list_remove(&animadata->transform.link);
449 animadata->transform_set = 0;
451 weston_view_geometry_dirty(ev);
454 usurf->restrain_configure = 0;
455 if ((usurf->animation.visible == ANIMA_HIDE_AT_END) &&
456 (usurf->visible != 0)) {
457 ico_window_mgr_set_visible(usurf, 0);
458 weston_surface_damage(usurf->surface);
460 if ((usurf->animation.visible == ANIMA_SHOW_AT_END) &&
461 (usurf->visible == 0)) {
462 ico_window_mgr_set_visible(usurf, 1);
463 weston_surface_damage(usurf->surface);
465 weston_view_geometry_dirty(ev);
466 ico_window_mgr_restack_layer(usurf);
468 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
469 if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE) {
470 switch(usurf->animation.type) {
471 case ICO_WINDOW_MGR_ANIMATION_OPHIDE:
472 case ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS:
473 usurf->animation.hide_anima = usurf->animation.next_anima;
475 case ICO_WINDOW_MGR_ANIMATION_OPSHOW:
476 case ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS:
477 usurf->animation.show_anima = usurf->animation.next_anima;
479 case ICO_WINDOW_MGR_ANIMATION_OPMOVE:
480 usurf->animation.move_anima = usurf->animation.next_anima;
482 case ICO_WINDOW_MGR_ANIMATION_OPRESIZE:
483 usurf->animation.resize_anima = usurf->animation.next_anima;
488 usurf->animation.next_anima = ICO_WINDOW_MGR_ANIMATION_NONE;
491 usurf->animation.animadata = NULL;
492 animadata->next_free = free_data;
493 free_data = animadata;
495 usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE;
497 ico_window_mgr_restack_layer(usurf);
499 #if PERFORMANCE_EVALUATIONS > 0
500 uifw_perf("SWAP_BUFFER End Animation appid=%s surface=%08x anima=%d",
501 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
502 #endif /*PERFORMANCE_EVALUATIONS*/
505 /*--------------------------------------------------------------------------*/
507 * @brief animation_slide: slide animation
509 * @param[in] animation weston animation table
510 * @param[in] outout weston output table
511 * @param[in] mseces current time(unused)
514 /*--------------------------------------------------------------------------*/
516 animation_slide(struct weston_animation *animation,
517 struct weston_output *output, uint32_t msecs)
519 struct uifw_win_surface *usurf;
520 struct weston_surface *es;
521 struct weston_view *ev;
527 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
529 par = animation_cont(animation, output, msecs);
531 /* continue animation */
533 weston_compositor_schedule_repaint(weston_ec);
537 ev = ico_ivi_get_primary_view(usurf);
538 par = usurf->animation.current;
540 uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d",
541 usurf->surfaceid, animation->frame_counter, par,
542 usurf->animation.anima, usurf->animation.state);
548 switch (usurf->animation.anima) {
549 case ANIMA_SLIDE_TORIGHT: /* slide in left to right */
550 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
551 /* slide in left to right */
552 x = 0 - usurf->animation.pos_width +
553 ((usurf->animation.pos_x + usurf->animation.pos_width) * par / 100);
556 /* slide out right to left */
557 x = 0 - usurf->animation.pos_width +
558 ((usurf->animation.pos_x + usurf->animation.pos_width) * (100 - par) / 100);
561 case ANIMA_SLIDE_TOLEFT: /* slide in right to left */
562 dwidth = usurf->node_tbl->disp_width;
563 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
564 /* slide in right to left */
565 x = usurf->animation.pos_x +
566 (dwidth - usurf->animation.pos_x) * (100 - par) / 100;
569 /* slide out left to right */
570 x = usurf->animation.pos_x + (dwidth - usurf->animation.pos_x) * par / 100;
573 case ANIMA_SLIDE_TOBOTTOM: /* slide in top to bottom */
574 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
575 /* slide in top to bottom */
576 y = 0 - usurf->animation.pos_height +
577 ((usurf->animation.pos_y + usurf->animation.pos_height) * par / 100);
580 /* slide out bottom to top */
581 y = 0 - usurf->animation.pos_height +
582 ((usurf->animation.pos_y + usurf->animation.pos_height) * (100 - par) / 100);
585 default: /*ANIMA_SLIDE_TOTOP*/ /* slide in bottom to top */
586 dheight = usurf->node_tbl->disp_height;
587 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
588 /* slide in bottom to top */
589 y = usurf->animation.pos_y +
590 (dheight - usurf->animation.pos_y) * (100 - par) / 100;
593 /* slide out top to bottom */
594 y = usurf->animation.pos_y + (dheight - usurf->animation.pos_y) * par / 100;
599 uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d)",
600 usurf->surfaceid, par, x, y, usurf->x, usurf->y);
601 ev->geometry.x = usurf->node_tbl->disp_x + x;
602 ev->geometry.y = usurf->node_tbl->disp_y + y;
603 if ((ev->output) && (es->buffer_ref.buffer) &&
604 (es->width > 0) && (es->height > 0)) {
605 weston_view_geometry_dirty(ev);
606 weston_surface_damage(es);
609 /* end of animation */
610 animation_end(usurf, 1);
611 uifw_trace("animation_slide: End of animation");
614 /* continue animation */
615 weston_compositor_schedule_repaint(weston_ec);
619 /*--------------------------------------------------------------------------*/
621 * @brief animation_wipe: wipe animation
623 * @param[in] animation weston animation table
624 * @param[in] outout weston output table
625 * @param[in] mseces current time(unused)
628 /*--------------------------------------------------------------------------*/
630 animation_wipe(struct weston_animation *animation,
631 struct weston_output *output, uint32_t msecs)
633 struct uifw_win_surface *usurf;
634 struct weston_surface *es;
635 struct weston_view *ev;
642 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
644 par = animation_cont(animation, output, msecs);
646 /* continue animation */
648 weston_compositor_schedule_repaint(weston_ec);
652 ev = ico_ivi_get_primary_view(usurf);
653 par = usurf->animation.current;
655 uifw_debug("animation_wipe: %08x count=%d %d%% anima=%d state=%d",
656 usurf->surfaceid, animation->frame_counter, par,
657 usurf->animation.anima, usurf->animation.state);
662 width = usurf->width;
663 height = usurf->width;
666 switch (usurf->animation.anima) {
667 case ANIMA_WIPE_TORIGHT: /* wipe in left to right */
668 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
669 /* wipe in left to right */
670 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
673 /* wipe out right to left */
674 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
676 if (width <= 0) width = 1;
678 case ANIMA_WIPE_TOLEFT: /* wipe in right to left */
679 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
680 /* wipe in right to left */
681 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
684 /* wipe out left to right */
685 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
687 if (width <= 0) width = 1;
688 x = x + (usurf->width - width);
690 case ANIMA_WIPE_TOBOTTOM: /* wipe in top to bottom */
691 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
692 /* wipe in top to bottom */
693 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
696 /* wipe out bottom to top */
697 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
699 if (height <= 0) height = 1;
701 default: /*ANIMA_WIPE_TOTOP*/ /* wipe in bottom to top */
702 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
703 /* wipe in bottom to top */
704 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
707 /* wipe out top to bottom */
708 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
710 if (height <= 0) height = 1;
711 y = y + (usurf->height - height);
716 ev->geometry.x = usurf->node_tbl->disp_x + x;
717 ev->geometry.y = usurf->node_tbl->disp_y + y;
720 if ((ev->output) && (es->buffer_ref.buffer)) {
721 weston_view_geometry_dirty(ev);
722 weston_surface_damage(es);
725 /* end of animation */
726 animation_end(usurf, 1);
727 uifw_trace("animation_wipe: End of animation");
730 /* continue animation */
731 weston_compositor_schedule_repaint(weston_ec);
735 /*--------------------------------------------------------------------------*/
737 * @brief animation_swing: swing animation
739 * @param[in] animation weston animation table
740 * @param[in] outout weston output table
741 * @param[in] mseces current time(unused)
744 /*--------------------------------------------------------------------------*/
746 animation_swing(struct weston_animation *animation,
747 struct weston_output *output, uint32_t msecs)
749 struct uifw_win_surface *usurf;
750 struct weston_surface *es;
751 struct weston_view *ev;
752 struct animation_data *animadata;
759 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
761 par = animation_cont(animation, output, msecs);
763 /* continue animation */
765 weston_compositor_schedule_repaint(weston_ec);
770 uifw_debug("animation_swing: %08x count=%d %d%% anima=%d state=%d",
771 usurf->surfaceid, animation->frame_counter, par,
772 usurf->animation.anima, usurf->animation.state);
774 animadata = (struct animation_data *)usurf->animation.animadata;
776 ev = ico_ivi_get_primary_view(usurf);
777 par = usurf->animation.current;
778 if (animation->frame_counter == 1) {
779 if (animadata->transform_set == 0) {
780 animadata->transform_set = 1;
781 weston_matrix_init(&animadata->transform.matrix);
782 wl_list_init(&animadata->transform.link);
783 wl_list_insert(&ev->geometry.transformation_list,
784 &animadata->transform.link);
786 animadata->end_function = animation_swing_end;
795 switch (usurf->animation.anima) {
796 case ANIMA_SWING_TORIGHT: /* swing in left to right */
797 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
798 /* swing in left to right */
799 scalex = ((float)par + 5.0f) / 105.0f;
802 /* swing out right to left */
803 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
805 if (scalex <= 0.0) scalex = 0.01;
807 case ANIMA_SWING_TOLEFT: /* seing in right to left */
808 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
809 /* swing in right to left */
810 scalex = ((float)par + 5.0f) / 105.0f;
813 /* swing out left to right */
814 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
816 if (scalex <= 0.0) scalex = 0.01;
817 x = x + (int)((float)usurf->width * (1.0f - scalex));
819 case ANIMA_SWING_TOBOTTOM: /* swing in top to bottom */
820 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
821 /* swing in top to bottom */
822 scaley = ((float)par + 5.0f) / 105.0f;
825 /* swing out bottom to top */
826 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
828 if (scaley <= 0.0) scaley = 0.01;
830 default: /*ANIMA_SWING*/ /* swing in bottom to top */
831 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
832 /* wipe in bottom to top */
833 scaley = ((float)par + 5.0f) / 105.0f;
836 /* wipe out top to bottom */
837 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
839 if (scaley <= 0.0) scaley = 0.01;
840 y = y + (int)((float)usurf->height * (1.0f - scaley));
845 ev->geometry.x = usurf->node_tbl->disp_x + x;
846 ev->geometry.y = usurf->node_tbl->disp_y + y;
847 weston_matrix_init(&animadata->transform.matrix);
848 weston_matrix_translate(&animadata->transform.matrix,
849 -0.5f * usurf->width, -0.5f * usurf->height, 0);
850 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
851 weston_matrix_translate(&animadata->transform.matrix,
852 0.5f * usurf->width, 0.5f * usurf->height, 0);
854 if ((ev->output) && (es->buffer_ref.buffer)) {
855 weston_view_geometry_dirty(ev);
856 weston_surface_damage(es);
859 /* end of animation */
860 animation_end(usurf, 1);
861 uifw_trace("animation_swing: End of animation");
864 /* continue animation */
865 weston_compositor_schedule_repaint(weston_ec);
869 /*--------------------------------------------------------------------------*/
871 * @brief animation_swing_end: swing animation end
873 * @param[in] animation weston animation table
876 /*--------------------------------------------------------------------------*/
878 animation_swing_end(struct weston_animation *animation)
880 struct uifw_win_surface *usurf;
881 struct weston_surface *es;
882 struct weston_view *ev;
884 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
885 if (usurf && usurf->surface) {
887 ev = ico_ivi_get_primary_view(usurf);
890 if ((ev->output) && (es->buffer_ref.buffer)) {
891 weston_surface_damage(es);
896 /*--------------------------------------------------------------------------*/
898 * @brief animation_fade: fade animation
900 * @param[in] animation weston animation table
901 * @param[in] outout weston output table
902 * @param[in] mseces current time(unused)
905 /*--------------------------------------------------------------------------*/
907 animation_fade(struct weston_animation *animation,
908 struct weston_output *output, uint32_t msecs)
910 struct uifw_win_surface *usurf;
911 struct animation_data *animadata;
912 struct weston_surface *es;
913 struct weston_view *ev;
916 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
918 par = animation_cont(animation, output, msecs);
920 /* continue animation */
922 weston_compositor_schedule_repaint(weston_ec);
927 animadata = (struct animation_data *)usurf->animation.animadata;
929 ev = ico_ivi_get_primary_view(usurf);
930 par = usurf->animation.current;
931 if (animation->frame_counter == 1) {
932 if (animadata->transform_set == 0) {
933 animadata->transform_set = 1;
934 weston_matrix_init(&animadata->transform.matrix);
935 wl_list_init(&animadata->transform.link);
936 wl_list_insert(&ev->geometry.transformation_list,
937 &animadata->transform.link);
939 animadata->end_function = animation_fade_end;
941 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
942 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
943 ico_window_mgr_set_weston_surface(usurf,
944 usurf->animation.pos_x, usurf->animation.pos_y,
945 usurf->animation.pos_width,
946 usurf->animation.pos_height);
950 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
952 ev->alpha = ((float)par) / 100.0f;
954 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
956 ev->alpha = 1.0f - (((float)par) / 100.0f);
959 /* fade move/resize */
960 if ((par >= 50) || (usurf->animation.ahalf)) {
961 ev->alpha = ((float)(par*2 - 100)) / 100.0f;
962 if (usurf->animation.ahalf == 0) {
963 uifw_trace("animation_fade: fade move chaneg to show");
964 usurf->animation.ahalf = 1;
966 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
967 usurf->width, usurf->height);
968 ico_window_mgr_change_surface(usurf,
969 usurf->animation.no_configure ? -1 : 0, 1);
970 ico_window_mgr_restack_layer(usurf);
974 ev->alpha = 1.0f - (((float)(par*2)) / 100.0f);
977 if (ev->alpha < 0.0) ev->alpha = 0.0;
978 else if (ev->alpha > 1.0) ev->alpha = 1.0;
980 uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
981 usurf->surfaceid, animation->frame_counter, par,
982 ev->alpha, usurf->animation.anima, usurf->animation.state);
984 if ((ev->output) && (es->buffer_ref.buffer) &&
985 (es->width > 0) && (es->height > 0)) {
986 weston_surface_damage(es);
989 /* end of animation */
990 animation_end(usurf, 1);
991 uifw_trace("animation_fade: End of animation");
994 /* continue animation */
995 weston_compositor_schedule_repaint(weston_ec);
999 /*--------------------------------------------------------------------------*/
1001 * @brief animation_fade_end: fade animation end
1003 * @param[in] animation weston animation table
1006 /*--------------------------------------------------------------------------*/
1008 animation_fade_end(struct weston_animation *animation)
1010 struct uifw_win_surface *usurf;
1011 struct weston_surface *es;
1012 struct weston_view *ev;
1014 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1015 if (usurf && usurf->surface) {
1016 es = usurf->surface;
1017 ev = ico_ivi_get_primary_view(usurf);
1020 if ((ev->output) && (es->buffer_ref.buffer) &&
1021 (es->width > 0) && (es->height > 0)) {
1022 weston_surface_damage(es);
1027 /*--------------------------------------------------------------------------*/
1029 * @brief animation_zoom: zoom animation
1031 * @param[in] animation weston animation table
1032 * @param[in] outout weston output table
1033 * @param[in] mseces current time(unused)
1036 /*--------------------------------------------------------------------------*/
1038 animation_zoom(struct weston_animation *animation,
1039 struct weston_output *output, uint32_t msecs)
1041 struct uifw_win_surface *usurf;
1042 struct animation_data *animadata;
1043 struct weston_surface *es;
1044 struct weston_view *ev;
1046 float scalex, scaley;
1050 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1052 par = animation_cont(animation, output, msecs);
1054 /* continue animation */
1056 weston_compositor_schedule_repaint(weston_ec);
1061 animadata = (struct animation_data *)usurf->animation.animadata;
1062 es = usurf->surface;
1063 ev = ico_ivi_get_primary_view(usurf);
1064 par = usurf->animation.current;
1065 if (animation->frame_counter == 1) {
1066 if (animadata->transform_set == 0) {
1067 animadata->transform_set = 1;
1068 weston_matrix_init(&animadata->transform.matrix);
1069 wl_list_init(&animadata->transform.link);
1070 wl_list_insert(&ev->geometry.transformation_list,
1071 &animadata->transform.link);
1073 animadata->end_function = animation_zoom_end;
1075 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
1076 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1077 ico_window_mgr_set_weston_surface(usurf,
1078 usurf->animation.pos_x, usurf->animation.pos_y,
1079 usurf->animation.pos_width,
1080 usurf->animation.pos_height);
1084 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
1086 scalex = ((float)par + 5.0f) / 105.0f;
1089 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
1091 scalex = 1.0f - (((float)par + 5.0f) / 105.0f);
1095 /* zoom move/resize */
1096 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1097 usurf->width, usurf->height);
1098 ico_window_mgr_change_surface(usurf, usurf->animation.no_configure ? -1 : 0, 1);
1100 fu = (float)usurf->width;
1101 fa = (float)usurf->animation.pos_width;
1102 fp = (100.0f - (float)par) / 100.0f;
1103 scalex = (fu - (fu - fa) * fp) / fu;
1104 fu = (float)usurf->height;
1105 fa = (float)usurf->animation.pos_height;
1106 scaley = (fu - (fu - fa) * fp) / fu;
1108 x = (((float)usurf->animation.pos_x) - ((float)usurf->x)) * fp + (float)usurf->x
1109 + (((float)usurf->width * scalex) - (float)usurf->width) / 2.0f;
1110 y = (((float)usurf->animation.pos_y) - ((float)usurf->y)) * fp + (float)usurf->y
1111 + (((float)usurf->height * scaley) - (float) usurf->height) / 2.0f;
1112 uifw_trace("animation_zoom: %08x %d%% x=%d/%d y=%d/%d",
1113 usurf->surfaceid, par, x, usurf->x, y, usurf->y);
1114 uifw_trace("animation_zoom: sx=%4.2f sy=%4.2f x=%d->%d y=%d->%d cur=%d,%d",
1115 scalex, scaley, usurf->animation.pos_x, usurf->x,
1116 usurf->animation.pos_y, usurf->y, x, y);
1117 ico_window_mgr_set_weston_surface(usurf, x, y, usurf->width, usurf->height);
1119 weston_matrix_init(&animadata->transform.matrix);
1120 weston_matrix_translate(&animadata->transform.matrix,
1121 -0.5f * usurf->width, -0.5f * usurf->height, 0);
1122 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
1123 weston_matrix_translate(&animadata->transform.matrix,
1124 0.5f * usurf->width, 0.5f * usurf->height, 0);
1126 uifw_trace("animation_zoom: %08x count=%d %d%% w=%d/%d h=%d/%d anima=%d state=%d",
1127 usurf->surfaceid, animation->frame_counter, par,
1128 (int)(usurf->width * scalex), usurf->width,
1129 (int)(usurf->height * scaley), usurf->height,
1130 usurf->animation.anima, usurf->animation.state);
1132 if ((ev->output) && (es->buffer_ref.buffer) &&
1133 (es->width > 0) && (es->height > 0)) {
1134 weston_view_geometry_dirty(ev);
1135 weston_surface_damage(es);
1138 /* end of animation */
1139 animation_end(usurf, 1);
1140 uifw_trace("animation_zoom: End of animation");
1143 /* continue animation */
1144 weston_compositor_schedule_repaint(weston_ec);
1148 /*--------------------------------------------------------------------------*/
1150 * @brief animation_zoom_end: zoom animation end
1152 * @param[in] animation weston animation table
1155 /*--------------------------------------------------------------------------*/
1157 animation_zoom_end(struct weston_animation *animation)
1159 struct uifw_win_surface *usurf;
1160 struct weston_surface *es;
1161 struct weston_view *ev;
1163 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1164 if (usurf && usurf->surface) {
1165 es = usurf->surface;
1166 ev = ico_ivi_get_primary_view(usurf);
1169 if ((ev->output) && (es->buffer_ref.buffer) &&
1170 (es->width > 0) && (es->height > 0)) {
1171 weston_surface_damage(es);
1176 /*--------------------------------------------------------------------------*/
1178 * @brief module_init: initialize ico_window_animation
1179 * this function called from ico_pluign_loader
1181 * @param[in] es weston compositor
1182 * @param[in] argc number of arguments(unused)
1183 * @param[in] argv argument list(unused)
1188 /*--------------------------------------------------------------------------*/
1190 module_init(struct weston_compositor *ec, int *argc, char *argv[])
1193 struct animation_data *animadata;
1195 uifw_info("ico_window_animation: Enter(module_init)");
1197 /* allocate animation datas */
1199 for (i = 0; i < 50; i++) {
1200 animadata = (struct animation_data *)malloc(sizeof(struct animation_data));
1202 uifw_error("ico_window_animation: No Memory(module_init)");
1205 animadata->next_free = free_data;
1206 free_data = animadata;
1210 default_animation = (char *)ico_ivi_default_animation_name();
1211 animation_time = ico_ivi_default_animation_time();
1212 animation_fps = ico_ivi_default_animation_fps();
1213 animation_count = 0;
1215 ico_window_mgr_set_hook_animation(ico_window_animation);
1217 uifw_info("ico_window_animation: Leave(module_init)");