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 #define GX_SOURCE_CODE
22 
23 /* Include necessary system files.  */
24 
25 #include "gx_api.h"
26 #include "gx_display.h"
27 
28 /**************************************************************************/
29 /*                                                                        */
30 /*  FUNCTION                                               RELEASE        */
31 /*                                                                        */
32 /*    _gx_display_driver_8bpp_vertical_line_draw          PORTABLE C      */
33 /*                                                           6.1          */
34 /*  AUTHOR                                                                */
35 /*                                                                        */
36 /*    Kenneth Maxwell, Microsoft Corporation                              */
37 /*                                                                        */
38 /*  DESCRIPTION                                                           */
39 /*                                                                        */
40 /*    Generic 8bpp color format vertical line draw function.              */
41 /*                                                                        */
42 /*  INPUT                                                                 */
43 /*                                                                        */
44 /*    context                               Drawing context               */
45 /*    ystart                                y-coord of top endpoint       */
46 /*    yend                                  y-coord of bottom endpoint    */
47 /*    xpos                                  x-coord of left edge          */
48 /*    width                                 width of the line             */
49 /*    color                                 Color of line to draw         */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _gx_display_driver_vertical_line_alpha_draw                         */
58 /*                                          Basic display driver vertical */
59 /*                                            alpha line draw function    */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    GUIX Internal Code                                                  */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
70 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_gx_display_driver_8bpp_vertical_line_draw(GX_DRAW_CONTEXT * context,INT ystart,INT yend,INT xpos,INT width,GX_COLOR color)74 VOID _gx_display_driver_8bpp_vertical_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos, INT width, GX_COLOR color)
75 {
76 INT       row;
77 INT       column;
78 GX_UBYTE *put;
79 GX_UBYTE *rowstart;
80 INT       len = yend - ystart + 1;
81 #if defined GX_BRUSH_ALPHA_SUPPORT
82 GX_UBYTE alpha;
83 
84     alpha = context -> gx_draw_context_brush.gx_brush_alpha;
85     if (alpha == 0)
86     {
87         /* Nothing to drawn. Just return. */
88         return;
89     }
90     if (alpha != 0xff)
91     {
92         if (context -> gx_draw_context_display -> gx_display_color_format != GX_COLOR_FORMAT_8BIT_PACKED_PIXEL)
93         {
94             /* Alpha blend is not supported for palette driver. */
95             return;
96         }
97 
98         _gx_display_driver_vertical_line_alpha_draw(context, ystart, yend, xpos, width, color, alpha);
99         return;
100     }
101 #endif
102 
103     /* pick up starting address of canvas memory */
104     rowstart = (GX_UBYTE *)context -> gx_draw_context_memory;
105 
106     /* calculate start of scanline */
107     rowstart += context -> gx_draw_context_pitch * ystart;
108 
109     /* offset into starting pixel */
110     rowstart += xpos;
111 
112     /* draw line from top to bottom */
113     for (row = 0; row < len; row++)
114     {
115         put = rowstart;
116 
117         /* draw line width from left to right */
118         for (column = 0; column < width; column++)
119         {
120             *put++ = (GX_UBYTE)color;
121         }
122 
123         /* advance to the next scaneline */
124         rowstart += context -> gx_draw_context_pitch;
125     }
126 }
127