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_display.h"
28 #include "gx_canvas.h"
29 #include "gx_context.h"
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_display_driver_generic_polygon_draw             PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    Generic polygon draw function.                                      */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    context                               Drawing context               */
48 /*    vertex                                Array of vertexes             */
49 /*    num                                   Number of vertexes            */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _gx_canvas_line_draw                  Draw a line into canvas       */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    GUIX Internal Code                                                  */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
68 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
_gx_display_driver_generic_polygon_draw(GX_DRAW_CONTEXT * context,GX_POINT * vertex,INT num)72 VOID _gx_display_driver_generic_polygon_draw(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num)
73 {
74 INT index;
75 INT brush_width = context -> gx_draw_context_brush.gx_brush_width;
76 #if defined (GX_BRUSH_ALPHA_SUPPORT)
77 GX_UBYTE     temp_alpha;
78 UINT         brush_style;
79     temp_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
80     brush_style = context -> gx_draw_context_brush.gx_brush_style;
81     if (brush_width > 1)
82     {
83         if (temp_alpha != 0xff)
84         {
85             if ((brush_style & GX_BRUSH_ROUND) || (brush_style & GX_BRUSH_ALIAS))
86             {
87                 context -> gx_draw_context_brush.gx_brush_alpha = GX_ALPHA_VALUE_OPAQUE;
88             }
89         }
90     }
91 #endif
92 
93     if (brush_width > 0)
94     {
95         /*round end*/
96         for (index = 0; index < num; index++)
97         {
98             _gx_canvas_line_draw(vertex[index].gx_point_x, vertex[index].gx_point_y,
99                                  vertex[(index + 1) % num].gx_point_x, vertex[(index + 1) % num].gx_point_y);
100         }
101     }
102 #if defined (GX_BRUSH_ALPHA_SUPPORT)
103     context -> gx_draw_context_brush.gx_brush_alpha = temp_alpha;
104 #endif
105 }
106 
107