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

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