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 |
|
|
/* 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_1bpp_horizontal_pattern_line_draw */ |
33 |
|
|
/* PORTABLE C */ |
34 |
|
|
/* 6.1 */ |
35 |
|
|
/* AUTHOR */ |
36 |
|
|
/* */ |
37 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
38 |
|
|
/* */ |
39 |
|
|
/* DESCRIPTION */ |
40 |
|
|
/* */ |
41 |
|
|
/* Horizontal pattern line draw function for 1bpp display driver. */ |
42 |
|
|
/* */ |
43 |
|
|
/* INPUT */ |
44 |
|
|
/* */ |
45 |
|
|
/* context Drawing context */ |
46 |
|
|
/* xstart x-coord of left endpoint */ |
47 |
|
|
/* xend x-coord of right endpoint */ |
48 |
|
|
/* ypos y-coord of line top */ |
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 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
67 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
68 |
|
|
/* resulting in version 6.1 */ |
69 |
|
|
/* */ |
70 |
|
|
/**************************************************************************/ |
71 |
|
21 |
VOID _gx_display_driver_1bpp_horizontal_pattern_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos) |
72 |
|
|
{ |
73 |
|
|
INT column; |
74 |
|
|
GX_UBYTE *put; |
75 |
|
|
GX_UBYTE *rowstart; |
76 |
|
|
ULONG pattern; |
77 |
|
|
ULONG mask; |
78 |
|
|
GX_UBYTE on_color; |
79 |
|
|
GX_UBYTE off_color; |
80 |
|
|
INT pos; |
81 |
|
21 |
INT len = xend - xstart + 1; |
82 |
|
21 |
INT start_in_byte = 0; |
83 |
|
|
GX_UBYTE start_mask; |
84 |
|
|
|
85 |
|
|
/* pick up start address of canvas memory */ |
86 |
|
21 |
rowstart = (GX_UBYTE *)context -> gx_draw_context_memory; |
87 |
|
|
|
88 |
|
21 |
pos = context -> gx_draw_context_pitch * ypos + xstart; |
89 |
|
|
|
90 |
|
|
/* pick up the requested pattern and mask */ |
91 |
|
21 |
pattern = context -> gx_draw_context_brush.gx_brush_line_pattern; |
92 |
|
21 |
mask = context -> gx_draw_context_brush.gx_brush_pattern_mask; |
93 |
|
21 |
on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color & 0x01; |
94 |
|
21 |
off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color & 0x01; |
95 |
|
|
|
96 |
|
21 |
put = rowstart; |
97 |
|
21 |
put += pos >> 3; |
98 |
|
21 |
start_in_byte = pos & 0x07; |
99 |
|
21 |
start_mask = (GX_UBYTE)(((GX_UBYTE)0x80) >> start_in_byte); |
100 |
|
|
|
101 |
✓✓ |
3622 |
for (column = 0; column < len; column++) |
102 |
|
|
{ |
103 |
✓✓ |
3601 |
if (pattern & mask) |
104 |
|
|
{ |
105 |
✓✓ |
1789 |
if (on_color == 0x00) |
106 |
|
|
{ |
107 |
|
989 |
*put = (GX_UBYTE)((*put) & (~start_mask)); |
108 |
|
|
} |
109 |
|
|
else |
110 |
|
|
{ |
111 |
|
800 |
*put |= start_mask; |
112 |
|
|
} |
113 |
|
|
} |
114 |
|
|
else |
115 |
|
|
{ |
116 |
✓✓ |
1812 |
if (off_color == 0x00) |
117 |
|
|
{ |
118 |
|
810 |
*put &= (GX_UBYTE)((*put) & (~start_mask)); |
119 |
|
|
} |
120 |
|
|
else |
121 |
|
|
{ |
122 |
|
1002 |
*put |= start_mask; |
123 |
|
|
} |
124 |
|
|
} |
125 |
|
3601 |
start_mask >>= 1; |
126 |
✓✓ |
3601 |
if (start_mask == 0) |
127 |
|
|
{ |
128 |
|
448 |
put++; |
129 |
|
448 |
start_mask = 0x80; |
130 |
|
|
} |
131 |
|
|
|
132 |
|
3601 |
mask >>= 1; |
133 |
✓✓ |
3601 |
if (!mask) |
134 |
|
|
{ |
135 |
|
132 |
mask = 0x80000000; |
136 |
|
|
} |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
/* save current masks value back to brush */ |
140 |
|
21 |
context -> gx_draw_context_brush.gx_brush_pattern_mask = mask; |
141 |
|
21 |
} |
142 |
|
|
|