1 
2 /***************************************************************************
3  * Copyright (c) 2024 Microsoft Corporation
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the MIT License which is available at
7  * https://opensource.org/licenses/MIT.
8  *
9  * SPDX-License-Identifier: MIT
10  **************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   Display Management (Display)                                        */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 
23 #define GX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "gx_api.h"
29 #include "gx_display.h"
30 
31 #if defined(GX_MOUSE_SUPPORT) && !defined(GX_HARDWARE_MOUSE_SUPPORT)
32 static GX_UBYTE mouse_capture_memory[GX_MOUSE_MAX_RESOLUTION * GX_MOUSE_MAX_RESOLUTION] = { 0 };
33 #endif
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _gx_display_driver_8bit_palette_setup               PORTABLE C      */
39 /*                                                           6.1.3        */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Kenneth Maxwell, Microsoft Corporation                              */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    8-bit palettte color format display driver setup routine.           */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    display                               The display control block     */
51 /*    aux_data                              Driver-defined auxiliary data */
52 /*    toggle_function                       Driver-defined screen toggle  */
53 /*                                            function                    */
54 /*                                                                        */
55 /*  OUTPUT                                                                */
56 /*                                                                        */
57 /*    None                                                                */
58 /*                                                                        */
59 /*  CALLS                                                                 */
60 /*                                                                        */
61 /*    None                                                                */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    GUIX Internal Code                                                  */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
72 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*  12-31-2020     Kenneth Maxwell          Modified comment(s),          */
75 /*                                            added rotation angle        */
76 /*                                            initialization,             */
77 /*                                            resulting in version 6.1.3  */
78 /*                                                                        */
79 /**************************************************************************/
_gx_display_driver_8bit_palette_setup(GX_DISPLAY * display,VOID * aux_data,VOID (* toggle_function)(struct GX_CANVAS_STRUCT * canvas,GX_RECTANGLE * dirty_area))80 VOID     _gx_display_driver_8bit_palette_setup(GX_DISPLAY *display, VOID *aux_data,
81                                                VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,
82                                                                        GX_RECTANGLE *dirty_area))
83 {
84     /* Default initiate and complete function to null for general condition. */
85     display -> gx_display_driver_drawing_initiate              = GX_NULL;
86     display -> gx_display_driver_drawing_complete              = GX_NULL;
87 
88 #if defined(GX_MOUSE_SUPPORT)
89 #if defined(GX_HARDWARE_MOUSE_SUPPORT)
90     display -> gx_display_mouse_position_set                   = GX_NULL;
91     display -> gx_display_mouse_enable                         = GX_NULL;
92 #else
93     display -> gx_display_mouse.gx_mouse_capture_memory        = (GX_UBYTE *)mouse_capture_memory;
94     display -> gx_display_mouse.gx_mouse_status                = 0;
95 
96     display -> gx_display_mouse.gx_mouse_position.gx_point_x   = display -> gx_display_width / 2;
97     display -> gx_display_mouse.gx_mouse_position.gx_point_y   = display -> gx_display_height / 2;
98 
99     /* these functions are specific to the display color format, and will be NULL for hardware mouse */
100     display -> gx_display_mouse_capture                        = _gx_display_driver_8bpp_mouse_capture;
101     display -> gx_display_mouse_restore                        = _gx_display_driver_8bpp_mouse_restore;
102     display -> gx_display_mouse_draw                           = _gx_display_driver_generic_mouse_draw;
103     display -> gx_display_driver_drawing_initiate              = _gx_display_driver_generic_drawing_initiate;
104     display -> gx_display_driver_drawing_complete              = _gx_display_driver_generic_drawing_complete;
105     display -> gx_display_mouse_position_set                   = _gx_display_driver_generic_mouse_position_set;
106     display -> gx_display_mouse_enable                         = _gx_display_driver_generic_mouse_enable;
107 #endif
108 
109     /* these functions are generic, same for every color depth, but will be overridden for hardware mouse */
110     display -> gx_display_mouse.gx_mouse_cursor_info           = GX_NULL;
111     display -> gx_display_mouse_define                         = _gx_display_driver_generic_mouse_define;
112 #endif
113 
114     display -> gx_display_rotation_angle                       = 0;
115     display -> gx_display_driver_data                          = (VOID *)aux_data;
116     display -> gx_display_accelerator                          = GX_NULL;
117     display -> gx_display_layer_services                       = GX_NULL;
118     display -> gx_display_driver_callback_assign               = GX_NULL;
119 
120     display -> gx_display_color_format                         = GX_COLOR_FORMAT_8BIT_PALETTE;
121     display -> gx_display_driver_canvas_copy                   = _gx_display_driver_8bpp_canvas_copy;
122     display -> gx_display_driver_simple_line_draw              = _gx_display_driver_8bpp_simple_line_draw;
123     display -> gx_display_driver_horizontal_line_draw          = _gx_display_driver_8bpp_horizontal_line_draw;
124     display -> gx_display_driver_vertical_line_draw            = _gx_display_driver_8bpp_vertical_line_draw;
125     display -> gx_display_driver_horizontal_pattern_line_draw  = _gx_display_driver_8bpp_horizontal_pattern_line_draw;
126     display -> gx_display_driver_horizontal_pixelmap_line_draw = _gx_display_driver_8bpp_horizontal_pixelmap_line_draw;
127     display -> gx_display_driver_vertical_pattern_line_draw    = _gx_display_driver_8bpp_vertical_pattern_line_draw;
128     display -> gx_display_driver_pixel_write                   = _gx_display_driver_8bpp_pixel_write;
129     display -> gx_display_driver_block_move                    = _gx_display_driver_8bpp_block_move;
130 
131     display -> gx_display_driver_native_color_get              = _gx_display_driver_8bit_palette_native_color_get;
132     display -> gx_display_driver_row_pitch_get                 = _gx_display_driver_8bpp_row_pitch_get;
133     display -> gx_display_driver_pixelmap_draw                 = _gx_display_driver_8bpp_pixelmap_draw;
134     display -> gx_display_driver_pixelmap_rotate               = _gx_display_driver_8bpp_pixelmap_rotate;
135     display -> gx_display_driver_alphamap_draw                 = GX_NULL;
136     display -> gx_display_driver_simple_wide_line_draw         = _gx_display_driver_generic_simple_wide_line_draw;
137     display -> gx_display_driver_polygon_draw                  = _gx_display_driver_generic_polygon_draw;
138     display -> gx_display_driver_polygon_fill                  = _gx_display_driver_generic_polygon_fill;
139 
140     display -> gx_display_driver_anti_aliased_line_draw        = GX_NULL;
141     display -> gx_display_driver_anti_aliased_wide_line_draw   = GX_NULL;
142 
143 #if defined(GX_ARC_DRAWING_SUPPORT)
144     display -> gx_display_driver_anti_aliased_circle_draw      = GX_NULL;
145     display -> gx_display_driver_anti_aliased_ellipse_draw     = GX_NULL;
146     display -> gx_display_driver_circle_draw                   = _gx_display_driver_generic_circle_draw;
147     display -> gx_display_driver_circle_fill                   = _gx_display_driver_generic_circle_fill;
148     display -> gx_display_driver_pie_fill                      = _gx_display_driver_generic_pie_fill;
149     display -> gx_display_driver_anti_aliased_arc_draw         = GX_NULL;
150     display -> gx_display_driver_arc_draw                      = _gx_display_driver_generic_arc_draw;
151     display -> gx_display_driver_arc_fill                      = _gx_display_driver_generic_arc_fill;
152     display -> gx_display_driver_ellipse_draw                  = _gx_display_driver_generic_ellipse_draw;
153     display -> gx_display_driver_ellipse_fill                  = _gx_display_driver_generic_ellipse_fill;
154     display -> gx_display_driver_anti_aliased_wide_circle_draw = GX_NULL;
155     display -> gx_display_driver_wide_circle_draw              = _gx_display_driver_generic_wide_circle_draw;
156     display -> gx_display_driver_anti_aliased_wide_ellipse_draw= GX_NULL;
157     display -> gx_display_driver_wide_ellipse_draw             = _gx_display_driver_generic_wide_ellipse_draw;
158     display -> gx_display_driver_anti_aliased_wide_arc_draw    = GX_NULL;
159     display -> gx_display_driver_wide_arc_draw                 = _gx_display_driver_generic_wide_arc_draw;
160 #endif
161 
162     display -> gx_display_driver_palette_set                   = GX_NULL;
163     display -> gx_display_driver_buffer_toggle                 = toggle_function;
164 
165     display -> gx_display_driver_canvas_blend                  = GX_NULL;
166     display -> gx_display_driver_pixel_blend                   = GX_NULL;
167     display -> gx_display_driver_pixelmap_blend                = GX_NULL;
168 
169 #if(GX_PALETTE_MODE_AA_TEXT_COLORS == 8)
170     display -> gx_display_driver_4bit_glyph_draw               = _gx_display_driver_8bpp_glyph_3bit_draw;
171 #else
172     display -> gx_display_driver_4bit_glyph_draw               = _gx_display_driver_8bpp_glyph_4bit_draw;
173 #endif
174     display -> gx_display_driver_1bit_glyph_draw               = _gx_display_driver_8bpp_glyph_1bit_draw;
175 
176 #if defined(GX_SOFTWARE_DECODER_SUPPORT)
177     display -> gx_display_driver_jpeg_draw                     = GX_NULL;
178     display -> gx_display_driver_png_draw                      = GX_NULL;
179 #endif
180 }
181 
182