2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013 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>
42 #include "ico_ivi_common.h"
43 #include "ico_ivi_shell.h"
44 #include "ico_window_mgr.h"
47 #define ANIMA_ZOOM 1 /* ZoomIn/ZoomOut */
48 #define ANIMA_FADE 2 /* FadeIn/FadeOut */
49 #define ANIMA_SLIDE_TORIGHT 11 /* SlideIn left to right/SlideOut right to left */
50 #define ANIMA_SLIDE_TOLEFT 12 /* SlideIn right to left/SlideOut left to right */
51 #define ANIMA_SLIDE_TOBOTTOM 13 /* SlideIn top to bottom/SlideOut bottom to top */
52 #define ANIMA_SLIDE_TOTOP 14 /* SlideIn bottom to top/SlideOut top to bottom */
53 #define ANIMA_WIPE_TORIGHT 21 /* WipeIn left to right/WipeOut right to left */
54 #define ANIMA_WIPE_TOLEFT 22 /* WipeIn right to left/WipeOut left to right */
55 #define ANIMA_WIPE_TOBOTTOM 23 /* WipeIn top to bottom/WipeOut bottom to top */
56 #define ANIMA_WIPE_TOTOP 24 /* WipeIn bottom to top/WipeOut top to bottom */
57 #define ANIMA_SWING_TORIGHT 31 /* SwingIn left to right/SwingOut right to left */
58 #define ANIMA_SWING_TOLEFT 32 /* SwingIn right to left/SwingOut left to right */
59 #define ANIMA_SWING_TOBOTTOM 33 /* SwingIn top to bottom/SwingOut bottom to top */
60 #define ANIMA_SWING_TOTOP 34 /* SwingIn bottom to top/SwingOut top to bottom */
62 /* Visible control at end of animation */
63 #define ANIMA_NOCONTROL_AT_END 0 /* no need surface show/hide at end of animation*/
64 #define ANIMA_SHOW_AT_END 1 /* surface show at end of animation */
65 #define ANIMA_HIDE_AT_END 2 /* surface hide at end of animation */
68 struct animation_data {
69 struct animation_data *next_free; /* free data list */
70 char transform_set; /* need transform reset at end */
71 char res[3]; /* (unused) */
72 struct weston_transform transform; /* transform matrix */
73 void (*end_function)(struct weston_animation *animation);
74 /* animation end function */
77 /* static valiables */
78 static struct weston_compositor *weston_ec; /* Weston compositor */
79 static char *default_animation; /* default animation name */
80 static int animation_fps; /* animation frame rate(frame/sec) */
81 static int animation_time; /* default animation time(ms) */
82 static int animation_count; /* current number of animations */
83 static struct animation_data *free_data; /* free data list */
85 /* support animation names */
86 static const struct _supprt_animaetions {
89 } supprt_animaetions[] = {
90 { "fade", ANIMA_FADE },
91 { "zoom", ANIMA_ZOOM },
92 { "slide", ANIMA_SLIDE_TOTOP },
93 { "slide.toleft", ANIMA_SLIDE_TOLEFT },
94 { "slide.toright", ANIMA_SLIDE_TORIGHT },
95 { "slide.totop", ANIMA_SLIDE_TOTOP },
96 { "slide.tobottom", ANIMA_SLIDE_TOBOTTOM },
97 { "wipe", ANIMA_WIPE_TOTOP },
98 { "wipe.toleft", ANIMA_WIPE_TOLEFT },
99 { "wipe.toright", ANIMA_WIPE_TORIGHT },
100 { "wipe.totop", ANIMA_WIPE_TOTOP },
101 { "wipe.tobottom", ANIMA_WIPE_TOBOTTOM },
102 { "swing", ANIMA_SWING_TOTOP },
103 { "swing.toleft", ANIMA_SWING_TOLEFT },
104 { "swing.toright", ANIMA_SWING_TORIGHT },
105 { "swing.totop", ANIMA_SWING_TOTOP },
106 { "swing.tobottom", ANIMA_SWING_TOBOTTOM },
110 /* static function */
111 /* slide animation */
112 static void animation_slide(struct weston_animation *animation,
113 struct weston_output *output, uint32_t msecs);
115 static void animation_wipe(struct weston_animation *animation,
116 struct weston_output *output, uint32_t msecs);
117 /* swing animation */
118 static void animation_swing(struct weston_animation *animation,
119 struct weston_output *output, uint32_t msecs);
120 /* swing animation end */
121 static void animation_swing_end(struct weston_animation *animation);
123 static void animation_fade(struct weston_animation *animation,
124 struct weston_output *output, uint32_t msecs);
125 /* fade animation end */
126 static void animation_fade_end(struct weston_animation *animation);
128 static void animation_zoom(struct weston_animation *animation,
129 struct weston_output *output, uint32_t msecs);
130 /* zoom animation end */
131 static void animation_zoom_end(struct weston_animation *animation);
132 /* continue animation */
133 static int animation_cont(struct weston_animation *animation,
134 struct weston_output *output, uint32_t msecs);
135 /* terminate animation */
136 static void animation_end(struct uifw_win_surface *usurf, const int disp);
138 /*--------------------------------------------------------------------------*/
140 * @brief ico_window_animation: Animation addin entry
142 * @param[in] op animation operation
143 * @param[in] data data
145 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMA success
146 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL success(no control)
147 * @retval ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA error(no animation)
149 /*--------------------------------------------------------------------------*/
151 ico_window_animation(const int op, void *data)
153 struct uifw_win_surface *usurf;
154 struct weston_output *output;
160 if (op == ICO_WINDOW_MGR_ANIMATION_NAME) {
161 /* convert animation name to animation type value */
162 for (idx = 0; supprt_animaetions[idx].animaid > 0; idx++) {
163 if (strcasecmp(supprt_animaetions[idx].name, (char *)data) == 0) {
164 uifw_trace("ico_window_animation: Type %s(%d)",
165 (char *)data, supprt_animaetions[idx].animaid);
166 return supprt_animaetions[idx].animaid;
169 uifw_warn("ico_window_animation: Unknown Type %s", (char *)data);
170 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
173 usurf = (struct uifw_win_surface *)data;
175 if (op == ICO_WINDOW_MGR_ANIMATION_DESTROY) {
176 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
177 (usurf->animation.animadata != NULL)) {
178 uifw_trace("ico_window_animation: Destroy %08x", usurf->surfaceid);
179 animation_end(usurf, 0);
181 return ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
184 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
186 if (op == ICO_WINDOW_MGR_ANIMATION_OPCANCEL) {
187 /* cancel animation */
188 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
189 (usurf->animation.animation.frame != NULL)) {
190 uifw_trace("ico_window_animation: cancel %s.%08x",
191 usurf->uclient->appid, usurf->surfaceid);
192 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 0);
194 animation_end(usurf, 1);
195 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
198 /* setup animation */
199 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
200 (usurf->animation.current > 95)) {
201 usurf->animation.animation.frame_counter = 1;
202 usurf->animation.current = 0;
203 usurf->animation.ahalf = 0;
204 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) {
205 wl_list_init(&usurf->animation.animation.link);
206 output = container_of(weston_ec->output_list.next,
207 struct weston_output, link);
208 wl_list_insert(output->animation_list.prev,
209 &usurf->animation.animation.link);
213 else if (((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) &&
214 ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
215 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS))) ||
216 ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) &&
217 ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
218 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)))) {
219 /* change ...In(ex.FadeIn) to ...Out(FadeOut) or ...Out to ...In */
220 nowsec = weston_compositor_get_time();
221 usurf->animation.current = 100 - usurf->animation.current;
222 if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE)||
223 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
224 usurf->animation.time = usurf->animation.hide_time;
227 usurf->animation.time = usurf->animation.show_time;
229 if (usurf->animation.time == 0) {
230 usurf->animation.time = animation_time;
232 ret = ((usurf->animation.current) * usurf->animation.time) / 100;
233 if (nowsec >= (uint32_t)ret) {
234 usurf->animation.starttime = nowsec - ret;
237 usurf->animation.starttime = ((long long)nowsec) + ((long long)0x100000000L)
240 usurf->animation.animation.frame_counter = 2;
243 /* set animation function */
244 if ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
245 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
246 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_SHOW;
247 animaid = usurf->animation.show_anima;
248 usurf->animation.anima = animaid;
249 uifw_trace("ico_window_animation: show(in) %s.%08x anima=%d",
250 usurf->uclient->appid, usurf->surfaceid, animaid);
251 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
253 else if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
254 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
255 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_HIDE;
256 animaid = usurf->animation.hide_anima;
257 usurf->animation.anima = animaid;
258 uifw_trace("ico_window_animation: hide(out) %s.%08x anima=%d",
259 usurf->uclient->appid, usurf->surfaceid, animaid);
260 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
261 usurf->animation.visible = ANIMA_HIDE_AT_END;
263 else if (op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
264 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_MOVE;
265 animaid = usurf->animation.move_anima;
266 usurf->animation.anima = animaid;
267 uifw_trace("ico_window_animation: move %s.%08x anima=%d",
268 usurf->uclient->appid, usurf->surfaceid, animaid);
269 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
271 else if (op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
272 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE;
273 animaid = usurf->animation.resize_anima;
274 usurf->animation.anima = animaid;
275 uifw_trace("ico_window_animation: resize %s.%08x anima=%d",
276 usurf->uclient->appid, usurf->surfaceid, animaid);
277 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
280 uifw_trace("ico_window_animation: Op=%d unknown", op);
281 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
283 if ((animaid == ANIMA_SLIDE_TOLEFT) || (animaid == ANIMA_SLIDE_TORIGHT) ||
284 (animaid == ANIMA_SLIDE_TOTOP) || (animaid == ANIMA_SLIDE_TOBOTTOM)) {
285 usurf->animation.animation.frame = animation_slide;
286 usurf->restrain_configure = 1;
287 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
289 else if ((animaid == ANIMA_WIPE_TOLEFT) || (animaid == ANIMA_WIPE_TORIGHT) ||
290 (animaid == ANIMA_WIPE_TOTOP) || (animaid == ANIMA_WIPE_TOBOTTOM)) {
291 usurf->animation.animation.frame = animation_wipe;
292 usurf->restrain_configure = 1;
293 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
295 else if ((animaid == ANIMA_SWING_TOLEFT) || (animaid == ANIMA_SWING_TORIGHT) ||
296 (animaid == ANIMA_SWING_TOTOP) || (animaid == ANIMA_SWING_TOBOTTOM)) {
297 usurf->animation.animation.frame = animation_swing;
298 usurf->restrain_configure = 1;
299 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
301 else if (animaid == ANIMA_FADE) {
302 usurf->animation.animation.frame = animation_fade;
303 usurf->restrain_configure = 1;
304 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
306 else if (animaid == ANIMA_ZOOM) {
307 usurf->animation.animation.frame = animation_zoom;
308 usurf->restrain_configure = 1;
309 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
313 usurf->animation.animation.frame = NULL;
314 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
315 usurf->restrain_configure = 0;
316 usurf->animation.anima = 0;
317 wl_list_remove(&usurf->animation.animation.link);
318 ret = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
320 usurf->animation.type = op;
322 weston_compositor_schedule_repaint(weston_ec);
326 /*--------------------------------------------------------------------------*/
328 * @brief animation_cont: continue animation
330 * @param[in] animation weston animation table
331 * @param[in] output weston output table
332 * @param[in] msecs current time stamp
333 * @return time has come
334 * @retval =0 time has come
335 * @retval >0 time has not yet come(return value is current parcent)
337 /*--------------------------------------------------------------------------*/
339 animation_cont(struct weston_animation *animation, struct weston_output *output,
342 struct uifw_win_surface *usurf;
346 nowsec = weston_compositor_get_time();
348 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
350 if (animation->frame_counter <= 1) {
351 /* first call, initialize */
352 animation->frame_counter = 1;
353 usurf->animation.starttime = nowsec;
354 usurf->animation.current = 1000;
355 if (! usurf->animation.animadata) {
357 usurf->animation.animadata = (void *)free_data;
358 free_data = free_data->next_free;
361 usurf->animation.animadata = (void *)malloc(sizeof(struct animation_data));
363 memset(usurf->animation.animadata, 0, sizeof(struct animation_data));
366 else if (! usurf->animation.animadata) {
367 animation_end(usurf, 0);
371 if (nowsec >= usurf->animation.starttime) {
372 nowsec = nowsec - usurf->animation.starttime; /* elapsed time(ms) */
375 nowsec = (uint32_t)(((long long)0x100000000L) +
376 ((long long)nowsec) - ((long long)usurf->animation.starttime));
378 switch (usurf->animation.state) {
379 case ICO_WINDOW_MGR_ANIMATION_STATE_SHOW:
380 usurf->animation.time = usurf->animation.show_time;
382 case ICO_WINDOW_MGR_ANIMATION_STATE_HIDE:
383 usurf->animation.time = usurf->animation.hide_time;
385 case ICO_WINDOW_MGR_ANIMATION_STATE_MOVE:
386 usurf->animation.time = usurf->animation.move_time;
389 usurf->animation.time = usurf->animation.resize_time;
392 if (usurf->animation.time == 0) {
393 usurf->animation.time = animation_time;
395 if (((output == NULL) && (msecs == 0)) || (nowsec >= ((uint32_t)usurf->animation.time))) {
399 par = (nowsec * 100 + usurf->animation.time / 2) / usurf->animation.time;
400 if (par < 2) par = 2;
403 (abs(usurf->animation.current - par) >=
404 (((1000 * 100) / animation_fps) / usurf->animation.time)) ||
405 ((animation_count > 1) && (par != usurf->animation.current))) {
406 usurf->animation.current = par;
412 /*--------------------------------------------------------------------------*/
414 * @brief animation_end: terminate animation
416 * @param[in] usurf UIFW surface table
417 * @param[in] disp display control(1)/no display(0)
420 /*--------------------------------------------------------------------------*/
422 animation_end(struct uifw_win_surface *usurf, const int disp)
424 struct animation_data *animadata;
426 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
427 animadata = (struct animation_data *)usurf->animation.animadata;
429 if (animation_count > 0) {
434 if (animadata->end_function) {
435 (*animadata->end_function)(&usurf->animation.animation);
437 wl_list_remove(&usurf->animation.animation.link);
438 if (animadata->transform_set) {
439 wl_list_remove(&animadata->transform.link);
440 animadata->transform_set = 0;
442 weston_surface_geometry_dirty(usurf->surface);
445 usurf->restrain_configure = 0;
446 if ((usurf->animation.visible == ANIMA_HIDE_AT_END) &&
447 (usurf->visible != 0)) {
448 ico_window_mgr_set_visible(usurf, 0);
449 weston_surface_damage(usurf->surface);
451 if ((usurf->animation.visible == ANIMA_SHOW_AT_END) &&
452 (usurf->visible == 0)) {
453 ico_window_mgr_set_visible(usurf, 1);
454 weston_surface_damage(usurf->surface);
456 weston_surface_geometry_dirty(usurf->surface);
457 ico_window_mgr_restack_layer(usurf);
459 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
460 if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE) {
461 switch(usurf->animation.type) {
462 case ICO_WINDOW_MGR_ANIMATION_OPHIDE:
463 case ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS:
464 usurf->animation.hide_anima = usurf->animation.next_anima;
466 case ICO_WINDOW_MGR_ANIMATION_OPSHOW:
467 case ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS:
468 usurf->animation.show_anima = usurf->animation.next_anima;
470 case ICO_WINDOW_MGR_ANIMATION_OPMOVE:
471 usurf->animation.move_anima = usurf->animation.next_anima;
473 case ICO_WINDOW_MGR_ANIMATION_OPRESIZE:
474 usurf->animation.resize_anima = usurf->animation.next_anima;
479 usurf->animation.next_anima = ICO_WINDOW_MGR_ANIMATION_NONE;
482 usurf->animation.animadata = NULL;
483 animadata->next_free = free_data;
484 free_data = animadata;
486 usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE;
488 ico_window_mgr_restack_layer(usurf);
492 /*--------------------------------------------------------------------------*/
494 * @brief animation_slide: slide animation
496 * @param[in] animation weston animation table
497 * @param[in] outout weston output table
498 * @param[in] mseces current time(unused)
501 /*--------------------------------------------------------------------------*/
503 animation_slide(struct weston_animation *animation,
504 struct weston_output *output, uint32_t msecs)
506 struct uifw_win_surface *usurf;
507 struct weston_surface *es;
513 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
515 par = animation_cont(animation, output, msecs);
517 /* continue animation */
519 weston_compositor_schedule_repaint(weston_ec);
523 par = usurf->animation.current;
525 uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d",
526 usurf->surfaceid, animation->frame_counter, par,
527 usurf->animation.anima, usurf->animation.state);
533 switch (usurf->animation.anima) {
534 case ANIMA_SLIDE_TORIGHT: /* slide in left to right */
535 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
536 /* slide in left to right */
537 x = 0 - usurf->animation.pos_width +
538 ((usurf->animation.pos_x + usurf->animation.pos_width) * par / 100);
541 /* slide out right to left */
542 x = 0 - usurf->animation.pos_width +
543 ((usurf->animation.pos_x + usurf->animation.pos_width) * (100 - par) / 100);
546 case ANIMA_SLIDE_TOLEFT: /* slide in right to left */
547 dwidth = usurf->node_tbl->disp_width;
548 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
549 /* slide in right to left */
550 x = usurf->animation.pos_x +
551 (dwidth - usurf->animation.pos_x) * (100 - par) / 100;
554 /* slide out left to right */
555 x = usurf->animation.pos_x + (dwidth - usurf->animation.pos_x) * par / 100;
558 case ANIMA_SLIDE_TOBOTTOM: /* slide in top to bottom */
559 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
560 /* slide in top to bottom */
561 y = 0 - usurf->animation.pos_height +
562 ((usurf->animation.pos_y + usurf->animation.pos_height) * par / 100);
565 /* slide out bottom to top */
566 y = 0 - usurf->animation.pos_height +
567 ((usurf->animation.pos_y + usurf->animation.pos_height) * (100 - par) / 100);
570 default: /*ANIMA_SLIDE_TOTOP*/ /* slide in bottom to top */
571 dheight = usurf->node_tbl->disp_height;
572 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
573 /* slide in bottom to top */
574 y = usurf->animation.pos_y +
575 (dheight - usurf->animation.pos_y) * (100 - par) / 100;
578 /* slide out top to bottom */
579 y = usurf->animation.pos_y + (dheight - usurf->animation.pos_y) * par / 100;
584 uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d)",
585 usurf->surfaceid, par, x, y, usurf->x, usurf->y);
586 es->geometry.x = usurf->node_tbl->disp_x + x;
587 es->geometry.y = usurf->node_tbl->disp_y + y;
588 if ((es->output) && (es->buffer_ref.buffer) &&
589 (es->geometry.width > 0) && (es->geometry.height > 0)) {
590 weston_surface_geometry_dirty(es);
591 weston_surface_damage(es);
594 /* end of animation */
595 animation_end(usurf, 1);
596 uifw_trace("animation_slide: End of animation");
599 /* continue animation */
600 weston_compositor_schedule_repaint(weston_ec);
604 /*--------------------------------------------------------------------------*/
606 * @brief animation_wipe: wipe animation
608 * @param[in] animation weston animation table
609 * @param[in] outout weston output table
610 * @param[in] mseces current time(unused)
613 /*--------------------------------------------------------------------------*/
615 animation_wipe(struct weston_animation *animation,
616 struct weston_output *output, uint32_t msecs)
618 struct uifw_win_surface *usurf;
619 struct weston_surface *es;
626 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
628 par = animation_cont(animation, output, msecs);
630 /* continue animation */
632 weston_compositor_schedule_repaint(weston_ec);
636 par = usurf->animation.current;
638 uifw_debug("animation_wipe: %08x count=%d %d%% anima=%d state=%d",
639 usurf->surfaceid, animation->frame_counter, par,
640 usurf->animation.anima, usurf->animation.state);
645 width = usurf->width;
646 height = usurf->width;
649 switch (usurf->animation.anima) {
650 case ANIMA_WIPE_TORIGHT: /* wipe in left to right */
651 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
652 /* wipe in left to right */
653 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
656 /* wipe out right to left */
657 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
659 if (width <= 0) width = 1;
661 case ANIMA_WIPE_TOLEFT: /* wipe in right to left */
662 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
663 /* wipe in right to left */
664 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
667 /* wipe out left to right */
668 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
670 if (width <= 0) width = 1;
671 x = x + (usurf->width - width);
673 case ANIMA_WIPE_TOBOTTOM: /* wipe in top to bottom */
674 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
675 /* wipe in top to bottom */
676 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
679 /* wipe out bottom to top */
680 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
682 if (height <= 0) height = 1;
684 default: /*ANIMA_WIPE_TOTOP*/ /* wipe in bottom to top */
685 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
686 /* wipe in bottom to top */
687 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
690 /* wipe out top to bottom */
691 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
693 if (height <= 0) height = 1;
694 y = y + (usurf->height - height);
699 es->geometry.x = usurf->node_tbl->disp_x + x;
700 es->geometry.y = usurf->node_tbl->disp_y + y;
701 es->geometry.width = width;
702 es->geometry.height = height;
703 if ((es->output) && (es->buffer_ref.buffer)) {
704 weston_surface_geometry_dirty(es);
705 weston_surface_damage(es);
708 /* end of animation */
709 animation_end(usurf, 1);
710 uifw_trace("animation_wipe: End of animation");
713 /* continue animation */
714 weston_compositor_schedule_repaint(weston_ec);
718 /*--------------------------------------------------------------------------*/
720 * @brief animation_swing: swing animation
722 * @param[in] animation weston animation table
723 * @param[in] outout weston output table
724 * @param[in] mseces current time(unused)
727 /*--------------------------------------------------------------------------*/
729 animation_swing(struct weston_animation *animation,
730 struct weston_output *output, uint32_t msecs)
732 struct uifw_win_surface *usurf;
733 struct weston_surface *es;
734 struct animation_data *animadata;
741 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
743 par = animation_cont(animation, output, msecs);
745 /* continue animation */
747 weston_compositor_schedule_repaint(weston_ec);
752 uifw_debug("animation_swing: %08x count=%d %d%% anima=%d state=%d",
753 usurf->surfaceid, animation->frame_counter, par,
754 usurf->animation.anima, usurf->animation.state);
756 animadata = (struct animation_data *)usurf->animation.animadata;
758 par = usurf->animation.current;
759 if (animation->frame_counter == 1) {
760 if (animadata->transform_set == 0) {
761 animadata->transform_set = 1;
762 weston_matrix_init(&animadata->transform.matrix);
763 wl_list_init(&animadata->transform.link);
764 wl_list_insert(&es->geometry.transformation_list,
765 &animadata->transform.link);
767 animadata->end_function = animation_swing_end;
776 switch (usurf->animation.anima) {
777 case ANIMA_SWING_TORIGHT: /* swing in left to right */
778 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
779 /* swing in left to right */
780 scalex = ((float)par + 5.0f) / 105.0f;
783 /* swing out right to left */
784 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
786 if (scalex <= 0.0) scalex = 0.01;
788 case ANIMA_SWING_TOLEFT: /* seing in right to left */
789 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
790 /* swing in right to left */
791 scalex = ((float)par + 5.0f) / 105.0f;
794 /* swing out left to right */
795 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
797 if (scalex <= 0.0) scalex = 0.01;
798 x = x + (int)((float)usurf->width * (1.0f - scalex));
800 case ANIMA_SWING_TOBOTTOM: /* swing in top to bottom */
801 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
802 /* swing in top to bottom */
803 scaley = ((float)par + 5.0f) / 105.0f;
806 /* swing out bottom to top */
807 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
809 if (scaley <= 0.0) scaley = 0.01;
811 default: /*ANIMA_SWING*/ /* swing in bottom to top */
812 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
813 /* wipe in bottom to top */
814 scaley = ((float)par + 5.0f) / 105.0f;
817 /* wipe out top to bottom */
818 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
820 if (scaley <= 0.0) scaley = 0.01;
821 y = y + (int)((float)usurf->height * (1.0f - scaley));
826 es->geometry.x = usurf->node_tbl->disp_x + x;
827 es->geometry.y = usurf->node_tbl->disp_y + y;
828 weston_matrix_init(&animadata->transform.matrix);
829 weston_matrix_translate(&animadata->transform.matrix,
830 -0.5f * usurf->width, -0.5f * usurf->height, 0);
831 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
832 weston_matrix_translate(&animadata->transform.matrix,
833 0.5f * usurf->width, 0.5f * usurf->height, 0);
835 if ((es->output) && (es->buffer_ref.buffer)) {
836 weston_surface_geometry_dirty(es);
837 weston_surface_damage(es);
840 /* end of animation */
841 animation_end(usurf, 1);
842 uifw_trace("animation_swing: End of animation");
845 /* continue animation */
846 weston_compositor_schedule_repaint(weston_ec);
850 /*--------------------------------------------------------------------------*/
852 * @brief animation_swing_end: swing animation end
854 * @param[in] animation weston animation table
857 /*--------------------------------------------------------------------------*/
859 animation_swing_end(struct weston_animation *animation)
861 struct uifw_win_surface *usurf;
862 struct weston_surface *es;
864 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
865 if (usurf && usurf->surface) {
869 if ((es->output) && (es->buffer_ref.buffer)) {
870 weston_surface_damage(es);
875 /*--------------------------------------------------------------------------*/
877 * @brief animation_fade: fade animation
879 * @param[in] animation weston animation table
880 * @param[in] outout weston output table
881 * @param[in] mseces current time(unused)
884 /*--------------------------------------------------------------------------*/
886 animation_fade(struct weston_animation *animation,
887 struct weston_output *output, uint32_t msecs)
889 struct uifw_win_surface *usurf;
890 struct animation_data *animadata;
891 struct weston_surface *es;
894 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
896 par = animation_cont(animation, output, msecs);
898 /* continue animation */
900 weston_compositor_schedule_repaint(weston_ec);
905 animadata = (struct animation_data *)usurf->animation.animadata;
907 par = usurf->animation.current;
908 if (animation->frame_counter == 1) {
909 if (animadata->transform_set == 0) {
910 animadata->transform_set = 1;
911 weston_matrix_init(&animadata->transform.matrix);
912 wl_list_init(&animadata->transform.link);
913 wl_list_insert(&es->geometry.transformation_list,
914 &animadata->transform.link);
916 animadata->end_function = animation_fade_end;
918 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
919 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
920 ico_window_mgr_set_weston_surface(usurf,
921 usurf->animation.pos_x, usurf->animation.pos_y,
922 usurf->animation.pos_width,
923 usurf->animation.pos_height);
927 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
929 es->alpha = ((float)par) / 100.0f;
931 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
933 es->alpha = 1.0f - (((float)par) / 100.0f);
936 /* fade move/resize */
937 if ((par >= 50) || (usurf->animation.ahalf)) {
938 es->alpha = ((float)(par*2 - 100)) / 100.0f;
939 if (usurf->animation.ahalf == 0) {
940 uifw_trace("animation_fade: fade move chaneg to show");
941 usurf->animation.ahalf = 1;
943 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
944 usurf->width, usurf->height);
945 ico_window_mgr_change_surface(usurf,
946 usurf->animation.no_configure ? -1 : 0, 1);
947 ico_window_mgr_restack_layer(usurf);
951 es->alpha = 1.0f - (((float)(par*2)) / 100.0f);
954 if (es->alpha < 0.0) es->alpha = 0.0;
955 else if (es->alpha > 1.0) es->alpha = 1.0;
957 uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
958 usurf->surfaceid, animation->frame_counter, par,
959 es->alpha, usurf->animation.anima, usurf->animation.state);
961 if ((es->output) && (es->buffer_ref.buffer) &&
962 (es->geometry.width > 0) && (es->geometry.height > 0)) {
963 weston_surface_damage(es);
966 /* end of animation */
967 animation_end(usurf, 1);
968 uifw_trace("animation_fade: End of animation");
971 /* continue animation */
972 weston_compositor_schedule_repaint(weston_ec);
976 /*--------------------------------------------------------------------------*/
978 * @brief animation_fade_end: fade animation end
980 * @param[in] animation weston animation table
983 /*--------------------------------------------------------------------------*/
985 animation_fade_end(struct weston_animation *animation)
987 struct uifw_win_surface *usurf;
988 struct weston_surface *es;
990 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
991 if (usurf && usurf->surface) {
995 if ((es->output) && (es->buffer_ref.buffer) &&
996 (es->geometry.width > 0) && (es->geometry.height > 0)) {
997 weston_surface_damage(es);
1002 /*--------------------------------------------------------------------------*/
1004 * @brief animation_zoom: zoom animation
1006 * @param[in] animation weston animation table
1007 * @param[in] outout weston output table
1008 * @param[in] mseces current time(unused)
1011 /*--------------------------------------------------------------------------*/
1013 animation_zoom(struct weston_animation *animation,
1014 struct weston_output *output, uint32_t msecs)
1016 struct uifw_win_surface *usurf;
1017 struct animation_data *animadata;
1018 struct weston_surface *es;
1020 float scalex, scaley;
1024 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1026 par = animation_cont(animation, output, msecs);
1028 /* continue animation */
1030 weston_compositor_schedule_repaint(weston_ec);
1035 animadata = (struct animation_data *)usurf->animation.animadata;
1036 es = usurf->surface;
1037 par = usurf->animation.current;
1038 if (animation->frame_counter == 1) {
1039 if (animadata->transform_set == 0) {
1040 animadata->transform_set = 1;
1041 weston_matrix_init(&animadata->transform.matrix);
1042 wl_list_init(&animadata->transform.link);
1043 wl_list_insert(&es->geometry.transformation_list,
1044 &animadata->transform.link);
1046 animadata->end_function = animation_zoom_end;
1048 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
1049 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1050 ico_window_mgr_set_weston_surface(usurf,
1051 usurf->animation.pos_x, usurf->animation.pos_y,
1052 usurf->animation.pos_width,
1053 usurf->animation.pos_height);
1057 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
1059 scalex = ((float)par + 5.0f) / 105.0f;
1062 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
1064 scalex = 1.0f - (((float)par + 5.0f) / 105.0f);
1068 /* zoom move/resize */
1069 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1070 usurf->width, usurf->height);
1071 ico_window_mgr_change_surface(usurf, usurf->animation.no_configure ? -1 : 0, 1);
1073 fu = (float)usurf->width;
1074 fa = (float)usurf->animation.pos_width;
1075 fp = (100.0f - (float)par) / 100.0f;
1076 scalex = (fu - (fu - fa) * fp) / fu;
1077 fu = (float)usurf->height;
1078 fa = (float)usurf->animation.pos_height;
1079 scaley = (fu - (fu - fa) * fp) / fu;
1081 x = (((float)usurf->animation.pos_x) - ((float)usurf->x)) * fp + (float)usurf->x
1082 + (((float)usurf->width * scalex) - (float)usurf->width) / 2.0f;
1083 y = (((float)usurf->animation.pos_y) - ((float)usurf->y)) * fp + (float)usurf->y
1084 + (((float)usurf->height * scaley) - (float) usurf->height) / 2.0f;
1085 uifw_trace("animation_zoom: %08x %d%% x=%d/%d y=%d/%d",
1086 usurf->surfaceid, par, x, usurf->x, y, usurf->y);
1087 uifw_trace("animation_zoom: sx=%4.2f sy=%4.2f x=%d->%d y=%d->%d cur=%d,%d",
1088 scalex, scaley, usurf->animation.pos_x, usurf->x,
1089 usurf->animation.pos_y, usurf->y, x, y);
1090 ico_window_mgr_set_weston_surface(usurf, x, y, usurf->width, usurf->height);
1092 weston_matrix_init(&animadata->transform.matrix);
1093 weston_matrix_translate(&animadata->transform.matrix,
1094 -0.5f * usurf->width, -0.5f * usurf->height, 0);
1095 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
1096 weston_matrix_translate(&animadata->transform.matrix,
1097 0.5f * usurf->width, 0.5f * usurf->height, 0);
1099 uifw_trace("animation_zoom: %08x count=%d %d%% w=%d/%d h=%d/%d anima=%d state=%d",
1100 usurf->surfaceid, animation->frame_counter, par,
1101 (int)(usurf->width * scalex), usurf->width,
1102 (int)(usurf->height * scaley), usurf->height,
1103 usurf->animation.anima, usurf->animation.state);
1105 if ((es->output) && (es->buffer_ref.buffer) &&
1106 (es->geometry.width > 0) && (es->geometry.height > 0)) {
1107 weston_surface_geometry_dirty(es);
1108 weston_surface_damage(es);
1111 /* end of animation */
1112 animation_end(usurf, 1);
1113 uifw_trace("animation_zoom: End of animation");
1116 /* continue animation */
1117 weston_compositor_schedule_repaint(weston_ec);
1121 /*--------------------------------------------------------------------------*/
1123 * @brief animation_zoom_end: zoom animation end
1125 * @param[in] animation weston animation table
1128 /*--------------------------------------------------------------------------*/
1130 animation_zoom_end(struct weston_animation *animation)
1132 struct uifw_win_surface *usurf;
1133 struct weston_surface *es;
1135 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1136 if (usurf && usurf->surface) {
1137 es = usurf->surface;
1140 if ((es->output) && (es->buffer_ref.buffer) &&
1141 (es->geometry.width > 0) && (es->geometry.height > 0)) {
1142 weston_surface_damage(es);
1147 /*--------------------------------------------------------------------------*/
1149 * @brief module_init: initialize ico_window_animation
1150 * this function called from ico_pluign_loader
1152 * @param[in] es weston compositor
1153 * @param[in] argc number of arguments(unused)
1154 * @param[in] argv argument list(unused)
1159 /*--------------------------------------------------------------------------*/
1161 module_init(struct weston_compositor *ec, int *argc, char *argv[])
1164 struct animation_data *animadata;
1166 uifw_info("ico_window_animation: Enter(module_init)");
1168 /* allocate animation datas */
1170 for (i = 0; i < 50; i++) {
1171 animadata = (struct animation_data *)malloc(sizeof(struct animation_data));
1173 uifw_error("ico_window_animation: No Memory(module_init)");
1176 animadata->next_free = free_data;
1177 free_data = animadata;
1181 default_animation = (char *)ico_ivi_default_animation_name();
1182 animation_time = ico_ivi_default_animation_time();
1183 animation_fps = ico_ivi_default_animation_fps();
1184 animation_count = 0;
1186 ico_window_mgr_set_hook_animation(ico_window_animation);
1188 uifw_info("ico_window_animation: Leave(module_init)");