1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** GUIX Component                                                        */
16 /**                                                                       */
17 /**   Utility (Utility)                                                   */
18 /**                                                                       */
19 /**************************************************************************/
20 #define GX_SOURCE_CODE
21 
22 
23 /* Include necessary system files.  */
24 
25 #include "gx_api.h"
26 #include "gx_utility.h"
27 
28 /* Predefined table for power calculation, which used in expo and elastic easing function.
29    The table value have been enlarged by 256 for precision need. */
30 #if defined(GX_EXPO_ELASTIC_EASING_SUPPORT)
31 static UINT _gx_utility_pow_0_10_table[501] = {
32     0x100, 0x103, 0x107, 0x10a, 0x10e, 0x112, 0x116, 0x11a, 0x11e, 0x122, 0x126, 0x12a, 0x12e, 0x132, 0x136, 0x13b, 0x13f, 0x144, 0x148, 0x14d,
33     0x151, 0x156, 0x15b, 0x160, 0x165, 0x16a, 0x16f, 0x174, 0x179, 0x17e, 0x184, 0x189, 0x18e, 0x194, 0x19a, 0x19f, 0x1a5, 0x1ab, 0x1b1, 0x1b7,
34     0x1bd, 0x1c3, 0x1ca, 0x1d0, 0x1d7, 0x1dd, 0x1e4, 0x1eb, 0x1f1, 0x1f8, 0x200, 0x207, 0x20e, 0x215, 0x21d, 0x224, 0x22c, 0x234, 0x23c, 0x244,
35     0x24c, 0x254, 0x25c, 0x265, 0x26d, 0x276, 0x27f, 0x288, 0x291, 0x29a, 0x2a3, 0x2ad, 0x2b6, 0x2c0, 0x2ca, 0x2d4, 0x2de, 0x2e8, 0x2f2, 0x2fd,
36     0x308, 0x312, 0x31d, 0x329, 0x334, 0x33f, 0x34b, 0x357, 0x363, 0x36f, 0x37b, 0x387, 0x394, 0x3a1, 0x3ae, 0x3bb, 0x3c8, 0x3d6, 0x3e3, 0x3f1,
37     0x400, 0x40e, 0x41c, 0x42b, 0x43a, 0x449, 0x458, 0x468, 0x478, 0x488, 0x498, 0x4a8, 0x4b9, 0x4ca, 0x4db, 0x4ec, 0x4fe, 0x510, 0x522, 0x534,
38     0x547, 0x55a, 0x56d, 0x580, 0x594, 0x5a8, 0x5bc, 0x5d0, 0x5e5, 0x5fa, 0x610, 0x625, 0x63b, 0x652, 0x668, 0x67f, 0x696, 0x6ae, 0x6c6, 0x6de,
39     0x6f6, 0x70f, 0x729, 0x742, 0x75c, 0x776, 0x791, 0x7ac, 0x7c7, 0x7e3, 0x800, 0x81c, 0x839, 0x856, 0x874, 0x892, 0x8b1, 0x8d0, 0x8f0, 0x910,
40     0x930, 0x951, 0x972, 0x994, 0x9b6, 0x9d9, 0x9fc, 0xa20, 0xa44, 0xa69, 0xa8e, 0xab4, 0xada, 0xb01, 0xb28, 0xb50, 0xb78, 0xba1, 0xbcb, 0xbf5,
41     0xc20, 0xc4b, 0xc77, 0xca4, 0xcd1, 0xcfe, 0xd2d, 0xd5c, 0xd8c, 0xdbc, 0xded, 0xe1f, 0xe52, 0xe85, 0xeb9, 0xeed, 0xf23, 0xf59, 0xf8f, 0xfc7,
42     0x1000, 0x1039, 0x1073, 0x10ad, 0x10e9, 0x1125, 0x1163, 0x11a1, 0x11e0, 0x1220, 0x1261, 0x12a2, 0x12e5, 0x1328, 0x136d, 0x13b2, 0x13f9, 0x1440, 0x1488, 0x14d2,
43     0x151c, 0x1568, 0x15b4, 0x1602, 0x1650, 0x16a0, 0x16f1, 0x1743, 0x1796, 0x17ea, 0x1840, 0x1897, 0x18ee, 0x1948, 0x19a2, 0x19fd, 0x1a5a, 0x1ab9, 0x1b18, 0x1b79,
44     0x1bdb, 0x1c3f, 0x1ca4, 0x1d0a, 0x1d72, 0x1ddb, 0x1e46, 0x1eb2, 0x1f1f, 0x1f8f, 0x1fff, 0x2072, 0x20e6, 0x215b, 0x21d3, 0x224b, 0x22c6, 0x2342, 0x23c0, 0x2440,
45     0x24c2, 0x2545, 0x25ca, 0x2651, 0x26da, 0x2765, 0x27f2, 0x2881, 0x2911, 0x29a4, 0x2a39, 0x2ad0, 0x2b69, 0x2c04, 0x2ca1, 0x2d41, 0x2de2, 0x2e86, 0x2f2d, 0x2fd5,
46     0x3080, 0x312e, 0x31dd, 0x3290, 0x3344, 0x33fb, 0x34b5, 0x3572, 0x3631, 0x36f2, 0x37b7, 0x387e, 0x3948, 0x3a14, 0x3ae4, 0x3bb6, 0x3c8c, 0x3d64, 0x3e3f, 0x3f1e,
47     0x3fff, 0x40e4, 0x41cc, 0x42b7, 0x43a6, 0x4497, 0x458d, 0x4685, 0x4781, 0x4881, 0x4984, 0x4a8a, 0x4b95, 0x4ca3, 0x4db5, 0x4ecb, 0x4fe4, 0x5102, 0x5223, 0x5349,
48     0x5472, 0x55a0, 0x56d2, 0x5808, 0x5943, 0x5a82, 0x5bc5, 0x5d0d, 0x5e5a, 0x5fab, 0x6101, 0x625c, 0x63bb, 0x6520, 0x6689, 0x67f7, 0x696b, 0x6ae4, 0x6c62, 0x6de5,
49     0x6f6e, 0x70fc, 0x7290, 0x7429, 0x75c8, 0x776d, 0x7918, 0x7ac9, 0x7c7f, 0x7e3c, 0x7fff, 0x81c9, 0x8399, 0x856f, 0x874c, 0x892f, 0x8b1a, 0x8d0b, 0x8f03, 0x9102,
50     0x9308, 0x9515, 0x972a, 0x9946, 0x9b6a, 0x9d96, 0x9fc9, 0xa204, 0xa447, 0xa692, 0xa8e5, 0xab41, 0xada5, 0xb011, 0xb286, 0xb504, 0xb78b, 0xba1b, 0xbcb4, 0xbf57,
51     0xc203, 0xc4b8, 0xc777, 0xca40, 0xcd12, 0xcfef, 0xd2d6, 0xd5c8, 0xd8c4, 0xdbca, 0xdedc, 0xe1f8, 0xe520, 0xe853, 0xeb91, 0xeedb, 0xf230, 0xf592, 0xf8ff, 0xfc79,
52     0xffff, 0x10392, 0x10732, 0x10adf, 0x10e98, 0x1125f, 0x11634, 0x11a16, 0x11e06, 0x12204, 0x12611, 0x12a2b, 0x12e55, 0x1328d, 0x136d5, 0x13b2c, 0x13f92, 0x14408, 0x1488e, 0x14d24,
53     0x151cb, 0x15682, 0x15b4a, 0x16023, 0x1650d, 0x16a09, 0x16f17, 0x17437, 0x17969, 0x17eae, 0x18406, 0x18970, 0x18eee, 0x19480, 0x19a25, 0x19fdf, 0x1a5ad, 0x1ab90, 0x1b188, 0x1b795,
54     0x1bdb8, 0x1c3f1, 0x1ca40, 0x1d0a6, 0x1d722, 0x1ddb6, 0x1e461, 0x1eb24, 0x1f1ff, 0x1f8f3, 0x1ffff, 0x20725, 0x20e64, 0x215be, 0x21d31, 0x224bf, 0x22c68, 0x2342c, 0x23c0d, 0x24409,
55     0x24c22, 0x25457, 0x25cab, 0x2651b, 0x26daa, 0x27658, 0x27f25, 0x28811, 0x2911d, 0x29a49, 0x2a396, 0x2ad04, 0x2b694, 0x2c047, 0x2ca1b, 0x2d413, 0x2de2f, 0x2e86f, 0x2f2d3, 0x2fd5c,
56     0x3080c, 0x312e1, 0x31ddd, 0x32900, 0x3344b, 0x33fbf, 0x34b5b, 0x35721, 0x36311, 0x36f2b, 0x37b71, 0x387e3, 0x39481, 0x3a14c, 0x3ae45, 0x3bb6d, 0x3c8c3, 0x3d649, 0x3e3ff, 0x3f1e6,
57     0x3ffff
58 };
59 #endif
60 
61 /**************************************************************************/
62 /*                                                                        */
63 /*  FUNCTION                                               RELEASE        */
64 /*                                                                        */
65 /*    _gx_utility_pow_0_10                                PORTABLE C      */
66 /*                                                           6.1          */
67 /*  AUTHOR                                                                */
68 /*                                                                        */
69 /*    Kenneth Maxwell, Microsoft Corporation                              */
70 /*                                                                        */
71 /*  DESCRIPTION                                                           */
72 /*                                                                        */
73 /*    Internal helper function to get the power value, with base value    */
74 /*    equal to 2, exponent value between (0, 10).                         */
75 /*                                                                        */
76 /*  INPUT                                                                 */
77 /*                                                                        */
78 /*    exponent                               Exponent value that have     */
79 /*                                             been enlarged by 256       */
80 /*                                                                        */
81 /*  OUTPUT                                                                */
82 /*                                                                        */
83 /*    None                                                                */
84 /*                                                                        */
85 /*  CALLS                                                                 */
86 /*                                                                        */
87 /*    None                                                                */
88 /*                                                                        */
89 /*  CALLED BY                                                             */
90 /*                                                                        */
91 /*    _gx_utility_easing_function_calculate                               */
92 /*                                                                        */
93 /*  RELEASE HISTORY                                                       */
94 /*                                                                        */
95 /*    DATE              NAME                      DESCRIPTION             */
96 /*                                                                        */
97 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
98 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
99 /*                                            resulting in version 6.1    */
100 /*                                                                        */
101 /**************************************************************************/
102 #if defined(GX_EXPO_ELASTIC_EASING_SUPPORT)
_gx_utility_pow_0_10(INT b)103 static INT _gx_utility_pow_0_10(INT b)
104 {
105     b >>= 1;
106     return (INT)_gx_utility_pow_0_10_table[b];
107 }
108 #endif
109 
110 /**************************************************************************/
111 /*                                                                        */
112 /*  FUNCTION                                               RELEASE        */
113 /*                                                                        */
114 /*    _gx_utility_bounce_ease_out                         PORTABLE C      */
115 /*                                                           6.1          */
116 /*  AUTHOR                                                                */
117 /*                                                                        */
118 /*    Kenneth Maxwell, Microsoft Corporation                              */
119 /*                                                                        */
120 /*  DESCRIPTION                                                           */
121 /*                                                                        */
122 /*    Internal helper function to get the ratio of current value to total */
123 /*    value with bounce ease out animation applied.                       */
124 /*                                                                        */
125 /*                                                                        */
126 /*  INPUT                                                                 */
127 /*                                                                        */
128 /*    t                                     Current step                  */
129 /*    d                                     Total steps                   */
130 /*    return_tt                             Numerator of returned ratio   */
131 /*    return_dd                             Denominator of returned ratio */
132 /*                                                                        */
133 /*  OUTPUT                                                                */
134 /*                                                                        */
135 /*    None                                                                */
136 /*                                                                        */
137 /*  CALLS                                                                 */
138 /*                                                                        */
139 /*    None                                                                */
140 /*                                                                        */
141 /*  CALLED BY                                                             */
142 /*                                                                        */
143 /*    _gx_utility_easing_function_calculate                               */
144 /*                                                                        */
145 /*  RELEASE HISTORY                                                       */
146 /*                                                                        */
147 /*    DATE              NAME                      DESCRIPTION             */
148 /*                                                                        */
149 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
150 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
151 /*                                            resulting in version 6.1    */
152 /*                                                                        */
153 /**************************************************************************/
_gx_utility_bounce_ease_out(INT t,INT d,INT * return_tt,INT * return_dd)154 static VOID _gx_utility_bounce_ease_out(INT t, INT d, INT *return_tt, INT *return_dd)
155 {
156 INT tt;
157 INT dd;
158 
159     tt = 11 * t;
160     if (tt < 4 * d)
161     {
162         tt = tt * tt;
163         dd = 16 * d * d;
164     }
165     else if (tt < 8 * d)
166     {
167         dd = d * d;
168         tt = (tt - 6 * d);
169         tt = tt * tt + 12 * dd;
170         dd = 16 * dd;
171     }
172     else if (tt < 10 * d)
173     {
174         dd = d * d;
175         tt = tt - 9 * d;
176         tt = tt * tt + 15 * dd;
177         dd = 16 * dd;
178     }
179     else
180     {
181         dd = d * d;
182         tt = 2 * tt - 21 * d;
183         tt = tt * tt + 63 * dd;
184         dd = 64 * dd;
185     }
186 
187     *return_tt = tt;
188     *return_dd = dd;
189 }
190 
191 /**************************************************************************/
192 /*                                                                        */
193 /*  FUNCTION                                               RELEASE        */
194 /*                                                                        */
195 /*    _gx_utility_easing_function_calculate               PORTABLE C      */
196 /*                                                           6.1          */
197 /*  AUTHOR                                                                */
198 /*                                                                        */
199 /*    Kenneth Maxwell, Microsoft Corporation                              */
200 /*                                                                        */
201 /*  DESCRIPTION                                                           */
202 /*                                                                        */
203 /*    Internal helper function to calculate next value with specified     */
204 /*    easing function.                                                    */
205 /*                                                                        */
206 /*                                                                        */
207 /*  INPUT                                                                 */
208 /*                                                                        */
209 /*    easing_function_type                  Type of easing function       */
210 /*    start_val                             Start value of animation      */
211 /*    end_val                               End value of animation        */
212 /*    t                                     Current time of animation     */
213 /*    d                                     Duration time of animation    */
214 /*    current_val                           Retrieved current value       */
215 /*                                                                        */
216 /*  OUTPUT                                                                */
217 /*                                                                        */
218 /*    None                                                                */
219 /*                                                                        */
220 /*  CALLS                                                                 */
221 /*                                                                        */
222 /*    None                                                                */
223 /*                                                                        */
224 /*  CALLED BY                                                             */
225 /*                                                                        */
226 /*    _gx_system_timer_update               Update active system timers   */
227 /*                                                                        */
228 /*  RELEASE HISTORY                                                       */
229 /*                                                                        */
230 /*    DATE              NAME                      DESCRIPTION             */
231 /*                                                                        */
232 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
233 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
234 /*                                            resulting in version 6.1    */
235 /*                                                                        */
236 /**************************************************************************/
_gx_utility_easing_function_calculate(USHORT easing_function_type,INT start_val,INT end_val,INT t,INT d,INT * current_val)237 UINT _gx_utility_easing_function_calculate(USHORT easing_function_type, INT start_val, INT end_val, INT t, INT d, INT *current_val)
238 {
239 INT y;
240 INT tt;
241 INT dd;
242 
243     switch (easing_function_type & GX_ANIMATION_EASING_FUNC_MASK)
244     {
245     case GX_ANIMATION_BACK_EASE_IN:
246         y = (end_val - start_val) * t / d;
247         y = y * t / d;
248         y = y * (27 * t - 17 * d) / 10 / d;
249         y = y + start_val;
250         break;
251 
252     case GX_ANIMATION_BACK_EASE_OUT:
253         y = (end_val - start_val) * (t - d) / d;
254         y = y * (t - d) / d;
255         y = y * (27 * (t - d) + 17 * d) / 10 / d;
256         y = y + end_val;
257         break;
258 
259     case GX_ANIMATION_BACK_EASE_IN_OUT:
260         if ((t << 1) < d)
261         {
262             y = (end_val - start_val) * t / d;
263             y = y * t / d;
264             y = y * (144 * t - 52 * d) / 10 / d;
265             y = y + start_val;
266         }
267         else
268         {
269             y = (end_val - start_val) * (t - d) / d;
270             y = y * (t - d) / d;
271             y = y * (144 * (t - d) + 52 * d) / 10 / d;
272             y = y + end_val;
273         }
274         break;
275 
276     case GX_ANIMATION_BOUNCE_EASE_IN:
277         t = d - t;
278         _gx_utility_bounce_ease_out(t, d, &tt, &dd);
279         tt = dd - tt;
280         y = ((end_val - start_val) * tt / dd) + start_val;
281         break;
282     case GX_ANIMATION_BOUNCE_EASE_OUT:
283         _gx_utility_bounce_ease_out(t, d, &tt, &dd);
284         y = ((end_val - start_val) * tt / dd) + start_val;
285         break;
286     case GX_ANIMATION_BOUNCE_EASE_IN_OUT:
287         t <<= 1;
288         if (t < d)
289         {
290             t = d - t;
291             _gx_utility_bounce_ease_out(t, d, &tt, &dd);
292 
293             y = (end_val - start_val) * tt / dd / 2;
294             y = (end_val + start_val) / 2 - y;
295         }
296         else
297         {
298             t = t - d;
299             _gx_utility_bounce_ease_out(t, d, &tt, &dd);
300             y = (end_val - start_val) * tt / dd / 2;
301             y = y + (end_val + start_val) / 2;
302         }
303         break;
304     case GX_ANIMATION_CIRC_EASE_IN:
305         dd = (1 << 16);
306         dd = dd * t / d;
307         dd = dd * t / d;
308         dd = (1 << 16) - dd;
309 
310         tt = (INT)_gx_utility_math_sqrt((UINT)dd);
311         tt = 256 - tt;
312         dd = 256;
313         y = ((end_val - start_val) * tt / dd) + start_val;
314         break;
315     case GX_ANIMATION_CIRC_EASE_OUT:
316         dd = (1 << 16);
317         dd = dd * (t - d) / d;
318         dd = dd * (t - d) / d;
319         dd = (1 << 16) - dd;
320 
321         tt = (INT)_gx_utility_math_sqrt((UINT)dd);
322         dd = 256;
323         y = ((end_val - start_val) * tt / dd) + start_val;
324         break;
325     case GX_ANIMATION_CIRC_EASE_IN_OUT:
326         if ((t << 1) < d)
327         {
328             dd = (1 << 18);
329             dd = dd * t / d;
330             dd = dd * t / d;
331             dd = (1 << 16) - dd;
332 
333             tt = (INT)_gx_utility_math_sqrt((UINT)dd);
334             tt = 256 - tt;
335         }
336         else
337         {
338             dd = (1 << 18);
339             dd = dd * (t - d) / d;
340             dd = dd * (t - d) / d;
341             dd = (1 << 16) - dd;
342 
343             tt = (INT)_gx_utility_math_sqrt((UINT)dd);
344             tt = 256 + tt;
345         }
346         dd = 512;
347         y = ((end_val - start_val) * tt / dd) + start_val;
348         break;
349     case GX_ANIMATION_CUBIC_EASE_IN:
350         y = (end_val - start_val) * t / d;
351         y = y * t / d;
352         y = y * t / d + start_val;
353         break;
354     case GX_ANIMATION_CUBIC_EASE_OUT:
355         t = t - d;
356 
357         y = (end_val - start_val) * t / d;
358         y = y * t / d;
359         y = y * t / d + end_val;
360         break;
361     case GX_ANIMATION_CUBIC_EASE_IN_OUT:
362         if ((t << 1) < d)
363         {
364             y = (end_val - start_val) * (t << 2) / d;
365             y = y * t / d;
366             y = y * t / d + start_val;
367         }
368         else
369         {
370             t = t - d;
371             y = (end_val - start_val) * (t << 2) / d;
372             y = y * t / d;
373             y = y * t / d + end_val;
374         }
375         break;
376 #if defined(GX_EXPO_ELASTIC_EASING_SUPPORT)
377     case GX_ANIMATION_ELASTIC_EASE_IN:
378         tt = 1000 * (d - t) / d;
379         dd = _gx_utility_pow_0_10(tt);
380         tt = 900 * t / d - 967;
381         tt = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(tt));
382         tt = GX_FIXED_VAL_TO_INT(tt << 8);
383         y = (start_val - end_val) * tt / dd + start_val;
384         break;
385     case GX_ANIMATION_ELASTIC_EASE_OUT:
386         tt = 1000 * t / d;
387         dd = _gx_utility_pow_0_10(tt);
388         tt = 900 * t / d - 67;
389         tt = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(tt));
390         tt = GX_FIXED_VAL_TO_INT(tt << 8);
391         y = (end_val - start_val) * tt / dd + end_val;
392         break;
393     case GX_ANIMATION_ELASTIC_EASE_IN_OUT:
394         t <<= 1;
395         if (t < d)
396         {
397             tt = 1000 * (d - t) / d;
398             dd = _gx_utility_pow_0_10(tt);
399             tt = 400 * t / d - 445;
400             tt = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(tt));
401             tt = GX_FIXED_VAL_TO_INT(tt << 8);
402 
403             y = (start_val - end_val) * tt / dd;
404             y = (y >> 1) + start_val;
405         }
406         else
407         {
408             tt = 1000 * (t - d) / d;
409             dd = _gx_utility_pow_0_10(tt);
410             tt = 400 * t / d - 445;
411             tt = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(tt));
412             tt = GX_FIXED_VAL_TO_INT(tt << 8);
413 
414             y = (end_val - start_val) * tt / dd;
415             y = (y >> 1) + end_val;
416         }
417         break;
418     case GX_ANIMATION_EXPO_EASE_IN:
419         t = 1000 * (d - t) / d;
420         d = _gx_utility_pow_0_10(t);
421 
422         y = ((end_val - start_val) << 8) / d + start_val;
423         break;
424     case GX_ANIMATION_EXPO_EASE_OUT:
425         t = 1000 * t / d;
426         d = _gx_utility_pow_0_10(t);
427 
428         y = ((start_val - end_val) << 8) / d + end_val;
429         break;
430     case GX_ANIMATION_EXPO_EASE_IN_OUT:
431         t <<= 1;
432         if (t < d)
433         {
434             t = 1000 * (d - t) / d;
435             d = _gx_utility_pow_0_10(t);
436 
437             y = ((end_val - start_val) << 7) / d + start_val;
438         }
439         else
440         {
441             t = 1000 * (t - d) / d;
442             d = _gx_utility_pow_0_10(t);
443 
444             y = ((start_val - end_val) << 7) / d + end_val;
445         }
446         break;
447 #endif
448     case GX_ANIMATION_QUAD_EASE_IN:
449         y = (end_val - start_val) * t / d;
450         y = y * t / d + start_val;
451         break;
452     case GX_ANIMATION_QUAD_EASE_OUT:
453         t = t * ((d << 1) - t);
454         d = d * d;
455 
456         y = ((end_val - start_val) * t / d) + start_val;
457         break;
458     case GX_ANIMATION_QUAD_EASE_IN_OUT:
459         tt = t * t;
460         dd = d * d;
461         if ((t << 1) < d)
462         {
463             tt = (tt << 1);
464         }
465         else
466         {
467             tt = -(2 * tt - 4 * t * d + dd);
468         }
469 
470         y = ((end_val - start_val) * tt / dd) + start_val;
471         break;
472     case GX_ANIMATION_QUART_EASE_IN:
473         y = (end_val - start_val) * t / d;
474         y = y * t / d;
475         y = y * t / d;
476         y = y * t / d + start_val;
477         break;
478     case GX_ANIMATION_QUART_EASE_OUT:
479         t = t - d;
480         y = (start_val - end_val) * t / d;
481         y = y * t / d;
482         y = y * t / d;
483         y = y * t / d + end_val;
484         break;
485     case GX_ANIMATION_QUART_EASE_IN_OUT:
486         if ((t << 1) < d)
487         {
488             y = (end_val - start_val) * (t << 3) / d;
489             y = y * t / d;
490             y = y * t / d;
491             y = y * t / d + start_val;
492         }
493         else
494         {
495             t = t - d;
496             y = (start_val - end_val) * (t << 3) / d;
497             y = y * t / d;
498             y = y * t / d;
499             y = y * t / d + end_val;
500         }
501         break;
502     case GX_ANIMATION_QUINT_EASE_IN:
503         y = (end_val - start_val)  * t / d;
504         y = y * t / d;
505         y = y * t / d;
506         y = y * t / d;
507         y = y * t / d + start_val;
508         break;
509     case GX_ANIMATION_QUINT_EASE_OUT:
510         t = t - d;
511         y = (end_val - start_val) * t / d;
512         y = y * t / d;
513         y = y * t / d;
514         y = y * t / d;
515         y = y * t / d + end_val;
516         break;
517     case GX_ANIMATION_QUINT_EASE_IN_OUT:
518         if ((t << 1) < d)
519         {
520             y = (end_val - start_val)  * (t << 4) / d;
521             y = y * t / d;
522             y = y * t / d;
523             y = y * t / d;
524             y = y * t / d + start_val;
525         }
526         else
527         {
528             t = t - d;
529             y = (end_val - start_val) * (t << 4) / d;
530             y = y * t / d;
531             y = y * t / d;
532             y = y * t / d;
533             y = y * t / d + end_val;
534         }
535         break;
536     case GX_ANIMATION_SINE_EASE_IN:
537         /* cos(t/d * PI / 2 * 256). */
538         t = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(90) * t / d);
539         t = GX_FIXED_VAL_ONE - t;
540 
541         y = GX_FIXED_VAL_TO_INT((end_val - start_val) * t);
542         y += start_val;
543         break;
544     case GX_ANIMATION_SINE_EASE_OUT:
545         /* sin(t/d * PI / 2). */
546         t = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(90) * t / d);
547 
548         y = GX_FIXED_VAL_TO_INT((end_val - start_val) * t);
549         y += start_val;
550         break;
551     case GX_ANIMATION_SINE_EASE_IN_OUT:
552         /* cos(t/d * PI * 256). */
553         t = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(180) * t / d);
554         t = GX_FIXED_VAL_ONE - t;
555 
556         y = GX_FIXED_VAL_TO_INT((end_val - start_val) * t);
557         y = (y >> 1) + start_val;
558         break;
559     default:
560         y = (end_val - start_val) * t / d + start_val;
561         break;
562     }
563 
564     (*current_val) = y;
565     return GX_SUCCESS;
566 }
567 
568