GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_generic_simple_wide_line_draw.c Lines: 54 54 100.0 %
Date: 2026-03-06 19:21:09 Branches: 26 26 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
/**   Display Management (Display)                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_utility.h"
29
#include "gx_display.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_display_driver_generic_simple_wide_line_draw    PORTABLE C      */
37
/*                                                           6.1.3        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*   Generic display driver function for non-aliased wide line.           */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    context                               Drawing context               */
49
/*    xstart                                x-coord of endpoint           */
50
/*    ystart                                y-coord of endpoint           */
51
/*    xend                                  x-coord of endpoint           */
52
/*    yend                                  y-coord of endpoint           */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_display_driver_generic_wide_line_points_calculate               */
61
/*                                          Calculate corners of wide line*/
62
/*    _gx_display_driver_generic_filled_circle_draw                       */
63
/*                                          Basic display driver solid    */
64
/*                                            circle draw function        */
65
/*    _gx_display_driver_generic_wide_line_fill                           */
66
/*                                          Basic display driver wide     */
67
/*                                            line draw function          */
68
/*                                                                        */
69
/*  CALLED BY                                                             */
70
/*                                                                        */
71
/*    GUIX Internal Code                                                  */
72
/*                                                                        */
73
/**************************************************************************/
74
8412
VOID _gx_display_driver_generic_simple_wide_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT ystart,
75
                                                      INT xend, INT yend)
76
{
77
8412
GX_DISPLAY     *display = context -> gx_draw_context_display;
78
GX_FIXED_POINT *line_points;
79
8412
INT             brush_width = context -> gx_draw_context_brush.gx_brush_width;
80
GX_RECTANGLE    clip_rect;
81
GX_FIXED_VAL    sxcenter;
82
GX_FIXED_VAL    sycenter;
83
GX_FIXED_VAL    excenter;
84
GX_FIXED_VAL    eycenter;
85
86
#if defined(GX_BRUSH_ALPHA_SUPPORT)
87
GX_UBYTE old_alpha;
88
8412
    old_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
89
8412
    if (context -> gx_draw_context_brush.gx_brush_style & GX_BRUSH_ROUND)
90
    {
91
3689
        context -> gx_draw_context_brush.gx_brush_alpha = GX_ALPHA_VALUE_OPAQUE;
92
    }
93
#endif
94
95

8412
    if ((context -> gx_draw_context_brush.gx_brush_style & GX_BRUSH_ROUND) &&
96
        (brush_width > 2))
97
    {
98
2954
        sxcenter = GX_FIXED_VAL_MAKE(xstart);
99
2954
        sycenter = GX_FIXED_VAL_MAKE(ystart);
100
2954
        excenter = GX_FIXED_VAL_MAKE(xend);
101
2954
        eycenter = GX_FIXED_VAL_MAKE(yend);
102
103
2954
        if (!(brush_width & 0x01))
104
        {
105
966
            if (ystart == yend)
106
            {
107
                /* Horizontal line. */
108
153
                sycenter -= GX_FIXED_VAL_HALF;
109
153
                eycenter -= GX_FIXED_VAL_HALF;
110
            }
111
813
            else if (xstart == xend)
112
            {
113
                /* Vertical line. */
114
171
                sxcenter -= GX_FIXED_VAL_HALF;
115
171
                excenter -= GX_FIXED_VAL_HALF;
116
            }
117
        }
118
119
2954
        _gx_display_driver_generic_filled_circle_draw(context, sxcenter, sycenter,
120
2954
                                                      GX_FIXED_VAL_MAKE(brush_width) >> 1);
121
122
2954
        _gx_display_driver_generic_filled_circle_draw(context, excenter, eycenter,
123
2954
                                                      GX_FIXED_VAL_MAKE(brush_width) >> 1);
124
    }
125
126
8412
    if (ystart == yend)
127
    {
128
        /* Horizontal line. */
129
130
521
        if (xstart > xend)
131
        {
132
175
            GX_SWAP_VALS(xstart, xend);
133
        }
134
135
521
        clip_rect.gx_rectangle_left = (GX_VALUE)xstart;
136
521
        clip_rect.gx_rectangle_right = (GX_VALUE)xend;
137
521
        clip_rect.gx_rectangle_top = (GX_VALUE)(ystart - (brush_width >> 1));
138
521
        clip_rect.gx_rectangle_bottom = (GX_VALUE)(clip_rect.gx_rectangle_top + brush_width - 1);
139
140
521
        if (_gx_utility_rectangle_overlap_detect(&clip_rect, context -> gx_draw_context_clip, &clip_rect))
141
        {
142
495
            display -> gx_display_driver_horizontal_line_draw(context,
143
495
                                                              clip_rect.gx_rectangle_left,
144
495
                                                              clip_rect.gx_rectangle_right,
145
495
                                                              clip_rect.gx_rectangle_top,
146
495
                                                              clip_rect.gx_rectangle_bottom - clip_rect.gx_rectangle_top + 1,
147
                                                              context -> gx_draw_context_brush.gx_brush_line_color);
148
        }
149
    }
150
7891
    else if (xstart == xend)
151
    {
152
        /* Vertical line. */
153
154
540
        if (ystart > yend)
155
        {
156
269
            GX_SWAP_VALS(ystart, yend);
157
        }
158
159
540
        clip_rect.gx_rectangle_left = (GX_VALUE)(xstart - (brush_width >> 1));
160
540
        clip_rect.gx_rectangle_right = (GX_VALUE)(clip_rect.gx_rectangle_left + brush_width - 1);
161
540
        clip_rect.gx_rectangle_top = (GX_VALUE)ystart;
162
540
        clip_rect.gx_rectangle_bottom = (GX_VALUE)yend;
163
164
540
        if (_gx_utility_rectangle_overlap_detect(&clip_rect, context -> gx_draw_context_clip, &clip_rect))
165
        {
166
504
            display -> gx_display_driver_vertical_line_draw(context,
167
504
                                                            clip_rect.gx_rectangle_top,
168
504
                                                            clip_rect.gx_rectangle_bottom,
169
504
                                                            clip_rect.gx_rectangle_left,
170
504
                                                            clip_rect.gx_rectangle_right - clip_rect.gx_rectangle_left + 1,
171
                                                            context -> gx_draw_context_brush.gx_brush_line_color);
172
        }
173
    }
174
    else
175
    {
176
        /* calcualte the corners of this line, save them
177
           to our points array
178
         */
179
7351
        line_points = _gx_display_driver_generic_wide_line_points_calculate(context, xstart, ystart,
180
                                                                            xend, yend, brush_width, GX_FALSE);
181
7351
        if (display -> gx_display_rotation_angle)
182
        {
183
2639
            _gx_display_driver_generic_rotated_wide_line_fill(context, line_points);
184
        }
185
        else
186
        {
187
4712
            _gx_display_driver_generic_wide_line_fill(context, line_points);
188
        }
189
    }
190
#if defined(GX_BRUSH_ALPHA_SUPPORT)
191
8412
    context -> gx_draw_context_brush.gx_brush_alpha = old_alpha;
192
#endif
193
8412
}
194