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