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_rotated_vertical_line_draw PORTABLE C      */
33 /*                                                           6.1.3        */
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 /*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
70 /*                                                                        */
71 /**************************************************************************/
_gx_display_driver_16bpp_rotated_vertical_line_draw(GX_DRAW_CONTEXT * context,INT ystart,INT yend,INT xpos,INT width,GX_COLOR color)72 VOID _gx_display_driver_16bpp_rotated_vertical_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos, INT width, GX_COLOR color)
73 {
74 INT     row;
75 INT     column;
76 USHORT *put;
77 USHORT *rowstart;
78 INT     len = yend - ystart + 1;
79 
80 #if defined GX_BRUSH_ALPHA_SUPPORT
81 GX_UBYTE alpha;
82 
83     alpha = context -> gx_draw_context_brush.gx_brush_alpha;
84     if (alpha == 0)
85     {
86         /* Nothing to drawn. Just return. */
87         return;
88     }
89     if (alpha != 0xff)
90     {
91         _gx_display_driver_vertical_line_alpha_draw(context, ystart, yend, xpos, width, color, alpha);
92         return;
93     }
94 #endif
95 
96     /* pick up starting address of canvas memory */
97     rowstart = (USHORT *)context -> gx_draw_context_memory;
98 
99     if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
100     {
101         /* calculate start of scanline */
102         rowstart += (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - xpos - 1) * context -> gx_draw_context_pitch;
103 
104         /* offset into starting pixel */
105         rowstart += ystart;
106     }
107     else
108     {
109         rowstart += (xpos + width - 1) * context -> gx_draw_context_pitch;
110         rowstart += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - yend - 1);
111     }
112 
113     /* draw line width from left to right */
114     for (column = 0; column < width; column++)
115     {
116         put = rowstart;
117         /* draw line from top to bottom */
118         for (row = 0; row < len; row++)
119         {
120             *put++ = (USHORT)color;
121         }
122 
123         /* advance to the right */
124         rowstart -= context -> gx_draw_context_pitch;
125     }
126 }
127 
128