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;
323 if (usurf->org_animation.saved) {
324 usurf->animation.type = usurf->org_animation.type;
325 usurf->animation.anima = usurf->org_animation.anima;
326 usurf->animation.next_anima = usurf->org_animation.next_anima;
327 usurf->animation.hide_anima = usurf->org_animation.hide_anima;
328 usurf->animation.hide_time = usurf->org_animation.hide_time;
329 usurf->animation.show_anima = usurf->org_animation.show_anima;
330 usurf->animation.show_time = usurf->org_animation.show_time;
331 usurf->animation.move_anima = usurf->org_animation.move_anima;
332 usurf->animation.move_time = usurf->org_animation.move_time;
333 usurf->animation.resize_anima = usurf->org_animation.resize_anima;
334 usurf->animation.resize_time = usurf->org_animation.resize_time;
335 usurf->org_animation.saved = 0;
338 usurf->animation.type = op;
339 #if PERFORMANCE_EVALUATIONS > 0
340 if (ret != ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) {
341 uifw_perf("SWAP_BUFFER Start Animation appid=%s surface=%08x anima=%d",
342 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
344 #endif /*PERFORMANCE_EVALUATIONS*/
346 weston_compositor_schedule_repaint(weston_ec);
350 /*--------------------------------------------------------------------------*/
352 * @brief animation_cont: continue animation
354 * @param[in] animation weston animation table
355 * @param[in] output weston output table
356 * @param[in] msecs current time stamp
357 * @return time has come
358 * @retval =0 time has come
359 * @retval >0 time has not yet come(return value is current parcent)
361 /*--------------------------------------------------------------------------*/
363 animation_cont(struct weston_animation *animation, struct weston_output *output,
366 struct uifw_win_surface *usurf;
370 nowsec = weston_compositor_get_time();
372 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
374 if (animation->frame_counter <= 1) {
375 /* first call, initialize */
376 animation->frame_counter = 1;
377 usurf->animation.starttime = nowsec;
378 usurf->animation.current = 1000;
379 if (! usurf->animation.animadata) {
381 usurf->animation.animadata = (void *)free_data;
382 free_data = free_data->next_free;
385 usurf->animation.animadata = (void *)malloc(sizeof(struct animation_data));
387 memset(usurf->animation.animadata, 0, sizeof(struct animation_data));
390 else if (! usurf->animation.animadata) {
391 animation_end(usurf, 0);
395 if (nowsec >= usurf->animation.starttime) {
396 nowsec = nowsec - usurf->animation.starttime; /* elapsed time(ms) */
399 nowsec = (uint32_t)(((long long)0x100000000L) +
400 ((long long)nowsec) - ((long long)usurf->animation.starttime));
402 switch (usurf->animation.state) {
403 case ICO_WINDOW_MGR_ANIMATION_STATE_SHOW:
404 usurf->animation.time = usurf->animation.show_time;
406 case ICO_WINDOW_MGR_ANIMATION_STATE_HIDE:
407 usurf->animation.time = usurf->animation.hide_time;
409 case ICO_WINDOW_MGR_ANIMATION_STATE_MOVE:
410 usurf->animation.time = usurf->animation.move_time;
413 usurf->animation.time = usurf->animation.resize_time;
416 if (usurf->animation.time == 0) {
417 usurf->animation.time = animation_time;
419 if (((output == NULL) && (msecs == 0)) || (nowsec >= ((uint32_t)usurf->animation.time))) {
423 par = (nowsec * 100 + usurf->animation.time / 2) / usurf->animation.time;
424 if (par < 2) par = 2;
427 (abs(usurf->animation.current - par) >=
428 (((1000 * 100) / animation_fps) / usurf->animation.time)) ||
429 ((animation_count > 1) && (par != usurf->animation.current))) {
430 usurf->animation.current = par;
436 /*--------------------------------------------------------------------------*/
438 * @brief animation_end: terminate animation
440 * @param[in] usurf UIFW surface table
441 * @param[in] disp display control(1)/no display(0)
444 /*--------------------------------------------------------------------------*/
446 animation_end(struct uifw_win_surface *usurf, const int disp)
448 struct animation_data *animadata;
449 struct weston_view *ev;
451 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
452 if (usurf->org_animation.saved) {
453 usurf->animation.type = usurf->org_animation.type;
454 usurf->animation.anima = usurf->org_animation.anima;
455 usurf->animation.next_anima = usurf->org_animation.next_anima;
456 usurf->animation.hide_anima = usurf->org_animation.hide_anima;
457 usurf->animation.hide_time = usurf->org_animation.hide_time;
458 usurf->animation.show_anima = usurf->org_animation.show_anima;
459 usurf->animation.show_time = usurf->org_animation.show_time;
460 usurf->animation.move_anima = usurf->org_animation.move_anima;
461 usurf->animation.move_time = usurf->org_animation.move_time;
462 usurf->animation.resize_anima = usurf->org_animation.resize_anima;
463 usurf->animation.resize_time = usurf->org_animation.resize_time;
464 usurf->org_animation.saved = 0;
466 animadata = (struct animation_data *)usurf->animation.animadata;
468 if (animation_count > 0) {
471 ev = ico_ivi_get_primary_view(usurf);
474 if (animadata->end_function) {
475 (*animadata->end_function)(&usurf->animation.animation);
477 wl_list_remove(&usurf->animation.animation.link);
478 if (animadata->transform_set) {
479 wl_list_remove(&animadata->transform.link);
480 animadata->transform_set = 0;
482 weston_view_geometry_dirty(ev);
485 usurf->restrain_configure = 0;
486 uifw_trace("animation_end: %08x vis=%d(%x)",
487 usurf->surfaceid, usurf->visible, usurf->animation.visible);
488 if ((usurf->animation.visible == ANIMA_HIDE_AT_END) &&
489 (usurf->visible != 0)) {
491 weston_layout_surfaceSetVisibility(usurf->ivisurf, 0);
492 weston_layout_commitChanges();
493 weston_surface_damage(usurf->surface);
494 weston_view_geometry_dirty(ev);
496 if ((usurf->animation.visible == ANIMA_SHOW_AT_END) &&
497 (usurf->visible == 0)) {
499 weston_layout_surfaceSetVisibility(usurf->ivisurf, 1);
500 weston_layout_commitChanges();
501 weston_surface_damage(usurf->surface);
502 weston_view_geometry_dirty(ev);
505 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
506 if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE) {
507 switch(usurf->animation.type) {
508 case ICO_WINDOW_MGR_ANIMATION_OPHIDE:
509 case ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS:
510 usurf->animation.hide_anima = usurf->animation.next_anima;
512 case ICO_WINDOW_MGR_ANIMATION_OPSHOW:
513 case ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS:
514 usurf->animation.show_anima = usurf->animation.next_anima;
516 case ICO_WINDOW_MGR_ANIMATION_OPMOVE:
517 usurf->animation.move_anima = usurf->animation.next_anima;
519 case ICO_WINDOW_MGR_ANIMATION_OPRESIZE:
520 usurf->animation.resize_anima = usurf->animation.next_anima;
525 usurf->animation.next_anima = ICO_WINDOW_MGR_ANIMATION_NONE;
528 usurf->animation.animadata = NULL;
529 animadata->next_free = free_data;
530 free_data = animadata;
532 usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE;
533 #if PERFORMANCE_EVALUATIONS > 0
534 uifw_perf("SWAP_BUFFER End Animation appid=%s surface=%08x anima=%d",
535 usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima);
536 #endif /*PERFORMANCE_EVALUATIONS*/
539 /*--------------------------------------------------------------------------*/
541 * @brief animation_slide: slide animation
543 * @param[in] animation weston animation table
544 * @param[in] outout weston output table
545 * @param[in] mseces current time(unused)
548 /*--------------------------------------------------------------------------*/
550 animation_slide(struct weston_animation *animation,
551 struct weston_output *output, uint32_t msecs)
553 struct uifw_win_surface *usurf;
554 struct animation_data *animadata;
555 struct weston_layout_SurfaceProperties prop;
559 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
561 par = animation_cont(animation, output, msecs);
563 /* continue animation */
565 weston_compositor_schedule_repaint(weston_ec);
569 if (animation->frame_counter == 1) {
570 animadata = (struct animation_data *)usurf->animation.animadata;
571 animadata->end_function = animation_slide_end;
573 par = usurf->animation.current;
575 uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d",
576 usurf->surfaceid, animation->frame_counter, par,
577 usurf->animation.anima, usurf->animation.state);
582 switch (usurf->animation.anima) {
583 case ANIMA_SLIDE_TORIGHT: /* slide in left to right */
584 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
585 /* slide in left to right */
586 x = 0 - usurf->animation.pos_width +
587 ((usurf->animation.pos_x + usurf->animation.pos_width) * par / 100);
590 /* slide out right to left */
591 x = 0 - usurf->animation.pos_width +
592 ((usurf->animation.pos_x + usurf->animation.pos_width) * (100 - par) / 100);
595 case ANIMA_SLIDE_TOLEFT: /* slide in right to left */
596 dwidth = usurf->node_tbl->disp_width;
597 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
598 /* slide in right to left */
599 x = usurf->animation.pos_x +
600 (dwidth - usurf->animation.pos_x) * (100 - par) / 100;
603 /* slide out left to right */
604 x = usurf->animation.pos_x + (dwidth - usurf->animation.pos_x) * par / 100;
607 case ANIMA_SLIDE_TOBOTTOM: /* slide in top to bottom */
608 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
609 /* slide in top to bottom */
610 y = 0 - usurf->animation.pos_height +
611 ((usurf->animation.pos_y + usurf->animation.pos_height) * par / 100);
614 /* slide out bottom to top */
615 y = 0 - usurf->animation.pos_height +
616 ((usurf->animation.pos_y + usurf->animation.pos_height) * (100 - par) / 100);
619 default: /*ANIMA_SLIDE_TOTOP*/ /* slide in bottom to top */
620 dheight = usurf->node_tbl->disp_height;
621 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
622 /* slide in bottom to top */
623 y = usurf->animation.pos_y +
624 (dheight - usurf->animation.pos_y) * (100 - par) / 100;
627 /* slide out top to bottom */
628 y = usurf->animation.pos_y + (dheight - usurf->animation.pos_y) * par / 100;
632 if ((par < 8) || (par > 92)) {
633 uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d) %08x",
634 usurf->surfaceid, par, x, y, usurf->x, usurf->y, (int)usurf->ivisurf);
636 if (weston_layout_getPropertiesOfSurface(usurf->ivisurf, &prop) == 0) {
637 if (weston_layout_surfaceSetDestinationRectangle(usurf->ivisurf, x, y,
638 prop.destWidth, prop.destHeight) == 0) {
639 weston_layout_commitChanges();
643 /* end of animation */
644 animation_end(usurf, 1);
645 uifw_trace("animation_slide: End of animation");
649 /*--------------------------------------------------------------------------*/
651 * @brief animation_slide_end: slide animation end
653 * @param[in] animation weston animation table
656 /*--------------------------------------------------------------------------*/
658 animation_slide_end(struct weston_animation *animation)
660 struct uifw_win_surface *usurf;
662 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
664 ico_window_mgr_set_weston_surface(usurf,
665 usurf->animation.pos_x, usurf->animation.pos_y,
666 usurf->animation.pos_width,
667 usurf->animation.pos_height);
671 /*--------------------------------------------------------------------------*/
673 * @brief animation_wipe: wipe animation
675 * @param[in] animation weston animation table
676 * @param[in] outout weston output table
677 * @param[in] mseces current time(unused)
680 /*--------------------------------------------------------------------------*/
682 animation_wipe(struct weston_animation *animation,
683 struct weston_output *output, uint32_t msecs)
685 struct uifw_win_surface *usurf;
686 struct weston_surface *es;
687 struct weston_view *ev;
694 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
696 par = animation_cont(animation, output, msecs);
698 /* continue animation */
700 weston_compositor_schedule_repaint(weston_ec);
704 ev = ico_ivi_get_primary_view(usurf);
705 par = usurf->animation.current;
707 uifw_debug("animation_wipe: %08x count=%d %d%% anima=%d state=%d",
708 usurf->surfaceid, animation->frame_counter, par,
709 usurf->animation.anima, usurf->animation.state);
714 width = usurf->width;
715 height = usurf->width;
718 switch (usurf->animation.anima) {
719 case ANIMA_WIPE_TORIGHT: /* wipe in left to right */
720 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
721 /* wipe in left to right */
722 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
725 /* wipe out right to left */
726 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
728 if (width <= 0) width = 1;
730 case ANIMA_WIPE_TOLEFT: /* wipe in right to left */
731 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
732 /* wipe in right to left */
733 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
736 /* wipe out left to right */
737 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
739 if (width <= 0) width = 1;
740 x = x + (usurf->width - width);
742 case ANIMA_WIPE_TOBOTTOM: /* wipe in top to bottom */
743 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
744 /* wipe in top to bottom */
745 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
748 /* wipe out bottom to top */
749 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
751 if (height <= 0) height = 1;
753 default: /*ANIMA_WIPE_TOTOP*/ /* wipe in bottom to top */
754 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
755 /* wipe in bottom to top */
756 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
759 /* wipe out top to bottom */
760 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
762 if (height <= 0) height = 1;
763 y = y + (usurf->height - height);
768 ev->geometry.x = usurf->node_tbl->disp_x + x;
769 ev->geometry.y = usurf->node_tbl->disp_y + y;
772 if ((ev->output) && (es->buffer_ref.buffer)) {
773 weston_view_geometry_dirty(ev);
774 weston_surface_damage(es);
777 /* end of animation */
778 animation_end(usurf, 1);
779 uifw_trace("animation_wipe: End of animation");
782 /* continue animation */
783 weston_compositor_schedule_repaint(weston_ec);
787 /*--------------------------------------------------------------------------*/
789 * @brief animation_swing: swing animation
791 * @param[in] animation weston animation table
792 * @param[in] outout weston output table
793 * @param[in] mseces current time(unused)
796 /*--------------------------------------------------------------------------*/
798 animation_swing(struct weston_animation *animation,
799 struct weston_output *output, uint32_t msecs)
801 struct uifw_win_surface *usurf;
802 struct weston_surface *es;
803 struct weston_view *ev;
804 struct animation_data *animadata;
811 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
813 par = animation_cont(animation, output, msecs);
815 /* continue animation */
817 weston_compositor_schedule_repaint(weston_ec);
822 uifw_debug("animation_swing: %08x count=%d %d%% anima=%d state=%d",
823 usurf->surfaceid, animation->frame_counter, par,
824 usurf->animation.anima, usurf->animation.state);
826 animadata = (struct animation_data *)usurf->animation.animadata;
828 ev = ico_ivi_get_primary_view(usurf);
829 par = usurf->animation.current;
830 if (animation->frame_counter == 1) {
831 if (animadata->transform_set == 0) {
832 animadata->transform_set = 1;
833 weston_matrix_init(&animadata->transform.matrix);
834 wl_list_init(&animadata->transform.link);
835 wl_list_insert(&ev->geometry.transformation_list,
836 &animadata->transform.link);
838 animadata->end_function = animation_swing_end;
847 switch (usurf->animation.anima) {
848 case ANIMA_SWING_TORIGHT: /* swing in left to right */
849 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
850 /* swing in left to right */
851 scalex = ((float)par + 5.0f) / 105.0f;
854 /* swing out right to left */
855 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
857 if (scalex <= 0.0) scalex = 0.01;
859 case ANIMA_SWING_TOLEFT: /* seing in right to left */
860 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
861 /* swing in right to left */
862 scalex = ((float)par + 5.0f) / 105.0f;
865 /* swing out left to right */
866 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
868 if (scalex <= 0.0) scalex = 0.01;
869 x = x + (int)((float)usurf->width * (1.0f - scalex));
871 case ANIMA_SWING_TOBOTTOM: /* swing in top to bottom */
872 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
873 /* swing in top to bottom */
874 scaley = ((float)par + 5.0f) / 105.0f;
877 /* swing out bottom to top */
878 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
880 if (scaley <= 0.0) scaley = 0.01;
882 default: /*ANIMA_SWING*/ /* swing in bottom to top */
883 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
884 /* wipe in bottom to top */
885 scaley = ((float)par + 5.0f) / 105.0f;
888 /* wipe out top to bottom */
889 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
891 if (scaley <= 0.0) scaley = 0.01;
892 y = y + (int)((float)usurf->height * (1.0f - scaley));
897 ev->geometry.x = usurf->node_tbl->disp_x + x;
898 ev->geometry.y = usurf->node_tbl->disp_y + y;
899 weston_matrix_init(&animadata->transform.matrix);
900 weston_matrix_translate(&animadata->transform.matrix,
901 -0.5f * usurf->width, -0.5f * usurf->height, 0);
902 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
903 weston_matrix_translate(&animadata->transform.matrix,
904 0.5f * usurf->width, 0.5f * usurf->height, 0);
906 if ((ev->output) && (es->buffer_ref.buffer)) {
907 weston_view_geometry_dirty(ev);
908 weston_surface_damage(es);
911 /* end of animation */
912 animation_end(usurf, 1);
913 uifw_trace("animation_swing: End of animation");
916 /* continue animation */
917 weston_compositor_schedule_repaint(weston_ec);
921 /*--------------------------------------------------------------------------*/
923 * @brief animation_swing_end: swing animation end
925 * @param[in] animation weston animation table
928 /*--------------------------------------------------------------------------*/
930 animation_swing_end(struct weston_animation *animation)
932 struct uifw_win_surface *usurf;
933 struct weston_surface *es;
934 struct weston_view *ev;
936 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
937 if (usurf && usurf->surface) {
939 ev = ico_ivi_get_primary_view(usurf);
940 ev->alpha = usurf->animation.alpha;
941 uifw_debug("animation_swing_end: %08x set alpha=%.2f",
942 usurf->surfaceid, usurf->animation.alpha);
943 if ((ev->output) && (es->buffer_ref.buffer)) {
944 weston_surface_damage(es);
949 /*--------------------------------------------------------------------------*/
951 * @brief animation_fade: fade animation
953 * @param[in] animation weston animation table
954 * @param[in] outout weston output table
955 * @param[in] mseces current time(unused)
958 /*--------------------------------------------------------------------------*/
960 animation_fade(struct weston_animation *animation,
961 struct weston_output *output, uint32_t msecs)
963 struct uifw_win_surface *usurf;
964 struct animation_data *animadata;
965 struct weston_surface *es;
966 struct weston_view *ev;
969 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
971 par = animation_cont(animation, output, msecs);
973 /* continue animation */
975 weston_compositor_schedule_repaint(weston_ec);
980 animadata = (struct animation_data *)usurf->animation.animadata;
982 ev = ico_ivi_get_primary_view(usurf);
983 par = usurf->animation.current;
984 if (animation->frame_counter == 1) {
985 if (animadata->transform_set == 0) {
986 animadata->transform_set = 1;
987 weston_matrix_init(&animadata->transform.matrix);
988 wl_list_init(&animadata->transform.link);
989 wl_list_insert(&ev->geometry.transformation_list,
990 &animadata->transform.link);
992 animadata->end_function = animation_fade_end;
994 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
995 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
996 ico_window_mgr_set_weston_surface(usurf,
997 usurf->animation.pos_x, usurf->animation.pos_y,
998 usurf->animation.pos_width,
999 usurf->animation.pos_height);
1003 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
1005 ev->alpha = ((float)par) / 100.0f;
1007 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
1009 ev->alpha = 1.0f - (((float)par) / 100.0f);
1012 /* fade move/resize */
1013 if ((par >= 50) || (usurf->animation.ahalf)) {
1014 ev->alpha = ((float)(par*2 - 100)) / 100.0f;
1015 if (usurf->animation.ahalf == 0) {
1016 uifw_trace("animation_fade: fade move chaneg to show");
1017 usurf->animation.ahalf = 1;
1019 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1020 usurf->width, usurf->height);
1024 ev->alpha = 1.0f - (((float)(par*2)) / 100.0f);
1027 if (ev->alpha < 0.0f) ev->alpha = 0.0f;
1028 else if (ev->alpha > 1.0f) ev->alpha = 1.0f;
1030 if ((par < 8) || (par > 92)) {
1031 uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
1032 usurf->surfaceid, animation->frame_counter, par,
1033 ev->alpha, usurf->animation.anima, usurf->animation.state);
1035 if ((ev->output) && (es->buffer_ref.buffer) &&
1036 (es->width > 0) && (es->height > 0)) {
1037 weston_surface_damage(es);
1040 /* end of animation */
1041 animation_end(usurf, 1);
1042 uifw_trace("animation_fade: End of animation");
1045 /* continue animation */
1046 weston_compositor_schedule_repaint(weston_ec);
1050 /*--------------------------------------------------------------------------*/
1052 * @brief animation_fade_end: fade animation end
1054 * @param[in] animation weston animation table
1057 /*--------------------------------------------------------------------------*/
1059 animation_fade_end(struct weston_animation *animation)
1061 struct uifw_win_surface *usurf;
1062 struct weston_surface *es;
1063 struct weston_view *ev;
1065 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1066 if (usurf && usurf->surface) {
1067 es = usurf->surface;
1068 ev = ico_ivi_get_primary_view(usurf);
1069 ev->alpha = usurf->animation.alpha;
1070 uifw_debug("animation_fade_end: %08x set alpha=%.2f",
1071 usurf->surfaceid, usurf->animation.alpha);
1072 if ((ev->output) && (es->buffer_ref.buffer) &&
1073 (es->width > 0) && (es->height > 0)) {
1074 weston_surface_damage(es);
1079 /*--------------------------------------------------------------------------*/
1081 * @brief animation_zoom: zoom animation
1083 * @param[in] animation weston animation table
1084 * @param[in] outout weston output table
1085 * @param[in] mseces current time(unused)
1088 /*--------------------------------------------------------------------------*/
1090 animation_zoom(struct weston_animation *animation,
1091 struct weston_output *output, uint32_t msecs)
1093 struct uifw_win_surface *usurf;
1094 struct animation_data *animadata;
1095 struct weston_surface *es;
1096 struct weston_view *ev;
1098 float scalex, scaley;
1102 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1104 par = animation_cont(animation, output, msecs);
1106 /* continue animation */
1108 weston_compositor_schedule_repaint(weston_ec);
1113 animadata = (struct animation_data *)usurf->animation.animadata;
1114 es = usurf->surface;
1115 ev = ico_ivi_get_primary_view(usurf);
1116 par = usurf->animation.current;
1117 if (animation->frame_counter == 1) {
1118 if (animadata->transform_set == 0) {
1119 animadata->transform_set = 1;
1120 weston_matrix_init(&animadata->transform.matrix);
1121 wl_list_init(&animadata->transform.link);
1122 wl_list_insert(&ev->geometry.transformation_list,
1123 &animadata->transform.link);
1125 animadata->end_function = animation_zoom_end;
1127 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
1128 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1129 ico_window_mgr_set_weston_surface(usurf,
1130 usurf->animation.pos_x, usurf->animation.pos_y,
1131 usurf->animation.pos_width,
1132 usurf->animation.pos_height);
1136 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
1138 scalex = ((float)par + 5.0f) / 105.0f;
1141 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
1143 scalex = 1.0f - (((float)par + 5.0f) / 105.0f);
1147 /* zoom move/resize */
1148 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1149 usurf->width, usurf->height);
1150 fu = (float)usurf->width;
1151 fa = (float)usurf->animation.pos_width;
1152 fp = (100.0f - (float)par) / 100.0f;
1153 scalex = (fu - (fu - fa) * fp) / fu;
1154 fu = (float)usurf->height;
1155 fa = (float)usurf->animation.pos_height;
1156 scaley = (fu - (fu - fa) * fp) / fu;
1158 x = (((float)usurf->animation.pos_x) - ((float)usurf->x)) * fp + (float)usurf->x
1159 + (((float)usurf->width * scalex) - (float)usurf->width) / 2.0f;
1160 y = (((float)usurf->animation.pos_y) - ((float)usurf->y)) * fp + (float)usurf->y
1161 + (((float)usurf->height * scaley) - (float) usurf->height) / 2.0f;
1162 uifw_trace("animation_zoom: %08x %d%% x=%d/%d y=%d/%d",
1163 usurf->surfaceid, par, x, usurf->x, y, usurf->y);
1164 uifw_trace("animation_zoom: sx=%4.2f sy=%4.2f x=%d->%d y=%d->%d cur=%d,%d",
1165 scalex, scaley, usurf->animation.pos_x, usurf->x,
1166 usurf->animation.pos_y, usurf->y, x, y);
1167 ico_window_mgr_set_weston_surface(usurf, x, y, usurf->width, usurf->height);
1169 weston_matrix_init(&animadata->transform.matrix);
1170 weston_matrix_translate(&animadata->transform.matrix,
1171 -0.5f * usurf->width, -0.5f * usurf->height, 0);
1172 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
1173 weston_matrix_translate(&animadata->transform.matrix,
1174 0.5f * usurf->width, 0.5f * usurf->height, 0);
1176 uifw_trace("animation_zoom: %08x count=%d %d%% w=%d/%d h=%d/%d anima=%d state=%d",
1177 usurf->surfaceid, animation->frame_counter, par,
1178 (int)(usurf->width * scalex), usurf->width,
1179 (int)(usurf->height * scaley), usurf->height,
1180 usurf->animation.anima, usurf->animation.state);
1182 if ((ev->output) && (es->buffer_ref.buffer) &&
1183 (es->width > 0) && (es->height > 0)) {
1184 weston_view_geometry_dirty(ev);
1185 weston_surface_damage(es);
1188 /* end of animation */
1189 animation_end(usurf, 1);
1190 uifw_trace("animation_zoom: End of animation");
1193 /* continue animation */
1194 weston_compositor_schedule_repaint(weston_ec);
1198 /*--------------------------------------------------------------------------*/
1200 * @brief animation_zoom_end: zoom animation end
1202 * @param[in] animation weston animation table
1205 /*--------------------------------------------------------------------------*/
1207 animation_zoom_end(struct weston_animation *animation)
1209 struct uifw_win_surface *usurf;
1210 struct weston_surface *es;
1211 struct weston_view *ev;
1213 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1214 if (usurf && usurf->surface) {
1215 es = usurf->surface;
1216 ev = ico_ivi_get_primary_view(usurf);
1217 ev->alpha = usurf->animation.alpha;
1218 if ((ev->output) && (es->buffer_ref.buffer) &&
1219 (es->width > 0) && (es->height > 0)) {
1220 weston_surface_damage(es);
1225 /*--------------------------------------------------------------------------*/
1227 * @brief module_init: initialize ico_window_animation
1228 * this function called from ico_pluign_loader
1230 * @param[in] es weston compositor
1231 * @param[in] argc number of arguments(unused)
1232 * @param[in] argv argument list(unused)
1237 /*--------------------------------------------------------------------------*/
1239 module_init(struct weston_compositor *ec, int *argc, char *argv[])
1242 struct animation_data *animadata;
1244 uifw_info("ico_window_animation: Enter(module_init)");
1246 /* allocate animation datas */
1248 for (i = 0; i < 50; i++) {
1249 animadata = (struct animation_data *)malloc(sizeof(struct animation_data));
1251 uifw_error("ico_window_animation: No Memory(module_init)");
1254 animadata->next_free = free_data;
1255 free_data = animadata;
1259 default_animation = (char *)ico_ivi_default_animation_name();
1260 animation_time = ico_ivi_default_animation_time();
1261 animation_fps = ico_ivi_default_animation_fps();
1262 animation_count = 0;
1264 ico_window_mgr_set_hook_animation(ico_window_animation);
1266 uifw_info("ico_window_animation: Leave(module_init)");