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