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 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _gx_display_driver_8bpp_horizontal_pattern_line_draw                */
35 /*                                                        PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    Generic 8bpp color format horizontal pattern line draw function.    */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    context                               Drawing context               */
48 /*    xstart                                x-coord of left endpoint      */
49 /*    xend                                  x-coord of right endpoint     */
50 /*    ypos                                  y-coord of line top           */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    None                                                                */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    None                                                                */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    GUIX Internal Code                                                  */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*                                                                        */
72 /**************************************************************************/
_gx_display_driver_8bpp_horizontal_pattern_line_draw(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT ypos)73 VOID _gx_display_driver_8bpp_horizontal_pattern_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos)
74 {
75 INT       column;
76 GX_UBYTE *put;
77 GX_UBYTE *rowstart;
78 ULONG     pattern;
79 ULONG     mask;
80 GX_UBYTE  on_color;
81 GX_UBYTE  off_color;
82 
83 INT       len = xend - xstart + 1;
84 
85     /* pick up start address of canvas memory */
86     rowstart = (GX_UBYTE *)context -> gx_draw_context_memory;
87 
88     /* calculate start of row address */
89     rowstart +=  context -> gx_draw_context_pitch * ypos;
90 
91     /* calculate pixel address */
92     rowstart +=  xstart;
93     /* draw 1-pixel hi lines to fill width */
94 
95     /* pick up the requested pattern and mask */
96     pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
97     mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
98     on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color;
99     off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color;
100 
101     put = rowstart;
102 
103     /* draw one line, left to right */
104     for (column = 0; column < len; column++)
105     {
106         if (pattern & mask)
107         {
108             *put++ = on_color;
109         }
110         else
111         {
112             *put++ = off_color;
113         }
114         mask >>= 1;
115         if (!mask)
116         {
117             mask = 0x80000000;
118         }
119     }
120 
121     /* save current masks value back to brush */
122     context -> gx_draw_context_brush.gx_brush_pattern_mask = mask;
123 }
124 
125