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