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 #define GX_SOURCE_CODE
21 
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_16bpp_vertical_line_draw         PORTABLE C      */
33 /*                                                           6.3.0        */
34 /*  AUTHOR                                                                */
35 /*                                                                        */
36 /*    Kenneth Maxwell, Microsoft Corporation                              */
37 /*                                                                        */
38 /*  DESCRIPTION                                                           */
39 /*                                                                        */
40 /*    Generic vertical line draw function for 16bpp canvas.               */
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 write        */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _gx_display_driver_vertical_line_alpha_draw                         */
58 /*                                          Display driver basic vertical */
59 /*                                            line alpha 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 /*  10-31-2023     Ting Zhu                 Modified comment(s),          */
73 /*                                            added partial canvas buffer */
74 /*                                            support,                    */
75 /*                                            resulting in version 6.3.0  */
76 /*                                                                        */
77 /**************************************************************************/
_gx_display_driver_16bpp_vertical_line_draw(GX_DRAW_CONTEXT * context,INT ystart,INT yend,INT xpos,INT width,GX_COLOR color)78 VOID _gx_display_driver_16bpp_vertical_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos, INT width, GX_COLOR color)
79 {
80 INT     row;
81 INT     column;
82 USHORT *put;
83 USHORT *rowstart;
84 INT     len = yend - ystart + 1;
85 #if defined GX_BRUSH_ALPHA_SUPPORT
86 GX_UBYTE alpha;
87 
88     alpha = context -> gx_draw_context_brush.gx_brush_alpha;
89     if (alpha == 0)
90     {
91         /* Nothing to drawn. Just return. */
92         return;
93     }
94     if (alpha != 0xff)
95     {
96         _gx_display_driver_vertical_line_alpha_draw(context, ystart, yend, xpos, width, color, alpha);
97         return;
98     }
99 #endif
100 
101     /* pick up starting address of canvas memory */
102     rowstart = (USHORT *)context -> gx_draw_context_memory;
103 
104     GX_CALCULATE_PUTROW(rowstart, xpos, ystart, context);
105 
106     /* draw line from top to bottom */
107     for (row = 0; row < len; row++)
108     {
109         put = rowstart;
110 
111         /* draw line width from left to right */
112         for (column = 0; column < width; column++)
113         {
114             *put++ = (USHORT)color;
115         }
116 
117         /* advance to the next scaneline */
118         rowstart += context -> gx_draw_context_pitch;
119     }
120 }
121 
122