GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_circular_gauge_background_draw.c Lines: 31 31 100.0 %
Date: 2026-03-06 19:21:09 Branches: 16 16 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
/**   Circular Gauge Management (Circular Gauge)                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_icon.h"
29
#include "gx_system.h"
30
#include "gx_context.h"
31
#include "gx_canvas.h"
32
#include "gx_circular_gauge.h"
33
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _gx_circular_gauge_background_draw                  PORTABLE C      */
40
/*                                                           6.1.9        */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    This function draws background of the specified circular gauge.     */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    gauge                                 Pointer to circular gauge     */
52
/*                                            control block               */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_icon_background_draw              Draw icon background          */
61
/*    _gx_context_pixelmap_get              Gets the pixelmap associated  */
62
/*                                            the supplied resource ID.   */
63
/*    _gx_circular_gauge_needle_rotate      Needle rotate function        */
64
/*    _gx_canvas_pixelmap_draw              Draw the specified pixelmap.  */
65
/*    _gx_system_memory_free                Free memory.                  */
66
/*    [gx_display_driver_callback_assign]   Assigns widget callback       */
67
/*                                            function                    */
68
/*    _gx_circular_gauge_needle_rotate_callback                           */
69
/*                                          Needle rotate callback        */
70
/*                                            function                    */
71
/*                                                                        */
72
/*  CALLED BY                                                             */
73
/*                                                                        */
74
/*    GUIX Internal Code                                                  */
75
/*                                                                        */
76
/**************************************************************************/
77
1727
VOID  _gx_circular_gauge_background_draw(GX_CIRCULAR_GAUGE *gauge)
78
{
79
GX_PIXELMAP            *map;
80
GX_CIRCULAR_GAUGE_INFO *info;
81
GX_DISPLAY             *display;
82
GX_BOOL                 free_mem;
83
84
/* pickup pointer to current context */
85
1727
GX_DRAW_CONTEXT *context = _gx_system_current_draw_context;
86
87
1727
    display = context -> gx_draw_context_display;
88
89
90
    /* Pick up gauge information.  */
91
1727
    info = &gauge -> gx_circular_gauge_info;
92
1727
    free_mem = GX_FALSE;
93
94
1727
    if (gauge -> gx_circular_gauge_info.gx_circular_gauge_info_needle_pixelmap)
95
    {
96
        /* get pointer to needle source image */
97
1713
        _gx_context_pixelmap_get(gauge -> gx_circular_gauge_info.gx_circular_gauge_info_needle_pixelmap,
98
                                 &gauge -> gx_circular_gauge_needle_source);
99
    }
100
101
1727
    if (gauge -> gx_circular_gauge_current_angle != 0)
102
    {
103
1647
        if (display -> gx_display_driver_callback_assign)
104
        {
105
            /* rotate the needle while gauge background is being drawn */
106
109
            display -> gx_display_driver_callback_assign(_gx_circular_gauge_needle_rotate_callback, gauge);
107
        }
108
        else
109
        {
110
            /* rotate the needle inline: */
111
1538
            _gx_circular_gauge_needle_rotate(gauge);
112
        }
113
1647
        map = &gauge -> gx_circular_gauge_needle_rotated;
114
1647
        free_mem = GX_TRUE;
115
    }
116
    else
117
    {
118
80
        map = gauge -> gx_circular_gauge_needle_source;
119
80
        gauge -> gx_circular_gauge_current_needle_x = gauge -> gx_widget_size.gx_rectangle_left +
120
80
            info -> gx_circular_gauge_info_needle_xpos -
121
80
            info -> gx_circular_gauge_info_needle_xcor;
122
80
        gauge -> gx_circular_gauge_current_needle_y = gauge -> gx_widget_size.gx_rectangle_top +
123
80
            info -> gx_circular_gauge_info_needle_ypos -
124
80
            info -> gx_circular_gauge_info_needle_ycor;
125
    }
126
127
    /* Call icon draw function to draw the background.  */
128
1727
    _gx_icon_background_draw((GX_ICON *)gauge);
129
130

1727
    if ((map != GX_NULL) && (map -> gx_pixelmap_data != GX_NULL))
131
    {
132
        /* Draw needle .  */
133
1711
        _gx_canvas_pixelmap_draw((GX_VALUE)gauge -> gx_circular_gauge_current_needle_x,
134
1711
                                 (GX_VALUE)gauge -> gx_circular_gauge_current_needle_y,
135
                                 map);
136
137
        /* Free rotate needle pixelmap memory.  */
138

1711
        if (_gx_system_memory_free && free_mem)
139
        {
140
1644
            if (map -> gx_pixelmap_aux_data)
141
            {
142
16
                _gx_system_memory_free((VOID *)map -> gx_pixelmap_aux_data);
143
16
                map -> gx_pixelmap_aux_data = GX_NULL;
144
            }
145
1644
            _gx_system_memory_free((VOID *)map -> gx_pixelmap_data);
146
1644
            map -> gx_pixelmap_data = GX_NULL;
147
        }
148
    }
149
1727
}
150