2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Window Animation (Weston(Wayland) PlugIn)
37 #include <sys/types.h>
41 #include <weston/compositor.h>
43 #include <ilm/ilm_types.h>
44 #include <weston/weston-layout.h>
45 #include "ico_ivi_common_private.h"
46 #include "ico_window_mgr_private.h"
49 #define ANIMA_ZOOM 1 /* ZoomIn/ZoomOut */
50 #define ANIMA_FADE 2 /* FadeIn/FadeOut */
51 #define ANIMA_SLIDE_TORIGHT 11 /* SlideIn left to right/SlideOut right to left */
52 #define ANIMA_SLIDE_TOLEFT 12 /* SlideIn right to left/SlideOut left to right */
53 #define ANIMA_SLIDE_TOBOTTOM 13 /* SlideIn top to bottom/SlideOut bottom to top */
54 #define ANIMA_SLIDE_TOTOP 14 /* SlideIn bottom to top/SlideOut top to bottom */
55 #define ANIMA_WIPE_TORIGHT 21 /* WipeIn left to right/WipeOut right to left */
56 #define ANIMA_WIPE_TOLEFT 22 /* WipeIn right to left/WipeOut left to right */
57 #define ANIMA_WIPE_TOBOTTOM 23 /* WipeIn top to bottom/WipeOut bottom to top */
58 #define ANIMA_WIPE_TOTOP 24 /* WipeIn bottom to top/WipeOut top to bottom */
59 #define ANIMA_SWING_TORIGHT 31 /* SwingIn left to right/SwingOut right to left */
60 #define ANIMA_SWING_TOLEFT 32 /* SwingIn right to left/SwingOut left to right */
61 #define ANIMA_SWING_TOBOTTOM 33 /* SwingIn top to bottom/SwingOut bottom to top */
62 #define ANIMA_SWING_TOTOP 34 /* SwingIn bottom to top/SwingOut top to bottom */
64 /* Visible control at end of animation */
65 #define ANIMA_NOCONTROL_AT_END 0 /* no need surface show/hide at end of animation*/
66 #define ANIMA_SHOW_AT_END 1 /* surface show at end of animation */
67 #define ANIMA_HIDE_AT_END 2 /* surface hide at end of animation */
70 struct animation_data {
71 struct animation_data *next_free; /* free data list */
72 char transform_set; /* need transform reset at end */
73 char res[3]; /* (unused) */
74 struct weston_transform transform; /* transform matrix */
75 void (*end_function)(struct weston_animation *animation);
76 /* animation end function */
79 /* static valiables */
80 static struct weston_compositor *weston_ec; /* Weston compositor */
81 static char *default_animation; /* default animation name */
82 static int animation_fps; /* animation frame rate(frame/sec) */
83 static int animation_time; /* default animation time(ms) */
84 static int animation_count; /* current number of animations */
85 static struct animation_data *free_data; /* free data list */
87 /* support animation names */
88 static const struct _supprt_animaetions {
91 } supprt_animaetions[] = {
92 { "fade", ANIMA_FADE },
93 { "zoom", ANIMA_ZOOM },
94 { "slide", ANIMA_SLIDE_TOTOP },
95 { "slide.toleft", ANIMA_SLIDE_TOLEFT },
96 { "slide.toright", ANIMA_SLIDE_TORIGHT },
97 { "slide.totop", ANIMA_SLIDE_TOTOP },
98 { "slide.tobottom", ANIMA_SLIDE_TOBOTTOM },
99 { "wipe", ANIMA_WIPE_TOTOP },
100 { "wipe.toleft", ANIMA_WIPE_TOLEFT },
101 { "wipe.toright", ANIMA_WIPE_TORIGHT },
102 { "wipe.totop", ANIMA_WIPE_TOTOP },
103 { "wipe.tobottom", ANIMA_WIPE_TOBOTTOM },
104 { "swing", ANIMA_SWING_TOTOP },
105 { "swing.toleft", ANIMA_SWING_TOLEFT },
106 { "swing.toright", ANIMA_SWING_TORIGHT },
107 { "swing.totop", ANIMA_SWING_TOTOP },
108 { "swing.tobottom", ANIMA_SWING_TOBOTTOM },
112 /* static function */
113 /* slide animation */
114 static void animation_slide(struct weston_animation *animation,
115 struct weston_output *output, uint32_t msecs);
117 static void animation_wipe(struct weston_animation *animation,
118 struct weston_output *output, uint32_t msecs);
119 /* swing animation */
120 static void animation_swing(struct weston_animation *animation,
121 struct weston_output *output, uint32_t msecs);
122 /* swing animation end */
123 static void animation_swing_end(struct weston_animation *animation);
125 static void animation_fade(struct weston_animation *animation,
126 struct weston_output *output, uint32_t msecs);
127 /* fade animation end */
128 static void animation_fade_end(struct weston_animation *animation);
129 /* slide animation end */
130 static void animation_slide_end(struct weston_animation *animation);
132 static void animation_zoom(struct weston_animation *animation,
133 struct weston_output *output, uint32_t msecs);
134 /* zoom animation end */
135 static void animation_zoom_end(struct weston_animation *animation);
136 /* continue animation */
137 static int animation_cont(struct weston_animation *animation,
138 struct weston_output *output, uint32_t msecs);
139 /* terminate animation */
140 static void animation_end(struct uifw_win_surface *usurf, const int disp);
142 /*--------------------------------------------------------------------------*/
144 * @brief ico_window_animation: Animation addin entry
146 * @param[in] op animation operation
147 * @param[in] data data
149 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMA success
150 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL success(no control)
151 * @retval ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA error(no animation)
153 /*--------------------------------------------------------------------------*/
155 ico_window_animation(const int op, void *data)
157 struct uifw_win_surface *usurf;
158 struct weston_output *output;
164 if (op == ICO_WINDOW_MGR_ANIMATION_NAME) {
165 /* convert animation name to animation type value */
166 for (idx = 0; supprt_animaetions[idx].animaid > 0; idx++) {
167 if (strcasecmp(supprt_animaetions[idx].name, (char *)data) == 0) {
168 uifw_trace("ico_window_animation: Type %s(%d)",
169 (char *)data, supprt_animaetions[idx].animaid);
170 return supprt_animaetions[idx].animaid;
173 uifw_warn("ico_window_animation: Unknown Type %s", (char *)data);
174 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
177 usurf = (struct uifw_win_surface *)data;
179 if (op == ICO_WINDOW_MGR_ANIMATION_DESTROY) {
180 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
181 (usurf->animation.animadata != NULL)) {
182 uifw_trace("ico_window_animation: Destroy %08x", usurf->surfaceid);
183 animation_end(usurf, 0);
185 return ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
188 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
190 if (op == ICO_WINDOW_MGR_ANIMATION_OPCANCEL) {
191 /* cancel animation */
192 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
193 (usurf->animation.animation.frame != NULL)) {
194 uifw_trace("ico_window_animation: cancel %s.%08x",
195 usurf->uclient->appid, usurf->surfaceid);
196 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 0);
198 animation_end(usurf, 1);
199 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
202 /* setup animation */
203 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
204 (usurf->animation.current > 95)) {
205 usurf->animation.animation.frame_counter = 1;
206 usurf->animation.current = 0;
207 usurf->animation.ahalf = 0;
208 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) {
209 wl_list_init(&usurf->animation.animation.link);
210 output = container_of(weston_ec->output_list.next,
211 struct weston_output, link);
212 wl_list_insert(output->animation_list.prev,
213 &usurf->animation.animation.link);
217 else if (((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) &&
218 ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
219 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS))) ||
220 ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) &&
221 ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
222 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)))) {
223 /* change ...In(ex.FadeIn) to ...Out(FadeOut) or ...Out to ...In */
224 nowsec = weston_compositor_get_time();
225 usurf->animation.current = 100 - usurf->animation.current;
226 if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE)||
227 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
228 usurf->animation.time = usurf->animation.hide_time;
231 usurf->animation.time = usurf->animation.show_time;
233 if (usurf->animation.time == 0) {
234 usurf->animation.time = animation_time;
236 ret = ((usurf->animation.current) * usurf->animation.time) / 100;
237 if (nowsec >= (uint32_t)ret) {
238 usurf->animation.starttime = nowsec - ret;
241 usurf->animation.starttime = ((long long)nowsec) + ((long long)0x100000000L)
244 usurf->animation.animation.frame_counter = 2;
247 /* set animation function */
248 if ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
249 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
250 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_SHOW;
251 animaid = usurf->animation.show_anima;
252 usurf->animation.anima = animaid;
253 uifw_trace("ico_window_animation: show(in) %s.%08x anima=%d",
254 usurf->uclient->appid, usurf->surfaceid, animaid);
255 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
257 else if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
258 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
259 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_HIDE;
260 animaid = usurf->animation.hide_anima;
261 usurf->animation.anima = animaid;
262 uifw_trace("ico_window_animation: hide(out) %s.%08x anima=%d",
263 usurf->uclient->appid, usurf->surfaceid, animaid);
264 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
265 usurf->animation.visible = ANIMA_HIDE_AT_END;
267 else if (op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
268 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_MOVE;
269 animaid = usurf->animation.move_anima;
270 usurf->animation.anima = animaid;
271 uifw_trace("ico_window_animation: move %s.%08x anima=%d",
272 usurf->uclient->appid, usurf->surfaceid, animaid);
273 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
275 else if (op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
276 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE;
277 animaid = usurf->animation.resize_anima;
278 usurf->animation.anima = animaid;
279 uifw_trace("ico_window_animation: resize %s.%08x anima=%d",
280 usurf->uclient->appid, usurf->surfaceid, animaid);
281 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
284 uifw_trace("ico_window_animation: Op=%d unknown", op);
285 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
287 if ((animaid == ANIMA_SLIDE_TOLEFT) || (animaid == ANIMA_SLIDE_TORIGHT) ||
288 (animaid == ANIMA_SLIDE_TOTOP) || (animaid == ANIMA_SLIDE_TOBOTTOM)) {
289 usurf->animation.animation.frame = animation_slide;
290 usurf->restrain_configure = 1;
291 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
293 else if ((animaid == ANIMA_WIPE_TOLEFT) || (animaid == ANIMA_WIPE_TORIGHT) ||
294 (animaid == ANIMA_WIPE_TOTOP) || (animaid == ANIMA_WIPE_TOBOTTOM)) {
295 usurf->animation.animation.frame = animation_wipe;
296 usurf->restrain_configure = 1;
297 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
299 else if ((animaid == ANIMA_SWING_TOLEFT) || (animaid == ANIMA_SWING_TORIGHT) ||
300 (animaid == ANIMA_SWING_TOTOP) || (animaid == ANIMA_SWING_TOBOTTOM)) {
301 usurf->animation.animation.frame = animation_swing;
302 usurf->restrain_configure = 1;
303 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
305 else if (animaid == ANIMA_FADE) {
306 usurf->animation.animation.frame = animation_fade;
307 usurf->restrain_configure = 1;
308 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
310 else if (animaid == ANIMA_ZOOM) {
311 usurf->animation.animation.frame = animation_zoom;
312 usurf->restrain_configure = 1;
313 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
317 usurf->animation.animation.frame = NULL;
318 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
319 usurf->restrain_configure = 0;
320 usurf->animation.anima = 0;
321 wl_list_remove(&usurf->animation.animation.link);
322 ret = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
324 usurf->animation.type = op;
325 #if PERFORMANCE_EVALUATIONS > 0
326 if (ret != ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) {
327 uifw_perf("SWAP_BUFFER Start Animation appid=%s surface=%08x anima=%d",
328 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
330 #endif /*PERFORMANCE_EVALUATIONS*/
332 weston_compositor_schedule_repaint(weston_ec);
336 /*--------------------------------------------------------------------------*/
338 * @brief animation_cont: continue animation
340 * @param[in] animation weston animation table
341 * @param[in] output weston output table
342 * @param[in] msecs current time stamp
343 * @return time has come
344 * @retval =0 time has come
345 * @retval >0 time has not yet come(return value is current parcent)
347 /*--------------------------------------------------------------------------*/
349 animation_cont(struct weston_animation *animation, struct weston_output *output,
352 struct uifw_win_surface *usurf;
356 nowsec = weston_compositor_get_time();
358 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
360 if (animation->frame_counter <= 1) {
361 /* first call, initialize */
362 animation->frame_counter = 1;
363 usurf->animation.starttime = nowsec;
364 usurf->animation.current = 1000;
365 if (! usurf->animation.animadata) {
367 usurf->animation.animadata = (void *)free_data;
368 free_data = free_data->next_free;
371 usurf->animation.animadata = (void *)malloc(sizeof(struct animation_data));
373 memset(usurf->animation.animadata, 0, sizeof(struct animation_data));
376 else if (! usurf->animation.animadata) {
377 animation_end(usurf, 0);
381 if (nowsec >= usurf->animation.starttime) {
382 nowsec = nowsec - usurf->animation.starttime; /* elapsed time(ms) */
385 nowsec = (uint32_t)(((long long)0x100000000L) +
386 ((long long)nowsec) - ((long long)usurf->animation.starttime));
388 switch (usurf->animation.state) {
389 case ICO_WINDOW_MGR_ANIMATION_STATE_SHOW:
390 usurf->animation.time = usurf->animation.show_time;
392 case ICO_WINDOW_MGR_ANIMATION_STATE_HIDE:
393 usurf->animation.time = usurf->animation.hide_time;
395 case ICO_WINDOW_MGR_ANIMATION_STATE_MOVE:
396 usurf->animation.time = usurf->animation.move_time;
399 usurf->animation.time = usurf->animation.resize_time;
402 if (usurf->animation.time == 0) {
403 usurf->animation.time = animation_time;
405 if (((output == NULL) && (msecs == 0)) || (nowsec >= ((uint32_t)usurf->animation.time))) {
409 par = (nowsec * 100 + usurf->animation.time / 2) / usurf->animation.time;
410 if (par < 2) par = 2;
413 (abs(usurf->animation.current - par) >=
414 (((1000 * 100) / animation_fps) / usurf->animation.time)) ||
415 ((animation_count > 1) && (par != usurf->animation.current))) {
416 usurf->animation.current = par;
422 /*--------------------------------------------------------------------------*/
424 * @brief animation_end: terminate animation
426 * @param[in] usurf UIFW surface table
427 * @param[in] disp display control(1)/no display(0)
430 /*--------------------------------------------------------------------------*/
432 animation_end(struct uifw_win_surface *usurf, const int disp)
434 struct animation_data *animadata;
435 struct weston_view *ev;
437 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
438 animadata = (struct animation_data *)usurf->animation.animadata;
440 if (animation_count > 0) {
443 ev = ico_ivi_get_primary_view(usurf);
446 if (animadata->end_function) {
447 (*animadata->end_function)(&usurf->animation.animation);
449 wl_list_remove(&usurf->animation.animation.link);
450 if (animadata->transform_set) {
451 wl_list_remove(&animadata->transform.link);
452 animadata->transform_set = 0;
454 weston_view_geometry_dirty(ev);
457 usurf->restrain_configure = 0;
458 uifw_trace("animation_end: %08x vis=%d(%x)",
459 usurf->surfaceid, usurf->visible, usurf->animation.visible);
460 if ((usurf->animation.visible == ANIMA_HIDE_AT_END) &&
461 (usurf->visible != 0)) {
463 weston_layout_surfaceSetVisibility(usurf->ivisurf, 0);
464 weston_layout_commitChanges();
465 weston_surface_damage(usurf->surface);
466 weston_view_geometry_dirty(ev);
468 if ((usurf->animation.visible == ANIMA_SHOW_AT_END) &&
469 (usurf->visible == 0)) {
471 weston_layout_surfaceSetVisibility(usurf->ivisurf, 1);
472 weston_layout_commitChanges();
473 weston_surface_damage(usurf->surface);
474 weston_view_geometry_dirty(ev);
477 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
478 if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE) {
479 switch(usurf->animation.type) {
480 case ICO_WINDOW_MGR_ANIMATION_OPHIDE:
481 case ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS:
482 usurf->animation.hide_anima = usurf->animation.next_anima;
484 case ICO_WINDOW_MGR_ANIMATION_OPSHOW:
485 case ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS:
486 usurf->animation.show_anima = usurf->animation.next_anima;
488 case ICO_WINDOW_MGR_ANIMATION_OPMOVE:
489 usurf->animation.move_anima = usurf->animation.next_anima;
491 case ICO_WINDOW_MGR_ANIMATION_OPRESIZE:
492 usurf->animation.resize_anima = usurf->animation.next_anima;
497 usurf->animation.next_anima = ICO_WINDOW_MGR_ANIMATION_NONE;
500 usurf->animation.animadata = NULL;
501 animadata->next_free = free_data;
502 free_data = animadata;
504 usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE;
505 #if PERFORMANCE_EVALUATIONS > 0
506 uifw_perf("SWAP_BUFFER End Animation appid=%s surface=%08x anima=%d",
507 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
508 #endif /*PERFORMANCE_EVALUATIONS*/
511 /*--------------------------------------------------------------------------*/
513 * @brief animation_slide: slide animation
515 * @param[in] animation weston animation table
516 * @param[in] outout weston output table
517 * @param[in] mseces current time(unused)
520 /*--------------------------------------------------------------------------*/
522 animation_slide(struct weston_animation *animation,
523 struct weston_output *output, uint32_t msecs)
525 struct uifw_win_surface *usurf;
526 struct animation_data *animadata;
527 struct weston_layout_SurfaceProperties prop;
531 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
533 par = animation_cont(animation, output, msecs);
535 /* continue animation */
537 weston_compositor_schedule_repaint(weston_ec);
541 if (animation->frame_counter == 1) {
542 animadata = (struct animation_data *)usurf->animation.animadata;
543 animadata->end_function = animation_slide_end;
545 par = usurf->animation.current;
547 uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d",
548 usurf->surfaceid, animation->frame_counter, par,
549 usurf->animation.anima, usurf->animation.state);
554 switch (usurf->animation.anima) {
555 case ANIMA_SLIDE_TORIGHT: /* slide in left to right */
556 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
557 /* slide in left to right */
558 x = 0 - usurf->animation.pos_width +
559 ((usurf->animation.pos_x + usurf->animation.pos_width) * par / 100);
562 /* slide out right to left */
563 x = 0 - usurf->animation.pos_width +
564 ((usurf->animation.pos_x + usurf->animation.pos_width) * (100 - par) / 100);
567 case ANIMA_SLIDE_TOLEFT: /* slide in right to left */
568 dwidth = usurf->node_tbl->disp_width;
569 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
570 /* slide in right to left */
571 x = usurf->animation.pos_x +
572 (dwidth - usurf->animation.pos_x) * (100 - par) / 100;
575 /* slide out left to right */
576 x = usurf->animation.pos_x + (dwidth - usurf->animation.pos_x) * par / 100;
579 case ANIMA_SLIDE_TOBOTTOM: /* slide in top to bottom */
580 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
581 /* slide in top to bottom */
582 y = 0 - usurf->animation.pos_height +
583 ((usurf->animation.pos_y + usurf->animation.pos_height) * par / 100);
586 /* slide out bottom to top */
587 y = 0 - usurf->animation.pos_height +
588 ((usurf->animation.pos_y + usurf->animation.pos_height) * (100 - par) / 100);
591 default: /*ANIMA_SLIDE_TOTOP*/ /* slide in bottom to top */
592 dheight = usurf->node_tbl->disp_height;
593 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
594 /* slide in bottom to top */
595 y = usurf->animation.pos_y +
596 (dheight - usurf->animation.pos_y) * (100 - par) / 100;
599 /* slide out top to bottom */
600 y = usurf->animation.pos_y + (dheight - usurf->animation.pos_y) * par / 100;
604 if ((par < 8) || (par > 92)) {
605 uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d) %08x",
606 usurf->surfaceid, par, x, y, usurf->x, usurf->y, (int)usurf->ivisurf);
608 if (weston_layout_getPropertiesOfSurface(usurf->ivisurf, &prop) == 0) {
609 if (weston_layout_surfaceSetDestinationRectangle(usurf->ivisurf, x, y,
610 prop.destWidth, prop.destHeight) == 0) {
611 weston_layout_commitChanges();
615 /* end of animation */
616 animation_end(usurf, 1);
617 uifw_trace("animation_slide: End of animation");
621 /*--------------------------------------------------------------------------*/
623 * @brief animation_slide_end: slide animation end
625 * @param[in] animation weston animation table
628 /*--------------------------------------------------------------------------*/
630 animation_slide_end(struct weston_animation *animation)
632 struct uifw_win_surface *usurf;
634 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
636 ico_window_mgr_set_weston_surface(usurf,
637 usurf->animation.pos_x, usurf->animation.pos_y,
638 usurf->animation.pos_width,
639 usurf->animation.pos_height);
643 /*--------------------------------------------------------------------------*/
645 * @brief animation_wipe: wipe animation
647 * @param[in] animation weston animation table
648 * @param[in] outout weston output table
649 * @param[in] mseces current time(unused)
652 /*--------------------------------------------------------------------------*/
654 animation_wipe(struct weston_animation *animation,
655 struct weston_output *output, uint32_t msecs)
657 struct uifw_win_surface *usurf;
658 struct weston_surface *es;
659 struct weston_view *ev;
666 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
668 par = animation_cont(animation, output, msecs);
670 /* continue animation */
672 weston_compositor_schedule_repaint(weston_ec);
676 ev = ico_ivi_get_primary_view(usurf);
677 par = usurf->animation.current;
679 uifw_debug("animation_wipe: %08x count=%d %d%% anima=%d state=%d",
680 usurf->surfaceid, animation->frame_counter, par,
681 usurf->animation.anima, usurf->animation.state);
686 width = usurf->width;
687 height = usurf->width;
690 switch (usurf->animation.anima) {
691 case ANIMA_WIPE_TORIGHT: /* wipe in left to right */
692 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
693 /* wipe in left to right */
694 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
697 /* wipe out right to left */
698 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
700 if (width <= 0) width = 1;
702 case ANIMA_WIPE_TOLEFT: /* wipe in right to left */
703 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
704 /* wipe in right to left */
705 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
708 /* wipe out left to right */
709 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
711 if (width <= 0) width = 1;
712 x = x + (usurf->width - width);
714 case ANIMA_WIPE_TOBOTTOM: /* wipe in top to bottom */
715 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
716 /* wipe in top to bottom */
717 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
720 /* wipe out bottom to top */
721 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
723 if (height <= 0) height = 1;
725 default: /*ANIMA_WIPE_TOTOP*/ /* wipe in bottom to top */
726 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
727 /* wipe in bottom to top */
728 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
731 /* wipe out top to bottom */
732 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
734 if (height <= 0) height = 1;
735 y = y + (usurf->height - height);
740 ev->geometry.x = usurf->node_tbl->disp_x + x;
741 ev->geometry.y = usurf->node_tbl->disp_y + y;
744 if ((ev->output) && (es->buffer_ref.buffer)) {
745 weston_view_geometry_dirty(ev);
746 weston_surface_damage(es);
749 /* end of animation */
750 animation_end(usurf, 1);
751 uifw_trace("animation_wipe: End of animation");
754 /* continue animation */
755 weston_compositor_schedule_repaint(weston_ec);
759 /*--------------------------------------------------------------------------*/
761 * @brief animation_swing: swing animation
763 * @param[in] animation weston animation table
764 * @param[in] outout weston output table
765 * @param[in] mseces current time(unused)
768 /*--------------------------------------------------------------------------*/
770 animation_swing(struct weston_animation *animation,
771 struct weston_output *output, uint32_t msecs)
773 struct uifw_win_surface *usurf;
774 struct weston_surface *es;
775 struct weston_view *ev;
776 struct animation_data *animadata;
783 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
785 par = animation_cont(animation, output, msecs);
787 /* continue animation */
789 weston_compositor_schedule_repaint(weston_ec);
794 uifw_debug("animation_swing: %08x count=%d %d%% anima=%d state=%d",
795 usurf->surfaceid, animation->frame_counter, par,
796 usurf->animation.anima, usurf->animation.state);
798 animadata = (struct animation_data *)usurf->animation.animadata;
800 ev = ico_ivi_get_primary_view(usurf);
801 par = usurf->animation.current;
802 if (animation->frame_counter == 1) {
803 if (animadata->transform_set == 0) {
804 animadata->transform_set = 1;
805 weston_matrix_init(&animadata->transform.matrix);
806 wl_list_init(&animadata->transform.link);
807 wl_list_insert(&ev->geometry.transformation_list,
808 &animadata->transform.link);
810 animadata->end_function = animation_swing_end;
819 switch (usurf->animation.anima) {
820 case ANIMA_SWING_TORIGHT: /* swing in left to right */
821 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
822 /* swing in left to right */
823 scalex = ((float)par + 5.0f) / 105.0f;
826 /* swing out right to left */
827 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
829 if (scalex <= 0.0) scalex = 0.01;
831 case ANIMA_SWING_TOLEFT: /* seing in right to left */
832 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
833 /* swing in right to left */
834 scalex = ((float)par + 5.0f) / 105.0f;
837 /* swing out left to right */
838 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
840 if (scalex <= 0.0) scalex = 0.01;
841 x = x + (int)((float)usurf->width * (1.0f - scalex));
843 case ANIMA_SWING_TOBOTTOM: /* swing in top to bottom */
844 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
845 /* swing in top to bottom */
846 scaley = ((float)par + 5.0f) / 105.0f;
849 /* swing out bottom to top */
850 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
852 if (scaley <= 0.0) scaley = 0.01;
854 default: /*ANIMA_SWING*/ /* swing in bottom to top */
855 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
856 /* wipe in bottom to top */
857 scaley = ((float)par + 5.0f) / 105.0f;
860 /* wipe out top to bottom */
861 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
863 if (scaley <= 0.0) scaley = 0.01;
864 y = y + (int)((float)usurf->height * (1.0f - scaley));
869 ev->geometry.x = usurf->node_tbl->disp_x + x;
870 ev->geometry.y = usurf->node_tbl->disp_y + y;
871 weston_matrix_init(&animadata->transform.matrix);
872 weston_matrix_translate(&animadata->transform.matrix,
873 -0.5f * usurf->width, -0.5f * usurf->height, 0);
874 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
875 weston_matrix_translate(&animadata->transform.matrix,
876 0.5f * usurf->width, 0.5f * usurf->height, 0);
878 if ((ev->output) && (es->buffer_ref.buffer)) {
879 weston_view_geometry_dirty(ev);
880 weston_surface_damage(es);
883 /* end of animation */
884 animation_end(usurf, 1);
885 uifw_trace("animation_swing: End of animation");
888 /* continue animation */
889 weston_compositor_schedule_repaint(weston_ec);
893 /*--------------------------------------------------------------------------*/
895 * @brief animation_swing_end: swing animation end
897 * @param[in] animation weston animation table
900 /*--------------------------------------------------------------------------*/
902 animation_swing_end(struct weston_animation *animation)
904 struct uifw_win_surface *usurf;
905 struct weston_surface *es;
906 struct weston_view *ev;
908 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
909 if (usurf && usurf->surface) {
911 ev = ico_ivi_get_primary_view(usurf);
912 ev->alpha = usurf->animation.alpha;
913 uifw_debug("animation_swing_end: %08x set alpha=%.2f",
914 usurf->surfaceid, usurf->animation.alpha);
915 if ((ev->output) && (es->buffer_ref.buffer)) {
916 weston_surface_damage(es);
921 /*--------------------------------------------------------------------------*/
923 * @brief animation_fade: fade animation
925 * @param[in] animation weston animation table
926 * @param[in] outout weston output table
927 * @param[in] mseces current time(unused)
930 /*--------------------------------------------------------------------------*/
932 animation_fade(struct weston_animation *animation,
933 struct weston_output *output, uint32_t msecs)
935 struct uifw_win_surface *usurf;
936 struct animation_data *animadata;
937 struct weston_surface *es;
938 struct weston_view *ev;
941 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
943 par = animation_cont(animation, output, msecs);
945 /* continue animation */
947 weston_compositor_schedule_repaint(weston_ec);
952 animadata = (struct animation_data *)usurf->animation.animadata;
954 ev = ico_ivi_get_primary_view(usurf);
955 par = usurf->animation.current;
956 if (animation->frame_counter == 1) {
957 if (animadata->transform_set == 0) {
958 animadata->transform_set = 1;
959 weston_matrix_init(&animadata->transform.matrix);
960 wl_list_init(&animadata->transform.link);
961 wl_list_insert(&ev->geometry.transformation_list,
962 &animadata->transform.link);
964 animadata->end_function = animation_fade_end;
966 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
967 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
968 ico_window_mgr_set_weston_surface(usurf,
969 usurf->animation.pos_x, usurf->animation.pos_y,
970 usurf->animation.pos_width,
971 usurf->animation.pos_height);
975 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
977 ev->alpha = ((float)par) / 100.0f;
979 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
981 ev->alpha = 1.0f - (((float)par) / 100.0f);
984 /* fade move/resize */
985 if ((par >= 50) || (usurf->animation.ahalf)) {
986 ev->alpha = ((float)(par*2 - 100)) / 100.0f;
987 if (usurf->animation.ahalf == 0) {
988 uifw_trace("animation_fade: fade move chaneg to show");
989 usurf->animation.ahalf = 1;
991 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
992 usurf->width, usurf->height);
996 ev->alpha = 1.0f - (((float)(par*2)) / 100.0f);
999 if (ev->alpha < 0.0f) ev->alpha = 0.0f;
1000 else if (ev->alpha > 1.0f) ev->alpha = 1.0f;
1002 if ((par < 8) || (par > 92)) {
1003 uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
1004 usurf->surfaceid, animation->frame_counter, par,
1005 ev->alpha, usurf->animation.anima, usurf->animation.state);
1007 if ((ev->output) && (es->buffer_ref.buffer) &&
1008 (es->width > 0) && (es->height > 0)) {
1009 weston_surface_damage(es);
1012 /* end of animation */
1013 animation_end(usurf, 1);
1014 uifw_trace("animation_fade: End of animation");
1017 /* continue animation */
1018 weston_compositor_schedule_repaint(weston_ec);
1022 /*--------------------------------------------------------------------------*/
1024 * @brief animation_fade_end: fade animation end
1026 * @param[in] animation weston animation table
1029 /*--------------------------------------------------------------------------*/
1031 animation_fade_end(struct weston_animation *animation)
1033 struct uifw_win_surface *usurf;
1034 struct weston_surface *es;
1035 struct weston_view *ev;
1037 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1038 if (usurf && usurf->surface) {
1039 es = usurf->surface;
1040 ev = ico_ivi_get_primary_view(usurf);
1041 ev->alpha = usurf->animation.alpha;
1042 uifw_debug("animation_fade_end: %08x set alpha=%.2f",
1043 usurf->surfaceid, usurf->animation.alpha);
1044 if ((ev->output) && (es->buffer_ref.buffer) &&
1045 (es->width > 0) && (es->height > 0)) {
1046 weston_surface_damage(es);
1051 /*--------------------------------------------------------------------------*/
1053 * @brief animation_zoom: zoom animation
1055 * @param[in] animation weston animation table
1056 * @param[in] outout weston output table
1057 * @param[in] mseces current time(unused)
1060 /*--------------------------------------------------------------------------*/
1062 animation_zoom(struct weston_animation *animation,
1063 struct weston_output *output, uint32_t msecs)
1065 struct uifw_win_surface *usurf;
1066 struct animation_data *animadata;
1067 struct weston_surface *es;
1068 struct weston_view *ev;
1070 float scalex, scaley;
1074 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1076 par = animation_cont(animation, output, msecs);
1078 /* continue animation */
1080 weston_compositor_schedule_repaint(weston_ec);
1085 animadata = (struct animation_data *)usurf->animation.animadata;
1086 es = usurf->surface;
1087 ev = ico_ivi_get_primary_view(usurf);
1088 par = usurf->animation.current;
1089 if (animation->frame_counter == 1) {
1090 if (animadata->transform_set == 0) {
1091 animadata->transform_set = 1;
1092 weston_matrix_init(&animadata->transform.matrix);
1093 wl_list_init(&animadata->transform.link);
1094 wl_list_insert(&ev->geometry.transformation_list,
1095 &animadata->transform.link);
1097 animadata->end_function = animation_zoom_end;
1099 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
1100 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1101 ico_window_mgr_set_weston_surface(usurf,
1102 usurf->animation.pos_x, usurf->animation.pos_y,
1103 usurf->animation.pos_width,
1104 usurf->animation.pos_height);
1108 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
1110 scalex = ((float)par + 5.0f) / 105.0f;
1113 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
1115 scalex = 1.0f - (((float)par + 5.0f) / 105.0f);
1119 /* zoom move/resize */
1120 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1121 usurf->width, usurf->height);
1122 fu = (float)usurf->width;
1123 fa = (float)usurf->animation.pos_width;
1124 fp = (100.0f - (float)par) / 100.0f;
1125 scalex = (fu - (fu - fa) * fp) / fu;
1126 fu = (float)usurf->height;
1127 fa = (float)usurf->animation.pos_height;
1128 scaley = (fu - (fu - fa) * fp) / fu;
1130 x = (((float)usurf->animation.pos_x) - ((float)usurf->x)) * fp + (float)usurf->x
1131 + (((float)usurf->width * scalex) - (float)usurf->width) / 2.0f;
1132 y = (((float)usurf->animation.pos_y) - ((float)usurf->y)) * fp + (float)usurf->y
1133 + (((float)usurf->height * scaley) - (float) usurf->height) / 2.0f;
1134 uifw_trace("animation_zoom: %08x %d%% x=%d/%d y=%d/%d",
1135 usurf->surfaceid, par, x, usurf->x, y, usurf->y);
1136 uifw_trace("animation_zoom: sx=%4.2f sy=%4.2f x=%d->%d y=%d->%d cur=%d,%d",
1137 scalex, scaley, usurf->animation.pos_x, usurf->x,
1138 usurf->animation.pos_y, usurf->y, x, y);
1139 ico_window_mgr_set_weston_surface(usurf, x, y, usurf->width, usurf->height);
1141 weston_matrix_init(&animadata->transform.matrix);
1142 weston_matrix_translate(&animadata->transform.matrix,
1143 -0.5f * usurf->width, -0.5f * usurf->height, 0);
1144 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
1145 weston_matrix_translate(&animadata->transform.matrix,
1146 0.5f * usurf->width, 0.5f * usurf->height, 0);
1148 uifw_trace("animation_zoom: %08x count=%d %d%% w=%d/%d h=%d/%d anima=%d state=%d",
1149 usurf->surfaceid, animation->frame_counter, par,
1150 (int)(usurf->width * scalex), usurf->width,
1151 (int)(usurf->height * scaley), usurf->height,
1152 usurf->animation.anima, usurf->animation.state);
1154 if ((ev->output) && (es->buffer_ref.buffer) &&
1155 (es->width > 0) && (es->height > 0)) {
1156 weston_view_geometry_dirty(ev);
1157 weston_surface_damage(es);
1160 /* end of animation */
1161 animation_end(usurf, 1);
1162 uifw_trace("animation_zoom: End of animation");
1165 /* continue animation */
1166 weston_compositor_schedule_repaint(weston_ec);
1170 /*--------------------------------------------------------------------------*/
1172 * @brief animation_zoom_end: zoom animation end
1174 * @param[in] animation weston animation table
1177 /*--------------------------------------------------------------------------*/
1179 animation_zoom_end(struct weston_animation *animation)
1181 struct uifw_win_surface *usurf;
1182 struct weston_surface *es;
1183 struct weston_view *ev;
1185 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1186 if (usurf && usurf->surface) {
1187 es = usurf->surface;
1188 ev = ico_ivi_get_primary_view(usurf);
1189 ev->alpha = usurf->animation.alpha;
1190 if ((ev->output) && (es->buffer_ref.buffer) &&
1191 (es->width > 0) && (es->height > 0)) {
1192 weston_surface_damage(es);
1197 /*--------------------------------------------------------------------------*/
1199 * @brief module_init: initialize ico_window_animation
1200 * this function called from ico_pluign_loader
1202 * @param[in] es weston compositor
1203 * @param[in] argc number of arguments(unused)
1204 * @param[in] argv argument list(unused)
1209 /*--------------------------------------------------------------------------*/
1211 module_init(struct weston_compositor *ec, int *argc, char *argv[])
1214 struct animation_data *animadata;
1216 uifw_info("ico_window_animation: Enter(module_init)");
1218 /* allocate animation datas */
1220 for (i = 0; i < 50; i++) {
1221 animadata = (struct animation_data *)malloc(sizeof(struct animation_data));
1223 uifw_error("ico_window_animation: No Memory(module_init)");
1226 animadata->next_free = free_data;
1227 free_data = animadata;
1231 default_animation = (char *)ico_ivi_default_animation_name();
1232 animation_time = ico_ivi_default_animation_time();
1233 animation_fps = ico_ivi_default_animation_fps();
1234 animation_count = 0;
1236 ico_window_mgr_set_hook_animation(ico_window_animation);
1238 uifw_info("ico_window_animation: Leave(module_init)");