GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_easing_function_calculate.c Lines: 276 276 100.0 %
Date: 2024-12-05 08:52:37 Branches: 55 55 100.0 %

Line Branch Exec Source
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)
103
480
static INT _gx_utility_pow_0_10(INT b)
104
{
105
480
    b >>= 1;
106
480
    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
/**************************************************************************/
154
240
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
240
    tt = 11 * t;
160
240
    if (tt < 4 * d)
161
    {
162
88
        tt = tt * tt;
163
88
        dd = 16 * d * d;
164
    }
165
152
    else if (tt < 8 * d)
166
    {
167
88
        dd = d * d;
168
88
        tt = (tt - 6 * d);
169
88
        tt = tt * tt + 12 * dd;
170
88
        dd = 16 * dd;
171
    }
172
64
    else if (tt < 10 * d)
173
    {
174
44
        dd = d * d;
175
44
        tt = tt - 9 * d;
176
44
        tt = tt * tt + 15 * dd;
177
44
        dd = 16 * dd;
178
    }
179
    else
180
    {
181
20
        dd = d * d;
182
20
        tt = 2 * tt - 21 * d;
183
20
        tt = tt * tt + 63 * dd;
184
20
        dd = 64 * dd;
185
    }
186
187
240
    *return_tt = tt;
188
240
    *return_dd = dd;
189
240
}
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
/**************************************************************************/
237
3200
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







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