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 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_display.h"
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _gx_display_driver_16bpp_horizontal_line_draw       PORTABLE C      */
35 /*                                                           6.3.0        */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Kenneth Maxwell, Microsoft Corporation                              */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    Generic 16bpp 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 /*                                          Display driver basic          */
61 /*                                            horiztonal alpha line draw  */
62 /*                                            route                       */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    GUIX Internal Code                                                  */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
73 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*  10-31-2023     Ting Zhu                 Modified comment(s),          */
76 /*                                            added partial canvas buffer */
77 /*                                            support,                    */
78 /*                                            resulting in version 6.3.0  */
79 /*                                                                        */
80 /**************************************************************************/
_gx_display_driver_16bpp_horizontal_line_draw(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT ypos,INT width,GX_COLOR color)81 VOID _gx_display_driver_16bpp_horizontal_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos, INT width, GX_COLOR color)
82 {
83 INT     row;
84 INT     column;
85 USHORT *put;
86 USHORT *rowstart;
87 INT     len = xend - xstart + 1;
88 
89 #if defined GX_BRUSH_ALPHA_SUPPORT
90 GX_UBYTE alpha;
91 
92     alpha = context -> gx_draw_context_brush.gx_brush_alpha;
93     if (alpha == 0)
94     {
95         /* Nothing to drawn. Just return. */
96         return;
97     }
98 
99     if (alpha != 0xff)
100     {
101         _gx_display_driver_horizontal_line_alpha_draw(context, xstart, xend, ypos, width, color, alpha);
102         return;
103     }
104 #endif
105 
106     /* pick up start address of canvas memory */
107     rowstart = (USHORT *)context -> gx_draw_context_memory;
108 
109     GX_CALCULATE_PUTROW(rowstart, xstart, ypos, context);
110 
111     /* draw 1-pixel hi lines to fill width */
112     for (row = 0; row < width; row++)
113     {
114         put = rowstart;
115 
116         /* draw one line, left to right */
117         for (column = 0; column < len; column++)
118         {
119             *put++ = (USHORT)color;
120         }
121         rowstart += context -> gx_draw_context_pitch;
122     }
123 
124 }
125