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 30 /**************************************************************************/ 31 /* */ 32 /* FUNCTION RELEASE */ 33 /* */ 34 /* _gx_display_driver_1bpp_mouse_capture PORTABLE C */ 35 /* 6.1 */ 36 /* AUTHOR */ 37 /* */ 38 /* Kenneth Maxwell, Microsoft Corporation */ 39 /* */ 40 /* DESCRIPTION */ 41 /* */ 42 /* This service captures canvas memory under mouse position. */ 43 /* */ 44 /* INPUT */ 45 /* */ 46 /* display Display control block */ 47 /* */ 48 /* OUTPUT */ 49 /* */ 50 /* CALLS */ 51 /* */ 52 /* */ 53 /* CALLED BY */ 54 /* */ 55 /* GUIX Internal Code */ 56 /* */ 57 /* RELEASE HISTORY */ 58 /* */ 59 /* DATE NAME DESCRIPTION */ 60 /* */ 61 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 62 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 63 /* resulting in version 6.1 */ 64 /* */ 65 /**************************************************************************/ 66 #if defined(GX_MOUSE_SUPPORT) 67 #if !defined(GX_HARDWARE_MOUSE_SUPPORT) _gx_display_driver_1bpp_mouse_capture(GX_DISPLAY * display)68VOID _gx_display_driver_1bpp_mouse_capture(GX_DISPLAY *display) 69 { 70 INT width; 71 INT height; 72 INT row; 73 INT column; 74 GX_UBYTE *put; 75 GX_UBYTE *putrow; 76 GX_UBYTE *getrow; 77 GX_UBYTE *get; 78 GX_PIXELMAP *map; 79 GX_RESOURCE_ID image_id; 80 GX_RECTANGLE mouse_rect; 81 GX_UBYTE getmask; 82 GX_UBYTE putmask; 83 GX_CANVAS *canvas; 84 85 if (display -> gx_display_mouse.gx_mouse_capture_memory) 86 { 87 if (display -> gx_display_mouse.gx_mouse_cursor_info) 88 { 89 canvas = display -> gx_display_mouse.gx_mouse_canvas; 90 image_id = display -> gx_display_mouse.gx_mouse_cursor_info -> gx_mouse_cursor_image_id; 91 92 if (image_id && image_id < display -> gx_display_pixelmap_table_size) 93 { 94 map = display -> gx_display_pixelmap_table[image_id]; 95 96 mouse_rect.gx_rectangle_left = display -> gx_display_mouse.gx_mouse_position.gx_point_x; 97 mouse_rect.gx_rectangle_top = display -> gx_display_mouse.gx_mouse_position.gx_point_y; 98 mouse_rect.gx_rectangle_left = (GX_VALUE)(mouse_rect.gx_rectangle_left - display -> gx_display_mouse.gx_mouse_cursor_info -> gx_mouse_cursor_hotspot_x); 99 mouse_rect.gx_rectangle_top = (GX_VALUE)(mouse_rect.gx_rectangle_top - display -> gx_display_mouse.gx_mouse_cursor_info -> gx_mouse_cursor_hotspot_y); 100 101 mouse_rect.gx_rectangle_right = (GX_VALUE)(mouse_rect.gx_rectangle_left + map -> gx_pixelmap_width - 1); 102 mouse_rect.gx_rectangle_bottom = (GX_VALUE)(mouse_rect.gx_rectangle_top + map -> gx_pixelmap_height - 1); 103 104 if (mouse_rect.gx_rectangle_left < 0) 105 { 106 mouse_rect.gx_rectangle_left = 0; 107 } 108 if (mouse_rect.gx_rectangle_top < 0) 109 { 110 mouse_rect.gx_rectangle_top = 0; 111 } 112 if (mouse_rect.gx_rectangle_right >= canvas -> gx_canvas_x_resolution) 113 { 114 mouse_rect.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1); 115 } 116 if (mouse_rect.gx_rectangle_bottom >= canvas -> gx_canvas_y_resolution) 117 { 118 mouse_rect.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1); 119 } 120 width = mouse_rect.gx_rectangle_right - mouse_rect.gx_rectangle_left + 1; 121 height = mouse_rect.gx_rectangle_bottom - mouse_rect.gx_rectangle_top + 1; 122 } 123 else 124 { 125 width = height = 0; 126 } 127 128 if (width > 0 && height > 0) 129 { 130 display -> gx_display_mouse.gx_mouse_rect = mouse_rect; 131 132 getrow = (GX_UBYTE *)canvas -> gx_canvas_memory; 133 getrow += ((canvas -> gx_canvas_x_resolution + 7) >> 3) * mouse_rect.gx_rectangle_top; 134 getrow += mouse_rect.gx_rectangle_left >> 3; 135 putrow = (GX_UBYTE *)display -> gx_display_mouse.gx_mouse_capture_memory; 136 137 for (row = 0; row < height; row++) 138 { 139 get = getrow; 140 put = putrow; 141 142 getmask = (GX_UBYTE)(((GX_UBYTE)0x80) >> (mouse_rect.gx_rectangle_left & 0x07)); 143 putmask = 0x80; 144 145 for (column = 0; column < width; column++) 146 { 147 if ((*get) & getmask) 148 { 149 *put |= putmask; 150 } 151 else 152 { 153 *put = (GX_UBYTE)((*put) & (~putmask)); 154 } 155 getmask >>= 1; 156 putmask >>= 1; 157 if (!getmask) 158 { 159 get++; 160 getmask = 0x80; 161 } 162 if (!putmask) 163 { 164 put++; 165 putmask = 0x80; 166 } 167 } 168 getrow += (canvas -> gx_canvas_x_resolution + 7) >> 3; 169 putrow += (width + 7) >> 3; 170 } 171 } 172 else 173 { 174 display -> gx_display_mouse.gx_mouse_rect.gx_rectangle_top = 0; 175 display -> gx_display_mouse.gx_mouse_rect.gx_rectangle_bottom = -1; 176 display -> gx_display_mouse.gx_mouse_rect.gx_rectangle_left = 0; 177 display -> gx_display_mouse.gx_mouse_rect.gx_rectangle_right = -1; 178 } 179 } 180 } 181 } 182 #endif 183 #endif 184 185