GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_sprite_draw.c Lines: 16 16 100.0 %
Date: 2026-03-06 19:21:09 Branches: 10 10 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
/**   Sprite Management (Sprite)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_display.h"
30
#include "gx_context.h"
31
#include "gx_canvas.h"
32
#include "gx_widget.h"
33
#include "gx_sprite.h"
34
35
36
/**************************************************************************/
37
/*                                                                        */
38
/*  FUNCTION                                               RELEASE        */
39
/*                                                                        */
40
/*    _gx_sprite_draw                                     PORTABLE C      */
41
/*                                                           6.1.9        */
42
/*  AUTHOR                                                                */
43
/*                                                                        */
44
/*    Kenneth Maxwell, Microsoft Corporation                              */
45
/*                                                                        */
46
/*  DESCRIPTION                                                           */
47
/*                                                                        */
48
/*    This service draws a sprite widget.                                 */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    sprite                                Pointer to sprite widget      */
53
/*                                            control block               */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    _gx_context_pixelmap_get              Get the pixelmap in the       */
62
/*                                            current context             */
63
/*    _gx_canvas_pixelmap_blend             Blend pixelmap                */
64
/*    _gx_canvas_pixelmap_draw              Draw pixelmap                 */
65
/*    _gx_widget_children_draw              Draw the children of a widget */
66
/*                                                                        */
67
/*                                                                        */
68
/*  CALLED BY                                                             */
69
/*                                                                        */
70
/*    Application Code                                                    */
71
/*    GUIX Internal Code                                                  */
72
/*                                                                        */
73
/**************************************************************************/
74
856
VOID  _gx_sprite_draw(GX_SPRITE *sprite)
75
{
76
GX_SPRITE_FRAME *frame;
77
GX_PIXELMAP     *map;
78
GX_VALUE         xpos;
79
GX_VALUE         ypos;
80
81
    /* Draw sprite background.  */
82
856
    _gx_widget_background_draw((GX_WIDGET *)sprite);
83
84
856
    if (sprite -> gx_sprite_frame_list)
85
    {
86
842
        if (sprite -> gx_sprite_current_frame < sprite -> gx_sprite_frame_count)
87
        {
88
841
            frame = &sprite -> gx_sprite_frame_list[sprite -> gx_sprite_current_frame];
89
841
            if (frame -> gx_sprite_frame_pixelmap)
90
            {
91
840
                _gx_widget_context_fill_set((GX_WIDGET *)sprite);
92
93
840
                _gx_context_pixelmap_get(frame -> gx_sprite_frame_pixelmap, &map);
94
840
                if (map)
95
                {
96
838
                    xpos = (GX_VALUE)(sprite -> gx_widget_size.gx_rectangle_left + frame -> gx_sprite_frame_x_offset);
97
838
                    ypos = (GX_VALUE)(sprite -> gx_widget_size.gx_rectangle_top + frame -> gx_sprite_frame_y_offset);
98
99
838
                    if (frame -> gx_sprite_frame_alpha != GX_ALPHA_VALUE_OPAQUE)
100
                    {
101
4
                        _gx_canvas_pixelmap_blend(xpos, ypos, map, frame -> gx_sprite_frame_alpha);
102
                    }
103
                    else
104
                    {
105
834
                        _gx_canvas_pixelmap_draw(xpos, ypos, map);
106
                    }
107
                }
108
            }
109
        }
110
    }
111
112
    /* Draw children widgets of prompt widget.  */
113
856
    _gx_widget_children_draw((GX_WIDGET *)sprite);
114
856
}
115