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 /** Win32 Display Management (Display) */
18 /** */
19 /**************************************************************************/
20 #ifdef WIN32
21 #include "tx_api.h"
22 #include "gx_api.h"
23 #include "gx_system.h"
24 #include "gx_display.h"
25 #include "windows.h"
26 #include "gx_win32_display_driver.h"
27 #include "gx_dave2d_simulation_display_driver.h"
28
29 /**************************************************************************/
30 /* */
31 /* FUNCTION RELEASE */
32 /* */
33 /* win32_dave2d_simulation_565rgb_bitmap_header_create */
34 /* PORTABLE C */
35 /* 6.4.0 */
36 /* AUTHOR */
37 /* */
38 /* Ting Zhu, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function creates bitmap header for 565rgb driver. */
43 /* */
44 /* INPUT */
45 /* */
46 /* display Pointer to GX_DISPLAY */
47 /* */
48 /* OUTPUT */
49 /* */
50 /* None */
51 /* */
52 /* CALLS */
53 /* */
54 /* None */
55 /* */
56 /* CALLED BY */
57 /* */
58 /* win32_dave2d_graphics_driver_setup_565rgb */
59 /* */
60 /* RELEASE HISTORY */
61 /* */
62 /* DATE NAME DESCRIPTION */
63 /* */
64 /* 12-31-2023 Ting Zhu Initial Version 6.4.0 */
65 /* */
66 /**************************************************************************/
win32_dave2d_simulation_565rgb_bitmap_header_create(GX_DISPLAY * display)67 static void win32_dave2d_simulation_565rgb_bitmap_header_create(GX_DISPLAY *display)
68 {
69 DWORD *putmask;
70
71 GX_WIN32_DISPLAY_DRIVER_DATA *instance = (GX_WIN32_DISPLAY_DRIVER_DATA *)display -> gx_display_driver_data;
72
73 instance -> win32_driver_bmpinfo.gx_bmp_header.biSize = sizeof(BITMAPINFOHEADER);
74 instance -> win32_driver_bmpinfo.gx_bmp_header.biWidth = display -> gx_display_width;
75 instance -> win32_driver_bmpinfo.gx_bmp_header.biHeight = display -> gx_display_height;
76
77 instance -> win32_driver_bmpinfo.gx_bmp_header.biPlanes = 1;
78 instance -> win32_driver_bmpinfo.gx_bmp_header.biBitCount = 16;
79 instance -> win32_driver_bmpinfo.gx_bmp_header.biSizeImage = display -> gx_display_width * display -> gx_display_height * 2;
80 instance -> win32_driver_bmpinfo.gx_bmp_header.biClrUsed = 65535;
81 instance -> win32_driver_bmpinfo.gx_bmp_header.biClrImportant = 65535;
82 instance -> win32_driver_bmpinfo.gx_bmp_header.biCompression = BI_BITFIELDS;
83
84 putmask = (DWORD *)&(instance -> win32_driver_bmpinfo.gx_bmp_colors[0]);
85
86 *putmask++ = 0x0000f800;
87 *putmask++ = 0x000007e0;
88 *putmask = 0x0000001f;
89 }
90
91 /**************************************************************************/
92 /* */
93 /* FUNCTION RELEASE */
94 /* */
95 /* win32_dave2d_graphics_driver_setup_565rgb PORTABLE C */
96 /* 6.4.0 */
97 /* AUTHOR */
98 /* */
99 /* Ting Zhu, Microsoft Corporation */
100 /* */
101 /* DESCRIPTION */
102 /* */
103 /* This function creates a Windows specific 565rgb synergy simulation */
104 /* display driver. */
105 /* */
106 /* INPUT */
107 /* */
108 /* display Pointer to GX_DISPLAY */
109 /* */
110 /* OUTPUT */
111 /* */
112 /* status Completion status */
113 /* */
114 /* CALLS */
115 /* */
116 /* _gx_dave2d_simulation_display_driver_565rgb_setup */
117 /* guix display setup funciton. */
118 /* win32_dave2d_simulation_565rgb_bitmap_header_create */
119 /* Create bitmap header info */
120 /* gx_win32_get_free_data_instance Get display data instance */
121 /* GX_WIN32_EVENT_THREAD_CREATE Create event thread */
122 /* */
123 /* CALLED BY */
124 /* */
125 /* Application Code */
126 /* */
127 /* RELEASE HISTORY */
128 /* */
129 /* DATE NAME DESCRIPTION */
130 /* */
131 /* 12-31-2023 Ting Zhu Initial Version 6.4.0 */
132 /* 10-31-2022 Kenneth Maxwell Modify comments, change */
133 /* function name, */
134 /* resulting in Version 6.2.0 */
135 /* */
136 /**************************************************************************/
win32_dave2d_graphics_driver_setup_565rgb(GX_DISPLAY * display)137 UINT win32_dave2d_graphics_driver_setup_565rgb(GX_DISPLAY *display)
138 {
139 GX_WIN32_DISPLAY_DRIVER_DATA *data;
140
141 /* Initialize the low-level drawing function pointers.
142 For windows, these are always just the generic funcions,
143 but for some hardware, these will be customized,
144 optimized functions specific to that hardware. */
145 data = gx_win32_get_free_data_instance();
146 if (!data)
147 {
148 /* we don't have any free display data instance */
149 return(GX_FAILURE);
150 }
151
152 /* Save off format of this display driver. */
153 data -> win32_driver_type = GX_COLOR_FORMAT_565RGB;
154
155 _gx_dave2d_simulation_display_driver_565rgb_setup(display, data, gx_win32_display_buffer_toggle);
156
157 win32_dave2d_simulation_565rgb_bitmap_header_create(display);
158
159 /* Create the GUIX / Windows event thread
160 This thread is a substitute for a touch display
161 or keyboard driver thread that would be running
162 on embedded hardware. */
163 GX_WIN32_EVENT_THREAD_CREATE(data, "GUI-WIN32-565rgb");
164
165 return(GX_SUCCESS);
166 }
167 #endif /* WIN32 */
168
169