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_system.h" |
28 |
|
|
#include "gx_utility.h" |
29 |
|
|
#include "gx_display.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_display_driver_1bpp_glyph_1bpp_draw PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This draws the specified text using the current context, */ |
45 |
|
|
/* clipped to one viewport */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* context Draw context */ |
50 |
|
|
/* draw_area The rectangle where the glyph */ |
51 |
|
|
/* is to be drawn. */ |
52 |
|
|
/* map_offset Offset into the glyph */ |
53 |
|
|
/* glyph Pointer to glyph structure */ |
54 |
|
|
/* */ |
55 |
|
|
/* OUTPUT */ |
56 |
|
|
/* */ |
57 |
|
|
/* None */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLS */ |
60 |
|
|
/* */ |
61 |
|
|
/* None */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLED BY */ |
64 |
|
|
/* */ |
65 |
|
|
/* _gx_canvas_text_draw */ |
66 |
|
|
/* */ |
67 |
|
|
/* RELEASE HISTORY */ |
68 |
|
|
/* */ |
69 |
|
|
/* DATE NAME DESCRIPTION */ |
70 |
|
|
/* */ |
71 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
72 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
73 |
|
|
/* resulting in version 6.1 */ |
74 |
|
|
/* */ |
75 |
|
|
/**************************************************************************/ |
76 |
|
|
|
77 |
|
|
/* Draw area defines where the glyph is drawn. The draw area is not larger than the glyph. If it is smaller than |
78 |
|
|
the glyph, the map_offset defines the how many rows on the top to skip, and how many col on the left to skip. */ |
79 |
|
|
|
80 |
|
135578 |
VOID _gx_display_driver_1bpp_glyph_1bpp_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph) |
81 |
|
|
{ |
82 |
|
|
INT xval; |
83 |
|
|
INT yval; |
84 |
|
|
INT width; |
85 |
|
|
GX_UBYTE *putrow; |
86 |
|
|
GX_UBYTE *getrow; |
87 |
|
|
GX_UBYTE *put; |
88 |
|
|
GX_CONST GX_UBYTE *get; |
89 |
|
|
GX_UBYTE putmask; |
90 |
|
|
GX_UBYTE getmask; |
91 |
|
|
INT putstride; |
92 |
|
|
INT getstride; |
93 |
|
|
GX_UBYTE text_color; |
94 |
|
|
|
95 |
|
135578 |
text_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color; |
96 |
|
|
|
97 |
|
135578 |
putstride = (context -> gx_draw_context_pitch + 7) >> 3; |
98 |
|
135578 |
getstride = (glyph -> gx_glyph_width + 7) >> 3; |
99 |
|
|
|
100 |
|
135578 |
putrow = (GX_UBYTE *)context -> gx_draw_context_memory; |
101 |
|
135578 |
putrow += (draw_area -> gx_rectangle_top * putstride); |
102 |
|
135578 |
putrow += (draw_area -> gx_rectangle_left >> 3); |
103 |
|
|
|
104 |
|
135578 |
getrow = (GX_UBYTE *)(glyph -> gx_glyph_map); |
105 |
|
135578 |
getrow += (map_offset -> gx_point_y * getstride); |
106 |
|
135578 |
getrow += (map_offset -> gx_point_x >> 3); |
107 |
|
|
|
108 |
|
135578 |
width = draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1; |
109 |
|
|
|
110 |
✓✓ |
1730710 |
for (yval = draw_area -> gx_rectangle_top; yval <= draw_area -> gx_rectangle_bottom; yval++) |
111 |
|
|
{ |
112 |
|
1595132 |
put = putrow; |
113 |
|
1595132 |
get = getrow; |
114 |
|
|
|
115 |
|
1595132 |
putmask = (GX_UBYTE)(0x80 >> (draw_area -> gx_rectangle_left & 0x07)); |
116 |
|
1595132 |
getmask = (GX_UBYTE)(0x80 >> (map_offset -> gx_point_x & 0x07)); |
117 |
|
|
|
118 |
✓✓ |
13467014 |
for (xval = 0; xval < width; xval++) |
119 |
|
|
{ |
120 |
✓✓ |
11871882 |
if (text_color == 0x01) |
121 |
|
|
{ |
122 |
✓✓ |
9507621 |
if ((*get) & getmask) |
123 |
|
|
{ |
124 |
|
5137944 |
*put |= putmask; |
125 |
|
|
} |
126 |
|
|
} |
127 |
✓✓ |
2364261 |
else if (text_color == 0x00) |
128 |
|
|
{ |
129 |
✓✓ |
2363055 |
if ((*get) & getmask) |
130 |
|
|
{ |
131 |
|
1280479 |
*put = (GX_UBYTE)((*put) & (~putmask)); |
132 |
|
|
} |
133 |
|
|
} |
134 |
|
|
|
135 |
|
11871882 |
getmask >>= 1; |
136 |
|
11871882 |
putmask >>= 1; |
137 |
|
|
|
138 |
✓✓ |
11871882 |
if (!getmask) |
139 |
|
|
{ |
140 |
|
952992 |
getmask = 0x80; |
141 |
|
952992 |
get++; |
142 |
|
|
} |
143 |
|
|
|
144 |
✓✓ |
11871882 |
if (!putmask) |
145 |
|
|
{ |
146 |
|
1509758 |
putmask = 0x80; |
147 |
|
1509758 |
put++; |
148 |
|
|
} |
149 |
|
|
} |
150 |
|
|
|
151 |
|
1595132 |
putrow += putstride; |
152 |
|
1595132 |
getrow += getstride; |
153 |
|
|
} |
154 |
|
135578 |
} |
155 |
|
|
|