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