0be76d8ee7325ab59d9ee68dd6fdd527680990c2
[profile/ivi/ico-uxf-weston-plugin.git] / src / ico_window_animation.c
1 /*
2  * Copyright © 2010-2011 Intel Corporation
3  * Copyright © 2008-2011 Kristian Høgsberg
4  * Copyright © 2013 TOYOTA MOTOR CORPORATION.
5  *
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.
15  *
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.
23  */
24 /**
25  * @brief   Window Animation (Weston(Wayland) PlugIn)
26  *
27  * @date    Jul-26-2013
28  */
29
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <stdbool.h>
33 #include <string.h>
34 #include <unistd.h>
35 #include <math.h>
36 #include <time.h>
37 #include <sys/types.h>
38 #include <sys/time.h>
39 #include <sys/stat.h>
40
41 #include <weston/compositor.h>
42 #include "ico_ivi_common.h"
43 #include "ico_ivi_shell.h"
44 #include "ico_window_mgr.h"
45
46 /* Animation type               */
47 #define ANIMA_ZOOM              1           /* ZoomIn/ZoomOut                       */
48 #define ANIMA_FADE              2           /* FadeIn/FadeOut                       */
49 #define ANIMA_SLIDE_TORIGHT    11           /* SlideIn left to right/SlideOut right to left */
50 #define ANIMA_SLIDE_TOLEFT     12           /* SlideIn right to left/SlideOut left to right */
51 #define ANIMA_SLIDE_TOBOTTOM   13           /* SlideIn top to bottom/SlideOut bottom to top */
52 #define ANIMA_SLIDE_TOTOP      14           /* SlideIn bottom to top/SlideOut top to bottom */
53 #define ANIMA_WIPE_TORIGHT     21           /* WipeIn left to right/WipeOut right to left   */
54 #define ANIMA_WIPE_TOLEFT      22           /* WipeIn right to left/WipeOut left to right   */
55 #define ANIMA_WIPE_TOBOTTOM    23           /* WipeIn top to bottom/WipeOut bottom to top   */
56 #define ANIMA_WIPE_TOTOP       24           /* WipeIn bottom to top/WipeOut top to bottom   */
57 #define ANIMA_SWING_TORIGHT    31           /* SwingIn left to right/SwingOut right to left */
58 #define ANIMA_SWING_TOLEFT     32           /* SwingIn right to left/SwingOut left to right */
59 #define ANIMA_SWING_TOBOTTOM   33           /* SwingIn top to bottom/SwingOut bottom to top */
60 #define ANIMA_SWING_TOTOP      34           /* SwingIn bottom to top/SwingOut top to bottom */
61
62 /* Visible control at end of animation  */
63 #define ANIMA_NOCONTROL_AT_END  0           /* no need surface show/hide at end of animation*/
64 #define ANIMA_SHOW_AT_END       1           /* surface show at end of animation     */
65 #define ANIMA_HIDE_AT_END       2           /* surface hide at end of animation     */
66
67 /* animation data               */
68 struct animation_data   {
69     struct animation_data   *next_free;     /* free data list                       */
70     char    transform_set;                  /* need transform reset at end          */
71     char    res[3];                         /* (unused)                             */
72     struct weston_transform transform;      /* transform matrix                     */
73     void    (*end_function)(struct weston_animation *animation);
74                                             /* animation end function               */
75 };
76
77 /* static valiables             */
78 static struct weston_compositor *weston_ec; /* Weston compositor                    */
79 static char *default_animation;             /* default animation name               */
80 static int  animation_fps;                  /* animation frame rate(frame/sec)      */
81 static int  animation_time;                 /* default animation time(ms)           */
82 static int  animation_count;                /* current number of animations         */
83 static struct animation_data    *free_data; /* free data list                       */
84
85 /* support animation names      */
86 static const struct _supprt_animaetions {
87     char    *name;
88     int     animaid;
89 }               supprt_animaetions[] = {
90     { "fade", ANIMA_FADE },
91     { "zoom", ANIMA_ZOOM },
92     { "slide", ANIMA_SLIDE_TOTOP },
93     { "slide.toleft", ANIMA_SLIDE_TOLEFT },
94     { "slide.toright", ANIMA_SLIDE_TORIGHT },
95     { "slide.totop", ANIMA_SLIDE_TOTOP },
96     { "slide.tobottom", ANIMA_SLIDE_TOBOTTOM },
97     { "wipe", ANIMA_WIPE_TOTOP },
98     { "wipe.toleft", ANIMA_WIPE_TOLEFT },
99     { "wipe.toright", ANIMA_WIPE_TORIGHT },
100     { "wipe.totop", ANIMA_WIPE_TOTOP },
101     { "wipe.tobottom", ANIMA_WIPE_TOBOTTOM },
102     { "swing", ANIMA_SWING_TOTOP },
103     { "swing.toleft", ANIMA_SWING_TOLEFT },
104     { "swing.toright", ANIMA_SWING_TORIGHT },
105     { "swing.totop", ANIMA_SWING_TOTOP },
106     { "swing.tobottom", ANIMA_SWING_TOBOTTOM },
107     { "\0", -1 }
108 };
109
110 /* static function              */
111                                             /* slide animation                      */
112 static void animation_slide(struct weston_animation *animation,
113                             struct weston_output *output, uint32_t msecs);
114                                             /* wipe animation                       */
115 static void animation_wipe(struct weston_animation *animation,
116                            struct weston_output *output, uint32_t msecs);
117                                             /* swing animation                      */
118 static void animation_swing(struct weston_animation *animation,
119                             struct weston_output *output, uint32_t msecs);
120                                             /* swing animation end                  */
121 static void animation_swing_end(struct weston_animation *animation);
122                                             /* fade animation                       */
123 static void animation_fade(struct weston_animation *animation,
124                            struct weston_output *output, uint32_t msecs);
125                                             /* fade animation end                   */
126 static void animation_fade_end(struct weston_animation *animation);
127                                             /* zoom animation                       */
128 static void animation_zoom(struct weston_animation *animation,
129                            struct weston_output *output, uint32_t msecs);
130                                             /* zoom animation end                   */
131 static void animation_zoom_end(struct weston_animation *animation);
132                                             /* continue animation                   */
133 static int animation_cont(struct weston_animation *animation,
134                           struct weston_output *output, uint32_t msecs);
135                                             /* terminate animation                  */
136 static void animation_end(struct uifw_win_surface *usurf, const int disp);
137
138 /*--------------------------------------------------------------------------*/
139 /**
140  * @brief   ico_window_animation: Animation addin entry
141  *
142  * @param[in]   op      animation operation
143  * @param[in]   data    data
144  * @return      result
145  * @retval      ICO_WINDOW_MGR_ANIMATION_RET_ANIMA      success
146  * @retval      ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL success(no control)
147  * @retval      ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA    error(no animation)
148  */
149 /*--------------------------------------------------------------------------*/
150 static int
151 ico_window_animation(const int op, void *data)
152 {
153     struct uifw_win_surface *usurf;
154     struct weston_output *output;
155     int         idx;
156     int         ret;
157     uint32_t    nowsec;
158     int         animaid;
159
160     if (op == ICO_WINDOW_MGR_ANIMATION_NAME)    {
161         /* convert animation name to animation type value   */
162         for (idx = 0; supprt_animaetions[idx].animaid > 0; idx++)   {
163             if (strcasecmp(supprt_animaetions[idx].name, (char *)data) == 0)    {
164                 uifw_trace("ico_window_animation: Type %s(%d)",
165                            (char *)data, supprt_animaetions[idx].animaid);
166                 return supprt_animaetions[idx].animaid;
167             }
168         }
169         uifw_warn("ico_window_animation: Unknown Type %s", (char *)data);
170         return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
171     }
172
173     usurf = (struct uifw_win_surface *)data;
174
175     if (op == ICO_WINDOW_MGR_ANIMATION_DESTROY) {
176         if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
177             (usurf->animation.animadata != NULL)) {
178             uifw_trace("ico_window_animation: Destroy %08x", usurf->surfaceid);
179             animation_end(usurf, 0);
180         }
181         return ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
182     }
183
184     usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
185
186     if (op == ICO_WINDOW_MGR_ANIMATION_OPCANCEL)    {
187         /* cancel animation                     */
188         if ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
189             (usurf->animation.animation.frame != NULL)) {
190             uifw_trace("ico_window_animation: cancel %s.%08x",
191                        usurf->uclient->appid, usurf->surfaceid);
192             (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 0);
193         }
194         animation_end(usurf, 1);
195         ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
196     }
197     else    {
198         /* setup animation              */
199         if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) ||
200             (usurf->animation.current > 95))    {
201             usurf->animation.animation.frame_counter = 1;
202             usurf->animation.current = 0;
203             usurf->animation.ahalf = 0;
204             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE)  {
205                 wl_list_init(&usurf->animation.animation.link);
206                 output = container_of(weston_ec->output_list.next,
207                                       struct weston_output, link);
208                 wl_list_insert(output->animation_list.prev,
209                                &usurf->animation.animation.link);
210                 animation_count ++;
211             }
212         }
213         else if (((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW) &&
214                   ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
215                    (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS))) ||
216                  ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE) &&
217                   ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
218                    (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS))))   {
219             /* change ...In(ex.FadeIn) to ...Out(FadeOut) or ...Out to ...In    */
220             nowsec = weston_compositor_get_time();
221             usurf->animation.current = 100 - usurf->animation.current;
222             if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE)||
223                 (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
224                 usurf->animation.time = usurf->animation.hide_time;
225             }
226             else    {
227                 usurf->animation.time = usurf->animation.show_time;
228             }
229             if (usurf->animation.time == 0) {
230                 usurf->animation.time = animation_time;
231             }
232             ret = ((usurf->animation.current) * usurf->animation.time) / 100;
233             if (nowsec >= (uint32_t)ret)    {
234                 usurf->animation.starttime = nowsec - ret;
235             }
236             else    {
237                 usurf->animation.starttime = ((long long)nowsec) + ((long long)0x100000000L)
238                                              - ((long long)ret);
239             }
240             usurf->animation.animation.frame_counter = 2;
241         }
242
243         /* set animation function       */
244         if ((op == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
245             (op == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
246             usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_SHOW;
247             animaid = usurf->animation.show_anima;
248             usurf->animation.anima = animaid;
249             uifw_trace("ico_window_animation: show(in) %s.%08x anima=%d",
250                        usurf->uclient->appid, usurf->surfaceid, animaid);
251             ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
252         }
253         else if ((op == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
254                  (op == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS))    {
255             usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_HIDE;
256             animaid = usurf->animation.hide_anima;
257             usurf->animation.anima = animaid;
258             uifw_trace("ico_window_animation: hide(out) %s.%08x anima=%d",
259                        usurf->uclient->appid, usurf->surfaceid, animaid);
260             ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
261             usurf->animation.visible = ANIMA_HIDE_AT_END;
262         }
263         else if (op == ICO_WINDOW_MGR_ANIMATION_OPMOVE)    {
264             usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_MOVE;
265             animaid = usurf->animation.move_anima;
266             usurf->animation.anima = animaid;
267             uifw_trace("ico_window_animation: move %s.%08x anima=%d",
268                        usurf->uclient->appid, usurf->surfaceid, animaid);
269             ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
270         }
271         else if (op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE)    {
272             usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE;
273             animaid = usurf->animation.resize_anima;
274             usurf->animation.anima = animaid;
275             uifw_trace("ico_window_animation: resize %s.%08x anima=%d",
276                        usurf->uclient->appid, usurf->surfaceid, animaid);
277             ret = ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL;
278         }
279         else    {
280             uifw_trace("ico_window_animation: Op=%d unknown", op);
281             return ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
282         }
283         if ((animaid == ANIMA_SLIDE_TOLEFT) || (animaid == ANIMA_SLIDE_TORIGHT) ||
284             (animaid == ANIMA_SLIDE_TOTOP) || (animaid == ANIMA_SLIDE_TOBOTTOM))  {
285             usurf->animation.animation.frame = animation_slide;
286             usurf->restrain_configure = 1;
287             (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
288         }
289         else if ((animaid == ANIMA_WIPE_TOLEFT) || (animaid == ANIMA_WIPE_TORIGHT) ||
290                  (animaid == ANIMA_WIPE_TOTOP) || (animaid == ANIMA_WIPE_TOBOTTOM))  {
291             usurf->animation.animation.frame = animation_wipe;
292             usurf->restrain_configure = 1;
293             (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
294         }
295         else if ((animaid == ANIMA_SWING_TOLEFT) || (animaid == ANIMA_SWING_TORIGHT) ||
296                  (animaid == ANIMA_SWING_TOTOP) || (animaid == ANIMA_SWING_TOBOTTOM))  {
297             usurf->animation.animation.frame = animation_swing;
298             usurf->restrain_configure = 1;
299             (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
300         }
301         else if (animaid == ANIMA_FADE)   {
302             usurf->animation.animation.frame = animation_fade;
303             usurf->restrain_configure = 1;
304             (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
305         }
306         else if (animaid == ANIMA_ZOOM)   {
307             usurf->animation.animation.frame = animation_zoom;
308             usurf->restrain_configure = 1;
309             (*usurf->animation.animation.frame)(&usurf->animation.animation, NULL, 1);
310         }
311         else    {
312             /* no yet support   */
313             usurf->animation.animation.frame = NULL;
314             usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
315             usurf->restrain_configure = 0;
316             usurf->animation.anima = 0;
317             wl_list_remove(&usurf->animation.animation.link);
318             ret = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
319         }
320         usurf->animation.type = op;
321     }
322     weston_compositor_schedule_repaint(weston_ec);
323     return ret;
324 }
325
326 /*--------------------------------------------------------------------------*/
327 /**
328  * @brief   animation_cont: continue animation
329  *
330  * @param[in]   animation   weston animation table
331  * @param[in]   output      weston output table
332  * @param[in]   msecs       current time stamp
333  * @return      time has come
334  * @retval      =0          time has come
335  * @retval      >0          time has not yet come(return value is current parcent)
336  */
337 /*--------------------------------------------------------------------------*/
338 static int
339 animation_cont(struct weston_animation *animation, struct weston_output *output,
340                uint32_t msecs)
341 {
342     struct uifw_win_surface *usurf;
343     int         par;
344     uint32_t    nowsec;
345
346     nowsec = weston_compositor_get_time();
347
348     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
349
350     if (animation->frame_counter <= 1)  {
351         /* first call, initialize           */
352         animation->frame_counter = 1;
353         usurf->animation.starttime = nowsec;
354         usurf->animation.current = 1000;
355         if (! usurf->animation.animadata) {
356             if (free_data)  {
357                 usurf->animation.animadata = (void *)free_data;
358                 free_data = free_data->next_free;
359             }
360             else    {
361                 usurf->animation.animadata = (void *)malloc(sizeof(struct animation_data));
362             }
363             memset(usurf->animation.animadata, 0, sizeof(struct animation_data));
364         }
365     }
366     else if (! usurf->animation.animadata)    {
367         animation_end(usurf, 0);
368         return 999;
369     }
370
371     if (nowsec >= usurf->animation.starttime)   {
372         nowsec = nowsec - usurf->animation.starttime;   /* elapsed time(ms) */
373     }
374     else    {
375         nowsec = (uint32_t)(((long long)0x100000000L) +
376                             ((long long)nowsec) - ((long long)usurf->animation.starttime));
377     }
378     switch (usurf->animation.state) {
379     case ICO_WINDOW_MGR_ANIMATION_STATE_SHOW:
380         usurf->animation.time = usurf->animation.show_time;
381         break;
382     case ICO_WINDOW_MGR_ANIMATION_STATE_HIDE:
383         usurf->animation.time = usurf->animation.hide_time;
384         break;
385     case ICO_WINDOW_MGR_ANIMATION_STATE_MOVE:
386         usurf->animation.time = usurf->animation.move_time;
387         break;
388     default:
389         usurf->animation.time = usurf->animation.resize_time;
390         break;
391     }
392     if (usurf->animation.time == 0) {
393         usurf->animation.time = animation_time;
394     }
395     if (((output == NULL) && (msecs == 0)) || (nowsec >= ((uint32_t)usurf->animation.time))) {
396         par = 100;
397     }
398     else    {
399         par = (nowsec * 100 + usurf->animation.time / 2) / usurf->animation.time;
400         if (par < 2)    par = 2;
401     }
402     if ((par >= 100) ||
403         (abs(usurf->animation.current - par) >=
404          (((1000 * 100) / animation_fps) / usurf->animation.time)) ||
405         ((animation_count > 1) && (par != usurf->animation.current)))   {
406         usurf->animation.current = par;
407         return 0;
408     }
409     return par;
410 }
411
412 /*--------------------------------------------------------------------------*/
413 /**
414  * @brief   animation_end: terminate animation
415  *
416  * @param[in]   usurf       UIFW surface table
417  * @param[in]   disp        display control(1)/no display(0)
418  * @return      none
419  */
420 /*--------------------------------------------------------------------------*/
421 static void
422 animation_end(struct uifw_win_surface *usurf, const int disp)
423 {
424     struct animation_data   *animadata;
425
426     usurf->animation.state = ICO_WINDOW_MGR_ANIMATION_STATE_NONE;
427     animadata = (struct animation_data *)usurf->animation.animadata;
428
429     if (animation_count > 0)    {
430         animation_count --;
431     }
432
433     if (animadata)  {
434         if (animadata->end_function)    {
435             (*animadata->end_function)(&usurf->animation.animation);
436         }
437         wl_list_remove(&usurf->animation.animation.link);
438         if (animadata->transform_set)   {
439             wl_list_remove(&animadata->transform.link);
440             animadata->transform_set = 0;
441         }
442         weston_surface_geometry_dirty(usurf->surface);
443     }
444     if (disp)   {
445         usurf->restrain_configure = 0;
446         if ((usurf->animation.visible == ANIMA_HIDE_AT_END) &&
447             (usurf->visible != 0))  {
448             ico_window_mgr_set_visible(usurf, 0);
449             weston_surface_damage(usurf->surface);
450         }
451         if ((usurf->animation.visible == ANIMA_SHOW_AT_END) &&
452             (usurf->visible == 0))  {
453             ico_window_mgr_set_visible(usurf, 1);
454             weston_surface_damage(usurf->surface);
455         }
456         weston_surface_geometry_dirty(usurf->surface);
457         ico_window_mgr_restack_layer(usurf);
458     }
459     usurf->animation.visible = ANIMA_NOCONTROL_AT_END;
460     if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE)    {
461         switch(usurf->animation.type)   {
462         case ICO_WINDOW_MGR_ANIMATION_OPHIDE:
463         case ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS:
464             usurf->animation.hide_anima = usurf->animation.next_anima;
465             break;
466         case ICO_WINDOW_MGR_ANIMATION_OPSHOW:
467         case ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS:
468             usurf->animation.show_anima = usurf->animation.next_anima;
469             break;
470         case ICO_WINDOW_MGR_ANIMATION_OPMOVE:
471             usurf->animation.move_anima = usurf->animation.next_anima;
472             break;
473         case ICO_WINDOW_MGR_ANIMATION_OPRESIZE:
474             usurf->animation.resize_anima = usurf->animation.next_anima;
475             break;
476         default:
477             break;
478         }
479         usurf->animation.next_anima = ICO_WINDOW_MGR_ANIMATION_NONE;
480     }
481     if (animadata)   {
482         usurf->animation.animadata = NULL;
483         animadata->next_free = free_data;
484         free_data = animadata;
485     }
486     usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE;
487     if (! disp) {
488         ico_window_mgr_restack_layer(usurf);
489     }
490 }
491
492 /*--------------------------------------------------------------------------*/
493 /**
494  * @brief   animation_slide: slide animation
495  *
496  * @param[in]   animation   weston animation table
497  * @param[in]   outout      weston output table
498  * @param[in]   mseces      current time(unused)
499  * @return      none
500  */
501 /*--------------------------------------------------------------------------*/
502 static void
503 animation_slide(struct weston_animation *animation,
504                 struct weston_output *output, uint32_t msecs)
505 {
506     struct uifw_win_surface *usurf;
507     struct weston_surface   *es;
508     int         dwidth, dheight;
509     int         par;
510     int         x;
511     int         y;
512
513     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
514
515     par = animation_cont(animation, output, msecs);
516     if (par > 0)    {
517         /* continue animation   */
518         if( par <= 100) {
519             weston_compositor_schedule_repaint(weston_ec);
520         }
521         return;
522     }
523     par = usurf->animation.current;
524
525     uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d",
526                usurf->surfaceid, animation->frame_counter, par,
527                usurf->animation.anima, usurf->animation.state);
528
529     es = usurf->surface;
530     x = usurf->x;
531     y = usurf->y;
532
533     switch (usurf->animation.anima)  {
534     case ANIMA_SLIDE_TORIGHT:           /* slide in left to right           */
535         if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
536             /* slide in left to right   */
537             x = 0 - usurf->animation.pos_width +
538                 ((usurf->animation.pos_x + usurf->animation.pos_width) * par / 100);
539         }
540         else    {
541             /* slide out right to left  */
542             x = 0 - usurf->animation.pos_width +
543                 ((usurf->animation.pos_x + usurf->animation.pos_width) * (100 - par) / 100);
544         }
545         break;
546     case ANIMA_SLIDE_TOLEFT:            /* slide in right to left           */
547         dwidth = usurf->node_tbl->disp_width;
548         if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
549             /* slide in right to left   */
550             x = usurf->animation.pos_x +
551                 (dwidth - usurf->animation.pos_x) * (100 - par) / 100;
552         }
553         else    {
554             /* slide out left to right  */
555             x = usurf->animation.pos_x + (dwidth - usurf->animation.pos_x) * par / 100;
556         }
557         break;
558     case ANIMA_SLIDE_TOBOTTOM:          /* slide in top to bottom           */
559         if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
560             /* slide in top to bottom   */
561             y = 0 - usurf->animation.pos_height +
562                 ((usurf->animation.pos_y + usurf->animation.pos_height) * par / 100);
563         }
564         else    {
565             /* slide out bottom to top  */
566             y = 0 - usurf->animation.pos_height +
567                 ((usurf->animation.pos_y + usurf->animation.pos_height) * (100 - par) / 100);
568         }
569         break;
570     default: /*ANIMA_SLIDE_TOTOP*/      /* slide in bottom to top           */
571         dheight = usurf->node_tbl->disp_height;
572         if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
573             /* slide in bottom to top   */
574             y = usurf->animation.pos_y +
575                 (dheight - usurf->animation.pos_y) * (100 - par) / 100;
576         }
577         else    {
578             /* slide out top to bottom  */
579             y = usurf->animation.pos_y + (dheight - usurf->animation.pos_y) * par / 100;
580         }
581         break;
582     }
583
584     uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d)",
585                usurf->surfaceid, par, x, y, usurf->x, usurf->y);
586     es->geometry.x = usurf->node_tbl->disp_x + x;
587     es->geometry.y = usurf->node_tbl->disp_y + y;
588     if ((es->output) && (es->buffer_ref.buffer) &&
589         (es->geometry.width > 0) && (es->geometry.height > 0)) {
590         weston_surface_geometry_dirty(es);
591         weston_surface_damage(es);
592     }
593     if (par >= 100) {
594         /* end of animation     */
595         animation_end(usurf, 1);
596         uifw_trace("animation_slide: End of animation");
597     }
598     else    {
599         /* continue animation   */
600         weston_compositor_schedule_repaint(weston_ec);
601     }
602 }
603
604 /*--------------------------------------------------------------------------*/
605 /**
606  * @brief   animation_wipe: wipe animation
607  *
608  * @param[in]   animation   weston animation table
609  * @param[in]   outout      weston output table
610  * @param[in]   mseces      current time(unused)
611  * @return      none
612  */
613 /*--------------------------------------------------------------------------*/
614 static void
615 animation_wipe(struct weston_animation *animation,
616                struct weston_output *output, uint32_t msecs)
617 {
618     struct uifw_win_surface *usurf;
619     struct weston_surface   *es;
620     int         par;
621     int         x;
622     int         y;
623     int         width;
624     int         height;
625
626     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
627
628     par = animation_cont(animation, output, msecs);
629     if (par > 0)    {
630         /* continue animation   */
631         if( par <= 100) {
632             weston_compositor_schedule_repaint(weston_ec);
633         }
634         return;
635     }
636     par = usurf->animation.current;
637
638     uifw_debug("animation_wipe: %08x count=%d %d%% anima=%d state=%d",
639                usurf->surfaceid, animation->frame_counter, par,
640                usurf->animation.anima, usurf->animation.state);
641
642     es = usurf->surface;
643     x = usurf->x;
644     y = usurf->y;
645     width = usurf->width;
646     height = usurf->width;
647
648     if (par < 100)  {
649         switch (usurf->animation.anima)  {
650         case ANIMA_WIPE_TORIGHT:            /* wipe in left to right            */
651             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
652                 /* wipe in left to right    */
653                 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
654             }
655             else    {
656                 /* wipe out right to left   */
657                 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
658             }
659             if (width <= 0) width = 1;
660             break;
661         case ANIMA_WIPE_TOLEFT:             /* wipe in right to left            */
662             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
663                 /* wipe in right to left    */
664                 width = ((float)width) * ((float)par + 5.0f) / 105.0f;
665             }
666             else    {
667                 /* wipe out left to right   */
668                 width = width - (((float)width) * ((float)par + 5.0f) / 105.0f);
669             }
670             if (width <= 0) width = 1;
671             x = x + (usurf->width - width);
672             break;
673         case ANIMA_WIPE_TOBOTTOM:           /* wipe in top to bottom            */
674             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
675                 /* wipe in top to bottom    */
676                 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
677             }
678             else    {
679                 /* wipe out bottom to top   */
680                 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
681             }
682             if (height <= 0)    height = 1;
683             break;
684         default: /*ANIMA_WIPE_TOTOP*/       /* wipe in bottom to top            */
685             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
686                 /* wipe in bottom to top    */
687                 height = ((float)height) * ((float)par + 5.0f) / 105.0f;
688             }
689             else    {
690                 /* wipe out top to bottom   */
691                 height = height - (((float)height) * ((float)par + 5.0f) / 105.0f);
692             }
693             if (height <= 0)    height = 1;
694             y = y + (usurf->height - height);
695             break;
696         }
697     }
698
699     es->geometry.x = usurf->node_tbl->disp_x + x;
700     es->geometry.y = usurf->node_tbl->disp_y + y;
701     es->geometry.width = width;
702     es->geometry.height = height;
703     if ((es->output) && (es->buffer_ref.buffer))    {
704         weston_surface_geometry_dirty(es);
705         weston_surface_damage(es);
706     }
707     if (par >= 100) {
708         /* end of animation     */
709         animation_end(usurf, 1);
710         uifw_trace("animation_wipe: End of animation");
711     }
712     else    {
713         /* continue animation   */
714         weston_compositor_schedule_repaint(weston_ec);
715     }
716 }
717
718 /*--------------------------------------------------------------------------*/
719 /**
720  * @brief   animation_swing: swing animation
721  *
722  * @param[in]   animation   weston animation table
723  * @param[in]   outout      weston output table
724  * @param[in]   mseces      current time(unused)
725  * @return      none
726  */
727 /*--------------------------------------------------------------------------*/
728 static void
729 animation_swing(struct weston_animation *animation,
730                 struct weston_output *output, uint32_t msecs)
731 {
732     struct uifw_win_surface *usurf;
733     struct weston_surface   *es;
734     struct animation_data   *animadata;
735     int         par;
736     int         x;
737     int         y;
738     float       scalex;
739     float       scaley;
740
741     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
742
743     par = animation_cont(animation, output, msecs);
744     if (par > 0)    {
745         /* continue animation   */
746         if( par <= 100) {
747             weston_compositor_schedule_repaint(weston_ec);
748         }
749         return;
750     }
751
752     uifw_debug("animation_swing: %08x count=%d %d%% anima=%d state=%d",
753                usurf->surfaceid, animation->frame_counter, par,
754                usurf->animation.anima, usurf->animation.state);
755
756     animadata = (struct animation_data *)usurf->animation.animadata;
757     es = usurf->surface;
758     par = usurf->animation.current;
759     if (animation->frame_counter == 1)  {
760         if (animadata->transform_set == 0)  {
761             animadata->transform_set = 1;
762             weston_matrix_init(&animadata->transform.matrix);
763             wl_list_init(&animadata->transform.link);
764             wl_list_insert(&es->geometry.transformation_list,
765                            &animadata->transform.link);
766         }
767         animadata->end_function = animation_swing_end;
768     }
769
770     x = usurf->x;
771     y = usurf->y;
772     scalex = 1.0;
773     scaley = 1.0;
774
775     if (par < 100)  {
776         switch (usurf->animation.anima)  {
777         case ANIMA_SWING_TORIGHT:           /* swing in left to right           */
778             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
779                 /* swing in left to right   */
780                 scalex = ((float)par + 5.0f) / 105.0f;
781             }
782             else    {
783                 /* swing out right to left  */
784                 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
785             }
786             if (scalex <= 0.0)  scalex = 0.01;
787             break;
788         case ANIMA_SWING_TOLEFT:            /* seing in right to left           */
789             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
790                 /* swing in right to left   */
791                 scalex = ((float)par + 5.0f) / 105.0f;
792             }
793             else    {
794                 /* swing out left to right  */
795                 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
796             }
797             if (scalex <= 0.0)  scalex = 0.01;
798             x = x + (int)((float)usurf->width * (1.0f - scalex));
799             break;
800         case ANIMA_SWING_TOBOTTOM:          /* swing in top to bottom           */
801             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
802                 /* swing in top to bottom   */
803                 scaley = ((float)par + 5.0f) / 105.0f;
804             }
805             else    {
806                 /* swing out bottom to top  */
807                 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
808             }
809             if (scaley <= 0.0)  scaley = 0.01;
810             break;
811         default: /*ANIMA_SWING*/        /* swing in bottom to top               */
812             if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
813                 /* wipe in bottom to top    */
814                 scaley = ((float)par + 5.0f) / 105.0f;
815             }
816             else    {
817                 /* wipe out top to bottom   */
818                 scalex = 1.0 - (((float)par + 5.0f) / 105.0f);
819             }
820             if (scaley <= 0.0)  scaley = 0.01;
821             y = y + (int)((float)usurf->height * (1.0f - scaley));
822             break;
823         }
824     }
825
826     es->geometry.x = usurf->node_tbl->disp_x + x;
827     es->geometry.y = usurf->node_tbl->disp_y + y;
828     weston_matrix_init(&animadata->transform.matrix);
829     weston_matrix_translate(&animadata->transform.matrix,
830                             -0.5f * usurf->width, -0.5f * usurf->height, 0);
831     weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
832     weston_matrix_translate(&animadata->transform.matrix,
833                             0.5f * usurf->width, 0.5f * usurf->height, 0);
834
835     if ((es->output) && (es->buffer_ref.buffer))    {
836         weston_surface_geometry_dirty(es);
837         weston_surface_damage(es);
838     }
839     if (par >= 100) {
840         /* end of animation     */
841         animation_end(usurf, 1);
842         uifw_trace("animation_swing: End of animation");
843     }
844     else    {
845         /* continue animation   */
846         weston_compositor_schedule_repaint(weston_ec);
847     }
848 }
849
850 /*--------------------------------------------------------------------------*/
851 /**
852  * @brief   animation_swing_end: swing animation end
853  *
854  * @param[in]   animation   weston animation table
855  * @return      none
856  */
857 /*--------------------------------------------------------------------------*/
858 static void
859 animation_swing_end(struct weston_animation *animation)
860 {
861     struct uifw_win_surface *usurf;
862     struct weston_surface   *es;
863
864     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
865     if (usurf && usurf->surface)    {
866         es = usurf->surface;
867         es->alpha = 1.0;
868
869         if ((es->output) && (es->buffer_ref.buffer))    {
870             weston_surface_damage(es);
871         }
872     }
873 }
874
875 /*--------------------------------------------------------------------------*/
876 /**
877  * @brief   animation_fade: fade animation
878  *
879  * @param[in]   animation   weston animation table
880  * @param[in]   outout      weston output table
881  * @param[in]   mseces      current time(unused)
882  * @return      none
883  */
884 /*--------------------------------------------------------------------------*/
885 static void
886 animation_fade(struct weston_animation *animation,
887                struct weston_output *output, uint32_t msecs)
888 {
889     struct uifw_win_surface *usurf;
890     struct animation_data   *animadata;
891     struct weston_surface   *es;
892     int         par;
893
894     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
895
896     par = animation_cont(animation, output, msecs);
897     if (par > 0)    {
898         /* continue animation   */
899         if( par <= 100) {
900             weston_compositor_schedule_repaint(weston_ec);
901         }
902         return;
903     }
904
905     animadata = (struct animation_data *)usurf->animation.animadata;
906     es = usurf->surface;
907     par = usurf->animation.current;
908     if (animation->frame_counter == 1)  {
909         if (animadata->transform_set == 0)  {
910             animadata->transform_set = 1;
911             weston_matrix_init(&animadata->transform.matrix);
912             wl_list_init(&animadata->transform.link);
913             wl_list_insert(&es->geometry.transformation_list,
914                            &animadata->transform.link);
915         }
916         animadata->end_function = animation_fade_end;
917
918         if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
919             (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS))  {
920             ico_window_mgr_set_weston_surface(usurf,
921                                               usurf->animation.pos_x, usurf->animation.pos_y,
922                                               usurf->animation.pos_width,
923                                               usurf->animation.pos_height);
924         }
925     }
926
927     if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
928         /* fade in                  */
929         es->alpha = ((float)par) / 100.0f;
930     }
931     else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE)    {
932         /* fade out                 */
933         es->alpha = 1.0f - (((float)par) / 100.0f);
934     }
935     else    {
936         /* fade move/resize         */
937         if ((par >= 50) || (usurf->animation.ahalf))    {
938             es->alpha = ((float)(par*2 - 100)) / 100.0f;
939             if (usurf->animation.ahalf == 0)    {
940                 uifw_trace("animation_fade: fade move chaneg to show");
941                 usurf->animation.ahalf = 1;
942                 es->alpha = 0.0;
943                 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
944                                                   usurf->width, usurf->height);
945                 ico_window_mgr_change_surface(usurf,
946                                               usurf->animation.no_configure ? -1 : 0, 1);
947                 ico_window_mgr_restack_layer(usurf);
948             }
949         }
950         else    {
951             es->alpha = 1.0f - (((float)(par*2)) / 100.0f);
952         }
953     }
954     if (es->alpha < 0.0)        es->alpha = 0.0;
955     else if (es->alpha > 1.0)   es->alpha = 1.0;
956
957     uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
958                usurf->surfaceid, animation->frame_counter, par,
959                es->alpha, usurf->animation.anima, usurf->animation.state);
960
961     if ((es->output) && (es->buffer_ref.buffer) &&
962         (es->geometry.width > 0) && (es->geometry.height > 0)) {
963         weston_surface_damage(es);
964     }
965     if (par >= 100) {
966         /* end of animation     */
967         animation_end(usurf, 1);
968         uifw_trace("animation_fade: End of animation");
969     }
970     else    {
971         /* continue animation   */
972         weston_compositor_schedule_repaint(weston_ec);
973     }
974 }
975
976 /*--------------------------------------------------------------------------*/
977 /**
978  * @brief   animation_fade_end: fade animation end
979  *
980  * @param[in]   animation   weston animation table
981  * @return      none
982  */
983 /*--------------------------------------------------------------------------*/
984 static void
985 animation_fade_end(struct weston_animation *animation)
986 {
987     struct uifw_win_surface *usurf;
988     struct weston_surface   *es;
989
990     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
991     if (usurf && usurf->surface)    {
992         es = usurf->surface;
993         es->alpha = 1.0;
994
995         if ((es->output) && (es->buffer_ref.buffer) &&
996             (es->geometry.width > 0) && (es->geometry.height > 0)) {
997             weston_surface_damage(es);
998         }
999     }
1000 }
1001
1002 /*--------------------------------------------------------------------------*/
1003 /**
1004  * @brief   animation_zoom: zoom animation
1005  *
1006  * @param[in]   animation   weston animation table
1007  * @param[in]   outout      weston output table
1008  * @param[in]   mseces      current time(unused)
1009  * @return      none
1010  */
1011 /*--------------------------------------------------------------------------*/
1012 static void
1013 animation_zoom(struct weston_animation *animation,
1014                struct weston_output *output, uint32_t msecs)
1015 {
1016     struct uifw_win_surface *usurf;
1017     struct animation_data   *animadata;
1018     struct weston_surface   *es;
1019     int         par;
1020     float       scalex, scaley;
1021     float       fu, fa, fp;
1022     int         x, y;
1023
1024     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1025
1026     par = animation_cont(animation, output, msecs);
1027     if (par > 0)    {
1028         /* continue animation   */
1029         if( par <= 100) {
1030             weston_compositor_schedule_repaint(weston_ec);
1031         }
1032         return;
1033     }
1034
1035     animadata = (struct animation_data *)usurf->animation.animadata;
1036     es = usurf->surface;
1037     par = usurf->animation.current;
1038     if (animation->frame_counter == 1)  {
1039         if (animadata->transform_set == 0)  {
1040             animadata->transform_set = 1;
1041             weston_matrix_init(&animadata->transform.matrix);
1042             wl_list_init(&animadata->transform.link);
1043             wl_list_insert(&es->geometry.transformation_list,
1044                            &animadata->transform.link);
1045         }
1046         animadata->end_function = animation_zoom_end;
1047
1048         if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS) ||
1049             (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS))  {
1050             ico_window_mgr_set_weston_surface(usurf,
1051                                               usurf->animation.pos_x, usurf->animation.pos_y,
1052                                               usurf->animation.pos_width,
1053                                               usurf->animation.pos_height);
1054         }
1055     }
1056
1057     if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_SHOW)    {
1058         /* zoom in                  */
1059         scalex = ((float)par + 5.0f) / 105.0f;
1060         scaley = scalex;
1061     }
1062     else if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_HIDE)    {
1063         /* zoom out                 */
1064         scalex = 1.0f - (((float)par + 5.0f) / 105.0f);
1065         scaley = scalex;
1066     }
1067     else    {
1068         /* zoom move/resize         */
1069         ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1070                                           usurf->width, usurf->height);
1071         ico_window_mgr_change_surface(usurf, usurf->animation.no_configure ? -1 : 0, 1);
1072
1073         fu = (float)usurf->width;
1074         fa = (float)usurf->animation.pos_width;
1075         fp = (100.0f - (float)par) / 100.0f;
1076         scalex = (fu - (fu - fa) * fp) / fu;
1077         fu = (float)usurf->height;
1078         fa = (float)usurf->animation.pos_height;
1079         scaley = (fu - (fu - fa) * fp) / fu;
1080
1081         x = (((float)usurf->animation.pos_x) - ((float)usurf->x)) * fp + (float)usurf->x
1082             + (((float)usurf->width * scalex) - (float)usurf->width) / 2.0f;
1083         y = (((float)usurf->animation.pos_y) - ((float)usurf->y)) * fp + (float)usurf->y
1084             + (((float)usurf->height * scaley) - (float) usurf->height) / 2.0f;
1085         uifw_trace("animation_zoom: %08x %d%% x=%d/%d y=%d/%d",
1086                    usurf->surfaceid, par, x, usurf->x, y, usurf->y);
1087         uifw_trace("animation_zoom: sx=%4.2f sy=%4.2f x=%d->%d y=%d->%d cur=%d,%d",
1088                    scalex, scaley, usurf->animation.pos_x, usurf->x,
1089                    usurf->animation.pos_y, usurf->y, x, y);
1090         ico_window_mgr_set_weston_surface(usurf, x, y, usurf->width, usurf->height);
1091     }
1092     weston_matrix_init(&animadata->transform.matrix);
1093     weston_matrix_translate(&animadata->transform.matrix,
1094                             -0.5f * usurf->width, -0.5f * usurf->height, 0);
1095     weston_matrix_scale(&animadata->transform.matrix, scalex, scaley, 1.0f);
1096     weston_matrix_translate(&animadata->transform.matrix,
1097                             0.5f * usurf->width, 0.5f * usurf->height, 0);
1098
1099     uifw_trace("animation_zoom: %08x count=%d %d%% w=%d/%d h=%d/%d anima=%d state=%d",
1100                usurf->surfaceid, animation->frame_counter, par,
1101                (int)(usurf->width * scalex), usurf->width,
1102                (int)(usurf->height * scaley), usurf->height,
1103                usurf->animation.anima, usurf->animation.state);
1104
1105     if ((es->output) && (es->buffer_ref.buffer) &&
1106         (es->geometry.width > 0) && (es->geometry.height > 0)) {
1107         weston_surface_geometry_dirty(es);
1108         weston_surface_damage(es);
1109     }
1110     if (par >= 100) {
1111         /* end of animation     */
1112         animation_end(usurf, 1);
1113         uifw_trace("animation_zoom: End of animation");
1114     }
1115     else    {
1116         /* continue animation   */
1117         weston_compositor_schedule_repaint(weston_ec);
1118     }
1119 }
1120
1121 /*--------------------------------------------------------------------------*/
1122 /**
1123  * @brief   animation_zoom_end: zoom animation end
1124  *
1125  * @param[in]   animation   weston animation table
1126  * @return      none
1127  */
1128 /*--------------------------------------------------------------------------*/
1129 static void
1130 animation_zoom_end(struct weston_animation *animation)
1131 {
1132     struct uifw_win_surface *usurf;
1133     struct weston_surface   *es;
1134
1135     usurf = container_of(animation, struct uifw_win_surface, animation.animation);
1136     if (usurf && usurf->surface)    {
1137         es = usurf->surface;
1138         es->alpha = 1.0;
1139
1140         if ((es->output) && (es->buffer_ref.buffer) &&
1141             (es->geometry.width > 0) && (es->geometry.height > 0)) {
1142             weston_surface_damage(es);
1143         }
1144     }
1145 }
1146
1147 /*--------------------------------------------------------------------------*/
1148 /**
1149  * @brief   module_init: initialize ico_window_animation
1150  *                       this function called from ico_pluign_loader
1151  *
1152  * @param[in]   es          weston compositor
1153  * @param[in]   argc        number of arguments(unused)
1154  * @param[in]   argv        argument list(unused)
1155  * @return      result
1156  * @retval      0           sccess
1157  * @retval      -1          error
1158  */
1159 /*--------------------------------------------------------------------------*/
1160 WL_EXPORT int
1161 module_init(struct weston_compositor *ec, int *argc, char *argv[])
1162 {
1163     int     i;
1164     struct animation_data   *animadata;
1165
1166     uifw_info("ico_window_animation: Enter(module_init)");
1167
1168     /* allocate animation datas     */
1169     free_data = NULL;
1170     for (i = 0; i < 50; i++)    {
1171         animadata = (struct animation_data *)malloc(sizeof(struct animation_data));
1172         if (! animadata)    {
1173             uifw_error("ico_window_animation: No Memory(module_init)");
1174             return -1;
1175         }
1176         animadata->next_free = free_data;
1177         free_data = animadata;
1178     }
1179
1180     weston_ec = ec;
1181     default_animation = (char *)ico_ivi_default_animation_name();
1182     animation_time = ico_ivi_default_animation_time();
1183     animation_fps = ico_ivi_default_animation_fps();
1184     animation_count = 0;
1185
1186     ico_window_mgr_set_hook_animation(ico_window_animation);
1187
1188     uifw_info("ico_window_animation: Leave(module_init)");
1189
1190     return 0;
1191 }
1192