GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_easing_function_calculate.c Lines: 276 276 100.0 %
Date: 2026-03-06 19:21:09 Branches: 55 55 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Utility (Utility)                                                   */
19
/**                                                                       */
20
/**************************************************************************/
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_utility.h"
28
29
/* Predefined table for power calculation, which used in expo and elastic easing function.
30
   The table value have been enlarged by 256 for precision need. */
31
#if defined(GX_EXPO_ELASTIC_EASING_SUPPORT)
32
static UINT _gx_utility_pow_0_10_table[501] = {
33
    0x100, 0x103, 0x107, 0x10a, 0x10e, 0x112, 0x116, 0x11a, 0x11e, 0x122, 0x126, 0x12a, 0x12e, 0x132, 0x136, 0x13b, 0x13f, 0x144, 0x148, 0x14d,
34
    0x151, 0x156, 0x15b, 0x160, 0x165, 0x16a, 0x16f, 0x174, 0x179, 0x17e, 0x184, 0x189, 0x18e, 0x194, 0x19a, 0x19f, 0x1a5, 0x1ab, 0x1b1, 0x1b7,
35
    0x1bd, 0x1c3, 0x1ca, 0x1d0, 0x1d7, 0x1dd, 0x1e4, 0x1eb, 0x1f1, 0x1f8, 0x200, 0x207, 0x20e, 0x215, 0x21d, 0x224, 0x22c, 0x234, 0x23c, 0x244,
36
    0x24c, 0x254, 0x25c, 0x265, 0x26d, 0x276, 0x27f, 0x288, 0x291, 0x29a, 0x2a3, 0x2ad, 0x2b6, 0x2c0, 0x2ca, 0x2d4, 0x2de, 0x2e8, 0x2f2, 0x2fd,
37
    0x308, 0x312, 0x31d, 0x329, 0x334, 0x33f, 0x34b, 0x357, 0x363, 0x36f, 0x37b, 0x387, 0x394, 0x3a1, 0x3ae, 0x3bb, 0x3c8, 0x3d6, 0x3e3, 0x3f1,
38
    0x400, 0x40e, 0x41c, 0x42b, 0x43a, 0x449, 0x458, 0x468, 0x478, 0x488, 0x498, 0x4a8, 0x4b9, 0x4ca, 0x4db, 0x4ec, 0x4fe, 0x510, 0x522, 0x534,
39
    0x547, 0x55a, 0x56d, 0x580, 0x594, 0x5a8, 0x5bc, 0x5d0, 0x5e5, 0x5fa, 0x610, 0x625, 0x63b, 0x652, 0x668, 0x67f, 0x696, 0x6ae, 0x6c6, 0x6de,
40
    0x6f6, 0x70f, 0x729, 0x742, 0x75c, 0x776, 0x791, 0x7ac, 0x7c7, 0x7e3, 0x800, 0x81c, 0x839, 0x856, 0x874, 0x892, 0x8b1, 0x8d0, 0x8f0, 0x910,
41
    0x930, 0x951, 0x972, 0x994, 0x9b6, 0x9d9, 0x9fc, 0xa20, 0xa44, 0xa69, 0xa8e, 0xab4, 0xada, 0xb01, 0xb28, 0xb50, 0xb78, 0xba1, 0xbcb, 0xbf5,
42
    0xc20, 0xc4b, 0xc77, 0xca4, 0xcd1, 0xcfe, 0xd2d, 0xd5c, 0xd8c, 0xdbc, 0xded, 0xe1f, 0xe52, 0xe85, 0xeb9, 0xeed, 0xf23, 0xf59, 0xf8f, 0xfc7,
43
    0x1000, 0x1039, 0x1073, 0x10ad, 0x10e9, 0x1125, 0x1163, 0x11a1, 0x11e0, 0x1220, 0x1261, 0x12a2, 0x12e5, 0x1328, 0x136d, 0x13b2, 0x13f9, 0x1440, 0x1488, 0x14d2,
44
    0x151c, 0x1568, 0x15b4, 0x1602, 0x1650, 0x16a0, 0x16f1, 0x1743, 0x1796, 0x17ea, 0x1840, 0x1897, 0x18ee, 0x1948, 0x19a2, 0x19fd, 0x1a5a, 0x1ab9, 0x1b18, 0x1b79,
45
    0x1bdb, 0x1c3f, 0x1ca4, 0x1d0a, 0x1d72, 0x1ddb, 0x1e46, 0x1eb2, 0x1f1f, 0x1f8f, 0x1fff, 0x2072, 0x20e6, 0x215b, 0x21d3, 0x224b, 0x22c6, 0x2342, 0x23c0, 0x2440,
46
    0x24c2, 0x2545, 0x25ca, 0x2651, 0x26da, 0x2765, 0x27f2, 0x2881, 0x2911, 0x29a4, 0x2a39, 0x2ad0, 0x2b69, 0x2c04, 0x2ca1, 0x2d41, 0x2de2, 0x2e86, 0x2f2d, 0x2fd5,
47
    0x3080, 0x312e, 0x31dd, 0x3290, 0x3344, 0x33fb, 0x34b5, 0x3572, 0x3631, 0x36f2, 0x37b7, 0x387e, 0x3948, 0x3a14, 0x3ae4, 0x3bb6, 0x3c8c, 0x3d64, 0x3e3f, 0x3f1e,
48
    0x3fff, 0x40e4, 0x41cc, 0x42b7, 0x43a6, 0x4497, 0x458d, 0x4685, 0x4781, 0x4881, 0x4984, 0x4a8a, 0x4b95, 0x4ca3, 0x4db5, 0x4ecb, 0x4fe4, 0x5102, 0x5223, 0x5349,
49
    0x5472, 0x55a0, 0x56d2, 0x5808, 0x5943, 0x5a82, 0x5bc5, 0x5d0d, 0x5e5a, 0x5fab, 0x6101, 0x625c, 0x63bb, 0x6520, 0x6689, 0x67f7, 0x696b, 0x6ae4, 0x6c62, 0x6de5,
50
    0x6f6e, 0x70fc, 0x7290, 0x7429, 0x75c8, 0x776d, 0x7918, 0x7ac9, 0x7c7f, 0x7e3c, 0x7fff, 0x81c9, 0x8399, 0x856f, 0x874c, 0x892f, 0x8b1a, 0x8d0b, 0x8f03, 0x9102,
51
    0x9308, 0x9515, 0x972a, 0x9946, 0x9b6a, 0x9d96, 0x9fc9, 0xa204, 0xa447, 0xa692, 0xa8e5, 0xab41, 0xada5, 0xb011, 0xb286, 0xb504, 0xb78b, 0xba1b, 0xbcb4, 0xbf57,
52
    0xc203, 0xc4b8, 0xc777, 0xca40, 0xcd12, 0xcfef, 0xd2d6, 0xd5c8, 0xd8c4, 0xdbca, 0xdedc, 0xe1f8, 0xe520, 0xe853, 0xeb91, 0xeedb, 0xf230, 0xf592, 0xf8ff, 0xfc79,
53
    0xffff, 0x10392, 0x10732, 0x10adf, 0x10e98, 0x1125f, 0x11634, 0x11a16, 0x11e06, 0x12204, 0x12611, 0x12a2b, 0x12e55, 0x1328d, 0x136d5, 0x13b2c, 0x13f92, 0x14408, 0x1488e, 0x14d24,
54
    0x151cb, 0x15682, 0x15b4a, 0x16023, 0x1650d, 0x16a09, 0x16f17, 0x17437, 0x17969, 0x17eae, 0x18406, 0x18970, 0x18eee, 0x19480, 0x19a25, 0x19fdf, 0x1a5ad, 0x1ab90, 0x1b188, 0x1b795,
55
    0x1bdb8, 0x1c3f1, 0x1ca40, 0x1d0a6, 0x1d722, 0x1ddb6, 0x1e461, 0x1eb24, 0x1f1ff, 0x1f8f3, 0x1ffff, 0x20725, 0x20e64, 0x215be, 0x21d31, 0x224bf, 0x22c68, 0x2342c, 0x23c0d, 0x24409,
56
    0x24c22, 0x25457, 0x25cab, 0x2651b, 0x26daa, 0x27658, 0x27f25, 0x28811, 0x2911d, 0x29a49, 0x2a396, 0x2ad04, 0x2b694, 0x2c047, 0x2ca1b, 0x2d413, 0x2de2f, 0x2e86f, 0x2f2d3, 0x2fd5c,
57
    0x3080c, 0x312e1, 0x31ddd, 0x32900, 0x3344b, 0x33fbf, 0x34b5b, 0x35721, 0x36311, 0x36f2b, 0x37b71, 0x387e3, 0x39481, 0x3a14c, 0x3ae45, 0x3bb6d, 0x3c8c3, 0x3d649, 0x3e3ff, 0x3f1e6,
58
    0x3ffff
59
};
60
#endif
61
62
/**************************************************************************/
63
/*                                                                        */
64
/*  FUNCTION                                               RELEASE        */
65
/*                                                                        */
66
/*    _gx_utility_pow_0_10                                PORTABLE C      */
67
/*                                                           6.1          */
68
/*  AUTHOR                                                                */
69
/*                                                                        */
70
/*    Kenneth Maxwell, Microsoft Corporation                              */
71
/*                                                                        */
72
/*  DESCRIPTION                                                           */
73
/*                                                                        */
74
/*    Internal helper function to get the power value, with base value    */
75
/*    equal to 2, exponent value between (0, 10).                         */
76
/*                                                                        */
77
/*  INPUT                                                                 */
78
/*                                                                        */
79
/*    exponent                               Exponent value that have     */
80
/*                                             been enlarged by 256       */
81
/*                                                                        */
82
/*  OUTPUT                                                                */
83
/*                                                                        */
84
/*    None                                                                */
85
/*                                                                        */
86
/*  CALLS                                                                 */
87
/*                                                                        */
88
/*    None                                                                */
89
/*                                                                        */
90
/*  CALLED BY                                                             */
91
/*                                                                        */
92
/*    _gx_utility_easing_function_calculate                               */
93
/*                                                                        */
94
/**************************************************************************/
95
#if defined(GX_EXPO_ELASTIC_EASING_SUPPORT)
96
480
static INT _gx_utility_pow_0_10(INT b)
97
{
98
480
    b >>= 1;
99
480
    return (INT)_gx_utility_pow_0_10_table[b];
100
}
101
#endif
102
103
/**************************************************************************/
104
/*                                                                        */
105
/*  FUNCTION                                               RELEASE        */
106
/*                                                                        */
107
/*    _gx_utility_bounce_ease_out                         PORTABLE C      */
108
/*                                                           6.1          */
109
/*  AUTHOR                                                                */
110
/*                                                                        */
111
/*    Kenneth Maxwell, Microsoft Corporation                              */
112
/*                                                                        */
113
/*  DESCRIPTION                                                           */
114
/*                                                                        */
115
/*    Internal helper function to get the ratio of current value to total */
116
/*    value with bounce ease out animation applied.                       */
117
/*                                                                        */
118
/*                                                                        */
119
/*  INPUT                                                                 */
120
/*                                                                        */
121
/*    t                                     Current step                  */
122
/*    d                                     Total steps                   */
123
/*    return_tt                             Numerator of returned ratio   */
124
/*    return_dd                             Denominator of returned ratio */
125
/*                                                                        */
126
/*  OUTPUT                                                                */
127
/*                                                                        */
128
/*    None                                                                */
129
/*                                                                        */
130
/*  CALLS                                                                 */
131
/*                                                                        */
132
/*    None                                                                */
133
/*                                                                        */
134
/*  CALLED BY                                                             */
135
/*                                                                        */
136
/*    _gx_utility_easing_function_calculate                               */
137
/*                                                                        */
138
/**************************************************************************/
139
240
static VOID _gx_utility_bounce_ease_out(INT t, INT d, INT *return_tt, INT *return_dd)
140
{
141
INT tt;
142
INT dd;
143
144
240
    tt = 11 * t;
145
240
    if (tt < 4 * d)
146
    {
147
88
        tt = tt * tt;
148
88
        dd = 16 * d * d;
149
    }
150
152
    else if (tt < 8 * d)
151
    {
152
88
        dd = d * d;
153
88
        tt = (tt - 6 * d);
154
88
        tt = tt * tt + 12 * dd;
155
88
        dd = 16 * dd;
156
    }
157
64
    else if (tt < 10 * d)
158
    {
159
44
        dd = d * d;
160
44
        tt = tt - 9 * d;
161
44
        tt = tt * tt + 15 * dd;
162
44
        dd = 16 * dd;
163
    }
164
    else
165
    {
166
20
        dd = d * d;
167
20
        tt = 2 * tt - 21 * d;
168
20
        tt = tt * tt + 63 * dd;
169
20
        dd = 64 * dd;
170
    }
171
172
240
    *return_tt = tt;
173
240
    *return_dd = dd;
174
240
}
175
176
/**************************************************************************/
177
/*                                                                        */
178
/*  FUNCTION                                               RELEASE        */
179
/*                                                                        */
180
/*    _gx_utility_easing_function_calculate               PORTABLE C      */
181
/*                                                           6.1          */
182
/*  AUTHOR                                                                */
183
/*                                                                        */
184
/*    Kenneth Maxwell, Microsoft Corporation                              */
185
/*                                                                        */
186
/*  DESCRIPTION                                                           */
187
/*                                                                        */
188
/*    Internal helper function to calculate next value with specified     */
189
/*    easing function.                                                    */
190
/*                                                                        */
191
/*                                                                        */
192
/*  INPUT                                                                 */
193
/*                                                                        */
194
/*    easing_function_type                  Type of easing function       */
195
/*    start_val                             Start value of animation      */
196
/*    end_val                               End value of animation        */
197
/*    t                                     Current time of animation     */
198
/*    d                                     Duration time of animation    */
199
/*    current_val                           Retrieved current value       */
200
/*                                                                        */
201
/*  OUTPUT                                                                */
202
/*                                                                        */
203
/*    None                                                                */
204
/*                                                                        */
205
/*  CALLS                                                                 */
206
/*                                                                        */
207
/*    None                                                                */
208
/*                                                                        */
209
/*  CALLED BY                                                             */
210
/*                                                                        */
211
/*    _gx_system_timer_update               Update active system timers   */
212
/*                                                                        */
213
/**************************************************************************/
214
3200
UINT _gx_utility_easing_function_calculate(USHORT easing_function_type, INT start_val, INT end_val, INT t, INT d, INT *current_val)
215
{
216
INT y;
217
INT tt;
218
INT dd;
219
220







3200
    switch (easing_function_type & GX_ANIMATION_EASING_FUNC_MASK)
221
    {
222
100
    case GX_ANIMATION_BACK_EASE_IN:
223
100
        y = (end_val - start_val) * t / d;
224
100
        y = y * t / d;
225
100
        y = y * (27 * t - 17 * d) / 10 / d;
226
100
        y = y + start_val;
227
100
        break;
228
229
100
    case GX_ANIMATION_BACK_EASE_OUT:
230
100
        y = (end_val - start_val) * (t - d) / d;
231
100
        y = y * (t - d) / d;
232
100
        y = y * (27 * (t - d) + 17 * d) / 10 / d;
233
100
        y = y + end_val;
234
100
        break;
235
236
80
    case GX_ANIMATION_BACK_EASE_IN_OUT:
237
80
        if ((t << 1) < d)
238
        {
239
39
            y = (end_val - start_val) * t / d;
240
39
            y = y * t / d;
241
39
            y = y * (144 * t - 52 * d) / 10 / d;
242
39
            y = y + start_val;
243
        }
244
        else
245
        {
246
41
            y = (end_val - start_val) * (t - d) / d;
247
41
            y = y * (t - d) / d;
248
41
            y = y * (144 * (t - d) + 52 * d) / 10 / d;
249
41
            y = y + end_val;
250
        }
251
80
        break;
252
253
80
    case GX_ANIMATION_BOUNCE_EASE_IN:
254
80
        t = d - t;
255
80
        _gx_utility_bounce_ease_out(t, d, &tt, &dd);
256
80
        tt = dd - tt;
257
80
        y = ((end_val - start_val) * tt / dd) + start_val;
258
80
        break;
259
80
    case GX_ANIMATION_BOUNCE_EASE_OUT:
260
80
        _gx_utility_bounce_ease_out(t, d, &tt, &dd);
261
80
        y = ((end_val - start_val) * tt / dd) + start_val;
262
80
        break;
263
80
    case GX_ANIMATION_BOUNCE_EASE_IN_OUT:
264
80
        t <<= 1;
265
80
        if (t < d)
266
        {
267
39
            t = d - t;
268
39
            _gx_utility_bounce_ease_out(t, d, &tt, &dd);
269
270
39
            y = (end_val - start_val) * tt / dd / 2;
271
39
            y = (end_val + start_val) / 2 - y;
272
        }
273
        else
274
        {
275
41
            t = t - d;
276
41
            _gx_utility_bounce_ease_out(t, d, &tt, &dd);
277
41
            y = (end_val - start_val) * tt / dd / 2;
278
41
            y = y + (end_val + start_val) / 2;
279
        }
280
80
        break;
281
80
    case GX_ANIMATION_CIRC_EASE_IN:
282
80
        dd = (1 << 16);
283
80
        dd = dd * t / d;
284
80
        dd = dd * t / d;
285
80
        dd = (1 << 16) - dd;
286
287
80
        tt = (INT)_gx_utility_math_sqrt((UINT)dd);
288
80
        tt = 256 - tt;
289
80
        dd = 256;
290
80
        y = ((end_val - start_val) * tt / dd) + start_val;
291
80
        break;
292
80
    case GX_ANIMATION_CIRC_EASE_OUT:
293
80
        dd = (1 << 16);
294
80
        dd = dd * (t - d) / d;
295
80
        dd = dd * (t - d) / d;
296
80
        dd = (1 << 16) - dd;
297
298
80
        tt = (INT)_gx_utility_math_sqrt((UINT)dd);
299
80
        dd = 256;
300
80
        y = ((end_val - start_val) * tt / dd) + start_val;
301
80
        break;
302
215
    case GX_ANIMATION_CIRC_EASE_IN_OUT:
303
215
        if ((t << 1) < d)
304
        {
305
102
            dd = (1 << 18);
306
102
            dd = dd * t / d;
307
102
            dd = dd * t / d;
308
102
            dd = (1 << 16) - dd;
309
310
102
            tt = (INT)_gx_utility_math_sqrt((UINT)dd);
311
102
            tt = 256 - tt;
312
        }
313
        else
314
        {
315
113
            dd = (1 << 18);
316
113
            dd = dd * (t - d) / d;
317
113
            dd = dd * (t - d) / d;
318
113
            dd = (1 << 16) - dd;
319
320
113
            tt = (INT)_gx_utility_math_sqrt((UINT)dd);
321
113
            tt = 256 + tt;
322
        }
323
215
        dd = 512;
324
215
        y = ((end_val - start_val) * tt / dd) + start_val;
325
215
        break;
326
80
    case GX_ANIMATION_CUBIC_EASE_IN:
327
80
        y = (end_val - start_val) * t / d;
328
80
        y = y * t / d;
329
80
        y = y * t / d + start_val;
330
80
        break;
331
80
    case GX_ANIMATION_CUBIC_EASE_OUT:
332
80
        t = t - d;
333
334
80
        y = (end_val - start_val) * t / d;
335
80
        y = y * t / d;
336
80
        y = y * t / d + end_val;
337
80
        break;
338
80
    case GX_ANIMATION_CUBIC_EASE_IN_OUT:
339
80
        if ((t << 1) < d)
340
        {
341
39
            y = (end_val - start_val) * (t << 2) / d;
342
39
            y = y * t / d;
343
39
            y = y * t / d + start_val;
344
        }
345
        else
346
        {
347
41
            t = t - d;
348
41
            y = (end_val - start_val) * (t << 2) / d;
349
41
            y = y * t / d;
350
41
            y = y * t / d + end_val;
351
        }
352
80
        break;
353
#if defined(GX_EXPO_ELASTIC_EASING_SUPPORT)
354
80
    case GX_ANIMATION_ELASTIC_EASE_IN:
355
80
        tt = 1000 * (d - t) / d;
356
80
        dd = _gx_utility_pow_0_10(tt);
357
80
        tt = 900 * t / d - 967;
358
80
        tt = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(tt));
359
80
        tt = GX_FIXED_VAL_TO_INT(tt << 8);
360
80
        y = (start_val - end_val) * tt / dd + start_val;
361
80
        break;
362
80
    case GX_ANIMATION_ELASTIC_EASE_OUT:
363
80
        tt = 1000 * t / d;
364
80
        dd = _gx_utility_pow_0_10(tt);
365
80
        tt = 900 * t / d - 67;
366
80
        tt = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(tt));
367
80
        tt = GX_FIXED_VAL_TO_INT(tt << 8);
368
80
        y = (end_val - start_val) * tt / dd + end_val;
369
80
        break;
370
80
    case GX_ANIMATION_ELASTIC_EASE_IN_OUT:
371
80
        t <<= 1;
372
80
        if (t < d)
373
        {
374
39
            tt = 1000 * (d - t) / d;
375
39
            dd = _gx_utility_pow_0_10(tt);
376
39
            tt = 400 * t / d - 445;
377
39
            tt = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(tt));
378
39
            tt = GX_FIXED_VAL_TO_INT(tt << 8);
379
380
39
            y = (start_val - end_val) * tt / dd;
381
39
            y = (y >> 1) + start_val;
382
        }
383
        else
384
        {
385
41
            tt = 1000 * (t - d) / d;
386
41
            dd = _gx_utility_pow_0_10(tt);
387
41
            tt = 400 * t / d - 445;
388
41
            tt = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(tt));
389
41
            tt = GX_FIXED_VAL_TO_INT(tt << 8);
390
391
41
            y = (end_val - start_val) * tt / dd;
392
41
            y = (y >> 1) + end_val;
393
        }
394
80
        break;
395
80
    case GX_ANIMATION_EXPO_EASE_IN:
396
80
        t = 1000 * (d - t) / d;
397
80
        d = _gx_utility_pow_0_10(t);
398
399
80
        y = ((end_val - start_val) << 8) / d + start_val;
400
80
        break;
401
80
    case GX_ANIMATION_EXPO_EASE_OUT:
402
80
        t = 1000 * t / d;
403
80
        d = _gx_utility_pow_0_10(t);
404
405
80
        y = ((start_val - end_val) << 8) / d + end_val;
406
80
        break;
407
80
    case GX_ANIMATION_EXPO_EASE_IN_OUT:
408
80
        t <<= 1;
409
80
        if (t < d)
410
        {
411
39
            t = 1000 * (d - t) / d;
412
39
            d = _gx_utility_pow_0_10(t);
413
414
39
            y = ((end_val - start_val) << 7) / d + start_val;
415
        }
416
        else
417
        {
418
41
            t = 1000 * (t - d) / d;
419
41
            d = _gx_utility_pow_0_10(t);
420
421
41
            y = ((start_val - end_val) << 7) / d + end_val;
422
        }
423
80
        break;
424
#endif
425
80
    case GX_ANIMATION_QUAD_EASE_IN:
426
80
        y = (end_val - start_val) * t / d;
427
80
        y = y * t / d + start_val;
428
80
        break;
429
80
    case GX_ANIMATION_QUAD_EASE_OUT:
430
80
        t = t * ((d << 1) - t);
431
80
        d = d * d;
432
433
80
        y = ((end_val - start_val) * t / d) + start_val;
434
80
        break;
435
80
    case GX_ANIMATION_QUAD_EASE_IN_OUT:
436
80
        tt = t * t;
437
80
        dd = d * d;
438
80
        if ((t << 1) < d)
439
        {
440
39
            tt = (tt << 1);
441
        }
442
        else
443
        {
444
41
            tt = -(2 * tt - 4 * t * d + dd);
445
        }
446
447
80
        y = ((end_val - start_val) * tt / dd) + start_val;
448
80
        break;
449
80
    case GX_ANIMATION_QUART_EASE_IN:
450
80
        y = (end_val - start_val) * t / d;
451
80
        y = y * t / d;
452
80
        y = y * t / d;
453
80
        y = y * t / d + start_val;
454
80
        break;
455
80
    case GX_ANIMATION_QUART_EASE_OUT:
456
80
        t = t - d;
457
80
        y = (start_val - end_val) * t / d;
458
80
        y = y * t / d;
459
80
        y = y * t / d;
460
80
        y = y * t / d + end_val;
461
80
        break;
462
80
    case GX_ANIMATION_QUART_EASE_IN_OUT:
463
80
        if ((t << 1) < d)
464
        {
465
39
            y = (end_val - start_val) * (t << 3) / d;
466
39
            y = y * t / d;
467
39
            y = y * t / d;
468
39
            y = y * t / d + start_val;
469
        }
470
        else
471
        {
472
41
            t = t - d;
473
41
            y = (start_val - end_val) * (t << 3) / d;
474
41
            y = y * t / d;
475
41
            y = y * t / d;
476
41
            y = y * t / d + end_val;
477
        }
478
80
        break;
479
80
    case GX_ANIMATION_QUINT_EASE_IN:
480
80
        y = (end_val - start_val)  * t / d;
481
80
        y = y * t / d;
482
80
        y = y * t / d;
483
80
        y = y * t / d;
484
80
        y = y * t / d + start_val;
485
80
        break;
486
80
    case GX_ANIMATION_QUINT_EASE_OUT:
487
80
        t = t - d;
488
80
        y = (end_val - start_val) * t / d;
489
80
        y = y * t / d;
490
80
        y = y * t / d;
491
80
        y = y * t / d;
492
80
        y = y * t / d + end_val;
493
80
        break;
494
80
    case GX_ANIMATION_QUINT_EASE_IN_OUT:
495
80
        if ((t << 1) < d)
496
        {
497
39
            y = (end_val - start_val)  * (t << 4) / d;
498
39
            y = y * t / d;
499
39
            y = y * t / d;
500
39
            y = y * t / d;
501
39
            y = y * t / d + start_val;
502
        }
503
        else
504
        {
505
41
            t = t - d;
506
41
            y = (end_val - start_val) * (t << 4) / d;
507
41
            y = y * t / d;
508
41
            y = y * t / d;
509
41
            y = y * t / d;
510
41
            y = y * t / d + end_val;
511
        }
512
80
        break;
513
80
    case GX_ANIMATION_SINE_EASE_IN:
514
        /* cos(t/d * PI / 2 * 256). */
515
80
        t = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(90) * t / d);
516
80
        t = GX_FIXED_VAL_ONE - t;
517
518
80
        y = GX_FIXED_VAL_TO_INT((end_val - start_val) * t);
519
80
        y += start_val;
520
80
        break;
521
163
    case GX_ANIMATION_SINE_EASE_OUT:
522
        /* sin(t/d * PI / 2). */
523
163
        t = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(90) * t / d);
524
525
163
        y = GX_FIXED_VAL_TO_INT((end_val - start_val) * t);
526
163
        y += start_val;
527
163
        break;
528
80
    case GX_ANIMATION_SINE_EASE_IN_OUT:
529
        /* cos(t/d * PI * 256). */
530
80
        t = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(180) * t / d);
531
80
        t = GX_FIXED_VAL_ONE - t;
532
533
80
        y = GX_FIXED_VAL_TO_INT((end_val - start_val) * t);
534
80
        y = (y >> 1) + start_val;
535
80
        break;
536
542
    default:
537
542
        y = (end_val - start_val) * t / d + start_val;
538
542
        break;
539
    }
540
541
3200
    (*current_val) = y;
542
3200
    return GX_SUCCESS;
543
}
544