GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_generic_aliased_wide_line_draw.c Lines: 55 55 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_aliased_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 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_simple_wide_line_draw]                           */
61
/*                                          Basic display driver wide     */
62
/*                                            line draw function          */
63
/*    _gx_display_driver_generic_wide_line_points_calculate               */
64
/*                                          Calculate corners of wide line*/
65
/*    _gx_display_driver_generic_aliased_filled_circle_draw               */
66
/*                                          Basic display driver aliased  */
67
/*                                            circle fill function        */
68
/*    _gx_display_driver_generic_wide_line_fill                           */
69
/*                                          Basic display driver wide line*/
70
/*                                            draw function               */
71
/*                                                                        */
72
/*  CALLED BY                                                             */
73
/*                                                                        */
74
/*    GUIX Internal Code                                                  */
75
/*                                                                        */
76
/**************************************************************************/
77
6365
VOID _gx_display_driver_generic_aliased_wide_line_draw(GX_DRAW_CONTEXT *context, INT xstart,
78
                                                       INT ystart, INT xend, INT yend)
79
{
80
6365
GX_DISPLAY     *display = context -> gx_draw_context_display;
81
6365
INT             brush_width = context -> gx_draw_context_brush.gx_brush_width;
82
GX_FIXED_POINT *line_points;
83
GX_FIXED_VAL    sxcenter;
84
GX_FIXED_VAL    sycenter;
85
GX_FIXED_VAL    excenter;
86
GX_FIXED_VAL    eycenter;
87
GX_RECTANGLE    clip_rect;
88
89
#if defined(GX_BRUSH_ALPHA_SUPPORT)
90
GX_UBYTE old_alpha;
91
6365
    old_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
92
6365
    context -> gx_draw_context_brush.gx_brush_alpha = GX_ALPHA_VALUE_OPAQUE;
93
#endif
94
    /* calculate the corners of this line, save them
95
       to our points array
96
     */
97
6365
    if (!(context -> gx_draw_context_display -> gx_display_driver_pixel_blend))
98
    {
99
72
        display -> gx_display_driver_simple_wide_line_draw(context, xstart, ystart, xend, yend);
100
72
        return;
101
    }
102
103

6293
    if ((context -> gx_draw_context_brush.gx_brush_style & GX_BRUSH_ROUND) &&
104
        (brush_width > 2))
105
    {
106
1400
        sxcenter = GX_FIXED_VAL_MAKE(xstart);
107
1400
        sycenter = GX_FIXED_VAL_MAKE(ystart);
108
1400
        excenter = GX_FIXED_VAL_MAKE(xend);
109
1400
        eycenter = GX_FIXED_VAL_MAKE(yend);
110
111
1400
        if (!(brush_width & 0x01))
112
        {
113
626
            if (ystart == yend)
114
            {
115
                /* Horizontal line. */
116
53
                sycenter -= GX_FIXED_VAL_HALF;
117
53
                eycenter -= GX_FIXED_VAL_HALF;
118
            }
119
573
            else if (xstart == xend)
120
            {
121
                /* Vertical line. */
122
49
                sxcenter -= GX_FIXED_VAL_HALF;
123
49
                excenter -= GX_FIXED_VAL_HALF;
124
            }
125
        }
126
127
1400
        _gx_display_driver_generic_aliased_filled_circle_draw(context, sxcenter, sycenter,
128
1400
                                                              GX_FIXED_VAL_MAKE(brush_width) >> 1);
129
130
1400
        _gx_display_driver_generic_aliased_filled_circle_draw(context, excenter, eycenter,
131
1400
                                                              GX_FIXED_VAL_MAKE(brush_width) >> 1);
132
    }
133
134
6293
    if (ystart == yend)
135
    {
136
        /* Horizontal line. */
137
138
595
        if (xstart > xend)
139
        {
140
248
            GX_SWAP_VALS(xstart, xend);
141
        }
142
143
595
        clip_rect.gx_rectangle_left = (GX_VALUE)xstart;
144
595
        clip_rect.gx_rectangle_right = (GX_VALUE)xend;
145
595
        clip_rect.gx_rectangle_top = (GX_VALUE)(ystart - (brush_width >> 1));
146
595
        clip_rect.gx_rectangle_bottom = (GX_VALUE)(clip_rect.gx_rectangle_top + brush_width - 1);
147
148
595
        if (_gx_utility_rectangle_overlap_detect(&clip_rect, context -> gx_draw_context_clip, &clip_rect))
149
        {
150
571
            display -> gx_display_driver_horizontal_line_draw(context,
151
571
                                                              clip_rect.gx_rectangle_left,
152
571
                                                              clip_rect.gx_rectangle_right,
153
571
                                                              clip_rect.gx_rectangle_top,
154
571
                                                              clip_rect.gx_rectangle_bottom - clip_rect.gx_rectangle_top + 1,
155
                                                              context -> gx_draw_context_brush.gx_brush_line_color);
156
        }
157
    }
158
5698
    else if (xstart == xend)
159
    {
160
        /* Vertical line. */
161
162
490
        if (ystart > yend)
163
        {
164
276
            GX_SWAP_VALS(ystart, yend);
165
        }
166
167
490
        clip_rect.gx_rectangle_left = (GX_VALUE)(xstart - (brush_width >> 1));
168
490
        clip_rect.gx_rectangle_right = (GX_VALUE)(clip_rect.gx_rectangle_left + brush_width - 1);
169
490
        clip_rect.gx_rectangle_top = (GX_VALUE)ystart;
170
490
        clip_rect.gx_rectangle_bottom = (GX_VALUE)yend;
171
172
490
        if (_gx_utility_rectangle_overlap_detect(&clip_rect, context -> gx_draw_context_clip, &clip_rect))
173
        {
174
400
            display -> gx_display_driver_vertical_line_draw(context,
175
400
                                                            clip_rect.gx_rectangle_top,
176
400
                                                            clip_rect.gx_rectangle_bottom,
177
400
                                                            clip_rect.gx_rectangle_left,
178
400
                                                            clip_rect.gx_rectangle_right - clip_rect.gx_rectangle_left + 1,
179
                                                            context -> gx_draw_context_brush.gx_brush_line_color);
180
        }
181
    }
182
    else
183
    {
184
5208
        line_points = _gx_display_driver_generic_wide_line_points_calculate(context, xstart, ystart,
185
                                                                            xend, yend, brush_width, GX_TRUE);
186
187
5208
        if (display -> gx_display_rotation_angle)
188
        {
189
2088
            _gx_display_driver_generic_rotated_wide_line_fill(context, line_points);
190
        }
191
        else
192
        {
193
3120
            _gx_display_driver_generic_wide_line_fill(context, line_points);
194
        }
195
    }
196
197
#if defined(GX_BRUSH_ALPHA_SUPPORT)
198
6293
    context -> gx_draw_context_brush.gx_brush_alpha = old_alpha;
199
#endif
200
}
201