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 /**   Dispaly Management (Dispaly)                                        */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_display.h"
29 #include "gx_canvas.h"
30 #include "gx_system.h"
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_display_driver_generic_mouse_draw               PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This service draws the mouse image for software mouse.              */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    display                               Display control block         */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*  CALLS                                                                 */
53 /*                                                                        */
54 /*                                                                        */
55 /*  CALLED BY                                                             */
56 /*                                                                        */
57 /*    Application Code                                                    */
58 /*                                                                        */
59 /*  RELEASE HISTORY                                                       */
60 /*                                                                        */
61 /*    DATE              NAME                      DESCRIPTION             */
62 /*                                                                        */
63 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
64 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
65 /*                                            resulting in version 6.1    */
66 /*                                                                        */
67 /**************************************************************************/
68 #if defined(GX_MOUSE_SUPPORT)
69 #if !defined(GX_HARDWARE_MOUSE_SUPPORT)
_gx_display_driver_generic_mouse_draw(GX_DISPLAY * display)70 VOID _gx_display_driver_generic_mouse_draw(GX_DISPLAY *display)
71 {
72 GX_DRAW_CONTEXT  mouse_context;
73 GX_DRAW_CONTEXT *old_context;
74 GX_PIXELMAP     *map;
75 GX_VALUE         left;
76 GX_VALUE         top;
77 GX_RESOURCE_ID   image_id;
78 GX_CANVAS       *canvas;
79 
80     if(display -> gx_display_mouse.gx_mouse_cursor_info)
81     {
82         image_id = display -> gx_display_mouse.gx_mouse_cursor_info -> gx_mouse_cursor_image_id;
83 
84         if (image_id && image_id < display -> gx_display_pixelmap_table_size)
85         {
86             canvas = display -> gx_display_mouse.gx_mouse_canvas;
87             left = display -> gx_display_mouse.gx_mouse_position.gx_point_x;
88             top = display -> gx_display_mouse.gx_mouse_position.gx_point_y;
89             left = (GX_VALUE)(left - display -> gx_display_mouse.gx_mouse_cursor_info -> gx_mouse_cursor_hotspot_x);
90             top = (GX_VALUE)(top - display -> gx_display_mouse.gx_mouse_cursor_info -> gx_mouse_cursor_hotspot_y);
91             map = display -> gx_display_pixelmap_table[image_id];
92 
93             old_context = _gx_system_current_draw_context;
94 
95             // set up draw context clip area
96             mouse_context.gx_draw_context_dirty = display -> gx_display_mouse.gx_mouse_rect;
97 
98             // set up draw context view
99             mouse_context.gx_draw_context_simple_view.gx_view_next = NULL;
100             mouse_context.gx_draw_context_simple_view.gx_view_rectangle = display -> gx_display_mouse.gx_mouse_rect;
101             mouse_context.gx_draw_context_view_head = &mouse_context.gx_draw_context_simple_view;
102 
103             mouse_context.gx_draw_context_canvas = canvas;
104             /* Mouse pixelmap should never been blend. */
105             mouse_context.gx_draw_context_brush.gx_brush_alpha = 0xff;
106             mouse_context.gx_draw_context_display = display;
107             mouse_context.gx_draw_context_memory = canvas -> gx_canvas_memory;
108             mouse_context.gx_draw_context_pitch = canvas -> gx_canvas_x_resolution;
109 
110             _gx_system_current_draw_context = &mouse_context;
111             _gx_canvas_pixelmap_draw(left, top, map);
112 
113             _gx_system_current_draw_context = old_context;
114             display -> gx_display_mouse.gx_mouse_status |= GX_MOUSE_VISIBLE;
115         }
116     }
117 }
118 
119 #endif
120 #endif
121 
122