GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_animation_delete.c Lines: 16 16 100.0 %
Date: 2024-12-05 08:52:37 Branches: 10 10 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
/**   Animation Management (Animation)                                    */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_system.h"
28
#include "gx_animation.h"
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_animation_delete                                PORTABLE C      */
35
/*                                                           6.1.7        */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Ting Zhu, Microsoft Corporation                                     */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This function deletes an animation sequence if the input animation  */
43
/*    pointer is not NULL, otherwise, deletes all animations belong to    */
44
/*    the animation parent.                                               */
45
/*                                                                        */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    target                                Pointer to animation control  */
50
/*                                            block                       */
51
/*    parent                                Pointer to animation parent   */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*   _gx_animation_stop                     Deactivate an animation       */
60
/*   _gx_system_animation_free              Free system animation         */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    GUIX Internal Code                                                  */
65
/*    Application Code                                                    */
66
/*                                                                        */
67
/*  RELEASE HISTORY                                                       */
68
/*                                                                        */
69
/*    DATE              NAME                      DESCRIPTION             */
70
/*                                                                        */
71
/*  06-02-2021     Ting Zhu                 Initial Version 6.1.7         */
72
/*                                                                        */
73
/**************************************************************************/
74
75
3
UINT _gx_animation_delete(GX_ANIMATION *target, GX_WIDGET *parent)
76
{
77
GX_ANIMATION *animation;
78
GX_ANIMATION *next;
79
80
3
    if (target)
81
    {
82
2
        animation = target;
83
    }
84
    else
85
    {
86
1
        animation = _gx_system_animation_list;
87
    }
88
89
7
    while (animation)
90
    {
91
4
        if (target)
92
        {
93
2
            next = GX_NULL;
94
2
            parent = target -> gx_animation_info.gx_animation_parent;
95
        }
96
        else
97
        {
98
2
            next = animation -> gx_animation_next;
99
        }
100
101
4
        if (animation -> gx_animation_info.gx_animation_parent == parent)
102
        {
103
104
            /* Stop animation.  */
105
3
            _gx_animation_stop(animation);
106
107
3
            if (animation -> gx_animation_system_allocated)
108
            {
109
110
                /* If this animation came from the system pool, return it.  */
111
2
                _gx_system_animation_free(animation);
112
            }
113
            else
114
            {
115
                /* Invalid animation.  */
116
1
                animation -> gx_animation_status = 0;
117
            }
118
        }
119
120
4
        animation = next;
121
    }
122
123
3
    return(GX_SUCCESS);
124
}
125