2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Window Animation (Weston(Wayland) PlugIn)
37 #include <sys/types.h>
41 #include <weston/compositor.h>
42 #include "ico_ivi_common.h"
43 #include "ico_ivi_shell.h"
44 #include "ico_window_mgr.h"
47 #define ANIMA_ZOOM 1 /* ZoomIn/ZoomOut */
48 #define ANIMA_FADE 2 /* FadeIn/FadeOut */
49 #define ANIMA_SLIDE_TORIGHT 3 /* SlideIn left to right/SlideOut right to left*/
50 #define ANIMA_SLIDE_TOLEFT 4 /* SlideIn right to left/SlideOut left to right*/
51 #define ANIMA_SLIDE_TOBOTTOM 5 /* SlideIn top to bottom/SlideOut bottom to top*/
52 #define ANIMA_SLIDE_TOTOP 6 /* SlideIn bottom to top/SlideOut top to bottom*/
54 /* Visible control at end of animation */
55 #define ANIMA_NOCONTROL_AT_END 0 /* no need surface show/hide at end of animation*/
56 #define ANIMA_SHOW_AT_END 1 /* surface show at end of animation */
57 #define ANIMA_HIDE_AT_END 2 /* surface hide at end of animation */
60 struct animation_data {
61 struct animation_data *next_free; /* free data list */
62 char transform_set; /* need transform reset at end */
63 char res[3]; /* (unused) */
64 struct weston_transform transform; /* transform matrix */
65 void (*end_function)(struct weston_animation *animation);
66 /* animation end function */
69 /* static valiables */
70 static struct weston_compositor *weston_ec; /* Weston compositor */
71 static char *default_animation; /* default animation name */
72 static int animation_fps; /* animation frame rate(frame/sec) */
73 static int animation_time; /* default animation time(ms) */
74 static struct animation_data *free_data; /* free data list */
78 static void animation_slide(struct weston_animation *animation,
79 struct weston_output *output, uint32_t msecs);
81 static void animation_fade(struct weston_animation *animation,
82 struct weston_output *output, uint32_t msecs);
83 /* fade animation end */
84 static void animation_fade_end(struct weston_animation *animation);
86 static void animation_zoom(struct weston_animation *animation,
87 struct weston_output *output, uint32_t msecs);
88 /* zoom animation end */
89 static void animation_zoom_end(struct weston_animation *animation);
90 /* continue animation */
91 static int animation_cont(struct weston_animation *animation,
92 struct weston_output *output, uint32_t msecs);
93 /* terminate animation */
94 static void animation_end(struct uifw_win_surface *usurf, const int disp);
96 /*--------------------------------------------------------------------------*/
98 * @brief ico_window_animation: Animation addin entry
100 * @param[in] op animation operation
101 * @param[in] data data
103 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMA success
104 * @retval ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL success(no control)
105 * @retval ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA error(no animation)
107 /*--------------------------------------------------------------------------*/
109 ico_window_animation(const int op, void *data)
111 struct uifw_win_surface *usurf;
112 struct weston_output *output;
117 if (op == ICO_WINDOW_MGR_ANIMATION_NAME) {
118 /* convert animation name to animation type value */
119 if (strcasecmp((char *)data, "fade") == 0) {
120 uifw_trace("ico_window_animation: Type %s(%d)", (char *)data, ANIMA_FADE);
123 else if (strcasecmp((char *)data, "zoom") == 0) {
124 uifw_trace("ico_window_animation: Type %s(%d)", (char *)data, ANIMA_ZOOM);
127 else if (strcasecmp((char *)data, "slide.toleft") == 0) {
128 uifw_trace("ico_window_animation: Type %s(%d)", (char *)data, ANIMA_SLIDE_TOLEFT);
129 return ANIMA_SLIDE_TOLEFT;
131 else if (strcasecmp((char *)data, "slide.toright") == 0) {
132 uifw_trace("ico_window_animation: Type %s(%d)", (char *)data, ANIMA_SLIDE_TORIGHT);
133 return ANIMA_SLIDE_TORIGHT;
135 else if ((strcasecmp((char *)data, "slide.totop") == 0) ||
136 (strcasecmp((char *)data, "slide") == 0)) {
137 uifw_trace("ico_window_animation: Type %s(%d)", (char *)data, ANIMA_SLIDE_TOTOP);
138 return ANIMA_SLIDE_TOTOP;
140 else if (strcasecmp((char *)data, "slide.tobottom") == 0) {
141 uifw_trace("ico_window_animation: Type %s(%d)", (char *)data, ANIMA_SLIDE_TOBOTTOM);
142 return ANIMA_SLIDE_TOBOTTOM;
144 uifw_warn("ico_window_animation: Unknown Type %s", (char *)data);
145 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
148 usurf = (struct uifw_win_surface *)data;
150 if (op == ICO_WINDOW_MGR_ANIMATION_DESTROY) {
151 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
152 (usurf->animation.animadata != NULL)) {
153 uifw_trace("ico_window_animation: Destroy %08x", (int)usurf);
154 animation_end(usurf, 0);
156 return ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
159 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
161 if (op == ICO_WINDOW_MGR_ANIMATION_OPCANCEL) {
162 /* cancel animation */
163 if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
164 (usurf->animation.animation.frame != NULL)) {
165 uifw_trace("ico_window_animation: cancel %s.%08x",
166 usurf->uclient->appid, usurf->surfaceid);
167 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 0);
169 animation_end(usurf, 1);
170 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
173 /* setup animation */
174 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
175 (usurf->animation.current > 95)) {
176 usurf->animation.animation.frame_counter = 1;
177 usurf->animation.current = 0;
178 usurf->animation.ahalf = 0;
179 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) {
180 wl_list_init(&usurf->animation.animation.link);
181 output = container_of(weston_ec->output_list.next,
182 struct weston_output, link);
183 wl_list_insert(output->animation_list.prev,
184 &usurf->animation.animation.link);
187 else if (((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) &&
188 ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
189 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS))) ||
190 ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) &&
191 ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
192 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)))) {
193 /* change ...In(ex.FadeIn) to ...Out(FadeOut) or ...Out to ...In */
194 nowsec = weston_compositor_get_time();
195 usurf->animation.current = 100 - usurf->animation.current;
196 if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE)||
197 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
198 usurf->animation.time = usurf->animation.hide_time;
201 usurf->animation.time = usurf->animation.show_time;
203 if (usurf->animation.time == 0) {
204 usurf->animation.time = animation_time;
206 ret = ((usurf->animation.current) * usurf->animation.time) / 100;
207 if (nowsec >= (uint32_t)ret) {
208 usurf->animation.starttime = nowsec - ret;
211 usurf->animation.starttime = ((long long)nowsec) + ((long long)0x100000000L)
214 usurf->animation.animation.frame_counter = 2;
217 /* set animation function */
218 if ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
219 (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
220 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_SHOW;
221 animaid = usurf->animation.show_anima;
222 usurf->animation.anima = animaid;
223 uifw_trace("ico_window_animation: show(in) %s.%08x anima=%d",
224 usurf->uclient->appid, usurf->surfaceid, animaid);
225 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
227 else if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
228 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
229 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_HIDE;
230 animaid = usurf->animation.hide_anima;
231 usurf->animation.anima = animaid;
232 uifw_trace("ico_window_animation: hide(out) %s.%08x anima=%d",
233 usurf->uclient->appid, usurf->surfaceid, animaid);
234 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
235 usurf->animation.visible = ANIMA_HIDE_AT_END;
237 else if (op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
238 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_MOVE;
239 animaid = usurf->animation.move_anima;
240 usurf->animation.anima = animaid;
241 uifw_trace("ico_window_animation: move %s.%08x anima=%d",
242 usurf->uclient->appid, usurf->surfaceid, animaid);
243 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
245 else if (op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
246 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE;
247 animaid = usurf->animation.resize_anima;
248 usurf->animation.anima = animaid;
249 uifw_trace("ico_window_animation: resize %s.%08x anima=%d",
250 usurf->uclient->appid, usurf->surfaceid, animaid);
251 ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
254 uifw_trace("ico_window_animation: Op=%d unknown", op);
255 return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
257 if ((animaid == ANIMA_SLIDE_TOLEFT) || (animaid == ANIMA_SLIDE_TORIGHT) ||
258 (animaid == ANIMA_SLIDE_TOTOP) || (animaid == ANIMA_SLIDE_TOBOTTOM)) {
259 usurf->animation.animation.frame = animation_slide;
260 usurf->restrain_configure = 1;
261 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
263 else if (animaid == ANIMA_FADE) {
264 usurf->animation.animation.frame = animation_fade;
265 usurf->restrain_configure = 1;
266 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
268 else if (animaid == ANIMA_ZOOM) {
269 usurf->animation.animation.frame = animation_zoom;
270 usurf->restrain_configure = 1;
271 (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
275 usurf->animation.animation.frame = NULL;
276 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
277 usurf->restrain_configure = 0;
278 usurf->animation.anima = 0;
279 wl_list_remove(&usurf->animation.animation.link);
280 ret = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
282 usurf->animation.type = op;
284 weston_compositor_schedule_repaint(weston_ec);
288 /*--------------------------------------------------------------------------*/
290 * @brief animation_cont: continue animation
292 * @param[in] animation weston animation table
293 * @param[in] output weston output table
294 * @param[in] msecs current time stamp
295 * @return time has come
296 * @retval =0 time has come
297 * @retval >0 time has not yet come(return value is current parcent)
299 /*--------------------------------------------------------------------------*/
301 animation_cont(struct weston_animation *animation, struct weston_output *output,
304 struct uifw_win_surface *usurf;
308 nowsec = weston_compositor_get_time();
310 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
312 if (animation->frame_counter <= 1) {
313 /* first call, initialize */
314 animation->frame_counter = 1;
315 usurf->animation.starttime = nowsec;
316 usurf->animation.current = 1000;
317 if (! usurf->animation.animadata) {
319 usurf->animation.animadata = (void *)free_data;
320 free_data = free_data->next_free;
323 usurf->animation.animadata = (void *)malloc(sizeof(struct animation_data));
325 memset(usurf->animation.animadata, 0, sizeof(struct animation_data));
328 else if (! usurf->animation.animadata) {
329 animation_end(usurf, 0);
333 if (nowsec >= usurf->animation.starttime) {
334 nowsec = nowsec - usurf->animation.starttime; /* elapsed time(ms) */
337 nowsec = (uint32_t)(((long long)0x100000000L) +
338 ((long long)nowsec) - ((long long)usurf->animation.starttime));
340 switch (usurf->animation.state) {
341 case ICO_WINDOW_MGR_ANIMATION_STATE_SHOW:
342 usurf->animation.time = usurf->animation.show_time;
344 case ICO_WINDOW_MGR_ANIMATION_STATE_HIDE:
345 usurf->animation.time = usurf->animation.hide_time;
347 case ICO_WINDOW_MGR_ANIMATION_STATE_MOVE:
348 usurf->animation.time = usurf->animation.move_time;
351 usurf->animation.time = usurf->animation.resize_time;
354 if (usurf->animation.time == 0) {
355 usurf->animation.time = animation_time;
357 if (((output == NULL) && (msecs == 0)) || (nowsec >= ((uint32_t)usurf->animation.time))) {
361 par = (nowsec * 100 + usurf->animation.time / 2) / usurf->animation.time;
362 if (par < 2) par = 2;
365 (abs(usurf->animation.current - par) >=
366 (((1000 * 100) / animation_fps) / usurf->animation.time))) {
367 usurf->animation.current = par;
373 /*--------------------------------------------------------------------------*/
375 * @brief animation_end: terminate animation
377 * @param[in] usurf UIFW surface table
378 * @param[in] disp display control(1)/no display(0)
381 /*--------------------------------------------------------------------------*/
383 animation_end(struct uifw_win_surface *usurf, const int disp)
385 struct animation_data *animadata;
387 usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
388 animadata = (struct animation_data *)usurf->animation.animadata;
391 if (animadata->end_function) {
392 (*animadata->end_function)(&usurf->animation.animation);
394 wl_list_remove(&usurf->animation.animation.link);
395 if (animadata->transform_set) {
396 wl_list_remove(&animadata->transform.link);
397 animadata->transform_set = 0;
399 weston_surface_geometry_dirty(usurf->surface);
402 if ((usurf->animation.visible == ANIMA_HIDE_AT_END) &&
403 (usurf->visible != 0)) {
404 ico_window_mgr_set_visible(usurf, 0);
405 weston_surface_damage(usurf->surface);
407 if ((usurf->animation.visible == ANIMA_SHOW_AT_END) &&
408 (usurf->visible == 0)) {
409 ico_window_mgr_set_visible(usurf, 1);
410 weston_surface_damage(usurf->surface);
412 usurf->restrain_configure = 0;
413 weston_surface_geometry_dirty(usurf->surface);
414 weston_compositor_schedule_repaint(weston_ec);
416 usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
417 if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE) {
418 switch(usurf->animation.type) {
419 case ICO_WINDOW_MGR_ANIMATION_OPHIDE:
420 case ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS:
421 usurf->animation.hide_anima = usurf->animation.next_anima;
423 case ICO_WINDOW_MGR_ANIMATION_OPSHOW:
424 case ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS:
425 usurf->animation.show_anima = usurf->animation.next_anima;
427 case ICO_WINDOW_MGR_ANIMATION_OPMOVE:
428 usurf->animation.move_anima = usurf->animation.next_anima;
430 case ICO_WINDOW_MGR_ANIMATION_OPRESIZE:
431 usurf->animation.resize_anima = usurf->animation.next_anima;
436 usurf->animation.next_anima = ICO_WINDOW_MGR_ANIMATION_NONE;
439 usurf->animation.animadata = NULL;
440 animadata->next_free = free_data;
441 free_data = animadata;
443 usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE;
446 /*--------------------------------------------------------------------------*/
448 * @brief animation_slide: slide animation
450 * @param[in] animation weston animation table
451 * @param[in] outout weston output table
452 * @param[in] mseces current time(unused)
455 /*--------------------------------------------------------------------------*/
457 animation_slide(struct weston_animation *animation,
458 struct weston_output *output, uint32_t msecs)
460 struct uifw_win_surface *usurf;
461 struct weston_surface *es;
467 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
469 par = animation_cont(animation, output, msecs);
471 /* continue animation */
473 weston_compositor_schedule_repaint(weston_ec);
477 par = usurf->animation.current;
479 uifw_trace("animation_slide: usurf=%08x count=%d %d%% anima=%d state=%d",
480 (int)usurf, animation->frame_counter, par,
481 usurf->animation.anima, usurf->animation.state);
487 switch (usurf->animation.anima) {
488 case ANIMA_SLIDE_TORIGHT: /* slide in left to right */
489 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
490 /* slide in left to right */
491 x = 0 - usurf->animation.pos_width +
492 ((usurf->animation.pos_x + usurf->animation.pos_width) * par / 100);
495 /* slide out right to left */
496 x = 0 - usurf->animation.pos_width +
497 ((usurf->animation.pos_x + usurf->animation.pos_width) * (100 - par) / 100);
500 case ANIMA_SLIDE_TOLEFT: /* slide in right to left */
501 dwidth = (container_of(weston_ec->output_list.next,
502 struct weston_output, link))->width;
503 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
504 /* slide in right to left */
505 x = usurf->animation.pos_x +
506 (dwidth - usurf->animation.pos_x) * (100 - par) / 100;
509 /* slide out left to right */
510 x = usurf->animation.pos_x + (dwidth - usurf->animation.pos_x) * par / 100;
513 case ANIMA_SLIDE_TOBOTTOM: /* slide in top to bottom */
514 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
515 /* slide in top to bottom */
516 y = 0 - usurf->animation.pos_height +
517 ((usurf->animation.pos_y + usurf->animation.pos_height) * par / 100);
520 /* slide out bottom to top */
521 y = 0 - usurf->animation.pos_height +
522 ((usurf->animation.pos_y + usurf->animation.pos_height) * (100 - par) / 100);
525 default: /*ANIMA_SLIDE_TOTOP*/ /* slide in bottom to top */
526 dheight = (container_of(weston_ec->output_list.next,
527 struct weston_output, link))->height;
528 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
529 /* slide in bottom to top */
530 y = usurf->animation.pos_y +
531 (dheight - usurf->animation.pos_y) * (100 - par) / 100;
534 /* slide out top to bottom */
535 y = usurf->animation.pos_y + (dheight - usurf->animation.pos_y) * par / 100;
540 es->geometry.x = usurf->node_tbl->disp_x + x;
541 es->geometry.y = usurf->node_tbl->disp_y + y;
542 if ((es->output) && (es->buffer_ref.buffer) &&
543 (es->geometry.width > 0) && (es->geometry.height > 0)) {
544 weston_surface_geometry_dirty(es);
545 weston_surface_damage(es);
548 /* end of animation */
549 animation_end(usurf, 1);
550 uifw_trace("animation_slide: End of animation");
553 /* continue animation */
554 weston_compositor_schedule_repaint(weston_ec);
558 /*--------------------------------------------------------------------------*/
560 * @brief animation_fade: fade animation
562 * @param[in] animation weston animation table
563 * @param[in] outout weston output table
564 * @param[in] mseces current time(unused)
567 /*--------------------------------------------------------------------------*/
569 animation_fade(struct weston_animation *animation,
570 struct weston_output *output, uint32_t msecs)
572 struct uifw_win_surface *usurf;
573 struct animation_data *animadata;
574 struct weston_surface *es;
577 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
579 par = animation_cont(animation, output, msecs);
581 /* continue animation */
583 weston_compositor_schedule_repaint(weston_ec);
588 animadata = (struct animation_data *)usurf->animation.animadata;
590 par = usurf->animation.current;
591 if (animation->frame_counter == 1) {
592 if (animadata->transform_set == 0) {
593 animadata->transform_set = 1;
594 weston_matrix_init(&animadata->transform.matrix);
595 wl_list_init(&animadata->transform.link);
596 wl_list_insert(&es->geometry.transformation_list,
597 &animadata->transform.link);
599 animadata->end_function = animation_fade_end;
601 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
602 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
603 ico_window_mgr_set_weston_surface(usurf,
604 usurf->animation.pos_x, usurf->animation.pos_y,
605 usurf->animation.pos_width,
606 usurf->animation.pos_height);
610 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
612 es->alpha = ((float)par) / 100.0f;
614 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
616 es->alpha = 1.0f - (((float)par) / 100.0f);
619 /* fade move/resize */
620 if ((par >= 50) || (usurf->animation.ahalf)) {
621 es->alpha = ((float)(par*2 - 100)) / 100.0f;
622 if (usurf->animation.ahalf == 0) {
623 uifw_trace("animation_fade: fade move chaneg to show");
624 usurf->animation.ahalf = 1;
626 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
627 usurf->width, usurf->height);
628 ico_window_mgr_change_surface(usurf,
629 usurf->animation.no_configure ? -1 : 0, 1);
633 es->alpha = 1.0f - (((float)(par*2)) / 100.0f);
636 if (es->alpha < 0.0) es->alpha = 0.0;
637 else if (es->alpha > 1.0) es->alpha = 1.0;
639 uifw_trace("animation_fade: usurf=%08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
640 (int)usurf, animation->frame_counter, par, es->alpha,
641 usurf->animation.anima, usurf->animation.state);
643 if ((es->output) && (es->buffer_ref.buffer) &&
644 (es->geometry.width > 0) && (es->geometry.height > 0)) {
645 weston_surface_damage(es);
648 /* end of animation */
649 animation_end(usurf, 1);
650 uifw_trace("animation_fade: End of animation");
653 /* continue animation */
654 weston_compositor_schedule_repaint(weston_ec);
658 /*--------------------------------------------------------------------------*/
660 * @brief animation_fade_end: fade animation end
662 * @param[in] animation weston animation table
665 /*--------------------------------------------------------------------------*/
667 animation_fade_end(struct weston_animation *animation)
669 struct uifw_win_surface *usurf;
670 struct weston_surface *es;
672 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
673 if (usurf && usurf->surface) {
677 if ((es->output) && (es->buffer_ref.buffer) &&
678 (es->geometry.width > 0) && (es->geometry.height > 0)) {
679 weston_surface_damage(es);
684 /*--------------------------------------------------------------------------*/
686 * @brief animation_zoom: zoom animation
688 * @param[in] animation weston animation table
689 * @param[in] outout weston output table
690 * @param[in] mseces current time(unused)
693 /*--------------------------------------------------------------------------*/
695 animation_zoom(struct weston_animation *animation,
696 struct weston_output *output, uint32_t msecs)
698 struct uifw_win_surface *usurf;
699 struct animation_data *animadata;
700 struct weston_surface *es;
702 float scalex, scaley;
706 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
708 par = animation_cont(animation, output, msecs);
710 /* continue animation */
712 weston_compositor_schedule_repaint(weston_ec);
717 animadata = (struct animation_data *)usurf->animation.animadata;
719 par = usurf->animation.current;
720 if (animation->frame_counter == 1) {
721 if (animadata->transform_set == 0) {
722 animadata->transform_set = 1;
723 weston_matrix_init(&animadata->transform.matrix);
724 wl_list_init(&animadata->transform.link);
725 wl_list_insert(&es->geometry.transformation_list,
726 &animadata->transform.link);
728 animadata->end_function = animation_zoom_end;
730 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
731 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
732 ico_window_mgr_set_weston_surface(usurf,
733 usurf->animation.pos_x, usurf->animation.pos_y,
734 usurf->animation.pos_width,
735 usurf->animation.pos_height);
739 if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) {
741 scalex = ((float)par + 5.0f) / 105.0f;
744 else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) {
746 scalex = 1.0f - (((float)par + 5.0f) / 105.0f);
750 /* zoom move/resize */
751 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
752 usurf->width, usurf->height);
753 ico_window_mgr_change_surface(usurf, usurf->animation.no_configure ? -1 : 0, 1);
755 fu = (float)usurf->width;
756 fa = (float)usurf->animation.pos_width;
757 fp = (100.0f - (float)par) / 100.0f;
758 scalex = (fu - (fu - fa) * fp) / fu;
759 fu = (float)usurf->height;
760 fa = (float)usurf->animation.pos_height;
761 scaley = (fu - (fu - fa) * fp) / fu;
763 x = (((float)usurf->animation.pos_x) - ((float)usurf->x)) * fp + (float)usurf->x
764 + (((float)usurf->width * scalex) - (float)usurf->width) / 2.0f;
765 y = (((float)usurf->animation.pos_y) - ((float)usurf->y)) * fp + (float)usurf->y
766 + (((float)usurf->height * scaley) - (float) usurf->height) / 2.0f;
767 uifw_trace("animation_zoom: usurf=%08x %d%% x=%d/%d y=%d/%d",
768 (int)usurf, par, x, usurf->x, y, usurf->y);
769 uifw_trace("animation_zoom: sx=%4.2f sy=%4.2f x=%d->%d y=%d->%d cur=%d,%d",
770 scalex, scaley, usurf->animation.pos_x, usurf->x,
771 usurf->animation.pos_y, usurf->y, x, y);
772 ico_window_mgr_set_weston_surface(usurf, x, y, usurf->width, usurf->height);
774 weston_matrix_init(&animadata->transform.matrix);
775 weston_matrix_translate(&animadata->transform.matrix,
776 -0.5f * usurf->width, -0.5f * usurf->height, 0);
777 weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
778 weston_matrix_translate(&animadata->transform.matrix,
779 0.5f * usurf->width, 0.5f * usurf->height, 0);
781 uifw_trace("animation_zoom: usurf=%08x count=%d %d%% w=%d/%d h=%d/%d anima=%d state=%d",
782 (int)usurf, animation->frame_counter, par,
783 (int)(usurf->width * scalex), usurf->width,
784 (int)(usurf->height * scaley), usurf->height,
785 usurf->animation.anima, usurf->animation.state);
787 if ((es->output) && (es->buffer_ref.buffer) &&
788 (es->geometry.width > 0) && (es->geometry.height > 0)) {
789 weston_surface_geometry_dirty(es);
790 weston_surface_damage(es);
793 /* end of animation */
794 animation_end(usurf, 1);
795 uifw_trace("animation_zoom: End of animation");
798 /* continue animation */
799 weston_compositor_schedule_repaint(weston_ec);
803 /*--------------------------------------------------------------------------*/
805 * @brief animation_zoom_end: zoom animation end
807 * @param[in] animation weston animation table
810 /*--------------------------------------------------------------------------*/
812 animation_zoom_end(struct weston_animation *animation)
814 struct uifw_win_surface *usurf;
815 struct weston_surface *es;
817 usurf = container_of(animation, struct uifw_win_surface, animation.animation);
818 if (usurf && usurf->surface) {
822 if ((es->output) && (es->buffer_ref.buffer) &&
823 (es->geometry.width > 0) && (es->geometry.height > 0)) {
824 weston_surface_damage(es);
829 /*--------------------------------------------------------------------------*/
831 * @brief module_init: initialize ico_window_animation
832 * this function called from ico_pluign_loader
834 * @param[in] es weston compositor
835 * @param[in] argc number of arguments(unused)
836 * @param[in] argv argument list(unused)
841 /*--------------------------------------------------------------------------*/
843 module_init(struct weston_compositor *ec, int *argc, char *argv[])
846 struct animation_data *animadata;
848 uifw_info("ico_window_animation: Enter(module_init)");
850 /* allocate animation datas */
852 for (i = 0; i < 50; i++) {
853 animadata = (struct animation_data *)malloc(sizeof(struct animation_data));
855 uifw_error("ico_window_animation: No Memory(module_init)");
858 animadata->next_free = free_data;
859 free_data = animadata;
863 default_animation = (char *)ico_ivi_default_animation_name();
864 animation_time = ico_ivi_default_animation_time();
865 animation_fps = ico_ivi_default_animation_fps();
867 ico_window_mgr_set_hook_animation(ico_window_animation);
869 uifw_info("ico_window_animation: Leave(module_init)");