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 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_display.h"
28 
29 /**************************************************************************/
30 /*                                                                        */
31 /*  FUNCTION                                               RELEASE        */
32 /*                                                                        */
33 /*    _gx_display_driver_32bpp_rotated_horizontal_line_draw               */
34 /*                                                        PORTABLE C      */
35 /*                                                           6.1.4        */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Kenneth Maxwell, Microsoft Corporation                              */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    Generic 32bpp color format horizontal line draw function.           */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    context                               Drawing context               */
47 /*    xstart                                x-coord of left endpoint      */
48 /*    xend                                  x-coord of right endpoint     */
49 /*    ypos                                  y-coord of line top           */
50 /*    width                                 Width (height) of the line    */
51 /*    color                                 Color of line to write        */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    NOne                                                                */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    _gx_display_driver_horizontal_line_alpha_draw                       */
60 /*                                          Basic horizontal line alpha   */
61 /*                                            draw function               */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    GUIX Internal Code                                                  */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
72 /*                                                                        */
73 /**************************************************************************/
_gx_display_driver_32bpp_rotated_horizontal_line_draw(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT ypos,INT width,GX_COLOR color)74 VOID _gx_display_driver_32bpp_rotated_horizontal_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos, INT width, GX_COLOR color)
75 {
76 INT    row;
77 INT    column;
78 ULONG *put;
79 ULONG *rowstart;
80 INT    len = xend - xstart + 1;
81 
82 #if defined GX_BRUSH_ALPHA_SUPPORT
83 GX_UBYTE alpha;
84 
85     alpha = context -> gx_draw_context_brush.gx_brush_alpha;
86     if (alpha == 0)
87     {
88         /* Nothing to drawn. Just return.  */
89         return;
90     }
91 
92     if (alpha != 0xff)
93     {
94         _gx_display_driver_horizontal_line_alpha_draw(context, xstart, xend, ypos, width, color, alpha);
95         return;
96     }
97 #endif
98 
99     /* Pick up start address of canvas memory.  */
100     rowstart = (ULONG *)context -> gx_draw_context_memory;
101 
102     /* Calculate start of row address.  */
103     if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
104     {
105         rowstart += (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - xstart - 1) * context -> gx_draw_context_pitch;
106         rowstart += ypos;
107     }
108     else
109     {
110         rowstart += xend * context -> gx_draw_context_pitch;
111         rowstart += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - ypos - width);
112     }
113 
114     /* Draw one line, left to right.  */
115     for (column = 0; column < len; column++)
116     {
117         put = rowstart;
118 
119         /* Draw 1-pixel vertical lines to fill width.  */
120         for (row = 0; row < width; row++)
121         {
122             *put++ = (ULONG)color;
123         }
124 
125         rowstart -= context -> gx_draw_context_pitch;
126     }
127 }
128 
129