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 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    gx_win32_driver.h                                   PORTABLE C      */
28 /*                                                           6.1.10       */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Kenneth Maxwell, Microsoft Corporation                              */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the GUIX Win32 display drivers.                   */
36 /*                                                                        */
37 /*  RELEASE HISTORY                                                       */
38 /*                                                                        */
39 /*    DATE              NAME                      DESCRIPTION             */
40 /*                                                                        */
41 /*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
42 /*  02-02-2021     Kenneth Maxwell          Modified comment(s),          */
43 /*                                            added 8bpp/24bpp rotated    */
44 /*                                            display driver declarations,*/
45 /*                                            resulting in version 6.1.4  */
46 /*  06-02-2021     Ting Zhu                 Modified comment(s),          */
47 /*                                            declared gx_win32_driver_   */
48 /*                                            thread_initialize,          */
49 /*                                            resulting in version 6.1.7  */
50 /*  01-31-2022     Ting Zhu                 Modified comment(s), modified */
51 /*                                            driver data structure,      */
52 /*                                            resulting in version 6.1.10 */
53 /*                                                                        */
54 /**************************************************************************/
55 
56 #ifndef GX_WIN32_DRIVER_H
57 #define GX_WIN32_DRIVER_H
58 
59 #ifdef __cplusplus
60 
61 /* Yes, C++ compiler is present.  Use standard C.  */
62 extern   "C" {
63 
64 #endif
65 
66 #include "tx_api.h"
67 #include "gx_api.h"
68 #include "gx_system.h"
69 #include "gx_display.h"
70 #include "windows.h"
71 
72 #define GX_MAX_WIN32_DISPLAYS 2
73 #define GX_WIN32_STACK_SIZE   (16 * 1024)
74 
75 /* Define Windows bitmap structure. */
76 typedef struct GUIX_BMP_INFO_STRUCT
77 {
78     BITMAPINFOHEADER gx_bmp_header;
79     DWORD            gx_bmp_colors[256];
80 } GX_BMP_INFO;
81 
82 /* Define win32 display driver data structure. */
83 typedef struct GX_WIN32_DISPLAY_DRIVER_STRUCT
84 {
85     ULONG       win32_driver_type;
86     GX_BMP_INFO win32_driver_bmpinfo;
87     HWND        win32_driver_winhandle;
88     INT         win32_driver_ready;
89     HANDLE      win32_driver_thread_handle;
90     GX_WIN32_DISPLAY_DRIVER_EXTRA_MEMBERS_DECLEARE
91 } GX_WIN32_DISPLAY_DRIVER_DATA;
92 
93 /* Define win32 driver functions. */
94 UINT                          win32_graphics_driver_setup_monochrome(GX_DISPLAY *display);
95 UINT                          win32_graphics_driver_setup_4bpp_grayscale(GX_DISPLAY *display);
96 UINT                          win32_graphics_driver_setup_8bit_palette(GX_DISPLAY *display);
97 UINT                          win32_graphics_driver_setup_8bit_palette_rotated(GX_DISPLAY* display);
98 UINT                          win32_graphics_driver_setup_565rgb(GX_DISPLAY *display);
99 UINT                          win32_graphics_driver_setup_565rgb_rotated(GX_DISPLAY *display);
100 UINT                          win32_graphics_driver_setup_565bgr(GX_DISPLAY *display);
101 UINT                          win32_graphics_driver_setup_1555xrgb(GX_DISPLAY *display);
102 UINT                          win32_graphics_driver_setup_4444argb(GX_DISPLAY *display);
103 UINT                          win32_graphics_driver_setup_24xrgb(GX_DISPLAY *display);
104 UINT                          win32_graphics_driver_setup_24xrgb_rotated(GX_DISPLAY *display);
105 UINT                          win32_graphics_driver_setup_32argb(GX_DISPLAY *display);
106 UINT                          win32_graphics_driver_setup_32argb_rotated(GX_DISPLAY *display);
107 
108 UINT                          win32_chromeart_graphics_driver_setup_565rgb(GX_DISPLAY *display);
109 UINT                          win32_dave2d_graphics_driver_setup_8bit_palette(GX_DISPLAY *display);
110 UINT                          win32_dave2d_graphics_driver_setup_24xrgb(GX_DISPLAY *display);
111 UINT                          win32_dave2d_graphics_driver_setup_24xrgb_rotated(GX_DISPLAY *display);
112 UINT                          win32_dave2d_graphics_driver_setup_565rgb(GX_DISPLAY *display);
113 UINT                          win32_dave2d_graphics_driver_setup_565rgb_rotated(GX_DISPLAY *display);
114 
115 VOID                          win32_32bpp_bitmap_header_create(GX_DISPLAY *display);
116 VOID                          win32_display_driver_8bit_palette_set(GX_DISPLAY *display, GX_COLOR *palette, INT count);
117 VOID                          win32_8bit_palette_bitmap_header_create(GX_DISPLAY *display);
118 VOID                          win32_dave2d_simulation_24xrgb_bitmap_header_create(GX_DISPLAY *display);
119 void                          gx_win32_display_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);
120 void                          gx_win32_driver_thread_entry(ULONG thread_input);
121 void                          gx_win32_driver_thread_initialize(GX_WIN32_DISPLAY_DRIVER_DATA *instance);
122 HWND                          gx_win32_window_create(GX_WIN32_DISPLAY_DRIVER_DATA *gx_driver_ptr, WNDPROC gx_win32_event_process, INT xpos, INT ypos);
123 LRESULT CALLBACK              gx_win32_event_process(HWND, UINT, WPARAM, LPARAM);
124 void                          gx_win32_message_to_guix(USHORT event_type);
125 void                          gx_win32_input_driver(GX_WIN32_DISPLAY_DRIVER_DATA *instance);
126 GX_WIN32_DISPLAY_DRIVER_DATA *gx_win32_get_free_data_instance();
127 GX_WIN32_DISPLAY_DRIVER_DATA *gx_win32_get_data_instance_by_win_handle(HWND winHandle);
128 
129 /* Determine if a C++ compiler is being used.  If so, complete the standard
130    C conditional started above. */
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* GX_WIN32_DRIVER_H */
136 
137