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