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 /* Include necessary system files.  */
23 
24 #include "gx_api.h"
25 #include "gx_display.h"
26 
27 /**************************************************************************/
28 /*                                                                        */
29 /*  FUNCTION                                               RELEASE        */
30 /*                                                                        */
31 /*    _gx_display_driver_8bpp_rotated_vertical_line_draw  PORTABLE C      */
32 /*                                                           6.1.4        */
33 /*  AUTHOR                                                                */
34 /*                                                                        */
35 /*    Kenneth Maxwell, Microsoft Corporation                              */
36 /*                                                                        */
37 /*  DESCRIPTION                                                           */
38 /*                                                                        */
39 /*    Generic 8bpp color format rotated vertical line draw function.      */
40 /*                                                                        */
41 /*  INPUT                                                                 */
42 /*                                                                        */
43 /*    context                               Drawing context               */
44 /*    ystart                                y-coord of top endpoint       */
45 /*    yend                                  y-coord of bottom endpoint    */
46 /*    xpos                                  x-coord of left edge          */
47 /*    width                                 width of the line             */
48 /*    color                                 Color of line to draw         */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    None                                                                */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    None                                                                */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    GUIX Internal Code                                                  */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
67 /*                                                                        */
68 /**************************************************************************/
_gx_display_driver_8bpp_rotated_vertical_line_draw(GX_DRAW_CONTEXT * context,INT ystart,INT yend,INT xpos,INT width,GX_COLOR color)69 VOID _gx_display_driver_8bpp_rotated_vertical_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos, INT width, GX_COLOR color)
70 {
71 INT       row;
72 INT       column;
73 GX_UBYTE *put;
74 GX_UBYTE *rowstart;
75 INT       len = yend - ystart + 1;
76 
77     /* Pick up starting address of canvas memory.  */
78     rowstart = (GX_UBYTE *)context -> gx_draw_context_memory;
79 
80     if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
81     {
82         /* Calculate start of scanline.  */
83         rowstart += (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - xpos - 1) * context -> gx_draw_context_pitch;
84 
85         /* Offset into starting pixel.  */
86         rowstart += ystart;
87     }
88     else
89     {
90         rowstart += (xpos + width - 1) * context -> gx_draw_context_pitch;
91         rowstart += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - yend - 1);
92     }
93 
94     /* Draw line width from left to right.  */
95     for (column = 0; column < width; column++)
96     {
97         put = rowstart;
98 
99         /* Draw line from top to bottom.  */
100         for (row = 0; row < len; row++)
101         {
102             *put++ = (GX_UBYTE)color;
103         }
104 
105         /* Ddvance to the next scaneline.  */
106         rowstart -= context -> gx_draw_context_pitch;
107     }
108 }
109 
110