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>
42 #include <weston/ivi-layout-export.h>
43 #include "ico_ivi_common_private.h"
44 #include "ico_window_mgr_private.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 */
63 struct animation_data {
64 struct animation_data *next_free; /* free data list */
65 char transform_set; /* need transform reset at end */
66 char res[3]; /* (unused) */
67 struct weston_transform transform; /* transform matrix */
68 void (*end_function)(struct weston_animation *animation);
69 /* animation end function */
72 /* static valiables */
73 static struct weston_compositor *weston_ec; /* Weston compositor */
74 static char *default_animation; /* default animation name */
75 static int animation_fps; /* animation frame rate(frame/sec) */
76 static int animation_time; /* default animation time(ms) */
77 static int animation_count; /* current number of animations */
78 static struct animation_data *free_data; /* free data list */
80 /* support animation names */
81 static const struct _supprt_animaetions {
84 } supprt_animaetions[] = {
85 { "fade", ANIMA_FADE },
86 { "zoom", ANIMA_ZOOM },
87 { "slide", ANIMA_SLIDE_TOTOP },
88 { "slide.toleft", ANIMA_SLIDE_TOLEFT },
89 { "slide.toright", ANIMA_SLIDE_TORIGHT },
90 { "slide.totop", ANIMA_SLIDE_TOTOP },
91 { "slide.tobottom", ANIMA_SLIDE_TOBOTTOM },
92 { "wipe", ANIMA_WIPE_TOTOP },
93 { "wipe.toleft", ANIMA_WIPE_TOLEFT },
94 { "wipe.toright", ANIMA_WIPE_TORIGHT },
95 { "wipe.totop", ANIMA_WIPE_TOTOP },
96 { "wipe.tobottom", ANIMA_WIPE_TOBOTTOM },
97 { "swing", ANIMA_SWING_TOTOP },
98 { "swing.toleft", ANIMA_SWING_TOLEFT },
99 { "swing.toright", ANIMA_SWING_TORIGHT },
100 { "swing.totop", ANIMA_SWING_TOTOP },
101 { "swing.tobottom", ANIMA_SWING_TOBOTTOM },
105 /* static function */
106 /* slide animation */
107 static void animation_slide(struct weston_animation *animation,
108 struct weston_output *output, uint32_t msecs);
110 static void animation_wipe(struct weston_animation *animation,
111 struct weston_output *output, uint32_t msecs);
112 /* swing animation */
113 static void animation_swing(struct weston_animation *animation,
114 struct weston_output *output, uint32_t msecs);
115 /* swing animation end */
116 static void animation_swing_end(struct weston_animation *animation);
118 static void animation_fade(struct weston_animation *animation,
119 struct weston_output *output, uint32_t msecs);
120 /* fade animation end */
121 static void animation_fade_end(struct weston_animation *animation);
122 /* slide animation end */
123 static void animation_slide_end(struct weston_animation *animation);
125 static void animation_zoom(struct weston_animation *animation,
126 struct weston_output *output, uint32_t msecs);
127 /* zoom animation end */
128 static void animation_zoom_end(struct weston_animation *animation);
129 /* continue animation */
130 static int animation_cont(struct weston_animation *animation,
131 struct weston_output *output, uint32_t msecs);
132 /* terminate animation */
133 static void animation_end(struct uifw_win_surface *usurf, const int disp);
135 /*--------------------------------------------------------------------------*/
137 * @brief ico_window_animation: Animation addin entry
139 * @param[in] op animation operation
140 * @param[in] data data
142 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMA success
143 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL success(no control)
144 * @retval ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA error(no animation)
146 /*--------------------------------------------------------------------------*/
148 ico_window_animation(const int op, void *data)
150 struct uifw_win_surface *usurf;
151 struct weston_output *output;
157 if (op == ICO_WINDOW_MGR_ANIMATION_NAME) {
158 /* convert animation name to animation type value */
159 for (idx = 0; supprt_animaetions[idx].animaid > 0; idx++) {
160 if (strcasecmp(supprt_animaetions[idx].name, (char *)data) == 0) {
161 uifw_trace("ico_window_animation: Type %s(%d)",
162 (char *)data, supprt_animaetions[idx].animaid);
163 return supprt_animaetions[idx].animaid;
166 uifw_warn("ico_window_animation: Unknown Type %s", (char *)data);
167 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
170 usurf = (struct uifw_win_surface *)data;
172 if (op == ICO_WINDOW_MGR_ANIMATION_DESTROY) {
173 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
174 (usurf->animation.animadata != NULL)) {
175 uifw_trace("ico_window_animation: Destroy %08x", usurf->surfaceid);
176 animation_end(usurf, 0);
178 return ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
181 usurf->animation.visible = ICO_WINDOW_MGR_ANIMA_NOCONTROL_AT_END;
183 if (op == ICO_WINDOW_MGR_ANIMATION_OPCANCEL) {
184 /* cancel animation */
185 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
186 (usurf->animation.animation.frame != NULL)) {
187 uifw_trace("ico_window_animation: cancel %s.%08x",
188 usurf->uclient->appid, usurf->surfaceid);
189 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 0);
191 animation_end(usurf, 1);
192 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
195 /* setup animation */
196 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
197 (usurf->animation.current > 95)) {
198 usurf->animation.animation.frame_counter = 1;
199 usurf->animation.current = 0;
200 usurf->animation.ahalf = 0;
201 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) {
202 wl_list_init(&usurf->animation.animation.link);
203 output = container_of(weston_ec->output_list.next,
204 struct weston_output, link);
205 wl_list_insert(output->animation_list.prev,
206 &usurf->animation.animation.link);
210 else if (((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) &&
211 ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
212 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS))) ||
213 ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) &&
214 ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
215 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)))) {
216 /* change ...In(ex.FadeIn) to ...Out(FadeOut) or ...Out to ...In */
217 nowsec = weston_compositor_get_time();
218 usurf->animation.current = 100 - usurf->animation.current;
219 if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE)||
220 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
221 usurf->animation.time = usurf->animation.hide_time;
224 usurf->animation.time = usurf->animation.show_time;
226 if (usurf->animation.time == 0) {
227 usurf->animation.time = animation_time;
229 ret = ((usurf->animation.current) * usurf->animation.time) / 100;
230 if (nowsec >= (uint32_t)ret) {
231 usurf->animation.starttime = nowsec - ret;
234 usurf->animation.starttime = ((long long)nowsec) + ((long long)0x100000000L)
237 usurf->animation.animation.frame_counter = 2;
240 /* set animation function */
241 if ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
242 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
243 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_SHOW;
244 animaid = usurf->animation.show_anima;
245 usurf->animation.anima = animaid;
246 uifw_trace("ico_window_animation: show(in) %s.%08x anima=%d",
247 usurf->uclient->appid, usurf->surfaceid, animaid);
248 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
250 else if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
251 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
252 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_HIDE;
253 animaid = usurf->animation.hide_anima;
254 usurf->animation.anima = animaid;
255 uifw_trace("ico_window_animation: hide(out) %s.%08x anima=%d",
256 usurf->uclient->appid, usurf->surfaceid, animaid);
257 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
258 usurf->animation.visible = ICO_WINDOW_MGR_ANIMA_HIDE_AT_END;
260 else if (op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
261 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_MOVE;
262 animaid = usurf->animation.move_anima;
263 usurf->animation.anima = animaid;
264 uifw_trace("ico_window_animation: move %s.%08x anima=%d",
265 usurf->uclient->appid, usurf->surfaceid, animaid);
266 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
268 else if (op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
269 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE;
270 animaid = usurf->animation.resize_anima;
271 usurf->animation.anima = animaid;
272 uifw_trace("ico_window_animation: resize %s.%08x anima=%d",
273 usurf->uclient->appid, usurf->surfaceid, animaid);
274 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
277 uifw_trace("ico_window_animation: Op=%d unknown", op);
278 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
280 if ((animaid == ANIMA_SLIDE_TOLEFT) || (animaid == ANIMA_SLIDE_TORIGHT) ||
281 (animaid == ANIMA_SLIDE_TOTOP) || (animaid == ANIMA_SLIDE_TOBOTTOM)) {
282 usurf->animation.animation.frame = animation_slide;
283 usurf->restrain_configure = 1;
284 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
286 else if ((animaid == ANIMA_WIPE_TOLEFT) || (animaid == ANIMA_WIPE_TORIGHT) ||
287 (animaid == ANIMA_WIPE_TOTOP) || (animaid == ANIMA_WIPE_TOBOTTOM)) {
288 usurf->animation.animation.frame = animation_wipe;
289 usurf->restrain_configure = 1;
290 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
292 else if ((animaid == ANIMA_SWING_TOLEFT) || (animaid == ANIMA_SWING_TORIGHT) ||
293 (animaid == ANIMA_SWING_TOTOP) || (animaid == ANIMA_SWING_TOBOTTOM)) {
294 usurf->animation.animation.frame = animation_swing;
295 usurf->restrain_configure = 1;
296 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
298 else if (animaid == ANIMA_FADE) {
299 usurf->animation.animation.frame = animation_fade;
300 usurf->restrain_configure = 1;
301 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
303 else if (animaid == ANIMA_ZOOM) {
304 usurf->animation.animation.frame = animation_zoom;
305 usurf->restrain_configure = 1;
306 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
310 usurf->animation.animation.frame = NULL;
311 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
312 usurf->restrain_configure = 0;
313 usurf->animation.anima = 0;
314 wl_list_remove(&usurf->animation.animation.link);
315 ret = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
316 if (usurf->org_animation.saved) {
317 usurf->animation.type = usurf->org_animation.type;
318 usurf->animation.anima = usurf->org_animation.anima;
319 usurf->animation.next_anima = usurf->org_animation.next_anima;
320 usurf->animation.hide_anima = usurf->org_animation.hide_anima;
321 usurf->animation.hide_time = usurf->org_animation.hide_time;
322 usurf->animation.show_anima = usurf->org_animation.show_anima;
323 usurf->animation.show_time = usurf->org_animation.show_time;
324 usurf->animation.move_anima = usurf->org_animation.move_anima;
325 usurf->animation.move_time = usurf->org_animation.move_time;
326 usurf->animation.resize_anima = usurf->org_animation.resize_anima;
327 usurf->animation.resize_time = usurf->org_animation.resize_time;
328 usurf->org_animation.saved = 0;
331 usurf->animation.type = op;
332 #if PERFORMANCE_EVALUATIONS > 0
333 if (ret != ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) {
334 uifw_perf("SWAP_BUFFER Start Animation appid=%s surface=%08x anima=%d",
335 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
337 #endif /*PERFORMANCE_EVALUATIONS*/
339 weston_compositor_schedule_repaint(weston_ec);
343 /*--------------------------------------------------------------------------*/
345 * @brief animation_cont: continue animation
347 * @param[in] animation weston animation table
348 * @param[in] output weston output table
349 * @param[in] msecs current time stamp
350 * @return time has come
351 * @retval =0 time has come
352 * @retval >0 time has not yet come(return value is current parcent)
354 /*--------------------------------------------------------------------------*/
356 animation_cont(struct weston_animation *animation, struct weston_output *output,
359 struct uifw_win_surface *usurf;
363 nowsec = weston_compositor_get_time();
365 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
367 if (animation->frame_counter <= 1) {
368 /* first call, initialize */
369 animation->frame_counter = 1;
370 usurf->animation.starttime = nowsec;
371 usurf->animation.current = 1000;
372 if (! usurf->animation.animadata) {
374 usurf->animation.animadata = (void *)free_data;
375 free_data = free_data->next_free;
378 usurf->animation.animadata = (void *)malloc(sizeof(struct animation_data));
380 memset(usurf->animation.animadata, 0, sizeof(struct animation_data));
383 else if (! usurf->animation.animadata) {
384 animation_end(usurf, 0);
388 if (nowsec >= usurf->animation.starttime) {
389 nowsec = nowsec - usurf->animation.starttime; /* elapsed time(ms) */
392 nowsec = (uint32_t)(((long long)0x100000000L) +
393 ((long long)nowsec) - ((long long)usurf->animation.starttime));
395 switch (usurf->animation.state) {
396 case ICO_WINDOW_MGR_ANIMATION_STATE_SHOW:
397 usurf->animation.time = usurf->animation.show_time;
399 case ICO_WINDOW_MGR_ANIMATION_STATE_HIDE:
400 usurf->animation.time = usurf->animation.hide_time;
402 case ICO_WINDOW_MGR_ANIMATION_STATE_MOVE:
403 usurf->animation.time = usurf->animation.move_time;
406 usurf->animation.time = usurf->animation.resize_time;
409 if (usurf->animation.time == 0) {
410 usurf->animation.time = animation_time;
412 if (((output == NULL) && (msecs == 0)) || (nowsec >= ((uint32_t)usurf->animation.time))) {
416 par = (nowsec * 100 + usurf->animation.time / 2) / usurf->animation.time;
417 if (par < 2) par = 2;
420 (abs(usurf->animation.current - par) >=
421 (((1000 * 100) / animation_fps) / usurf->animation.time)) ||
422 ((animation_count > 1) && (par != usurf->animation.current))) {
423 usurf->animation.current = par;
429 /*--------------------------------------------------------------------------*/
431 * @brief animation_end: terminate animation
433 * @param[in] usurf UIFW surface table
434 * @param[in] disp display control(1)/no display(0)
437 /*--------------------------------------------------------------------------*/
439 animation_end(struct uifw_win_surface *usurf, const int disp)
441 struct animation_data *animadata;
442 struct weston_view *ev;
444 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
445 if (usurf->org_animation.saved) {
446 usurf->animation.type = usurf->org_animation.type;
447 usurf->animation.anima = usurf->org_animation.anima;
448 usurf->animation.next_anima = usurf->org_animation.next_anima;
449 usurf->animation.hide_anima = usurf->org_animation.hide_anima;
450 usurf->animation.hide_time = usurf->org_animation.hide_time;
451 usurf->animation.show_anima = usurf->org_animation.show_anima;
452 usurf->animation.show_time = usurf->org_animation.show_time;
453 usurf->animation.move_anima = usurf->org_animation.move_anima;
454 usurf->animation.move_time = usurf->org_animation.move_time;
455 usurf->animation.resize_anima = usurf->org_animation.resize_anima;
456 usurf->animation.resize_time = usurf->org_animation.resize_time;
457 usurf->org_animation.saved = 0;
459 animadata = (struct animation_data *)usurf->animation.animadata;
461 if (animation_count > 0) {
464 ev = ico_ivi_get_primary_view(usurf);
467 if (animadata->end_function) {
468 (*animadata->end_function)(&usurf->animation.animation);
470 wl_list_remove(&usurf->animation.animation.link);
471 if (animadata->transform_set) {
472 wl_list_remove(&animadata->transform.link);
473 animadata->transform_set = 0;
476 weston_view_geometry_dirty(ev);
480 uifw_trace("animation_end: %08x vis=%d(%x)",
481 usurf->surfaceid, usurf->visible, usurf->animation.visible);
482 usurf->internal_propchange |= 0x10;
483 if ((usurf->animation.visible == ICO_WINDOW_MGR_ANIMA_HIDE_AT_END) &&
484 (usurf->visible != 0)) {
486 ivi_layout_surface_set_visibility(usurf->ivisurf, 0);
487 ivi_layout_commit_changes();
488 weston_surface_damage(usurf->surface);
490 weston_view_geometry_dirty(ev);
493 if ((usurf->animation.visible == ICO_WINDOW_MGR_ANIMA_SHOW_AT_END) &&
494 (usurf->visible == 0)) {
496 ivi_layout_surface_set_visibility(usurf->ivisurf, 1);
497 ivi_layout_commit_changes();
498 weston_surface_damage(usurf->surface);
500 weston_view_geometry_dirty(ev);
503 usurf->internal_propchange &= ~0x10;
504 usurf->restrain_configure = 0;
506 usurf->animation.visible = ICO_WINDOW_MGR_ANIMA_NOCONTROL_AT_END;
507 if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE) {
508 switch(usurf->animation.type) {
509 case ICO_WINDOW_MGR_ANIMATION_OPHIDE:
510 case ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS:
511 usurf->animation.hide_anima = usurf->animation.next_anima;
513 case ICO_WINDOW_MGR_ANIMATION_OPSHOW:
514 case ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS:
515 usurf->animation.show_anima = usurf->animation.next_anima;
517 case ICO_WINDOW_MGR_ANIMATION_OPMOVE:
518 usurf->animation.move_anima = usurf->animation.next_anima;
520 case ICO_WINDOW_MGR_ANIMATION_OPRESIZE:
521 usurf->animation.resize_anima = usurf->animation.next_anima;
526 usurf->animation.next_anima = ICO_WINDOW_MGR_ANIMATION_NONE;
529 usurf->animation.animadata = NULL;
530 animadata->next_free = free_data;
531 free_data = animadata;
533 usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE;
534 #if PERFORMANCE_EVALUATIONS > 0
535 uifw_perf("SWAP_BUFFER End Animation appid=%s surface=%08x anima=%d",
536 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
537 #endif /*PERFORMANCE_EVALUATIONS*/
540 /*--------------------------------------------------------------------------*/
542 * @brief animation_slide: slide animation
544 * @param[in] animation weston animation table
545 * @param[in] outout weston output table
546 * @param[in] mseces current time(unused)
549 /*--------------------------------------------------------------------------*/
551 animation_slide(struct weston_animation *animation,
552 struct weston_output *output, uint32_t msecs)
554 struct uifw_win_surface *usurf;
555 struct animation_data *animadata;
556 const struct ivi_layout_surface_properties *prop;
560 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
562 par = animation_cont(animation, output, msecs);
564 /* continue animation */
566 weston_compositor_schedule_repaint(weston_ec);
570 if (animation->frame_counter == 1) {
571 animadata = (struct animation_data *)usurf->animation.animadata;
572 animadata->end_function = animation_slide_end;
574 par = usurf->animation.current;
576 uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d",
577 usurf->surfaceid, animation->frame_counter, par,
578 usurf->animation.anima, usurf->animation.state);
583 switch (usurf->animation.anima) {
584 case ANIMA_SLIDE_TORIGHT: /* slide in left to right */
585 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
586 /* slide in left to right */
587 x = 0 - usurf->animation.pos_width +
588 ((usurf->animation.pos_x + usurf->animation.pos_width) * par / 100);
591 /* slide out right to left */
592 x = 0 - usurf->animation.pos_width +
593 ((usurf->animation.pos_x + usurf->animation.pos_width) * (100 - par) / 100);
596 case ANIMA_SLIDE_TOLEFT: /* slide in right to left */
597 dwidth = usurf->node_tbl->disp_width;
598 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
599 /* slide in right to left */
600 x = usurf->animation.pos_x +
601 (dwidth - usurf->animation.pos_x) * (100 - par) / 100;
604 /* slide out left to right */
605 x = usurf->animation.pos_x + (dwidth - usurf->animation.pos_x) * par / 100;
608 case ANIMA_SLIDE_TOBOTTOM: /* slide in top to bottom */
609 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
610 /* slide in top to bottom */
611 y = 0 - usurf->animation.pos_height +
612 ((usurf->animation.pos_y + usurf->animation.pos_height) * par / 100);
615 /* slide out bottom to top */
616 y = 0 - usurf->animation.pos_height +
617 ((usurf->animation.pos_y + usurf->animation.pos_height) * (100 - par) / 100);
620 default: /*ANIMA_SLIDE_TOTOP*/ /* slide in bottom to top */
621 dheight = usurf->node_tbl->disp_height;
622 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
623 /* slide in bottom to top */
624 y = usurf->animation.pos_y +
625 (dheight - usurf->animation.pos_y) * (100 - par) / 100;
628 /* slide out top to bottom */
629 y = usurf->animation.pos_y + (dheight - usurf->animation.pos_y) * par / 100;
633 if ((par < 8) || (par > 92)) {
634 uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d) %08x",
635 usurf->surfaceid, par, x, y, usurf->x, usurf->y, (int)usurf->ivisurf);
637 if ((prop = ivi_layout_get_properties_of_surface(usurf->ivisurf))) {
638 usurf->internal_propchange |= 0x20;
639 if (ivi_layout_surface_set_destination_rectangle(usurf->ivisurf, x, y,
640 prop->dest_width, prop->dest_height) == 0) {
641 ivi_layout_commit_changes();
643 usurf->internal_propchange &= ~0x20;
646 /* end of animation */
647 animation_end(usurf, 1);
648 uifw_trace("animation_slide: End of animation");
651 /* continue animation */
652 weston_compositor_schedule_repaint(weston_ec);
656 /*--------------------------------------------------------------------------*/
658 * @brief animation_slide_end: slide animation end
660 * @param[in] animation weston animation table
663 /*--------------------------------------------------------------------------*/
665 animation_slide_end(struct weston_animation *animation)
667 struct uifw_win_surface *usurf;
669 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
671 ico_window_mgr_set_weston_surface(usurf,
672 usurf->animation.pos_x, usurf->animation.pos_y,
673 usurf->animation.pos_width,
674 usurf->animation.pos_height);
678 /*--------------------------------------------------------------------------*/
680 * @brief animation_wipe: wipe animation
682 * @param[in] animation weston animation table
683 * @param[in] outout weston output table
684 * @param[in] mseces current time(unused)
687 /*--------------------------------------------------------------------------*/
689 animation_wipe(struct weston_animation *animation,
690 struct weston_output *output, uint32_t msecs)
692 struct uifw_win_surface *usurf;
693 struct weston_surface *es;
694 struct weston_view *ev;
701 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
703 par = animation_cont(animation, output, msecs);
705 /* continue animation */
707 weston_compositor_schedule_repaint(weston_ec);
711 ev = ico_ivi_get_primary_view(usurf);
712 par = usurf->animation.current;
714 uifw_debug("animation_wipe: %08x count=%d %d%% anima=%d state=%d",
715 usurf->surfaceid, animation->frame_counter, par,
716 usurf->animation.anima, usurf->animation.state);
721 width = usurf->width;
722 height = usurf->width;
725 switch (usurf->animation.anima) {
726 case ANIMA_WIPE_TORIGHT: /* wipe in left to right */
727 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
728 /* wipe in left to right */
729 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
732 /* wipe out right to left */
733 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
735 if (width <= 0) width = 1;
737 case ANIMA_WIPE_TOLEFT: /* wipe in right to left */
738 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
739 /* wipe in right to left */
740 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
743 /* wipe out left to right */
744 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
746 if (width <= 0) width = 1;
747 x = x + (usurf->width - width);
749 case ANIMA_WIPE_TOBOTTOM: /* wipe in top to bottom */
750 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
751 /* wipe in top to bottom */
752 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
755 /* wipe out bottom to top */
756 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
758 if (height <= 0) height = 1;
760 default: /*ANIMA_WIPE_TOTOP*/ /* wipe in bottom to top */
761 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
762 /* wipe in bottom to top */
763 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
766 /* wipe out top to bottom */
767 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
769 if (height <= 0) height = 1;
770 y = y + (usurf->height - height);
778 ev->geometry.x = usurf->node_tbl->disp_x + x;
779 ev->geometry.y = usurf->node_tbl->disp_y + y;
780 if ((ev->output) && (es->buffer_ref.buffer)) {
781 weston_view_geometry_dirty(ev);
782 weston_surface_damage(es);
786 /* end of animation */
787 animation_end(usurf, 1);
788 uifw_trace("animation_wipe: End of animation");
791 /* continue animation */
792 weston_compositor_schedule_repaint(weston_ec);
796 /*--------------------------------------------------------------------------*/
798 * @brief animation_swing: swing animation
800 * @param[in] animation weston animation table
801 * @param[in] outout weston output table
802 * @param[in] mseces current time(unused)
805 /*--------------------------------------------------------------------------*/
807 animation_swing(struct weston_animation *animation,
808 struct weston_output *output, uint32_t msecs)
810 struct uifw_win_surface *usurf;
811 struct weston_surface *es;
812 struct weston_view *ev;
813 struct animation_data *animadata;
820 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
822 par = animation_cont(animation, output, msecs);
824 /* continue animation */
826 weston_compositor_schedule_repaint(weston_ec);
831 uifw_debug("animation_swing: %08x count=%d %d%% anima=%d state=%d",
832 usurf->surfaceid, animation->frame_counter, par,
833 usurf->animation.anima, usurf->animation.state);
835 animadata = (struct animation_data *)usurf->animation.animadata;
837 ev = ico_ivi_get_primary_view(usurf);
838 par = usurf->animation.current;
839 if (animation->frame_counter == 1) {
840 if (animadata->transform_set == 0) {
841 animadata->transform_set = 1;
842 weston_matrix_init(&animadata->transform.matrix);
843 wl_list_init(&animadata->transform.link);
845 wl_list_insert(&ev->geometry.transformation_list,
846 &animadata->transform.link);
849 animadata->end_function = animation_swing_end;
858 switch (usurf->animation.anima) {
859 case ANIMA_SWING_TORIGHT: /* swing in left to right */
860 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
861 /* swing in left to right */
862 scalex = ((float)par + 5.0f) / 105.0f;
865 /* swing out right to left */
866 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
868 if (scalex <= 0.0) scalex = 0.01;
870 case ANIMA_SWING_TOLEFT: /* seing in right to left */
871 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
872 /* swing in right to left */
873 scalex = ((float)par + 5.0f) / 105.0f;
876 /* swing out left to right */
877 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
879 if (scalex <= 0.0) scalex = 0.01;
880 x = x + (int)((float)usurf->width * (1.0f - scalex));
882 case ANIMA_SWING_TOBOTTOM: /* swing in top to bottom */
883 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
884 /* swing in top to bottom */
885 scaley = ((float)par + 5.0f) / 105.0f;
888 /* swing out bottom to top */
889 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
891 if (scaley <= 0.0) scaley = 0.01;
893 default: /*ANIMA_SWING*/ /* swing in bottom to top */
894 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
895 /* wipe in bottom to top */
896 scaley = ((float)par + 5.0f) / 105.0f;
899 /* wipe out top to bottom */
900 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
902 if (scaley <= 0.0) scaley = 0.01;
903 y = y + (int)((float)usurf->height * (1.0f - scaley));
908 weston_matrix_init(&animadata->transform.matrix);
909 weston_matrix_translate(&animadata->transform.matrix,
910 -0.5f * usurf->width, -0.5f * usurf->height, 0);
911 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
912 weston_matrix_translate(&animadata->transform.matrix,
913 0.5f * usurf->width, 0.5f * usurf->height, 0);
916 ev->geometry.x = usurf->node_tbl->disp_x + x;
917 ev->geometry.y = usurf->node_tbl->disp_y + y;
918 if ((ev->output) && (es->buffer_ref.buffer)) {
919 weston_view_geometry_dirty(ev);
920 weston_surface_damage(es);
924 /* end of animation */
925 animation_end(usurf, 1);
926 uifw_trace("animation_swing: End of animation");
929 /* continue animation */
930 weston_compositor_schedule_repaint(weston_ec);
934 /*--------------------------------------------------------------------------*/
936 * @brief animation_swing_end: swing animation end
938 * @param[in] animation weston animation table
941 /*--------------------------------------------------------------------------*/
943 animation_swing_end(struct weston_animation *animation)
945 struct uifw_win_surface *usurf;
946 struct weston_surface *es;
947 struct weston_view *ev;
949 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
950 if (usurf && usurf->surface) {
952 ev = ico_ivi_get_primary_view(usurf);
954 ev->alpha = usurf->animation.alpha;
955 uifw_debug("animation_swing_end: %08x set alpha=%.2f",
956 usurf->surfaceid, usurf->animation.alpha);
957 if ((ev->output) && (es->buffer_ref.buffer)) {
958 weston_surface_damage(es);
964 /*--------------------------------------------------------------------------*/
966 * @brief animation_fade: fade animation
968 * @param[in] animation weston animation table
969 * @param[in] outout weston output table
970 * @param[in] mseces current time(unused)
973 /*--------------------------------------------------------------------------*/
975 animation_fade(struct weston_animation *animation,
976 struct weston_output *output, uint32_t msecs)
978 struct uifw_win_surface *usurf;
979 struct animation_data *animadata;
980 struct weston_surface *es;
981 struct weston_view *ev;
984 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
986 par = animation_cont(animation, output, msecs);
988 /* continue animation */
990 weston_compositor_schedule_repaint(weston_ec);
995 animadata = (struct animation_data *)usurf->animation.animadata;
997 ev = ico_ivi_get_primary_view(usurf);
998 par = usurf->animation.current;
999 if (animation->frame_counter == 1) {
1000 if (animadata->transform_set == 0) {
1001 animadata->transform_set = 1;
1002 weston_matrix_init(&animadata->transform.matrix);
1003 wl_list_init(&animadata->transform.link);
1005 wl_list_insert(&ev->geometry.transformation_list,
1006 &animadata->transform.link);
1009 animadata->end_function = animation_fade_end;
1011 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
1012 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1013 ico_window_mgr_set_weston_surface(usurf,
1014 usurf->animation.pos_x,
1015 usurf->animation.pos_y,
1016 usurf->animation.pos_width,
1017 usurf->animation.pos_height);
1022 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
1024 ev->alpha = ((float)par) / 100.0f;
1026 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
1028 ev->alpha = 1.0f - (((float)par) / 100.0f);
1031 /* fade move/resize */
1032 if ((par >= 50) || (usurf->animation.ahalf)) {
1033 ev->alpha = ((float)(par*2 - 100)) / 100.0f;
1034 if (usurf->animation.ahalf == 0) {
1035 uifw_trace("animation_fade: fade move chaneg to show");
1036 usurf->animation.ahalf = 1;
1038 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1039 usurf->width, usurf->height);
1043 ev->alpha = 1.0f - (((float)(par*2)) / 100.0f);
1046 if (ev->alpha < 0.0f) ev->alpha = 0.0f;
1047 else if (ev->alpha > 1.0f) ev->alpha = 1.0f;
1049 if ((par < 8) || (par > 92)) {
1050 uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
1051 usurf->surfaceid, animation->frame_counter, par,
1052 ev->alpha, usurf->animation.anima, usurf->animation.state);
1054 if ((ev->output) && (es->buffer_ref.buffer) &&
1055 (es->width > 0) && (es->height > 0)) {
1056 weston_surface_damage(es);
1060 /* end of animation */
1061 animation_end(usurf, 1);
1062 uifw_trace("animation_fade: End of animation");
1065 /* continue animation */
1066 weston_compositor_schedule_repaint(weston_ec);
1070 /*--------------------------------------------------------------------------*/
1072 * @brief animation_fade_end: fade animation end
1074 * @param[in] animation weston animation table
1077 /*--------------------------------------------------------------------------*/
1079 animation_fade_end(struct weston_animation *animation)
1081 struct uifw_win_surface *usurf;
1082 struct weston_surface *es;
1083 struct weston_view *ev;
1085 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1086 if (usurf && usurf->surface) {
1087 es = usurf->surface;
1088 ev = ico_ivi_get_primary_view(usurf);
1090 ev->alpha = usurf->animation.alpha;
1091 uifw_debug("animation_fade_end: %08x set alpha=%.2f",
1092 usurf->surfaceid, usurf->animation.alpha);
1093 if ((ev->output) && (es->buffer_ref.buffer) &&
1094 (es->width > 0) && (es->height > 0)) {
1095 weston_surface_damage(es);
1101 /*--------------------------------------------------------------------------*/
1103 * @brief animation_zoom: zoom animation
1105 * @param[in] animation weston animation table
1106 * @param[in] outout weston output table
1107 * @param[in] mseces current time(unused)
1110 /*--------------------------------------------------------------------------*/
1112 animation_zoom(struct weston_animation *animation,
1113 struct weston_output *output, uint32_t msecs)
1115 struct uifw_win_surface *usurf;
1116 struct animation_data *animadata;
1117 struct weston_surface *es;
1118 struct weston_view *ev;
1120 float scalex, scaley;
1124 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1126 par = animation_cont(animation, output, msecs);
1128 /* continue animation */
1130 weston_compositor_schedule_repaint(weston_ec);
1135 animadata = (struct animation_data *)usurf->animation.animadata;
1136 es = usurf->surface;
1137 ev = ico_ivi_get_primary_view(usurf);
1138 par = usurf->animation.current;
1139 if (animation->frame_counter == 1) {
1140 if (animadata->transform_set == 0) {
1141 animadata->transform_set = 1;
1142 weston_matrix_init(&animadata->transform.matrix);
1143 wl_list_init(&animadata->transform.link);
1145 wl_list_insert(&ev->geometry.transformation_list,
1146 &animadata->transform.link);
1149 animadata->end_function = animation_zoom_end;
1151 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
1152 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1153 ico_window_mgr_set_weston_surface(usurf,
1154 usurf->animation.pos_x, usurf->animation.pos_y,
1155 usurf->animation.pos_width,
1156 usurf->animation.pos_height);
1160 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
1162 scalex = ((float)par + 5.0f) / 105.0f;
1165 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
1167 scalex = 1.0f - (((float)par + 5.0f) / 105.0f);
1171 /* zoom move/resize */
1172 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1173 usurf->width, usurf->height);
1174 fu = (float)usurf->width;
1175 fa = (float)usurf->animation.pos_width;
1176 fp = (100.0f - (float)par) / 100.0f;
1177 scalex = (fu - (fu - fa) * fp) / fu;
1178 fu = (float)usurf->height;
1179 fa = (float)usurf->animation.pos_height;
1180 scaley = (fu - (fu - fa) * fp) / fu;
1182 x = (((float)usurf->animation.pos_x) - ((float)usurf->x)) * fp + (float)usurf->x
1183 + (((float)usurf->width * scalex) - (float)usurf->width) / 2.0f;
1184 y = (((float)usurf->animation.pos_y) - ((float)usurf->y)) * fp + (float)usurf->y
1185 + (((float)usurf->height * scaley) - (float) usurf->height) / 2.0f;
1186 uifw_trace("animation_zoom: %08x %d%% x=%d/%d y=%d/%d",
1187 usurf->surfaceid, par, x, usurf->x, y, usurf->y);
1188 uifw_trace("animation_zoom: sx=%4.2f sy=%4.2f x=%d->%d y=%d->%d cur=%d,%d",
1189 scalex, scaley, usurf->animation.pos_x, usurf->x,
1190 usurf->animation.pos_y, usurf->y, x, y);
1191 ico_window_mgr_set_weston_surface(usurf, x, y, usurf->width, usurf->height);
1193 weston_matrix_init(&animadata->transform.matrix);
1194 weston_matrix_translate(&animadata->transform.matrix,
1195 -0.5f * usurf->width, -0.5f * usurf->height, 0);
1196 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
1197 weston_matrix_translate(&animadata->transform.matrix,
1198 0.5f * usurf->width, 0.5f * usurf->height, 0);
1200 uifw_trace("animation_zoom: %08x count=%d %d%% w=%d/%d h=%d/%d anima=%d state=%d",
1201 usurf->surfaceid, animation->frame_counter, par,
1202 (int)(usurf->width * scalex), usurf->width,
1203 (int)(usurf->height * scaley), usurf->height,
1204 usurf->animation.anima, usurf->animation.state);
1207 if ((ev->output) && (es->buffer_ref.buffer) &&
1208 (es->width > 0) && (es->height > 0)) {
1209 weston_view_geometry_dirty(ev);
1210 weston_surface_damage(es);
1214 /* end of animation */
1215 animation_end(usurf, 1);
1216 uifw_trace("animation_zoom: End of animation");
1219 /* continue animation */
1220 weston_compositor_schedule_repaint(weston_ec);
1224 /*--------------------------------------------------------------------------*/
1226 * @brief animation_zoom_end: zoom animation end
1228 * @param[in] animation weston animation table
1231 /*--------------------------------------------------------------------------*/
1233 animation_zoom_end(struct weston_animation *animation)
1235 struct uifw_win_surface *usurf;
1236 struct weston_surface *es;
1237 struct weston_view *ev;
1239 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1240 if (usurf && usurf->surface) {
1241 es = usurf->surface;
1242 ev = ico_ivi_get_primary_view(usurf);
1244 ev->alpha = usurf->animation.alpha;
1245 if ((ev->output) && (es->buffer_ref.buffer) &&
1246 (es->width > 0) && (es->height > 0)) {
1247 weston_surface_damage(es);
1253 /*--------------------------------------------------------------------------*/
1255 * @brief module_init: initialize ico_window_animation
1256 * this function called from ico_pluign_loader
1258 * @param[in] es weston compositor
1259 * @param[in] argc number of arguments(unused)
1260 * @param[in] argv argument list(unused)
1265 /*--------------------------------------------------------------------------*/
1267 module_init(struct weston_compositor *ec, int *argc, char *argv[])
1270 struct animation_data *animadata;
1272 uifw_info("ico_window_animation: Enter(module_init)");
1274 /* allocate animation datas */
1276 for (i = 0; i < 50; i++) {
1277 animadata = (struct animation_data *)malloc(sizeof(struct animation_data));
1279 uifw_error("ico_window_animation: No Memory(module_init)");
1282 animadata->next_free = free_data;
1283 free_data = animadata;
1287 default_animation = (char *)ico_ivi_default_animation_name();
1288 animation_time = ico_ivi_default_animation_time();
1289 animation_fps = ico_ivi_default_animation_fps();
1290 animation_count = 0;
1292 ico_window_mgr_set_hook_animation(ico_window_animation);
1294 uifw_info("ico_window_animation: Leave(module_init)");