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 /** Binres Loader Management (Binres Loader) */
18 /** */
19 /**************************************************************************/
20
21 #define GX_SOURCE_CODE
22
23
24 /* Include necessary system files. */
25
26 #include "gx_api.h"
27 #include "gx_binres_loader.h"
28 #include "gx_system.h"
29 #include "gx_utility.h"
30
31 extern GX_CONST GX_FONT _gx_system_font_mono;
32 extern GX_CONST GX_FONT _gx_system_font_4bpp;
33 extern GX_CONST GX_FONT _gx_system_font_8bpp;
34
35 /**************************************************************************/
36 /* */
37 /* FUNCTION RELEASE */
38 /* */
39 /* _gx_binres_theme_header_load PORTABLE C */
40 /* 6.1 */
41 /* AUTHOR */
42 /* */
43 /* Kenneth Maxwell, Microsoft Corporation */
44 /* */
45 /* DESCRIPTION */
46 /* */
47 /* This function reads theme header from a binary data buffer. */
48 /* */
49 /* INPUT */
50 /* */
51 /* info Binary read control block */
52 /* header Returned theme header */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* Status Completion status */
57 /* */
58 /* CALLS */
59 /* */
60 /* None */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* GUIX Internal Code */
65 /* */
66 /* RELEASE HISTORY */
67 /* */
68 /* DATE NAME DESCRIPTION */
69 /* */
70 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
71 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
72 /* removed use of memcpy, */
73 /* resulting in version 6.1 */
74 /* */
75 /**************************************************************************/
76 #ifdef GX_BINARY_RESOURCE_SUPPORT
77
_gx_binres_theme_header_load(GX_BINRES_DATA_INFO * info,GX_THEME_HEADER * header)78 static UINT _gx_binres_theme_header_load(GX_BINRES_DATA_INFO *info, GX_THEME_HEADER *header)
79 {
80 GX_BINRES_READ_USHORT(header -> gx_theme_header_magic_number, info -> gx_binres_root_address + info -> gx_binres_read_offset);
81 info -> gx_binres_read_offset += sizeof(USHORT);
82
83 GX_BINRES_READ_USHORT(header -> gx_theme_header_index, info -> gx_binres_root_address + info -> gx_binres_read_offset);
84 info -> gx_binres_read_offset += sizeof(USHORT);
85
86 GX_BINRES_READ_USHORT(header -> gx_theme_header_color_count, info -> gx_binres_root_address + info -> gx_binres_read_offset);
87 info -> gx_binres_read_offset += sizeof(USHORT);
88
89 GX_BINRES_READ_USHORT(header -> gx_theme_header_palette_count, info -> gx_binres_root_address + info -> gx_binres_read_offset);
90 info -> gx_binres_read_offset += sizeof(USHORT);
91
92 GX_BINRES_READ_USHORT(header -> gx_theme_header_font_count, info -> gx_binres_root_address + info -> gx_binres_read_offset);
93 info -> gx_binres_read_offset += sizeof(USHORT);
94
95 GX_BINRES_READ_USHORT(header -> gx_theme_header_pixelmap_count, info -> gx_binres_root_address + info -> gx_binres_read_offset);
96 info -> gx_binres_read_offset += sizeof(USHORT);
97
98 GX_BINRES_READ_GX_VALUE(header -> gx_theme_header_vscroll_appearance.gx_scroll_width, info -> gx_binres_root_address + info -> gx_binres_read_offset);
99 info -> gx_binres_read_offset += sizeof(GX_VALUE);
100
101 GX_BINRES_READ_GX_VALUE(header -> gx_theme_header_vscroll_appearance.gx_scroll_thumb_width, info -> gx_binres_root_address + info -> gx_binres_read_offset);
102 info -> gx_binres_read_offset += sizeof(GX_VALUE);
103
104 GX_BINRES_READ_GX_VALUE(header -> gx_theme_header_vscroll_appearance.gx_scroll_thumb_travel_min, info -> gx_binres_root_address + info -> gx_binres_read_offset);
105 info -> gx_binres_read_offset += sizeof(GX_VALUE);
106
107 GX_BINRES_READ_GX_VALUE(header -> gx_theme_header_vscroll_appearance.gx_scroll_thumb_travel_max, info -> gx_binres_root_address + info -> gx_binres_read_offset);
108 info -> gx_binres_read_offset += sizeof(GX_VALUE);
109
110 GX_BINRES_READ_GX_UBYTE(header -> gx_theme_header_vscroll_appearance.gx_scroll_thumb_border_style, info -> gx_binres_root_address + info -> gx_binres_read_offset);
111 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
112
113 GX_BINRES_READ_ULONG(header -> gx_theme_header_vscroll_appearance.gx_scroll_fill_pixelmap, info -> gx_binres_root_address + info -> gx_binres_read_offset);
114 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
115
116 GX_BINRES_READ_ULONG(header -> gx_theme_header_vscroll_appearance.gx_scroll_thumb_pixelmap, info -> gx_binres_root_address + info -> gx_binres_read_offset);
117 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
118
119 GX_BINRES_READ_ULONG(header -> gx_theme_header_vscroll_appearance.gx_scroll_up_pixelmap, info -> gx_binres_root_address + info -> gx_binres_read_offset);
120 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
121
122 GX_BINRES_READ_ULONG(header -> gx_theme_header_vscroll_appearance.gx_scroll_down_pixelmap, info -> gx_binres_root_address + info -> gx_binres_read_offset);
123 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
124
125 GX_BINRES_READ_ULONG(header -> gx_theme_header_vscroll_appearance.gx_scroll_thumb_color, info -> gx_binres_root_address + info -> gx_binres_read_offset);
126 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
127
128 GX_BINRES_READ_ULONG(header -> gx_theme_header_vscroll_appearance.gx_scroll_thumb_border_color, info -> gx_binres_root_address + info -> gx_binres_read_offset);
129 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
130
131 GX_BINRES_READ_ULONG(header -> gx_theme_header_vscroll_appearance.gx_scroll_button_color, info -> gx_binres_root_address + info -> gx_binres_read_offset);
132 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
133
134 GX_BINRES_READ_GX_VALUE(header -> gx_theme_header_hscroll_appearance.gx_scroll_width, info -> gx_binres_root_address + info -> gx_binres_read_offset);
135 info -> gx_binres_read_offset += sizeof(GX_VALUE);
136
137 GX_BINRES_READ_GX_VALUE(header -> gx_theme_header_hscroll_appearance.gx_scroll_thumb_width, info -> gx_binres_root_address + info -> gx_binres_read_offset);
138 info -> gx_binres_read_offset += sizeof(GX_VALUE);
139
140 GX_BINRES_READ_GX_VALUE(header -> gx_theme_header_hscroll_appearance.gx_scroll_thumb_travel_min, info -> gx_binres_root_address + info -> gx_binres_read_offset);
141 info -> gx_binres_read_offset += sizeof(GX_VALUE);
142
143 GX_BINRES_READ_GX_VALUE(header -> gx_theme_header_hscroll_appearance.gx_scroll_thumb_travel_max, info -> gx_binres_root_address + info -> gx_binres_read_offset);
144 info -> gx_binres_read_offset += sizeof(GX_VALUE);
145
146 GX_BINRES_READ_GX_UBYTE(header -> gx_theme_header_hscroll_appearance.gx_scroll_thumb_border_style, info -> gx_binres_root_address + info -> gx_binres_read_offset);
147 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
148
149 GX_BINRES_READ_ULONG(header -> gx_theme_header_hscroll_appearance.gx_scroll_fill_pixelmap, info -> gx_binres_root_address + info -> gx_binres_read_offset);
150 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
151
152 GX_BINRES_READ_ULONG(header -> gx_theme_header_hscroll_appearance.gx_scroll_thumb_pixelmap, info -> gx_binres_root_address + info -> gx_binres_read_offset);
153 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
154
155 GX_BINRES_READ_ULONG(header -> gx_theme_header_hscroll_appearance.gx_scroll_up_pixelmap, info -> gx_binres_root_address + info -> gx_binres_read_offset);
156 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
157
158 GX_BINRES_READ_ULONG(header -> gx_theme_header_hscroll_appearance.gx_scroll_down_pixelmap, info -> gx_binres_root_address + info -> gx_binres_read_offset);
159 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
160
161 GX_BINRES_READ_ULONG(header -> gx_theme_header_hscroll_appearance.gx_scroll_thumb_color, info -> gx_binres_root_address + info -> gx_binres_read_offset);
162 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
163
164 GX_BINRES_READ_ULONG(header -> gx_theme_header_hscroll_appearance.gx_scroll_thumb_border_color, info -> gx_binres_root_address + info -> gx_binres_read_offset);
165 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
166
167 GX_BINRES_READ_ULONG(header -> gx_theme_header_hscroll_appearance.gx_scroll_button_color, info -> gx_binres_root_address + info -> gx_binres_read_offset);
168 info -> gx_binres_read_offset += sizeof(GX_RESOURCE_ID);
169
170 GX_BINRES_READ_ULONG(header -> gx_theme_header_vscroll_style, info -> gx_binres_root_address + info -> gx_binres_read_offset);
171 info -> gx_binres_read_offset += sizeof(ULONG);
172
173 GX_BINRES_READ_ULONG(header -> gx_theme_header_hscroll_style, info -> gx_binres_root_address + info -> gx_binres_read_offset);
174 info -> gx_binres_read_offset += sizeof(ULONG);
175
176 GX_BINRES_READ_ULONG(header -> gx_theme_header_color_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
177 info -> gx_binres_read_offset += sizeof(ULONG);
178
179 GX_BINRES_READ_ULONG(header -> gx_theme_header_palette_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
180 info -> gx_binres_read_offset += sizeof(ULONG);
181
182 GX_BINRES_READ_ULONG(header -> gx_theme_header_font_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
183 info -> gx_binres_read_offset += sizeof(ULONG);
184
185 GX_BINRES_READ_ULONG(header -> gx_theme_header_pixelmap_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
186 info -> gx_binres_read_offset += sizeof(ULONG);
187
188 GX_BINRES_READ_ULONG(header -> gx_theme_header_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
189 info -> gx_binres_read_offset += sizeof(ULONG);
190
191 return GX_SUCCESS;
192 }
193 #endif
194
195 /**************************************************************************/
196 /* */
197 /* FUNCTION RELEASE */
198 /* */
199 /* _gx_binres_color_header_load PORTABLE C */
200 /* 6.1 */
201 /* AUTHOR */
202 /* */
203 /* Kenneth Maxwell, Microsoft Corporation */
204 /* */
205 /* DESCRIPTION */
206 /* */
207 /* This function reads color header from a binary data buffer. */
208 /* */
209 /* INPUT */
210 /* */
211 /* info Binary read control block */
212 /* header Returned color header */
213 /* */
214 /* OUTPUT */
215 /* */
216 /* Status Completion status */
217 /* */
218 /* CALLS */
219 /* */
220 /* None */
221 /* */
222 /* CALLED BY */
223 /* */
224 /* GUIX Internal Code */
225 /* */
226 /* RELEASE HISTORY */
227 /* */
228 /* DATE NAME DESCRIPTION */
229 /* */
230 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
231 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
232 /* removed use of memcpy, */
233 /* resulting in version 6.1 */
234 /* */
235 /**************************************************************************/
236 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_color_header_load(GX_BINRES_DATA_INFO * info,GX_COLOR_HEADER * header)237 static UINT _gx_binres_color_header_load(GX_BINRES_DATA_INFO *info, GX_COLOR_HEADER *header)
238 {
239 GX_BINRES_READ_USHORT(header -> gx_color_header_magic_number, info -> gx_binres_root_address + info -> gx_binres_read_offset);
240 info -> gx_binres_read_offset += sizeof(USHORT);
241
242 GX_BINRES_READ_USHORT(header -> gx_color_header_color_count, info -> gx_binres_root_address + info -> gx_binres_read_offset);
243 info -> gx_binres_read_offset += sizeof(USHORT);
244
245 GX_BINRES_READ_ULONG(header -> gx_color_header_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
246 info -> gx_binres_read_offset += sizeof(ULONG);
247
248 return GX_SUCCESS;
249 }
250 #endif
251
252 /**************************************************************************/
253 /* */
254 /* FUNCTION RELEASE */
255 /* */
256 /* _gx_binres_palette_header_load PORTABLE C */
257 /* 6.1 */
258 /* AUTHOR */
259 /* */
260 /* Kenneth Maxwell, Microsoft Corporation */
261 /* */
262 /* DESCRIPTION */
263 /* */
264 /* This function reads palette header from a binary data buffer. */
265 /* */
266 /* INPUT */
267 /* */
268 /* info Binary read control block */
269 /* header Returned palette header */
270 /* */
271 /* OUTPUT */
272 /* */
273 /* Status Completion status */
274 /* */
275 /* CALLS */
276 /* */
277 /* None */
278 /* */
279 /* CALLED BY */
280 /* */
281 /* GUIX Internal Code */
282 /* */
283 /* RELEASE HISTORY */
284 /* */
285 /* DATE NAME DESCRIPTION */
286 /* */
287 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
288 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
289 /* removed use of memcpy, */
290 /* resulting in version 6.1 */
291 /* */
292 /**************************************************************************/
293 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_palette_header_load(GX_BINRES_DATA_INFO * info,GX_PALETTE_HEADER * header)294 static UINT _gx_binres_palette_header_load(GX_BINRES_DATA_INFO *info, GX_PALETTE_HEADER *header)
295 {
296 GX_BINRES_READ_USHORT(header -> gx_palette_header_magic_number, info -> gx_binres_root_address + info -> gx_binres_read_offset);
297 info -> gx_binres_read_offset += sizeof(USHORT);
298
299 GX_BINRES_READ_USHORT(header -> gx_palette_header_color_count, info -> gx_binres_root_address + info -> gx_binres_read_offset);
300 info -> gx_binres_read_offset += sizeof(USHORT);
301
302 GX_BINRES_READ_ULONG(header -> gx_palette_header_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
303 info -> gx_binres_read_offset += sizeof(ULONG);
304
305 return GX_SUCCESS;
306 }
307 #endif
308
309 /**************************************************************************/
310 /* */
311 /* FUNCTION RELEASE */
312 /* */
313 /* _gx_binres_font_header_load PORTABLE C */
314 /* 6.3.0 */
315 /* AUTHOR */
316 /* */
317 /* Kenneth Maxwell, Microsoft Corporation */
318 /* */
319 /* DESCRIPTION */
320 /* */
321 /* This function reads font header from a binary data buffer. */
322 /* */
323 /* INPUT */
324 /* */
325 /* info Binary read control block */
326 /* header Returned font header */
327 /* */
328 /* OUTPUT */
329 /* */
330 /* Status Completion status */
331 /* */
332 /* CALLS */
333 /* */
334 /* None */
335 /* */
336 /* CALLED BY */
337 /* */
338 /* GUIX Internal Code */
339 /* */
340 /* RELEASE HISTORY */
341 /* */
342 /* DATE NAME DESCRIPTION */
343 /* */
344 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
345 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
346 /* removed use of memcpy, */
347 /* resulting in version 6.1 */
348 /* 10-31-2023 Ting Zhu Modified comment(s), */
349 /* made the function public, */
350 /* resulting in version 6.3.0 */
351 /* */
352 /**************************************************************************/
353 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_font_header_load(GX_BINRES_DATA_INFO * info,GX_FONT_HEADER * header)354 UINT _gx_binres_font_header_load(GX_BINRES_DATA_INFO *info, GX_FONT_HEADER *header)
355 {
356 GX_BINRES_READ_USHORT(header -> gx_font_header_magic_number, info -> gx_binres_root_address + info -> gx_binres_read_offset);
357 info -> gx_binres_read_offset += sizeof(USHORT);
358
359 if(header -> gx_font_header_magic_number != GX_MAGIC_NUMBER)
360 {
361 return GX_INVALID_FORMAT;
362 }
363
364 GX_BINRES_READ_USHORT(header -> gx_font_header_index, info -> gx_binres_root_address + info -> gx_binres_read_offset);
365 info -> gx_binres_read_offset += sizeof(USHORT);
366
367 GX_BINRES_READ_USHORT(header -> gx_font_header_page_count, info -> gx_binres_root_address + info -> gx_binres_read_offset);
368 info -> gx_binres_read_offset += sizeof(USHORT);
369
370 GX_BINRES_READ_GX_UBYTE(header -> gx_font_header_deault, info -> gx_binres_root_address + info -> gx_binres_read_offset);
371 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
372
373 GX_BINRES_READ_GX_UBYTE(header -> gx_font_header_bits, info -> gx_binres_root_address + info -> gx_binres_read_offset);
374 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
375
376 GX_BINRES_READ_ULONG(header -> gx_font_header_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
377 info -> gx_binres_read_offset += sizeof(ULONG);
378
379 GX_BINRES_READ_ULONG(header -> gx_font_header_data_offset, info -> gx_binres_root_address + info -> gx_binres_read_offset);
380 info -> gx_binres_read_offset += sizeof(ULONG);
381
382 return GX_SUCCESS;
383 }
384 #endif
385
386 /**************************************************************************/
387 /* */
388 /* FUNCTION RELEASE */
389 /* */
390 /* _gx_binres_page_header_load PORTABLE C */
391 /* 6.1 */
392 /* AUTHOR */
393 /* */
394 /* Kenneth Maxwell, Microsoft Corporation */
395 /* */
396 /* DESCRIPTION */
397 /* */
398 /* This function reads page header from a binary data buffer. */
399 /* */
400 /* INPUT */
401 /* */
402 /* info Binary read control block */
403 /* header Returned page header */
404 /* */
405 /* OUTPUT */
406 /* */
407 /* Status Completion status */
408 /* */
409 /* CALLS */
410 /* */
411 /* None */
412 /* */
413 /* CALLED BY */
414 /* */
415 /* GUIX Internal Code */
416 /* */
417 /* RELEASE HISTORY */
418 /* */
419 /* DATE NAME DESCRIPTION */
420 /* */
421 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
422 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
423 /* removed use of memcpy, */
424 /* resulting in version 6.1 */
425 /* */
426 /**************************************************************************/
427 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_page_header_load(GX_BINRES_DATA_INFO * info,GX_PAGE_HEADER * header)428 static UINT _gx_binres_page_header_load(GX_BINRES_DATA_INFO *info, GX_PAGE_HEADER *header)
429 {
430 ULONG read_data = 0;
431
432 GX_BINRES_READ_USHORT(header -> gx_page_header_magic_number, info -> gx_binres_root_address + info -> gx_binres_read_offset);
433 info -> gx_binres_read_offset += sizeof(USHORT);
434
435 if(header -> gx_page_header_magic_number != GX_MAGIC_NUMBER)
436 {
437 return GX_INVALID_FORMAT;
438 }
439
440 GX_BINRES_READ_USHORT(header -> gx_page_header_index, info -> gx_binres_root_address + info -> gx_binres_read_offset);
441 info -> gx_binres_read_offset += sizeof(USHORT);
442
443 GX_BINRES_READ_GX_UBYTE(header -> gx_page_header_format, info -> gx_binres_root_address + info -> gx_binres_read_offset);
444 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
445
446 GX_BINRES_READ_GX_UBYTE(header -> gx_page_header_prespace, info -> gx_binres_root_address + info -> gx_binres_read_offset);
447 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
448
449 GX_BINRES_READ_GX_UBYTE(header -> gx_page_header_postspace, info -> gx_binres_root_address + info -> gx_binres_read_offset);
450 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
451
452 GX_BINRES_READ_GX_UBYTE(header -> gx_page_header_line_height, info -> gx_binres_root_address + info -> gx_binres_read_offset);
453 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
454
455 GX_BINRES_READ_GX_UBYTE(header -> gx_page_header_baseline, info -> gx_binres_root_address + info -> gx_binres_read_offset);
456 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
457
458 /* In the binary resource file, CHAR_CODE is always stored as 4-byte value. */
459 GX_BINRES_READ_ULONG(read_data, info -> gx_binres_root_address + info -> gx_binres_read_offset);
460 info -> gx_binres_read_offset += sizeof(ULONG);
461 header -> gx_page_header_first_glyph = (GX_CHAR_CODE)read_data;
462
463 /* In the binary resource file, CHAR_CODE is always stored as 4-byte value. */
464 GX_BINRES_READ_ULONG(read_data, info -> gx_binres_root_address + info -> gx_binres_read_offset);
465 info -> gx_binres_read_offset += sizeof(ULONG);
466 header -> gx_page_header_last_glyph = (GX_CHAR_CODE)read_data;
467
468 GX_BINRES_READ_ULONG(header -> gx_page_header_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
469 info -> gx_binres_read_offset += sizeof(ULONG);
470
471 return GX_SUCCESS;
472 }
473 #endif
474
475 /**************************************************************************/
476 /* */
477 /* FUNCTION RELEASE */
478 /* */
479 /* _gx_binres_glyph_header_load PORTABLE C */
480 /* 6.1 */
481 /* AUTHOR */
482 /* */
483 /* Kenneth Maxwell, Microsoft Corporation */
484 /* */
485 /* DESCRIPTION */
486 /* */
487 /* This function reads glyph header from a binary data buffer. */
488 /* */
489 /* INPUT */
490 /* */
491 /* info Binary read control block */
492 /* header Returned glyph header */
493 /* */
494 /* OUTPUT */
495 /* */
496 /* Status Completion status */
497 /* */
498 /* CALLS */
499 /* */
500 /* None */
501 /* */
502 /* CALLED BY */
503 /* */
504 /* GUIX Internal Code */
505 /* */
506 /* RELEASE HISTORY */
507 /* */
508 /* DATE NAME DESCRIPTION */
509 /* */
510 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
511 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
512 /* removed use of memcpy, and */
513 /* updated with binary */
514 /* resource layout change, */
515 /* resulting in version 6.1 */
516 /* */
517 /**************************************************************************/
518 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_glyph_header_load(GX_BINRES_DATA_INFO * info,GX_GLYPH_HEADER * header)519 static UINT _gx_binres_glyph_header_load(GX_BINRES_DATA_INFO *info, GX_GLYPH_HEADER *header)
520 {
521 GX_BINRES_READ_USHORT(header -> gx_glyph_header_magic_number, info -> gx_binres_root_address + info -> gx_binres_read_offset);
522 info -> gx_binres_read_offset += sizeof(USHORT);
523
524 GX_BINRES_READ_USHORT(header -> gx_glyph_header_map_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
525 info -> gx_binres_read_offset += sizeof(USHORT);
526
527 GX_BINRES_READ_ULONG(header -> gx_glyph_header_map_offset, info -> gx_binres_root_address + info -> gx_binres_read_offset);
528 info -> gx_binres_read_offset += sizeof(ULONG);
529
530 GX_BINRES_READ_USHORT(header -> gx_glyph_header_index, info -> gx_binres_root_address + info -> gx_binres_read_offset);
531 info -> gx_binres_read_offset += sizeof(USHORT);
532
533 GX_BINRES_READ_SHORT(header -> gx_glyph_header_ascent, info -> gx_binres_root_address + info -> gx_binres_read_offset);
534 info -> gx_binres_read_offset += sizeof(SHORT);
535
536 GX_BINRES_READ_SHORT(header -> gx_glyph_header_descent, info -> gx_binres_root_address + info -> gx_binres_read_offset);
537 info -> gx_binres_read_offset += sizeof(SHORT);
538
539 GX_BINRES_READ_GX_UBYTE(header -> gx_glyph_header_advance, info -> gx_binres_root_address + info -> gx_binres_read_offset);
540 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
541
542 GX_BINRES_READ_GX_BYTE(header -> gx_glyph_header_leading, info -> gx_binres_root_address + info -> gx_binres_read_offset);
543 info -> gx_binres_read_offset += sizeof(GX_BYTE);
544
545 GX_BINRES_READ_GX_UBYTE(header -> gx_glyph_header_width, info -> gx_binres_root_address + info -> gx_binres_read_offset);
546 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
547
548 GX_BINRES_READ_GX_UBYTE(header -> gx_glyph_header_height, info -> gx_binres_root_address + info -> gx_binres_read_offset);
549 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
550
551 GX_BINRES_READ_ULONG(header -> gx_glyph_header_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
552 info -> gx_binres_read_offset += sizeof(ULONG);
553
554 return GX_SUCCESS;
555 }
556 #endif
557
558
559 /**************************************************************************/
560 /* */
561 /* FUNCTION RELEASE */
562 /* */
563 /* _gx_binres_kerning_glyph_header_load PORTABLE C */
564 /* 6.1 */
565 /* AUTHOR */
566 /* */
567 /* Kenneth Maxwell, Microsoft Corporation */
568 /* */
569 /* DESCRIPTION */
570 /* */
571 /* This function reads glyph header from a binary data buffer. */
572 /* */
573 /* INPUT */
574 /* */
575 /* info Binary read control block */
576 /* header Returned glyph header */
577 /* */
578 /* OUTPUT */
579 /* */
580 /* Status Completion status */
581 /* */
582 /* CALLS */
583 /* */
584 /* None */
585 /* */
586 /* CALLED BY */
587 /* */
588 /* GUIX Internal Code */
589 /* */
590 /* RELEASE HISTORY */
591 /* */
592 /* DATE NAME DESCRIPTION */
593 /* */
594 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
595 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
596 /* removed use of memcpy, */
597 /* resulting in version 6.1 */
598 /* */
599 /**************************************************************************/
600 #ifdef GX_FONT_KERNING_SUPPORT
601 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_kerning_glyph_header_load(GX_BINRES_DATA_INFO * info,GX_KERNING_GLYPH_HEADER * header)602 static UINT _gx_binres_kerning_glyph_header_load(GX_BINRES_DATA_INFO *info, GX_KERNING_GLYPH_HEADER *header)
603 {
604 _gx_binres_glyph_header_load(info, (GX_GLYPH_HEADER *)header);
605
606 GX_BINRES_READ_USHORT(header -> gx_glyph_header_kerning_table_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
607 info -> gx_binres_read_offset += sizeof(USHORT);
608
609 return GX_SUCCESS;
610 }
611 #endif
612 #endif
613
614 /**************************************************************************/
615 /* */
616 /* FUNCTION RELEASE */
617 /* */
618 /* _gx_binres_pixelmap_header_load PORTABLE C */
619 /* 6.3.0 */
620 /* AUTHOR */
621 /* */
622 /* Kenneth Maxwell, Microsoft Corporation */
623 /* */
624 /* DESCRIPTION */
625 /* */
626 /* This function reads pixelmap header from a binary data buffer. */
627 /* */
628 /* INPUT */
629 /* */
630 /* info Binary read control block */
631 /* header Returned pixelmap header */
632 /* */
633 /* OUTPUT */
634 /* */
635 /* Status Completion status */
636 /* */
637 /* CALLS */
638 /* */
639 /* None */
640 /* */
641 /* CALLED BY */
642 /* */
643 /* GUIX Internal Code */
644 /* */
645 /* RELEASE HISTORY */
646 /* */
647 /* DATE NAME DESCRIPTION */
648 /* */
649 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
650 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
651 /* removed use of memcpy, */
652 /* resulting in version 6.1 */
653 /* 10-31-2023 Ting Zhu Modified comment(s), */
654 /* added magic number check, */
655 /* resulting in version 6.3.0 */
656 /* */
657 /**************************************************************************/
658 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_pixelmap_header_load(GX_BINRES_DATA_INFO * info,GX_PIXELMAP_HEADER * header)659 static UINT _gx_binres_pixelmap_header_load(GX_BINRES_DATA_INFO *info, GX_PIXELMAP_HEADER *header)
660 {
661 GX_BINRES_READ_USHORT(header -> gx_pixelmap_header_magic_number, info -> gx_binres_root_address + info -> gx_binres_read_offset);
662 info -> gx_binres_read_offset += sizeof(USHORT);
663
664 if (header -> gx_pixelmap_header_magic_number != GX_MAGIC_NUMBER)
665 {
666 return GX_INVALID_FORMAT;
667 }
668
669 GX_BINRES_READ_USHORT(header -> gx_pixelmap_header_index, info -> gx_binres_root_address + info -> gx_binres_read_offset);
670 info -> gx_binres_read_offset += sizeof(USHORT);
671
672 GX_BINRES_READ_GX_UBYTE(header -> gx_pixelmap_header_version_major, info -> gx_binres_root_address + info -> gx_binres_read_offset);
673 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
674
675 GX_BINRES_READ_GX_UBYTE(header -> gx_pixelmap_header_version_minor, info -> gx_binres_root_address + info -> gx_binres_read_offset);
676 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
677
678 GX_BINRES_READ_GX_UBYTE(header -> gx_pixelmap_header_flags, info -> gx_binres_root_address + info -> gx_binres_read_offset);
679 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
680
681 GX_BINRES_READ_GX_UBYTE(header -> gx_pixelmap_header_format, info -> gx_binres_root_address + info -> gx_binres_read_offset);
682 info -> gx_binres_read_offset += sizeof(GX_UBYTE);
683
684 GX_BINRES_READ_ULONG(header -> gx_pixelmap_header_map_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
685 info -> gx_binres_read_offset += sizeof(ULONG);
686
687 GX_BINRES_READ_ULONG(header -> gx_pixelmap_header_aux_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
688 info -> gx_binres_read_offset += sizeof(ULONG);
689
690 GX_BINRES_READ_ULONG(header -> gx_pixelmap_header_transparent_color, info -> gx_binres_root_address + info -> gx_binres_read_offset);
691 info -> gx_binres_read_offset += sizeof(GX_COLOR);
692
693 GX_BINRES_READ_USHORT(header -> gx_pixelmap_header_width, info -> gx_binres_root_address + info -> gx_binres_read_offset);
694 info -> gx_binres_read_offset += sizeof(USHORT);
695
696 GX_BINRES_READ_USHORT(header -> gx_pixelmap_header_height, info -> gx_binres_root_address + info -> gx_binres_read_offset);
697 info -> gx_binres_read_offset += sizeof(USHORT);
698
699 GX_BINRES_READ_ULONG(header -> gx_pixelmap_header_data_size, info -> gx_binres_root_address + info -> gx_binres_read_offset);
700 info -> gx_binres_read_offset += sizeof(ULONG);
701
702 GX_BINRES_READ_ULONG(header -> gx_pixelmap_header_data_offset, info -> gx_binres_root_address + info -> gx_binres_read_offset);
703 info -> gx_binres_read_offset += sizeof(ULONG);
704
705 return GX_SUCCESS;
706 }
707 #endif
708
709 /**************************************************************************/
710 /* */
711 /* FUNCTION RELEASE */
712 /* */
713 /* _gx_binres_font_buffer_size_get PORTABLE C */
714 /* 6.3.0 */
715 /* AUTHOR */
716 /* */
717 /* Ting Zhu, Microsoft Corporation */
718 /* */
719 /* DESCRIPTION */
720 /* */
721 /* This function calculates the required buffer size needed for */
722 /* loading the font from the current position. */
723 /* */
724 /* INPUT */
725 /* */
726 /* info Binary resource control block */
727 /* buffer_size The required buffer size */
728 /* */
729 /* OUTPUT */
730 /* */
731 /* Status Completion status */
732 /* */
733 /* CALLS */
734 /* */
735 /* _gx_binres_font_header_load Read font header */
736 /* _gx_binres_page_header_load Read font page header */
737 /* */
738 /* CALLED BY */
739 /* */
740 /* GUIX Internal Code */
741 /* */
742 /* RELEASE HISTORY */
743 /* */
744 /* DATE NAME DESCRIPTION */
745 /* */
746 /* 10-31-2023 Ting Zhu Initial Version 6.3.0 */
747 /* */
748 /**************************************************************************/
749 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_font_buffer_size_get(GX_BINRES_DATA_INFO * info,UINT * buffer_size,GX_BOOL reset_read_offset)750 UINT _gx_binres_font_buffer_size_get(GX_BINRES_DATA_INFO *info, UINT *buffer_size, GX_BOOL reset_read_offset)
751 {
752 UINT status;
753 GX_FONT_HEADER font_header;
754 GX_PAGE_HEADER page_header;
755 USHORT page_index;
756 UINT glyph_count;
757 UINT read_offset = 0;
758 UINT temp;
759 UINT size = 0;
760 UINT old_offset;
761
762 if(reset_read_offset)
763 {
764 old_offset = info -> gx_binres_read_offset;
765 }
766
767 status = _gx_binres_font_header_load(info, &font_header);
768
769 if (status != GX_SUCCESS)
770 {
771 return status;
772 }
773
774 if (font_header.gx_font_header_data_offset)
775 {
776 /* The font data is not follow the header directly,
777 the data offset gives the position where the font
778 data located. */
779
780 /* Record current data offset. */
781 read_offset = info -> gx_binres_read_offset;
782
783 /* Temporarily reset data offset of access font data. */
784 info -> gx_binres_read_offset = font_header.gx_font_header_data_offset;
785
786 /* Load font header. */
787 _gx_binres_font_header_load(info, &font_header);
788 }
789
790 for (page_index = 0; page_index < font_header.gx_font_header_page_count; page_index++)
791 {
792 /* Load page header. */
793 status = _gx_binres_page_header_load(info, &page_header);
794
795 if(status != GX_SUCCESS)
796 {
797 return status;
798 }
799
800 info -> gx_binres_read_offset += page_header.gx_page_header_data_size;
801
802 #if defined(GX_EXTENDED_UNICODE_SUPPORT)
803 if (page_header.gx_page_header_last_glyph > GX_MAX_GLYPH_CODE)
804 {
805 return GX_INVALID_FONT;
806 }
807 #endif
808
809 /* Max glyph code is 0x10f000, overflow cannot occur. */
810 glyph_count = (UINT)(page_header.gx_page_header_last_glyph - page_header.gx_page_header_first_glyph + 1);
811
812 /* Calculate size for loading font page. */
813 temp = sizeof(GX_FONT);
814
815 /* Calculate size for loading glyphs. */
816 if (page_header.gx_page_header_format & GX_FONT_FORMAT_COMPRESSED)
817 {
818 temp += sizeof(GX_COMPRESSED_GLYPH) * glyph_count;
819 }
820 #if defined(GX_FONT_KERNING_SUPPORT)
821 else if (page_header.gx_page_header_format & GX_FONT_FORMAT_KERNING)
822 {
823 temp += sizeof(GX_KERNING_GLYPH) * glyph_count;
824 }
825 #endif
826 else
827 {
828 temp += sizeof(GX_GLYPH) * glyph_count;
829 }
830
831 GX_UTILITY_MATH_UINT_ADD(size, temp, size);
832 }
833
834 if (read_offset)
835 {
836 /* Restore data offset. */
837 info -> gx_binres_read_offset = read_offset;
838 read_offset = 0;
839 }
840
841 *buffer_size = size;
842
843 if (reset_read_offset)
844 {
845 /* Reset offset. */
846 info -> gx_binres_read_offset = old_offset;
847 }
848
849 return GX_SUCCESS;
850 }
851 #endif
852
853 /**************************************************************************/
854 /* */
855 /* FUNCTION RELEASE */
856 /* */
857 /* _gx_binres_theme_table_buffer_allocate PORTABLE C */
858 /* 6.3.0 */
859 /* AUTHOR */
860 /* */
861 /* Kenneth Maxwell, Microsoft Corporation */
862 /* */
863 /* DESCRIPTION */
864 /* */
865 /* This function allocates needed memory buffer for loading theme */
866 /* table. */
867 /* */
868 /* INPUT */
869 /* */
870 /* info Binary resource control block */
871 /* */
872 /* OUTPUT */
873 /* */
874 /* Status Completion status */
875 /* */
876 /* CALLS */
877 /* */
878 /* _gx_system_memory_allocator Application defined memory */
879 /* allocation function */
880 /* _gx_binres_resource_header_load Read resource header */
881 /* _gx_binres_theme_header_load Read theme header */
882 /* _gx_binres_font_buffer_size_get Get required font buffer size */
883 /* */
884 /* CALLED BY */
885 /* */
886 /* GUIX Internal Code */
887 /* */
888 /* RELEASE HISTORY */
889 /* */
890 /* DATE NAME DESCRIPTION */
891 /* */
892 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
893 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
894 /* resulting in version 6.1 */
895 /* 10-31-2023 Ting Zhu Modified comment(s), */
896 /* improved logic, */
897 /* resulting in version 6.3.0 */
898 /* */
899 /**************************************************************************/
900 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_theme_buffer_allocate(GX_BINRES_DATA_INFO * info,INT theme_id)901 static UINT _gx_binres_theme_buffer_allocate(GX_BINRES_DATA_INFO *info, INT theme_id)
902 {
903 UINT status = GX_SUCCESS;
904 GX_RESOURCE_HEADER res_header;
905 GX_THEME_HEADER theme_header;
906 USHORT theme_index;
907 USHORT font_index;
908 UINT temp;
909
910 /* Read resource header. */
911 info -> gx_binres_read_offset = 0;
912
913 _gx_binres_resource_header_load(info, &res_header);
914
915 if (res_header.gx_resource_header_magic_number != GX_MAGIC_NUMBER)
916 {
917 return GX_INVALID_FORMAT;
918 }
919
920 info -> gx_binres_buffer_size = 0;
921
922 for (theme_index = 0; theme_index < res_header.gx_resource_header_theme_count; theme_index++)
923 {
924 _gx_binres_theme_header_load(info, &theme_header);
925
926 if (theme_header.gx_theme_header_magic_number != GX_MAGIC_NUMBER)
927 {
928 return GX_INVALID_FORMAT;
929 }
930
931 if (theme_index == theme_id)
932 {
933 info -> gx_binres_buffer_size = sizeof(GX_THEME);
934
935 /* Color table buffer size. */
936 if (theme_header.gx_theme_header_color_data_size)
937 {
938 info -> gx_binres_read_offset += theme_header.gx_theme_header_color_data_size;
939 }
940
941 /* Palette table buffer size. */
942 if (theme_header.gx_theme_header_palette_data_size)
943 {
944 info -> gx_binres_read_offset += theme_header.gx_theme_header_palette_data_size;
945 }
946
947 /* Font table buffer size. */
948 if (theme_header.gx_theme_header_font_data_size)
949 {
950 /* Font count is USHORT type, overflow cannot occur. */
951 info -> gx_binres_buffer_size += sizeof(GX_FONT *) * theme_header.gx_theme_header_font_count;
952
953 for (font_index = 0; font_index < theme_header.gx_theme_header_font_count; font_index++)
954 {
955 status = _gx_binres_font_buffer_size_get(info, &temp, GX_FALSE);
956
957 if (status != GX_SUCCESS)
958 {
959 return status;
960 }
961
962 GX_UTILITY_MATH_UINT_ADD(info -> gx_binres_buffer_size, temp, info -> gx_binres_buffer_size);
963 }
964 }
965
966 /* Pixelmap table buffer size. */
967 if (theme_header.gx_theme_header_pixelmap_data_size)
968 {
969 /* Pixelmap count is USHORT type, overflow can not occur. */
970 temp = ((UINT)(theme_header.gx_theme_header_pixelmap_count + 1)) * sizeof(GX_PIXELMAP *);
971 temp += sizeof(GX_PIXELMAP) * theme_header.gx_theme_header_pixelmap_count;
972
973 GX_UTILITY_MATH_UINT_ADD(info -> gx_binres_buffer_size, temp, info -> gx_binres_buffer_size);
974
975 info -> gx_binres_read_offset += theme_header.gx_theme_header_pixelmap_data_size;
976 }
977
978 break;
979 }
980 else
981 {
982 info -> gx_binres_read_offset += theme_header.gx_theme_header_data_size;
983 }
984 }
985
986 info -> gx_binres_buffer = (GX_UBYTE *)_gx_system_memory_allocator(info -> gx_binres_buffer_size);
987
988 if (!info -> gx_binres_buffer)
989 {
990 return GX_SYSTEM_MEMORY_ERROR;
991 }
992
993 memset(info -> gx_binres_buffer, 0, info -> gx_binres_buffer_size);
994 info -> gx_binres_buffer_index = 0;
995
996 /* Reset read offset. */
997 info -> gx_binres_read_offset = 0;
998
999 return status;
1000 }
1001 #endif
1002
1003 /**************************************************************************/
1004 /* */
1005 /* FUNCTION RELEASE */
1006 /* */
1007 /* _gx_binres_glyphs_address_get PORTABLE C */
1008 /* 6.1 */
1009 /* AUTHOR */
1010 /* */
1011 /* Kenneth Maxwell, Microsoft Corporation */
1012 /* */
1013 /* DESCRIPTION */
1014 /* */
1015 /* This function finds the memory address of specified glyph data from */
1016 /* a binary data buffer. */
1017 /* */
1018 /* INPUT */
1019 /* */
1020 /* info Binary resource control block */
1021 /* glyph_count The number of glyphs that the */
1022 /* font page contains. */
1023 /* returned_glyphs Returned glyph address */
1024 /* */
1025 /* OUTPUT */
1026 /* */
1027 /* Status Completion status */
1028 /* */
1029 /* CALLS */
1030 /* */
1031 /* _gx_binres_glyph_header_load Read glyph data header */
1032 /* */
1033 /* CALLED BY */
1034 /* */
1035 /* GUIX Internal Code */
1036 /* */
1037 /* RELEASE HISTORY */
1038 /* */
1039 /* DATE NAME DESCRIPTION */
1040 /* */
1041 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1042 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1043 /* updated with binary */
1044 /* resource layout change, */
1045 /* resulting in version 6.1 */
1046 /* */
1047 /**************************************************************************/
1048 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_glyphs_address_get(GX_BINRES_DATA_INFO * info,USHORT glyph_count,GX_CONST GX_GLYPH ** returned_glyphs)1049 static UINT _gx_binres_glyphs_address_get(GX_BINRES_DATA_INFO *info, USHORT glyph_count, GX_CONST GX_GLYPH **returned_glyphs)
1050 {
1051 GX_GLYPH_HEADER header;
1052 GX_GLYPH *glyphs;
1053 USHORT index = 0;
1054
1055 glyphs = (GX_GLYPH *)(info -> gx_binres_buffer + info -> gx_binres_buffer_index);
1056 info -> gx_binres_buffer_index += sizeof(GX_GLYPH) * glyph_count;
1057
1058 for (index = 0; index < glyph_count; index++)
1059 {
1060 _gx_binres_glyph_header_load(info, &header);
1061
1062 if (header.gx_glyph_header_magic_number != GX_MAGIC_NUMBER)
1063 {
1064 return GX_INVALID_FORMAT;
1065 }
1066
1067 glyphs[index].gx_glyph_advance = header.gx_glyph_header_advance;
1068 glyphs[index].gx_glyph_ascent = header.gx_glyph_header_ascent;
1069 glyphs[index].gx_glyph_descent = header.gx_glyph_header_descent;
1070 glyphs[index].gx_glyph_height = header.gx_glyph_header_height;
1071 glyphs[index].gx_glyph_leading = header.gx_glyph_header_leading;
1072 glyphs[index].gx_glyph_width = header.gx_glyph_header_width;
1073
1074 /* Read glyph data. */
1075 if (header.gx_glyph_header_data_size)
1076 {
1077 glyphs[index].gx_glyph_map = (GX_UBYTE *)(info -> gx_binres_root_address + header.gx_glyph_header_map_offset);
1078 info -> gx_binres_read_offset += header.gx_glyph_header_data_size;
1079 }
1080 else
1081 {
1082 glyphs[index].gx_glyph_map = GX_NULL;
1083 }
1084 }
1085
1086 *returned_glyphs = glyphs;
1087
1088 return GX_SUCCESS;
1089 }
1090 #endif
1091
1092 /**************************************************************************/
1093 /* */
1094 /* FUNCTION RELEASE */
1095 /* */
1096 /* _gx_binres_kerning_glyphs_address_get PORTABLE C */
1097 /* 6.1 */
1098 /* AUTHOR */
1099 /* */
1100 /* Kenneth Maxwell, Microsoft Corporation */
1101 /* */
1102 /* DESCRIPTION */
1103 /* */
1104 /* This service gets the memory address of specified kerning glyph */
1105 /* from a binary data buffer. */
1106 /* */
1107 /* INPUT */
1108 /* */
1109 /* info Binary resource control block */
1110 /* glyph_count The number of glyphs that the */
1111 /* font page contains. */
1112 /* returned_glyphs Returned glyph address */
1113 /* */
1114 /* OUTPUT */
1115 /* */
1116 /* Status Completion status */
1117 /* */
1118 /* CALLS */
1119 /* */
1120 /* _gx_binres_kerning_glyph_header_load */
1121 /* */
1122 /* CALLED BY */
1123 /* */
1124 /* Application Code */
1125 /* GUIX Internal Code */
1126 /* */
1127 /* RELEASE HISTORY */
1128 /* */
1129 /* DATE NAME DESCRIPTION */
1130 /* */
1131 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1132 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1133 /* updated with binary */
1134 /* resource layout change, */
1135 /* resulting in version 6.1 */
1136 /* */
1137 /**************************************************************************/
1138 #ifdef GX_FONT_KERNING_SUPPORT
1139 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_kerning_glyphs_address_get(GX_BINRES_DATA_INFO * info,USHORT glyph_count,GX_CONST GX_KERNING_GLYPH ** returned_glyphs)1140 static UINT _gx_binres_kerning_glyphs_address_get(GX_BINRES_DATA_INFO *info, USHORT glyph_count,
1141 GX_CONST GX_KERNING_GLYPH **returned_glyphs)
1142 {
1143 GX_KERNING_GLYPH_HEADER header;
1144 GX_KERNING_GLYPH *glyphs;
1145 USHORT index = 0;
1146
1147 glyphs = (GX_KERNING_GLYPH *)(info -> gx_binres_buffer + info -> gx_binres_buffer_index);
1148 info -> gx_binres_buffer_index += sizeof(GX_KERNING_GLYPH) * glyph_count;
1149
1150 for (index = 0; index < glyph_count; index++)
1151 {
1152 _gx_binres_kerning_glyph_header_load(info, &header);
1153
1154 if (header.gx_glyph_header_magic_number != GX_MAGIC_NUMBER)
1155 {
1156 return GX_INVALID_FORMAT;
1157 }
1158
1159 glyphs[index].gx_glyph_advance = header.gx_glyph_header_advance;
1160 glyphs[index].gx_glyph_ascent = header.gx_glyph_header_ascent;
1161 glyphs[index].gx_glyph_descent = header.gx_glyph_header_descent;
1162 glyphs[index].gx_glyph_height = header.gx_glyph_header_height;
1163 glyphs[index].gx_glyph_leading = header.gx_glyph_header_leading;
1164 glyphs[index].gx_glyph_width = header.gx_glyph_header_width;
1165
1166 /* Read glyph data. */
1167 if (header.gx_glyph_header_data_size)
1168 {
1169 glyphs[index].gx_glyph_map = (GX_UBYTE *)(info -> gx_binres_root_address + header.gx_glyph_header_map_offset);
1170 info -> gx_binres_read_offset += header.gx_glyph_header_data_size;
1171 }
1172 else
1173 {
1174 glyphs[index].gx_glyph_map = GX_NULL;
1175 }
1176
1177 /* Set glyph kerning table. */
1178 if (header.gx_glyph_header_kerning_table_size)
1179 {
1180 glyphs[index].gx_kerning_table = (GX_UBYTE *)(info -> gx_binres_root_address + info -> gx_binres_read_offset);
1181 info -> gx_binres_read_offset += header.gx_glyph_header_kerning_table_size;
1182 }
1183 }
1184
1185 *returned_glyphs = glyphs;
1186
1187 return GX_SUCCESS;
1188 }
1189 #endif
1190 #endif
1191
1192 /**************************************************************************/
1193 /* */
1194 /* FUNCTION RELEASE */
1195 /* */
1196 /* _gx_binres_compressed_glyphs_address_get PORTABLE C */
1197 /* 6.1 */
1198 /* AUTHOR */
1199 /* */
1200 /* Kenneth Maxwell, Microsoft Corporation */
1201 /* */
1202 /* DESCRIPTION */
1203 /* */
1204 /* This service gets the memory address of specified compressed glyph */
1205 /* from a binary data buffer. */
1206 /* */
1207 /* INPUT */
1208 /* */
1209 /* info Binary resource control block */
1210 /* glyph_count The number of glyphs that the */
1211 /* font page contains. */
1212 /* returned_glyphs Returned glyph address */
1213 /* */
1214 /* OUTPUT */
1215 /* */
1216 /* Status Completion status */
1217 /* */
1218 /* CALLS */
1219 /* */
1220 /* _gx_binres_glyph_header_load Read glyph data header */
1221 /* */
1222 /* CALLED BY */
1223 /* */
1224 /* GUIX Internal Code */
1225 /* */
1226 /* RELEASE HISTORY */
1227 /* */
1228 /* DATE NAME DESCRIPTION */
1229 /* */
1230 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1231 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1232 /* updated with binary */
1233 /* resource layout change, */
1234 /* resulting in version 6.1 */
1235 /* */
1236 /**************************************************************************/
1237 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_compressed_glyphs_address_get(GX_BINRES_DATA_INFO * info,USHORT glyph_count,GX_CONST GX_COMPRESSED_GLYPH ** returned_glyphs)1238 static UINT _gx_binres_compressed_glyphs_address_get(GX_BINRES_DATA_INFO *info, USHORT glyph_count,
1239 GX_CONST GX_COMPRESSED_GLYPH **returned_glyphs)
1240 {
1241 GX_GLYPH_HEADER header;
1242 GX_COMPRESSED_GLYPH *glyphs;
1243 USHORT index = 0;
1244
1245 glyphs = (GX_COMPRESSED_GLYPH *)(info -> gx_binres_buffer + info -> gx_binres_buffer_index);
1246 info -> gx_binres_buffer_index += sizeof(GX_COMPRESSED_GLYPH) * glyph_count;
1247
1248 for (index = 0; index < glyph_count; index++)
1249 {
1250 _gx_binres_glyph_header_load(info, &header);
1251
1252 if (header.gx_glyph_header_magic_number != GX_MAGIC_NUMBER)
1253 {
1254 return GX_INVALID_FORMAT;
1255 }
1256
1257 glyphs[index].gx_glyph_advance = header.gx_glyph_header_advance;
1258 glyphs[index].gx_glyph_ascent = header.gx_glyph_header_ascent;
1259 glyphs[index].gx_glyph_descent = header.gx_glyph_header_descent;
1260 glyphs[index].gx_glyph_height = header.gx_glyph_header_height;
1261 glyphs[index].gx_glyph_leading = header.gx_glyph_header_leading;
1262 glyphs[index].gx_glyph_map_size = header.gx_glyph_header_map_size;
1263 glyphs[index].gx_glyph_width = header.gx_glyph_header_width;
1264
1265 /* Read glyph data. */
1266 if (header.gx_glyph_header_data_size)
1267 {
1268 glyphs[index].gx_glyph_map = (GX_UBYTE *)(info -> gx_binres_root_address + header.gx_glyph_header_map_offset);
1269 info -> gx_binres_read_offset += header.gx_glyph_header_data_size;
1270 }
1271 else
1272 {
1273 glyphs[index].gx_glyph_map = GX_NULL;
1274 }
1275 }
1276
1277 *returned_glyphs = glyphs;
1278
1279 return GX_SUCCESS;
1280 }
1281 #endif
1282
1283 /**************************************************************************/
1284 /* */
1285 /* FUNCTION RELEASE */
1286 /* */
1287 /* _gx_binres_one_font_load PORTABLE C */
1288 /* 6.3.0 */
1289 /* AUTHOR */
1290 /* */
1291 /* Ting Zhu, Microsoft Corporation */
1292 /* */
1293 /* DESCRIPTION */
1294 /* */
1295 /* This service loads a font from a binary data buffer. */
1296 /* */
1297 /* INPUT */
1298 /* */
1299 /* info Binary resource control block */
1300 /* return_font Returned font */
1301 /* */
1302 /* OUTPUT */
1303 /* */
1304 /* Status Completion status */
1305 /* */
1306 /* CALLS */
1307 /* */
1308 /* _gx_binres_font_header_load Read font header */
1309 /* _gx_binres_page_header_load Read font page header */
1310 /* _gx_binres_compressed_glyphs_read Read compressed glyph data */
1311 /* _gx_binres_glyphs_read Read glyph data */
1312 /* */
1313 /* CALLED BY */
1314 /* */
1315 /* GUIX Internal Code */
1316 /* */
1317 /* RELEASE HISTORY */
1318 /* */
1319 /* DATE NAME DESCRIPTION */
1320 /* */
1321 /* 10-31-2023 Ting Zhu Initial Version 6.3.0 */
1322 /* */
1323 /**************************************************************************/
1324 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_one_font_load(GX_BINRES_DATA_INFO * info,GX_FONT ** return_font)1325 UINT _gx_binres_one_font_load(GX_BINRES_DATA_INFO *info, GX_FONT **return_font)
1326 {
1327 UINT status = GX_SUCCESS;
1328 GX_FONT_HEADER font_header;
1329 GX_PAGE_HEADER header;
1330 GX_FONT *font;
1331 GX_FONT *head_page = GX_NULL;
1332 GX_FONT *pre_page = GX_NULL;
1333 USHORT index;
1334 USHORT glyph_count;
1335 UINT read_offset = 0;
1336
1337 /* Read font header. */
1338 status = _gx_binres_font_header_load(info, &font_header);
1339
1340 if (status != GX_SUCCESS)
1341 {
1342 return status;
1343 }
1344
1345 if (font_header.gx_font_header_deault)
1346 {
1347 switch (font_header.gx_font_header_bits)
1348 {
1349 case 1:
1350 head_page = (GX_FONT *)&_gx_system_font_mono;
1351 break;
1352
1353 case 4:
1354 head_page = (GX_FONT *)&_gx_system_font_4bpp;
1355 break;
1356
1357 case 8:
1358 head_page = (GX_FONT *)&_gx_system_font_8bpp;
1359 break;
1360 }
1361 }
1362 else
1363 {
1364 if (font_header.gx_font_header_data_offset)
1365 {
1366 /* The font data is not follow the header directly,
1367 the data offset gives the position where the font
1368 data located. */
1369
1370 /* Record current data offset. */
1371 read_offset = info -> gx_binres_read_offset;
1372
1373 /* Temporarily reset data offset to access font data. */
1374 info -> gx_binres_read_offset = font_header.gx_font_header_data_offset;
1375
1376 /* Read font header. */
1377 _gx_binres_font_header_load(info, &font_header);
1378 }
1379
1380 for (index = 0; index < font_header.gx_font_header_page_count; index++)
1381 {
1382 /* Read page header. */
1383 status = _gx_binres_page_header_load(info, &header);
1384
1385 if (status != GX_SUCCESS)
1386 {
1387 return status;
1388 }
1389
1390 font = (GX_FONT *)(info -> gx_binres_buffer + info -> gx_binres_buffer_index);
1391 info -> gx_binres_buffer_index += sizeof(GX_FONT);
1392
1393 font -> gx_font_baseline = header.gx_page_header_baseline;
1394 font -> gx_font_first_glyph = header.gx_page_header_first_glyph;
1395 font -> gx_font_format = header.gx_page_header_format;
1396 font -> gx_font_last_glyph = header.gx_page_header_last_glyph;
1397 font -> gx_font_line_height = header.gx_page_header_line_height;
1398 font -> gx_font_postspace = header.gx_page_header_postspace;
1399 font -> gx_font_prespace = header.gx_page_header_prespace;
1400
1401 /* Read glyphs data. */
1402 glyph_count = (USHORT)(font -> gx_font_last_glyph - font -> gx_font_first_glyph + 1);
1403
1404 if (font -> gx_font_format & GX_FONT_FORMAT_COMPRESSED)
1405 {
1406 status = _gx_binres_compressed_glyphs_address_get(info, glyph_count, &font -> gx_font_glyphs.gx_font_compressed_glyphs);
1407 }
1408 #if defined(GX_FONT_KERNING_SUPPORT)
1409 else if (font -> gx_font_format & GX_FONT_FORMAT_KERNING)
1410 {
1411 status = _gx_binres_kerning_glyphs_address_get(info, glyph_count, &font -> gx_font_glyphs.gx_font_kerning_glyphs);
1412 }
1413 #endif /* GX_FONT_KERNING_SUPPORT */
1414 else
1415 {
1416 status = _gx_binres_glyphs_address_get(info, glyph_count, &font -> gx_font_glyphs.gx_font_normal_glyphs);
1417 }
1418
1419 if (status != GX_SUCCESS)
1420 {
1421 break;
1422 }
1423
1424 font -> gx_font_next_page = NULL;
1425
1426 if (!head_page)
1427 {
1428 head_page = font;
1429 }
1430
1431 if (pre_page)
1432 {
1433 pre_page -> gx_font_next_page = font;
1434 }
1435
1436 pre_page = font;
1437 }
1438 }
1439
1440 if (read_offset)
1441 {
1442 /* Restore data offset. */
1443 info -> gx_binres_read_offset = read_offset;
1444 read_offset = 0;
1445 }
1446
1447 if (return_font)
1448 {
1449 *return_font = head_page;
1450 }
1451
1452 return status;
1453 }
1454 #endif
1455 /**************************************************************************/
1456 /* */
1457 /* FUNCTION RELEASE */
1458 /* */
1459 /* _gx_binres_color_table_load PORTABLE C */
1460 /* 6.1 */
1461 /* AUTHOR */
1462 /* */
1463 /* Kenneth Maxwell, Microsoft Corporation */
1464 /* */
1465 /* DESCRIPTION */
1466 /* */
1467 /* This function loads a color table from a binary data buffer. */
1468 /* */
1469 /* INPUT */
1470 /* */
1471 /* info Binary resource control block */
1472 /* color_count The number of colors to read */
1473 /* returned_color_table Returned color table */
1474 /* */
1475 /* OUTPUT */
1476 /* */
1477 /* Status Completion status */
1478 /* */
1479 /* CALLS */
1480 /* */
1481 /* _gx_binres_color_header_load Read color data header */
1482 /* */
1483 /* CALLED BY */
1484 /* */
1485 /* GUIX Internal Code */
1486 /* */
1487 /* RELEASE HISTORY */
1488 /* */
1489 /* DATE NAME DESCRIPTION */
1490 /* */
1491 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1492 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1493 /* resulting in version 6.1 */
1494 /* */
1495 /**************************************************************************/
1496 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_color_table_load(GX_BINRES_DATA_INFO * info,USHORT color_count,GX_COLOR ** returned_color_table)1497 static UINT _gx_binres_color_table_load(GX_BINRES_DATA_INFO *info, USHORT color_count, GX_COLOR **returned_color_table)
1498 {
1499 GX_COLOR_HEADER header;
1500 GX_COLOR *color_table = GX_NULL;
1501
1502 if (!color_count)
1503 {
1504 return GX_SUCCESS;
1505 }
1506
1507 /* Read color table header. */
1508 _gx_binres_color_header_load(info, &header);
1509
1510 if (header.gx_color_header_magic_number != GX_MAGIC_NUMBER)
1511 {
1512 return GX_INVALID_FORMAT;
1513 }
1514
1515 color_table = (GX_COLOR *)(info -> gx_binres_root_address + info -> gx_binres_read_offset);
1516 info -> gx_binres_read_offset += header.gx_color_header_data_size;
1517
1518 *returned_color_table = color_table;
1519
1520 return GX_SUCCESS;
1521 }
1522 #endif
1523
1524 /**************************************************************************/
1525 /* */
1526 /* FUNCTION RELEASE */
1527 /* */
1528 /* _gx_binres_palette_table_load PORTABLE C */
1529 /* 6.1 */
1530 /* AUTHOR */
1531 /* */
1532 /* Kenneth Maxwell, Microsoft Corporation */
1533 /* */
1534 /* DESCRIPTION */
1535 /* */
1536 /* This function loads a palette table from a binary data buffer. */
1537 /* */
1538 /* INPUT */
1539 /* */
1540 /* info Binary resource control block */
1541 /* color_count The number of colors to read */
1542 /* returned_palette_table Returned palette table */
1543 /* */
1544 /* OUTPUT */
1545 /* */
1546 /* Status Completion status */
1547 /* */
1548 /* CALLS */
1549 /* */
1550 /* _gx_binres_palette_header_load Read palette data header */
1551 /* */
1552 /* CALLED BY */
1553 /* */
1554 /* GUIX Internal Code */
1555 /* */
1556 /* RELEASE HISTORY */
1557 /* */
1558 /* DATE NAME DESCRIPTION */
1559 /* */
1560 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1561 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1562 /* resulting in version 6.1 */
1563 /* */
1564 /**************************************************************************/
1565 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_palette_table_load(GX_BINRES_DATA_INFO * info,USHORT color_count,GX_COLOR ** returned_palette_table)1566 static UINT _gx_binres_palette_table_load(GX_BINRES_DATA_INFO *info, USHORT color_count, GX_COLOR **returned_palette_table)
1567 {
1568 GX_PALETTE_HEADER header;
1569 GX_COLOR *palette_table = GX_NULL;
1570
1571 if (!color_count)
1572 {
1573 return GX_SUCCESS;
1574 }
1575
1576 /* Read palette table header. */
1577 _gx_binres_palette_header_load(info, &header);
1578
1579 if (header.gx_palette_header_magic_number != GX_MAGIC_NUMBER)
1580 {
1581 return GX_INVALID_FORMAT;
1582 }
1583
1584 palette_table = (GX_COLOR *)(info -> gx_binres_root_address + info -> gx_binres_read_offset);
1585 info -> gx_binres_read_offset += header.gx_palette_header_data_size;
1586
1587 *returned_palette_table = palette_table;
1588
1589 return GX_SUCCESS;
1590 }
1591 #endif
1592
1593 /**************************************************************************/
1594 /* */
1595 /* FUNCTION RELEASE */
1596 /* */
1597 /* _gx_binres_font_table_load PORTABLE C */
1598 /* 6.3.0 */
1599 /* AUTHOR */
1600 /* */
1601 /* Kenneth Maxwell, Microsoft Corporation */
1602 /* */
1603 /* DESCRIPTION */
1604 /* */
1605 /* This function loads a font table from resource data memory. */
1606 /* */
1607 /* INPUT */
1608 /* */
1609 /* info Binary resource control block */
1610 /* table_size Font table size */
1611 /* returned_font_table Returned font table */
1612 /* */
1613 /* OUTPUT */
1614 /* */
1615 /* Status Completion status */
1616 /* */
1617 /* CALLS */
1618 /* */
1619 /* _gx_binres_one_font_load Load one font */
1620 /* */
1621 /* CALLED BY */
1622 /* */
1623 /* GUIX Internal Code */
1624 /* */
1625 /* RELEASE HISTORY */
1626 /* */
1627 /* DATE NAME DESCRIPTION */
1628 /* */
1629 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1630 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1631 /* resulting in version 6.1 */
1632 /* 10-31-2023 Ting Zhu Modified comment(s), */
1633 /* improved logic, */
1634 /* resulting in version 6.3.0 */
1635 /* */
1636 /**************************************************************************/
1637 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_font_table_load(GX_BINRES_DATA_INFO * info,USHORT table_size,GX_FONT *** returned_font_table)1638 static UINT _gx_binres_font_table_load(GX_BINRES_DATA_INFO *info, USHORT table_size, GX_FONT ***returned_font_table)
1639 {
1640 UINT status = GX_SUCCESS;
1641 GX_FONT **font_table = GX_NULL;
1642 USHORT index;
1643
1644 font_table = (GX_FONT **)(info -> gx_binres_buffer + info -> gx_binres_buffer_index);
1645 info -> gx_binres_buffer_index += sizeof(GX_FONT *) * table_size;
1646
1647 for (index = 0; index < table_size; index++)
1648 {
1649 status = _gx_binres_one_font_load(info, &font_table[index]);
1650
1651 if (status != GX_SUCCESS)
1652 {
1653 return status;
1654 }
1655 }
1656
1657 *returned_font_table = font_table;
1658
1659 return status;
1660 }
1661 #endif
1662
1663 /**************************************************************************/
1664 /* */
1665 /* FUNCTION RELEASE */
1666 /* */
1667 /* _gx_binres_one_pixelmap_load PORTABLE C */
1668 /* 6.3.0 */
1669 /* AUTHOR */
1670 /* */
1671 /* Ting Zhu, Microsoft Corporation */
1672 /* */
1673 /* DESCRIPTION */
1674 /* */
1675 /* This function loads one pixelmap from resource data memory. */
1676 /* */
1677 /* INPUT */
1678 /* */
1679 /* info Binary resource control block */
1680 /* returned_pixelmap Returned pixelmap table */
1681 /* map_id Loaded pixelmap ID */
1682 /* */
1683 /* OUTPUT */
1684 /* */
1685 /* Status Completion status */
1686 /* */
1687 /* CALLS */
1688 /* */
1689 /* _gx_binres_pixelmap_header_load Read pixelmap header */
1690 /* */
1691 /* CALLED BY */
1692 /* */
1693 /* GUIX Internal Code */
1694 /* */
1695 /* RELEASE HISTORY */
1696 /* */
1697 /* DATE NAME DESCRIPTION */
1698 /* */
1699 /* 10-31-2023 Ting Zhu Initial Version 6.3.0 */
1700 /* */
1701 /**************************************************************************/
1702 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_one_pixelmap_load(GX_BINRES_DATA_INFO * info,GX_PIXELMAP ** returned_pixelmap,USHORT * map_id)1703 UINT _gx_binres_one_pixelmap_load(GX_BINRES_DATA_INFO *info, GX_PIXELMAP **returned_pixelmap, USHORT *map_id)
1704 {
1705 UINT status = GX_SUCCESS;
1706 GX_PIXELMAP_HEADER header;
1707 ULONG size;
1708 UINT read_offset = 0;
1709
1710 GX_PIXELMAP *pixelmap;
1711
1712 /* Read pixelmap header. */
1713 status = _gx_binres_pixelmap_header_load(info, &header);
1714
1715 if (status)
1716 {
1717 return status;
1718 }
1719
1720 if (header.gx_pixelmap_header_data_offset)
1721 {
1722 /* The pixelmap data is not follow the header directly,
1723 the data offset gives the position where the pixelmap
1724 data located. */
1725
1726 /* Record current data offset. */
1727 read_offset = info -> gx_binres_read_offset;
1728
1729 /* Temporarily reset data offset to access pixelmap data. */
1730 info -> gx_binres_read_offset = header.gx_pixelmap_header_data_offset;
1731
1732 /* Read pixelmap header. */
1733 _gx_binres_pixelmap_header_load(info, &header);
1734 }
1735
1736 /* Allocate memory for pixelmap. */
1737 pixelmap = (GX_PIXELMAP *)(info -> gx_binres_buffer + info -> gx_binres_buffer_index);
1738 info -> gx_binres_buffer_index += sizeof(GX_PIXELMAP);
1739
1740 pixelmap -> gx_pixelmap_aux_data_size = header.gx_pixelmap_header_aux_data_size;
1741 pixelmap -> gx_pixelmap_data_size = header.gx_pixelmap_header_map_size;
1742 pixelmap -> gx_pixelmap_flags = header.gx_pixelmap_header_flags;
1743 pixelmap -> gx_pixelmap_format = header.gx_pixelmap_header_format;
1744 pixelmap -> gx_pixelmap_width = (GX_VALUE)header.gx_pixelmap_header_width;
1745 pixelmap -> gx_pixelmap_height = (GX_VALUE)header.gx_pixelmap_header_height;
1746 pixelmap -> gx_pixelmap_transparent_color = header.gx_pixelmap_header_transparent_color;
1747 pixelmap -> gx_pixelmap_version_major = header.gx_pixelmap_header_version_major;
1748 pixelmap -> gx_pixelmap_version_minor = header.gx_pixelmap_header_version_minor;
1749
1750 /* Skip padding bytes. */
1751 info -> gx_binres_read_offset = (info -> gx_binres_read_offset + 3) & (~0x03UL);
1752
1753 /* Read pixelmap data. */
1754 size = pixelmap -> gx_pixelmap_data_size;
1755 if (size)
1756 {
1757 pixelmap -> gx_pixelmap_data = (GX_UBYTE *)(info -> gx_binres_root_address + info -> gx_binres_read_offset);
1758 info -> gx_binres_read_offset += size;
1759 }
1760
1761 /* Read pixelmap aux data. */
1762 size = pixelmap -> gx_pixelmap_aux_data_size;
1763 if (size)
1764 {
1765 pixelmap -> gx_pixelmap_aux_data = (GX_UBYTE *)(info -> gx_binres_root_address + info -> gx_binres_read_offset);
1766 info -> gx_binres_read_offset += size;
1767 }
1768
1769 if (read_offset)
1770 {
1771 /* Restore data offset. */
1772 info -> gx_binres_read_offset = read_offset;
1773 read_offset = 0;
1774 }
1775
1776 if (returned_pixelmap)
1777 {
1778 *returned_pixelmap = pixelmap;
1779 }
1780
1781 if (map_id)
1782 {
1783 *map_id = header.gx_pixelmap_header_index;
1784 }
1785
1786 return status;
1787 }
1788
1789
1790 /**************************************************************************/
1791 /* */
1792 /* FUNCTION RELEASE */
1793 /* */
1794 /* _gx_binres_pixelmap_table_load PORTABLE C */
1795 /* 6.3.0 */
1796 /* AUTHOR */
1797 /* */
1798 /* Kenneth Maxwell, Microsoft Corporation */
1799 /* */
1800 /* DESCRIPTION */
1801 /* */
1802 /* This function loads a pixelmap table from resource data memory. */
1803 /* */
1804 /* INPUT */
1805 /* */
1806 /* info Binary resource control block */
1807 /* table_size Pixelmap table size */
1808 /* returned_pixelmp_table Returned pixelmap table */
1809 /* */
1810 /* OUTPUT */
1811 /* */
1812 /* Status Completion status */
1813 /* */
1814 /* CALLS */
1815 /* */
1816 /* _gx_binres_one_pixelmap_load Load one pixelmap */
1817 /* */
1818 /* CALLED BY */
1819 /* */
1820 /* GUIX Internal Code */
1821 /* */
1822 /* RELEASE HISTORY */
1823 /* */
1824 /* DATE NAME DESCRIPTION */
1825 /* */
1826 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1827 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1828 /* resulting in version 6.1 */
1829 /* 10-31-2023 Ting Zhu Modified comment(s), */
1830 /* improved logic, */
1831 /* resulting in version 6.3.0 */
1832 /* */
1833 /**************************************************************************/
_gx_binres_pixelmap_table_load(GX_BINRES_DATA_INFO * info,USHORT table_size,GX_PIXELMAP ** pixelmap_table)1834 static UINT _gx_binres_pixelmap_table_load(GX_BINRES_DATA_INFO *info, USHORT table_size, GX_PIXELMAP **pixelmap_table)
1835 {
1836 UINT status = GX_SUCCESS;
1837 USHORT index;
1838 USHORT map_id;
1839 GX_PIXELMAP *pixelmap;
1840
1841 for (index = 1; index < table_size; index++)
1842 {
1843 status = _gx_binres_one_pixelmap_load(info, &pixelmap, &map_id);
1844
1845 while (index < map_id)
1846 {
1847 pixelmap_table[index++] = GX_NULL;
1848 }
1849
1850 pixelmap_table[index] = pixelmap;
1851
1852 if (status)
1853 {
1854 return status;
1855 }
1856 }
1857
1858 return status;
1859 }
1860 #endif
1861
1862 /**************************************************************************/
1863 /* */
1864 /* FUNCTION RELEASE */
1865 /* */
1866 /* _gx_binres_theme_load PORTABLE C */
1867 /* 6.1 */
1868 /* AUTHOR */
1869 /* */
1870 /* Kenneth Maxwell, Microsoft Corporation */
1871 /* */
1872 /* DESCRIPTION */
1873 /* */
1874 /* This service loads a theme table from a resource data memory. */
1875 /* */
1876 /* INPUT */
1877 /* */
1878 /* root_address Root address of binary */
1879 /* resource data */
1880 /* theme_id The indentifier of the theme */
1881 /* returned_theme Pointer to loaded theme */
1882 /* */
1883 /* OUTPUT */
1884 /* */
1885 /* Status Completion status */
1886 /* */
1887 /* CALLS */
1888 /* */
1889 /* _gx_binres_theme_buffer_allocate Allocate needed buffer for */
1890 /* loading theme table */
1891 /* _gx_binres_resource_header_load Read resource header */
1892 /* _gx_binres_theme_header_load Read theme header */
1893 /* _gx_binres_color_table_load Load color table */
1894 /* _gx_binres_palette_table_load Load palette table */
1895 /* _gx_binres_font_table_load Load font table */
1896 /* _gx_binres_pixelmap_table_load Load pixelmap table */
1897 /* _gx_system_memory_free Memory free function */
1898 /* */
1899 /* CALLED BY */
1900 /* */
1901 /* Application Code */
1902 /* */
1903 /* RELEASE HISTORY */
1904 /* */
1905 /* DATE NAME DESCRIPTION */
1906 /* */
1907 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1908 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1909 /* resulting in version 6.1 */
1910 /* */
1911 /**************************************************************************/
1912 #ifdef GX_BINARY_RESOURCE_SUPPORT
_gx_binres_theme_load(GX_UBYTE * root_address,INT theme_id,GX_THEME ** returned_theme)1913 UINT _gx_binres_theme_load(GX_UBYTE *root_address, INT theme_id, GX_THEME **returned_theme)
1914 {
1915 UINT status;
1916 GX_BINRES_DATA_INFO info;
1917 GX_RESOURCE_HEADER header;
1918 GX_THEME_HEADER theme_header;
1919 GX_THEME *theme;
1920 INT index;
1921
1922 memset(&info, 0, sizeof(GX_BINRES_DATA_INFO));
1923 memset(&theme_header, 0, sizeof(GX_THEME_HEADER));
1924
1925 info.gx_binres_root_address = (GX_UBYTE *)root_address;
1926
1927 /* Allocate memory that needed for theme table. */
1928 status = _gx_binres_theme_buffer_allocate(&info, theme_id);
1929
1930 /* Read binary resource header. */
1931
1932 if (status == GX_SUCCESS)
1933 {
1934 status = _gx_binres_resource_header_load(&info, &header);
1935 }
1936
1937 /* Read theme table. */
1938 if (status == GX_SUCCESS)
1939 {
1940 for (index = 0;; index++)
1941 {
1942
1943 /* Read theme header. */
1944 _gx_binres_theme_header_load(&info, &theme_header);
1945
1946 if (index == theme_id)
1947 {
1948 theme = (GX_THEME *)(info.gx_binres_buffer + info.gx_binres_buffer_index);
1949 info.gx_binres_buffer_index += sizeof(GX_THEME);
1950
1951 theme -> theme_color_table_size = theme_header.gx_theme_header_color_count;
1952 theme -> theme_palette_size = theme_header.gx_theme_header_palette_count;
1953 theme -> theme_font_table_size = theme_header.gx_theme_header_font_count;
1954 theme -> theme_pixelmap_table_size = (USHORT)(theme_header.gx_theme_header_pixelmap_count + 1);
1955 theme -> theme_vertical_scrollbar_appearance = theme_header.gx_theme_header_vscroll_appearance;
1956 theme -> theme_horizontal_scrollbar_appearance = theme_header.gx_theme_header_hscroll_appearance;
1957 theme -> theme_vertical_scroll_style = theme_header.gx_theme_header_hscroll_style;
1958 theme -> theme_horizontal_scroll_style = theme_header.gx_theme_header_hscroll_style;
1959
1960 /* Read color table. */
1961 status = _gx_binres_color_table_load(&info,
1962 theme_header.gx_theme_header_color_count,
1963 &theme -> theme_color_table);
1964
1965 /* Read palette table. */
1966 if ((status == GX_SUCCESS) && theme_header.gx_theme_header_palette_data_size)
1967 {
1968 status = _gx_binres_palette_table_load(&info,
1969 theme_header.gx_theme_header_palette_count,
1970 &theme -> theme_palette);
1971 }
1972
1973 /* Read font table. */
1974 if ((status == GX_SUCCESS) && theme_header.gx_theme_header_font_data_size && theme_header.gx_theme_header_font_count)
1975 {
1976 status = _gx_binres_font_table_load(&info,
1977 theme_header.gx_theme_header_font_count,
1978 &theme -> theme_font_table);
1979 }
1980
1981 /* Read pixelmap table. */
1982 if ((status == GX_SUCCESS) && theme_header.gx_theme_header_pixelmap_data_size && theme_header.gx_theme_header_pixelmap_count)
1983 {
1984 /* Allocate pixelmap table size. */
1985 theme -> theme_pixelmap_table = (GX_PIXELMAP **)(info.gx_binres_buffer + info.gx_binres_buffer_index);
1986 info.gx_binres_buffer_index += sizeof(GX_PIXELMAP *) * (UINT)(theme_header.gx_theme_header_pixelmap_count + 1);
1987
1988 /* Load pixelmap table. */
1989 status = _gx_binres_pixelmap_table_load(&info,
1990 theme -> theme_pixelmap_table_size,
1991 theme -> theme_pixelmap_table);
1992 }
1993
1994 if (status == GX_SUCCESS)
1995 {
1996 *returned_theme = theme;
1997 }
1998 else
1999 {
2000 /* Free allocated buffer if theme loading failed. */
2001 _gx_system_memory_free(info.gx_binres_buffer);
2002
2003 *returned_theme = GX_NULL;
2004 }
2005
2006 break;
2007 }
2008 else
2009 {
2010 info.gx_binres_read_offset += theme_header.gx_theme_header_data_size;
2011 }
2012 }
2013 }
2014
2015 return status;
2016 }
2017 #endif
2018
2019