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