A cursor acquisition and rendering method, device and medium
By establishing a semantic-level cursor state caching structure and multi-level differential update verification, combined with pixel statistics and hidden detection, we have achieved low resource consumption and high adaptability cursor acquisition and rendering, solving the problems of resource waste and insufficient adaptability in existing technologies and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI ZULE INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2026-03-05
- Publication Date
- 2026-07-10
AI Technical Summary
Existing cursor acquisition and rendering solutions lack an effective state memory mechanism, resulting in high resource consumption, inaccurate cursor positioning, abnormal cross-screen rendering, poor compatibility with different cursor formats, and inability to recognize application-hidden cursors, thus affecting user experience.
A semantic-level cursor state caching structure is established. Through multi-level differential update verification, rendering synchronous pixel statistics, hidden detection, and cross-screen rendering, cursor acquisition and rendering with low resource consumption and accurate adaptation to multiple scenarios are achieved.
It reduces CPU and memory resource consumption, improves the quality of cursor capture and rendering and interactive experience, solves the problems of resource waste and insufficient adaptability in traditional technologies, and ensures the accuracy and consistency of cursor rendering.
Smart Images

Figure CN122363787A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of graphics processing technology, and in particular to a cursor acquisition and rendering method, device and medium. Background Technology
[0002] With the rapid development of real-time screen interaction scenarios such as remote desktop, cloud gaming, screen sharing, and live streaming, the cursor, as a carrier of human-computer interaction, has become a key factor affecting user experience in terms of the completeness, accuracy, and resource consumption efficiency of its acquisition and rendering.
[0003] In related technologies, computer graphics processing systems lack effective cursor state memory mechanisms in their design. The need to repeatedly collect all cursor information between consecutive frames leads to excessive CPU and memory resource consumption, making it difficult to adapt to the real-time acquisition needs of low-configuration terminals. In multi-monitor cross-screen scenarios, cursor positioning is prone to errors, often resulting in rendering anomalies, cursor flickering, or even disappearance due to inaccurate coordinate transformations or ambiguous attribution determinations. Different cursor formats (monochrome, color, with alpha channel, mask-defined) have poor compatibility, requiring the development of specific processing logic, resulting in insufficient system scalability. In scenarios where applications actively hide the system cursor and draw custom cursors, existing technologies cannot accurately identify the hidden state, easily leading to the problem of double cursor overlay. Furthermore, the separation of pixel statistics and rendering processes in existing technologies adds extra computational overhead and reduces processing efficiency. Summary of the Invention
[0004] This application provides a cursor acquisition and rendering method, device, and medium to build a cache, perform differential update verification, synchronize pixel statistics during rendering, detect hidden objects and match handles if they are not hidden, perform coordinate transformation calibration, and perform cross-screen rendering. This achieves low resource consumption, accurate adaptation to multiple scenarios, and improves the quality of cursor acquisition and rendering as well as the interactive experience.
[0005] In a first aspect, embodiments of this application provide a cursor acquisition and rendering method, the method comprising:
[0006] Establish a cursor state cache structure, which remains valid throughout the acquisition session; The frame data in the session is obtained through the desktop copy interface, and multi-level differential update verification processing is performed on the frame data based on the cursor state cache structure. The cursor image after the multi-level differential update and verification process is rendered. During the rendering process, the pixel feature statistical processing of different types of pixels in the cursor image is completed simultaneously. Based on the results of the pixel feature statistical processing, and combined with the preset multi-dimensional detection rules, the cursor image hiding detection and determination are performed to determine whether the cursor image is hidden by the application. If it is determined that the cursor image is not hidden, the target display is located by matching the display handle identifier, and the virtual screen coordinates of the cursor image are converted into relative coordinates of the target display. The rendering position is then calibrated, and cross-screen rendering of the cursor image is completed based on the rendering position.
[0007] Furthermore, the establishment of the cursor state cache structure includes: The cursor state cache structure is created during system initialization. The cursor state cache structure includes the virtual screen absolute coordinates of the cursor image, the display relative coordinates, the display handle identifier where the cursor image is located, the display index, the cursor image shape identifier hash value, the cursor image hotspot coordinate offset, and the cursor image update timestamp. The cursor state cache structure is a semantic-level storage. The cursor state cache structure is used to distinguish the update types of the cursor image's position change, shape change, and cross-screen movement state. The cursor state cache structure updates the corresponding cache fields when the corresponding state of the cursor image changes.
[0008] Furthermore, the step of performing multi-level differential update processing on the frame data based on the cursor state cache structure includes: The cursor image update timestamp of the frame data returned by the desktop copy interface is compared with the timestamp of the cursor image cached in the cursor state cache structure. If the timestamp comparison is consistent, all cursor cache information in the cursor state cache structure is reused. If the timestamp verification comparison is inconsistent, the current position coordinates of the cursor image in the frame data are obtained and the position coordinates of the cursor image cached in the cursor state cache structure are compared. If the position coordinate verification comparison is consistent, the cursor position information in the cursor state cache structure is reused. If the position coordinates of the cursor image have not changed and the shape of the cursor image has changed, the cursor image timestamp and cursor image shape information in the cursor state cache structure are updated. If the position coordinate verification comparison is inconsistent, the display handle identifier of the current display of the cursor image in the frame data is compared with the display handle identifier cached in the cursor state cache structure. If the display handle identifier verification comparison is consistent, the display information in the cursor state cache structure is reused, the relative coordinates of the cursor image relative to the display are recalculated, and the virtual screen absolute coordinates, display relative coordinates, and timestamp fields of the cursor image in the cursor state cache structure are updated. If the display handle identifier verification and comparison are inconsistent, the new display information acquisition, coordinate transformation and display index update process will be executed.
[0009] Furthermore, the rendering process of the cursor image after the multi-level differential update and verification processing includes, during the rendering process, synchronously performing pixel feature statistical processing on different types of pixels in the cursor image, including: Identify the cursor format type of the cursor image in the frame data, including mask-defined cursors and ARGB format cursors; Pixel classification statistics are performed based on the cursor format type. In the same traversal loop that renders the cursor image, the pixel type is counted according to the classification rules corresponding to the cursor format type. The step of classifying pixel types according to the corresponding cursor format type includes: If it is a mask-defined cursor, pixel determination is performed based on the combination of AND and XOR mask bits, including: When the AND mask bit is 1 and the XOR mask bit is 0, it is determined to be a transparent pixel; When both the AND mask bit and the XOR mask bit are 0, the pixel is determined to be black. When the XOR mask bit is 1, all are determined to be valid color pixels; If the cursor is in ARGB format, pixel determination is performed based on the relationship between the Alpha channel value and the RGB value, including: When the alpha channel value is 0, it is determined to be the transparent pixel; If the Alpha channel value is greater than 0 and all RGB values are 0, it is determined to be a black pixel; If the Alpha channel value is greater than 0 and the RGB values are not all 0, it is determined to be a valid color pixel; The number of transparent pixels, black pixels, and effective color pixels are recorded synchronously, and the proportion of each type of pixel to the total number of pixels in the cursor image is calculated.
[0010] Further, the step of performing cursor image hiding detection and determination based on the result of the pixel feature statistical processing and in combination with preset multi-dimensional detection rules to determine whether the cursor image is hidden by the application includes: If the percentage of transparent pixels exceeds a preset full transparency threshold, the image is determined to be a hidden cursor image; if the percentage of transparent pixels does not exceed the preset full transparency threshold, the image is then judged according to the full black anomaly detection rule. In the all-black anomaly detection rule judgment, when the proportion of black pixels exceeds the preset all-black threshold and the number of effective color pixels is lower than the preset effective color pixel number threshold, the shape features of the cursor image are detected. If the aspect ratio of the cursor image does not conform to the preset aspect ratio range of the type cursor image, it is determined to be the hidden cursor image; otherwise, it enters the effective color pixel insufficient rule judgment. In the determination of insufficient effective color pixels, if the number of effective color pixels is lower than the preset effective color pixel threshold and the total number of pixels in the cursor image exceeds the preset total pixel threshold, then it is determined to be the hidden cursor image; otherwise, it is determined to be the visible cursor image.
[0011] Further, the step of matching and locating the target display by identifying the display handle, converting the virtual screen coordinates of the cursor image into relative coordinates of the target display, calibrating the rendering position, and completing cross-screen rendering of the cursor image based on the rendering position includes: Obtain the target display handle identifier and the display handle identifier where the cursor image is currently located. Determine whether the cursor image is within the current acquisition range by comparing the handle identifiers. The display handle identifier is reused from the cursor state cache structure or obtained through the display query interface. If the cursor image is within the acquisition range of the target display, obtain the position information of the target display on the virtual desktop, and convert the absolute virtual screen coordinates of the cursor image into relative coordinates relative to the upper left corner of the target display; Extract the hotspot coordinate offset of the cursor image stored in the cursor state cache structure, subtract the hotspot coordinate offset from the relative coordinate to obtain the calculation result, and determine the actual rendering start position of the cursor image based on the calculation result; Based on the actual rendering start position, the intersection of the rendering rectangle corresponding to the cursor image and the visible area rectangle of the target display is calculated by system boundary clipping. If the intersection is empty, rendering is skipped; if the intersection is not empty, the source region offset and target rendering position of the cursor image are calculated, and the cursor image pixels in the intersection area are rendered into the output image.
[0012] Furthermore, in the multi-level differential update verification, each level of verification is executed sequentially in order of increasing computational cost. When any level of the multi-level differential update verification passes, the data of the cursor state cache structure is reused and the subsequent update verification levels are terminated.
[0013] Furthermore, the method is compatible with all cursor format types, including monochrome cursors, colored cursors, colored cursors with an alpha channel, and cursors defined using a mask.
[0014] In a second aspect, embodiments of this application provide an electronic device, including: a memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the cursor acquisition and rendering method as described in the first aspect.
[0015] In a third aspect, embodiments of this application provide a storage medium for storing computer-executable instructions, which, when executed by a computer processor, are used to perform the cursor acquisition and rendering method as described in the first aspect.
[0016] This application's embodiments achieve significant technical effects through the synergy of various steps. A semantic-level cursor state caching structure is established, and multi-level differential update verification is performed. Verification is performed in ascending order of computational cost, and subsequent processes terminate upon successful verification. This reduces the number of system interface calls and the frequency of full data acquisition, thereby reducing CPU and memory resource consumption. Simultaneously, reusing cached data ensures the accuracy of cursor states, solving the resource waste problem caused by repetitive processing in traditional techniques. Pixel feature statistics are synchronously completed during rendering, avoiding secondary image traversal. Adaptability classification rules are designed for different cursor formats, not only reducing computational overhead but also achieving full compatibility with monochrome, color, alpha channel, and mask-defined cursors, improving the system's scalability and adaptability. Based on... Pixel statistics results are combined with multi-dimensional rules to determine hidden cursors. Through collaborative verification of rules such as full transparency threshold, full black anomaly, shape feature exclusion, and insufficient effective pixels, the system identifies scenarios where applications hide cursors, avoiding double cursor overlay and ensuring intuitive display. The system uses a display handle identifier to uniquely match and locate the target display. Combined with virtual coordinate to relative coordinate conversion, hotspot offset calibration, and boundary clipping, it solves the problems of cursor positioning deviation and rendering anomalies in multi-display cross-screen scenarios, ensuring that the cursor rendering position is consistent with the actual operation position. Because the precise processing in each preceding stage provides data support for subsequent processes, it ultimately achieves low-latency, high-quality, and widely compatible cursor acquisition and rendering, improving the user experience in real-time screen interaction scenarios such as remote desktops and cloud gaming. Attached Figure Description
[0017] Figure 1 This is a flowchart of a cursor acquisition and rendering method provided in an embodiment of this application; Figure 2 This is a flowchart illustrating the establishment of the cursor state cache structure provided in an embodiment of this application; Figure 3 This is a flowchart illustrating the multi-level differential update process for frame data provided in an embodiment of this application; Figure 4 This is a flowchart of cursor image rendering processing and pixel feature statistical processing provided in the embodiments of this application; Figure 5 This is a flowchart of the cursor image hiding detection and determination provided in the embodiments of this application; Figure 6 This is a flowchart of cross-screen rendering of a cursor image provided in an embodiment of this application; Figure 7 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but additional steps not included in the drawings may also be present. The above processes can correspond to methods, functions, procedures, subroutines, subroutines, etc.
[0019] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0020] The cursor acquisition and rendering method provided in this application establishes a semantic-level cursor state cache structure that is effective throughout the session. Combined with a differential update verification mechanism tiered by computational overhead, it reuses data from the cursor state cache structure, reducing invalid processing and system resource consumption. Pixel feature statistics are simultaneously performed during cursor image rendering, adapting to various cursor types such as mask-defined and ARGB formats. With multi-dimensional hiding detection rules, it accurately identifies scenarios where applications hide cursors, avoiding the problem of double cursor overlap. The method accurately matches and locates the target display using the display handle identifier, and combines coordinate transformation, hotspot calibration, and boundary clipping to achieve accurate rendering in multi-display cross-screen scenarios. This method does not rely on complex hardware; the core execution entity is an electronic device with data computing, processing, and storage capabilities, including personal computers, laptops, servers, tablets, and other terminal and server devices, making it widely adaptable.
[0021] Specifically, it can be applied to various real-time screen interaction scenarios such as remote desktop, cloud gaming, screen sharing, live streaming, and video conferencing: In remote desktop scenarios, it ensures accurate cursor synchronization and low-latency rendering when operating remotely; in cloud gaming scenarios, it ensures real-time response and visual consistency between the game cursor and operation commands; in live streaming and screen sharing scenarios, it avoids cursor flickering and rendering abnormalities, improving the audience's visual experience; and in video conferencing scenarios, it ensures clear presentation of the presenter's cursor operations.
[0022] The application scenarios listed above are merely illustrative examples. In practical applications, this method can also be extended to other scenarios requiring precise cursor acquisition and rendering, such as industrial monitoring screen interaction, intelligent cockpit display control, and remote medical screen operation. This application embodiment does not limit this application. Its core advantage lies in balancing low resource consumption, high adaptability, and rendering accuracy, effectively solving the pain points of traditional solutions such as high resource consumption, difficulty in adapting to multiple scenarios, inaccurate recognition of hidden cursors, and cross-screen rendering anomalies, thereby improving the smoothness of real-time screen interaction and user experience.
[0023] Figure 1 This is a flowchart of a cursor acquisition and rendering method provided in an embodiment of this application, such as... Figure 1 As shown, the cursor acquisition and rendering method specifically includes the following steps: Step 101: Establish a cursor state cache structure, which remains valid during the acquisition session.
[0024] The cursor state cache structure is a semantic-level storage structure created during system initialization. It remains valid throughout the entire acquisition session and stores information such as the absolute coordinates of the cursor on the virtual screen, the relative coordinates of the display, the display handle identifier, the display index, the shape identifier hash value, the hot spot coordinate offset, and the update timestamp. It is used to distinguish between cursor position changes, shape changes, and cross-screen movement states.
[0025] In one embodiment, the cursor state cache structure creation process is initiated during system initialization. This cursor state cache structure remains valid throughout the acquisition session and provides baseline data for differential update verification. Optionally, the virtual screen absolute coordinates are the absolute coordinates (x, y) of the cursor image on a virtual desktop composed of multiple monitors, covering the full size of the virtual desktop; the monitor relative coordinates are the coordinates (x', y') of the cursor image relative to the upper left corner of the monitor, used to quickly locate the cursor's position within the current monitor; the monitor handle identifier is a unique identifier for the monitor assigned by the operating system (such as the HMONITOR handle in Windows), used to accurately determine the monitor to which the cursor belongs; the monitor index is the sort index (0, 1, 2...) of the monitor in the system, used to assist in quickly finding monitor configuration information; the cursor shape identifier hash value is a 32-bit CRC hash value calculated based on the cursor image pixel data, used to quickly determine whether the cursor shape has changed; and the hotspot coordinate offset is the offset of the cursor hotspot relative to the upper left corner of the image. The cursor image is obtained directly from the operating system's cursor image interface; the update timestamp is the system timestamp of the last update of the cursor image state, used to determine whether the cursor state has changed.
[0026] In one embodiment, the cursor state cache structure is a semantic-level storage. Optionally, three update types—cursor position change, shape change, and cross-screen movement—are distinguished by field categories. The relevant fields are updated only when the corresponding state changes, avoiding the overhead of a full update. The cursor state cache structure is created when the acquisition session starts and destroyed when the session ends, maintaining data validity throughout and supporting inter-frame data reuse. Read and write operations are performed using memory alignment, are atomic, support concurrent access, and ensure data consistency.
[0027] Step 102: Obtain frame data from the session through the desktop copy interface, and perform multi-level differential update verification processing on the frame data based on the cursor state cache structure.
[0028] The multi-level differential update verification process is executed in ascending order of computational cost, including timestamp verification, location coordinate verification, and display handle identifier verification. Once any level of verification passes, the cached data is reused and subsequent verifications are terminated, reducing invalid data processing and system interface calls.
[0029] In one embodiment, after obtaining frame data via a desktop duplication interface (such as Windows' Desktop Duplication API), multi-level differential update verification is performed based on the cursor state cache structure to reduce invalid data processing. Optionally, after frame data acquisition is complete, cursor-related information (update timestamp, position coordinates, display handle identifier) is automatically extracted, and a multi-level verification process is initiated. The verification logic at each level includes: The first level (timestamp verification) compares the cursor image update timestamp in the frame data with the timestamp in the cursor state cache structure. If they match, it is determined that the cursor image state has not changed, all cursor state cache structure information is reused, and subsequent verification is terminated.
[0030] The second level (position coordinate verification) involves extracting the current position coordinates of the cursor image from the frame data and comparing them with the position coordinates in the cursor state cache structure. If they match, the position information is reused. If only the cursor image shape changes (determined by the shape identifier hash value), only the timestamp and shape information in the cursor state cache structure are updated, and subsequent verification is terminated.
[0031] The third level (monitor handle identifier verification) is used to extract the handle identifier of the current monitor where the cursor image is located if the position coordinates are inconsistent. It is then compared with the handle identifier in the cursor state cache structure. If they match, the monitor information is reused, the relative coordinates are recalculated, and the absolute coordinates, relative coordinates, and timestamp in the cursor state cache structure are updated.
[0032] Level 4 (Full Update): If the monitor handle identifiers are inconsistent, it is determined that the cursor image has moved across screens. The new monitor information acquisition, coordinate transformation, and monitor index update process are executed, and the cursor state cache structure is fully updated. Among them, the verification at each level is performed in order of increasing computational cost, with timestamp verification having the lowest cost, followed by position coordinate verification, monitor handle identifier verification having a slightly higher cost, and full update having the highest cost. An early termination mechanism is used to reduce invalid calculations.
[0033] Step 103: Render the cursor image after the multi-level differential update and verification process. During the rendering process, the pixel feature statistical processing of different types of pixels in the cursor image is completed simultaneously.
[0034] Among them, pixel feature statistics is a pixel classification and statistical operation that is executed synchronously when rendering the cursor image. It distinguishes transparent pixels, black pixels and effective color pixels according to the cursor image format type, records the number and proportion of each type of pixel, and provides data for hidden detection.
[0035] In one embodiment, the cursor image, after undergoing multi-level differential update verification, is rendered while pixel feature statistics are simultaneously performed, avoiding the overhead of secondary traversal. Optionally, the cursor image description information in the frame data is parsed to determine whether the cursor image format is mask-defined or ARGB format. Both formats cover all common cursor types (monochrome, color, with alpha channel, and mask-defined). Mask-defined cursors consist of AND and XOR masks, and the pixel type is defined by combining mask bits; each pixel of an ARGB format cursor contains an alpha channel (transparency) and RGB color values, directly defining the pixel display effect.
[0036] In one embodiment, within the same traversal loop of cursor image rendering, each pixel is classified and statistically analyzed according to the rules corresponding to its format type. This single traversal completes both rendering and statistical operations without additional computational overhead. Pixel classification rules include: For mask-defined cursors, AND mask bit 1 and XOR mask bit 0 → transparent pixels; AND mask bit 0 and XOR mask bit 0 → black pixels; AND mask bit 0 and XOR mask bit 1 → effective color pixels; AND mask bit 1 and XOR mask bit 1 → effective color pixels. For ARGB format cursors, Alpha channel value 0 → transparent pixels; Alpha channel value > 0 and all RGB values 0 → black pixels; Alpha channel value > 0 and not all RGB values 0 → effective color pixels. The number of transparent pixels, black pixels, and effective color pixels is recorded synchronously, and the proportion of each type of pixel to the total number of cursor pixels is calculated and stored in a temporary buffer for use in hidden detection.
[0037] Step 104: Based on the results of the pixel feature statistical processing and combined with the preset multi-dimensional detection rules, perform the cursor image hiding detection and determination to determine whether the cursor image is hidden by the application.
[0038] Among them, the multi-dimensional hiding detection rules are multi-level detection rules constructed based on pixel feature statistical results, including full transparency threshold detection, full black anomaly detection, and insufficient effective color pixels detection, which are used to determine whether the cursor image is hidden by the application.
[0039] In one embodiment, based on pixel feature statistics and a preset multi-dimensional detection rule, it is determined whether the cursor is hidden by the application. The preset threshold configuration includes: The default threshold for full transparency is 95% (configurable range 90%-99%). If the percentage of transparent pixels exceeds this threshold, the pixel is considered hidden. The default threshold for full black is 90% (configurable range 85%-95%). If the percentage of black pixels exceeds this threshold, an anomaly detection for full black is triggered. The default threshold for the number of effective colored pixels is 10 (configurable range 5-20). If the number of effective colored pixels is lower than this threshold, further judgment is triggered. The default threshold for the percentage of effective colored pixels is 5% (configurable range 3%-10%). If the percentage of effective colored pixels is lower than this threshold and the total number of pixels exceeds 64 (8×8), the pixel is considered hidden.
[0040] In the first level of detection (full transparency detection), if the proportion of transparent pixels exceeds the full transparency threshold, the cursor is directly determined to be hidden, and a hidden flag is set. In the second level of detection (full black anomaly detection), if the proportion of transparent pixels does not exceed the threshold, and the proportion of black pixels exceeds the full black threshold while the number of effective colored pixels is below the threshold, the cursor aspect ratio is checked; if the aspect ratio does not conform to the preset range (vertical I-shaped cursor 0.05-0.3, horizontal I-shaped cursor 3-20), it is determined to be hidden. In the third level of detection (insufficient effective pixels detection), if the full black anomaly detection is not triggered, and the number of effective colored pixels is below the threshold while the total number of pixels exceeds 64, it is determined to be hidden; otherwise, it is determined to be a visible cursor. For I-shaped cursors in text editing scenarios, aspect ratio and pixel distribution characteristics are used for exclusion to avoid false positives and ensure detection accuracy.
[0041] Step 105: If it is determined that the cursor image is not hidden, the target display is located by matching the display handle identifier, and the virtual screen coordinates of the cursor image are converted into the relative coordinates of the target display. The rendering position is then calibrated, and the cross-screen rendering of the cursor image is completed based on the rendering position.
[0042] The display handle identifier is a unique identifier assigned to each display by the operating system. It is used to accurately match and locate the display where the cursor is located, avoiding positioning errors caused by coordinate system overlap in multi-display scenarios. The hotspot coordinate offset is the coordinate offset of the point representing the actual click position in the cursor image relative to the top-left corner of the image. It is used to calibrate the cursor image rendering position to ensure that the click position is consistent with the visual position. Boundary clipping calculates the intersection of the cursor image rendering rectangle and the display's visible area rectangle, and only renders pixels within the intersection area to avoid rendering anomalies when part of the cursor image exceeds the screen boundary.
[0043] In one embodiment, if the cursor image is determined not to be hidden, the target monitor is located by matching the monitor handle identifier, completing coordinate transformation, hotspot calibration, and boundary clipping to achieve accurate cross-screen rendering. Optionally, during monitor matching and positioning, the handle identifier of the target monitor is obtained (reused from the cursor state cache structure or obtained through the monitor query interface), and compared with the handle identifier of the monitor where the cursor image is currently located to determine whether the cursor is within the current acquisition range. Handle identifier matching uses unique value comparison to avoid positioning errors caused by overlapping coordinate systems of multiple monitors, and is more accurate than traditional coordinate range judgment. If the cursor image is within the acquisition range, the position information of the target monitor on the virtual desktop (top-left corner coordinates) is obtained. , ), converting the cursor's virtual screen absolute coordinates (x, y) to relative coordinates ( , Extract the hotspot coordinate offsets from the cursor state cache structure. The actual rendering start position is obtained by subtracting the offset from the relative coordinates. , This ensures that the cursor image click position matches the visual position. Calculate the intersection of the cursor image rendering rectangle and the target display's visible area rectangle. If the intersection is empty, skip rendering; if the intersection is not empty, calculate the cursor image source area offset and the target rendering position, and only render pixels within the intersection area to the output image to avoid rendering anomalies caused by pixels outside the boundary.
[0044] This process optimizes the entire cursor image processing workflow through caching, verification, statistics, detection, and rendering design. The semantic-level cursor state caching structure and multi-level verification reduce unnecessary overhead, synchronous statistics reduce computational costs, and accurate hidden detection and cross-screen rendering ensure a better user experience, thereby improving the efficiency and accuracy of cursor image processing.
[0045] Figure 2 This is a flowchart illustrating the establishment of the cursor state cache structure provided in an embodiment of this application, as follows: Figure 2 As shown, the cursor acquisition and rendering method specifically includes the following steps: Step 201: Create the cursor state cache structure during system initialization. The cursor state cache structure includes the virtual screen absolute coordinates of the cursor image, the display relative coordinates, the display handle identifier where the cursor image is located, the display index, the cursor image shape identifier hash value, the cursor image hotspot coordinate offset, and the cursor image update timestamp. In one embodiment, during the system initialization phase (before the acquisition session starts), a cursor state cache structure is automatically created, specifying the definitions and storage formats of each field. Optionally, the cursor state cache structure is created using dynamic memory allocation, with the allocated address aligned to 64 bytes to ensure read / write efficiency; the structure size is fixed at 256 bytes, containing all core fields with no redundant data.
[0046] In one embodiment, field initialization includes: initializing coordinate fields (virtual screen absolute coordinates, monitor relative coordinates, hotspot coordinate offset) to (0, 0); initializing identifier fields (monitor handle identifier, monitor index) to 0, indicating that no monitor is associated; initializing shape identifier hash value to 0; and initializing update timestamp to system startup timestamp. Storage feature configuration sets the cursor state cache structure to read-only shared mode, allowing only the cursor processing thread to perform write operations, while other threads can only read, ensuring data security and consistency, and enabling a cache locking mechanism to avoid multi-threaded access conflicts.
[0047] Step 202: The cursor state cache structure is a semantic-level storage. The cursor state cache structure is used to distinguish the update type of the cursor image's position change, shape change, and cross-screen movement state. The cursor state cache structure updates the corresponding cache field when the corresponding state of the cursor image changes.
[0048] In one embodiment, after the cursor state cache structure is created, cursor image state data is stored according to semantic classification, and fields are dynamically updated based on the cursor change type. Optionally, the semantic classification mechanism divides the cached fields into four categories: position-related (virtual screen absolute coordinates, display relative coordinates), display-related (handle identifier, index), shape-related (shape identifier hash value), and auxiliary information (hotspot offset, timestamp), each corresponding to a cursor state change type. The dynamic update rules include: if only the position changes, the cursor image virtual screen absolute coordinates, display relative coordinates, and cursor image timestamp fields are updated, while the remaining fields remain unchanged; if only the shape changes, the cursor image shape identifier hash value and cursor image timestamp fields are updated, while the remaining fields remain unchanged; for cross-screen movement, the cursor image position-related fields, timestamp, and display-related fields are updated, while the shape-related and auxiliary information fields remain unchanged. All field update operations are executed through atomic operation functions to ensure the integrity of field updates in a multi-threaded environment and avoid logical errors caused by partial data updates.
[0049] The semantic-level caching structure enables fine-grained storage and dynamic updating of cursor image states, accurately updating fields according to the type of change, avoiding full processing, ensuring the cache is effective throughout the process and supporting concurrent access, providing a benchmark for differential verification, and reducing system resource consumption.
[0050] Figure 3 This is a flowchart illustrating the multi-level differential update process performed on frame data according to an embodiment of this application, such as... Figure 3 As shown, the cursor acquisition and rendering method specifically includes the following steps: Step 301: Perform a timestamp verification comparison between the cursor image update timestamp of the frame data returned by the desktop copy interface and the timestamp of the cursor image cached in the cursor state cache structure. If the timestamp verification comparison is consistent, then reuse all cursor cache information in the cursor state cache structure.
[0051] In one embodiment, the cursor image update timestamp in the frame data is obtained and compared with the timestamp in the cursor state cache structure. Optionally, the timestamp extraction is performed by extracting the cursor image update timestamp from the frame metadata returned by the desktop copy interface (maintained by the operating system and updated only when the cursor image state changes). The timestamp is in 64-bit integer format. If the extracted cursor image timestamp is the same as the timestamp in the cursor state cache structure, it is determined that the cursor image state has not changed. All cursor information (position, shape, display information, etc.) in the cursor state cache structure is directly reused, all subsequent verification processes are terminated, and the rendering stage begins. Timestamp verification requires only one 64-bit integer comparison operation, with minimal computational overhead and a low proportion of the single-frame processing time. The early termination mechanism reduces a large amount of unnecessary computation.
[0052] Step 302: If the timestamp verification comparison is inconsistent, the current position coordinates of the cursor image obtained from the frame data are compared with the position coordinates of the cursor image cached in the cursor state cache structure. If the position coordinate verification comparison is consistent, the cursor position information in the cursor state cache structure is reused. If the position coordinates of the cursor image have not changed, but the shape of the cursor image has changed, the cursor image timestamp and cursor image shape information in the cursor state cache structure are updated.
[0053] In one embodiment, if the cursor image timestamp verification is inconsistent, position coordinate verification is initiated. The current virtual screen absolute coordinates (x, y) of the cursor image are extracted from the frame data, with pixel-level precision. The extracted coordinates are compared component-by-component with the virtual screen absolute coordinates in the cursor state cache structure. If both the x and y components are consistent, the cursor position is determined to be unchanged, and the position-related information in the cursor state cache structure is reused. The shape identifier hash value of the current cursor image is calculated and compared with the shape identifier hash value in the cursor state cache structure. If they are inconsistent, it is determined that only the cursor image shape has changed, and the cursor image shape identifier hash value and timestamp field in the cursor state cache structure are updated, while the remaining fields remain unchanged.
[0054] Step 303: If the position coordinate verification comparison is inconsistent, the display handle identifier of the current display of the cursor image in the frame data is obtained and the display handle identifier cached in the cursor state cache structure is compared with the display handle identifier. If the display handle identifier verification comparison is consistent, the display information in the cursor state cache structure is reused, the relative coordinates of the cursor image with respect to the display are recalculated, and the virtual screen absolute coordinates, display relative coordinates and timestamp fields of the cursor image in the cursor state cache structure are updated.
[0055] In one embodiment, if the position coordinates are inconsistent, a monitor handle identifier verification is initiated. Optionally, the monitor handle identifier is obtained based on the current position coordinates of the cursor image through the system monitor query interface (such as the MonitorFromPoint function in Windows). The extracted monitor handle identifier is compared with the monitor handle identifier in the cursor state cache structure. If they match, it is determined that the cursor image is still moving within the same monitor, and the monitor information (monitor index, position information) in the cursor state cache structure is reused. Based on the new position coordinates of the cursor image and the monitor boundary information, the monitor relative coordinates (x'=x - x-coordinate of the top left corner of the monitor, y'=y - y-coordinate of the top left corner of the monitor) are recalculated, and the virtual screen absolute coordinates, monitor relative coordinates, and timestamp fields in the cursor state cache structure are updated.
[0056] Step 304: If the display handle identifier verification and comparison are inconsistent, then execute the new display information acquisition, coordinate transformation and display index update process.
[0057] In one embodiment, if the display handle identifier verification is inconsistent, it is determined that the cursor image has moved across screens, and a full update process is executed. Optionally, the system display configuration interface is called to obtain detailed information about the new display, including the virtual coordinates of the top-left corner, width and height dimensions, display index, pixel density, etc. The absolute coordinates of the cursor image on the virtual screen are converted to relative coordinates on the new display, calculated as relative coordinates = absolute coordinates - virtual coordinates of the top-left corner of the new display. The display handle identifier, display index, absolute coordinates of the virtual screen, relative coordinates of the display, and timestamp fields in the cursor state cache structure are updated, while the cursor image shape identifier hash value and hotspot coordinate offset remain unchanged (cross-screen movement does not change the cursor image shape and hotspots).
[0058] The system performs hierarchical verification based on computational overhead, comparing timestamps, coordinates, and handle identifiers sequentially. Invalid processes are terminated early, maximizing the reuse of cursor state cache structure data, reducing system interface calls and full data acquisition, shortening single-frame processing time, and reducing CPU and memory usage.
[0059] Figure 4 This is a flowchart of the cursor image rendering process and pixel feature statistical processing provided in the embodiments of this application, such as... Figure 4 As shown, the cursor acquisition and rendering method specifically includes the following steps: Step 401: Identify the cursor format type of the cursor image in the frame data, including mask-defined cursors and ARGB format cursors.
[0060] In one embodiment, the format of the cursor image after multi-level differential update verification is identified. Optionally, a format identifier field is extracted from the cursor image description data to determine whether the cursor is in mask-defined or ARGB format. Mask-defined cursors are compatible with traditional monochrome and dual-color cursors, consisting of an AND mask (controlling pixel transparency) and an XOR mask (controlling pixel color), with the mask data stored separately from the cursor image data. ARGB format cursors are compatible with modern color cursor images, supporting semi-transparent effects. Each pixel occupies 4 bytes (1 byte for the alpha channel and 1 byte each for RGB), directly storing the pixel's transparency and color information. Both formats cover cursor image types supported by all mainstream operating systems, and improved system compatibility is achieved through a unified interface adaptation process.
[0061] Step 402: Perform pixel classification statistics based on the cursor format type. In the same traversal loop that renders the cursor image, the pixel type is counted according to the classification rules corresponding to the cursor format type.
[0062] In one embodiment, cursor image rendering and pixel feature statistics are completed within the same traversal loop. Optionally, for mask-defined cursors, pixel attributes are defined using a combination of AND and XOR mask bits. Within the same traversal loop, the rendering calculation and statistical increment for each pixel are completed synchronously. First, the width (w) and height (h) of the cursor image are obtained, and the total number of pixels (w×h) is calculated. Three pixel statistics counters are initialized: the number of transparent pixels (initial value 0), the number of black pixels (initial value 0), and the number of effective colored pixels (initial value 0). Simultaneously, the AND mask bit array and XOR mask bit array of the cursor image are read (mask data is stored byte by byte, with 1 byte containing 8 pixel mask bits), and a rendering buffer is allocated (used to store the final rendered ARGB color value of each pixel).
[0063] Iterate through each pixel of the cursor image in row-major order (from row 0, column 0 to row h-1, column w-1), and perform the following operations on a single pixel: Based on the current pixel's index position, calculate its corresponding byte index (pixel index ÷ 8) and bit offset (pixel index % 8) in the AND and XOR mask bit arrays, and extract the pixel's AND mask bits (value 0 or 1) and XOR mask bits (value 0 or 1) through bit operations.
[0064] If the AND mask bit is 1 and the XOR mask bit is 0, it is determined to be a transparent pixel, and the transparent pixel count counter is incremented by 1; if the AND mask bit is 0 and the XOR mask bit is 0, it is determined to be a black pixel, and the black pixel count counter is incremented by 1; if the AND mask bit is 0 and the XOR mask bit is 1, or if the AND mask bit is 1 and the XOR mask bit is 1, it is determined to be a valid color pixel, and the valid color pixel count counter is incremented by 1.
[0065] After the statistical operation is completed, the final rendered color of the pixel is calculated based on the mask bit combination and written to the rendering buffer. Transparent pixels are directly set to fully transparent color (ARGB value 0x00000000, Alpha channel = 0, RGB channels are all 0); black pixels are set to pure black opaque (ARGB value 0xFF000000, Alpha channel = 255, RGB channels are all 0); the final value of the effective colored pixels is calculated by combining the background pixel color. First, the ARGB value of the background pixel at the current pixel position is obtained. The R, G, and B channel values of the background pixel are XORed with the XOR mask bits (1 corresponds to 255, 0 corresponds to 0). The Alpha channel is adjusted according to the AND mask bits (when AND=0, Alpha=255, completely opaque; when AND=1, the Alpha value of the background pixel is used). Finally, the ARGB rendered value of the pixel is generated and written to the buffer. After all pixels have been traversed, the proportions of transparent pixels, black pixels, and effective colored pixels to the total number of pixels are calculated based on the values of the three counters (proportion = corresponding counter value ÷ total number of pixels). The complete statistical results of the number of pixels and proportions are stored in a temporary buffer for use in cursor image hiding detection.
[0066] In one embodiment, each pixel of the ARGB format cursor directly stores the values of four channels: Alpha (transparency), R (red), G (green), and B (blue) (each channel has a value of 0-255). Pixel type statistics and color blending are performed synchronously within the same traversal loop. Similarly, the cursor width (w), height (h), and total number of pixels are first obtained, and three statistical counters are initialized (all with an initial value of 0). The ARGB pixel array of the cursor image is read (each element is the complete ARGB value of a pixel), a rendering buffer is allocated (to store the final color after blending the background), and a pixel buffer for the background image is prepared (to read the background color at the corresponding position).
[0067] Traverse each pixel in row-major order and perform the following synchronization operations: Read the complete value of the current pixel from the ARGB pixel array, and split the values of each channel through bitwise operations, where Alpha = (ARGB value >> 24) & 0xFF, R = (ARGB value >> 16) & 0xFF, G = (ARGB value >> 8) & 0xFF, and B = ARGB value & 0xFF; If the Alpha channel value is 0, it is determined to be a transparent pixel, and the transparent pixel count counter is incremented by 1; if the Alpha channel value is >0 and R=0, G=0, B=0, it is determined to be a black pixel, and the black pixel count counter is incremented by 1; if the Alpha channel value is >0 and R, G, B are not all 0 (at least one channel value is >0), it is determined to be a valid color pixel, and the valid color pixel count counter is incremented by 1.
[0068] After the statistical operation is completed, the final rendering value is calculated by combining the alpha channel and the background color, and written to the buffer. Transparent pixels directly use the ARGB value of the background pixels (no mixing is required, the cursor pixel is completely transparent); the black pixels are calculated to mix the colors. The R, G, and B channel values of the background pixels are mixed with the R, G, and B (all 0) of the black cursor pixels according to the alpha ratio. The formula is: Final channel value = Background channel value × (1 - Alpha / 255) + 0 × (Alpha / 255). The alpha channel retains the alpha value of the cursor pixels, and the final mixed ARGB value is generated; the effective color pixels are mixed with the background pixels according to the transparency ratio of the alpha channel. The formula is: Final R = Background R × (1 - Alpha / 255) + Cursor image R × (Alpha / 255). The G and B channels are handled similarly. The alpha channel takes the alpha value of the cursor pixels, and the final mixed ARGB value is generated and written to the rendering buffer. After all pixels have been traversed, the proportion of each type of pixel in the total number of pixels is calculated. The statistical results of the number of pixels (transparent / black / effective color) and the corresponding proportions are stored in a temporary buffer for use by cursor hiding detection.
[0069] Rendering and statistics are executed simultaneously, completing both operations in a single traversal, avoiding the overhead of secondary traversal, adapting to two core cursor formats, and providing accurate classification statistics. This not only improves processing efficiency but also provides data support for hidden detection, balancing performance and accuracy.
[0070] Figure 5 This is a flowchart of the cursor image hiding detection and determination provided in the embodiments of this application, such as... Figure 5 As shown, the cursor acquisition and rendering method specifically includes the following steps: Step 501: If the proportion of transparent pixels exceeds the preset full transparency threshold, the image is determined to be a hidden cursor image; if the proportion of transparent pixels does not exceed the preset full transparency threshold, the image is then judged according to the full black anomaly detection rule.
[0071] In one embodiment, a first layer of hidden detection is performed based on pixel feature statistics. Optionally, the proportion of transparent pixels to total pixels is obtained and compared with a preset full transparency threshold (default 95%). If the proportion of transparent pixels exceeds the threshold, it is determined that the cursor image is hidden by the application (e.g., the application sets an empty cursor), a hidden flag is set, and the subsequent detection process is terminated; if it does not exceed the threshold, the next layer of detection is performed.
[0072] Step 502: In the judgment of the all-black anomaly detection rule, if the proportion of black pixels exceeds the preset all-black threshold and the number of effective color pixels is lower than the preset effective color pixel number threshold, the shape features of the cursor image are detected. If the aspect ratio of the cursor image does not conform to the preset aspect ratio range of the type cursor image, it is determined to be the hidden cursor image; otherwise, the judgment of the insufficient effective color pixels rule is entered.
[0073] In one embodiment, a second layer of hidden detection is performed. Optionally, normal all-black cursor images (such as text editing I-shaped cursors) are excluded. If the proportion of black pixels exceeds the all-black threshold (default 90%) and the number of effective colored pixels is lower than the number threshold (default 10), shape feature detection is initiated. The aspect ratio (width / height) of the cursor image is calculated. If the aspect ratio is not within the preset range (vertical I-shaped cursor 0.05-0.3, horizontal I-shaped cursor 3-20), it is determined to be a hidden cursor; if it is within the preset range and the effective pixels are linearly distributed, it is determined to be a normal I-shaped cursor, and the next layer of detection is performed.
[0074] Step 503: In the determination of insufficient effective color pixels, if the number of effective color pixels is lower than the preset effective color pixel threshold and the total number of pixels in the cursor image exceeds the preset total pixel threshold, then it is determined to be the hidden cursor image; otherwise, it is determined to be the visible cursor image.
[0075] In one embodiment, a third layer of hiding detection is performed. Optionally, if the number of valid colored pixels is below a threshold (default 5) and the total number of pixels in the cursor image exceeds 64 (8×8), the cursor image data is determined to be abnormal (such as invalid data remaining after the application hides the cursor), and the cursor image is determined to be hidden. If the above hiding conditions are not met, the cursor image is determined to be visible, the hiding flag is cleared, and the rendering stage begins.
[0076] The three-level detection rules are progressive, combining pixel statistics and shape features to accurately identify scenarios where the application hides the cursor, effectively avoiding the problem of double cursor overlap, adapting to special scenarios such as text editing, with an extremely low false positive rate, and ensuring intuitive interaction.
[0077] Figure 6 This is a flowchart of cross-screen rendering of a cursor image provided in an embodiment of this application, such as... Figure 6 As shown, the cursor acquisition and rendering method specifically includes the following steps: Step 601: Obtain the target display handle identifier and the display handle identifier where the cursor image is currently located. Determine whether the cursor image is within the current acquisition range by comparing the handle identifiers. The display handle identifier is reused from the cursor state cache structure or obtained through the display query interface.
[0078] In one embodiment, the cursor image is determined to be within the target display range by matching the display handle identifier. Optionally, the handle identifier of the target display is configured by the user or automatically identified by the system, while the handle identifier of the display where the cursor image is currently located is reused from the cursor state cache structure or obtained through the display query interface. The two display handle identifiers are compared; if they match, the cursor image is determined to be within the current acquisition range; if they do not match, the cursor image is determined to be outside the acquisition range, and the rendering process is skipped. The handle identifier is a unique identifier for the display, ensuring accurate matching and avoiding positioning errors in scenarios where multiple display coordinate systems overlap, as is common with traditional coordinate range determination.
[0079] Step 602: If the cursor image is within the acquisition range of the target display, obtain the position information of the target display on the virtual desktop, and convert the absolute virtual screen coordinates of the cursor image into relative coordinates relative to the upper left corner of the target display.
[0080] In one embodiment, if the cursor image is within the acquisition range, coordinate transformation is performed. Optionally, the coordinates of the top-left corner of the target monitor on the virtual desktop are obtained through the system interface. , Convert the absolute coordinates (x, y) of the cursor image on the virtual screen to relative coordinates. , This ensures the accuracy of the coordinates relative to the top left corner of the target display.
[0081] Step 603: Extract the hotspot coordinate offset of the cursor image stored in the cursor state cache structure, subtract the hotspot coordinate offset from the relative coordinate to obtain the calculation result, and determine the actual rendering start position of the cursor image based on the calculation result.
[0082] In one embodiment, the actual rendering position of the cursor is calibrated based on the hotspot coordinate offset. The cursor hotspot coordinate offset is extracted from the cursor state cache structure. This value is provided by the operating system's cursor interface and represents the offset of the actual click position of the cursor image relative to the top-left corner of the image. Actual rendering start position = relative coordinates - hotspot offset, i.e. ( , This ensures that the cursor image rendering position matches the actual click position.
[0083] Step 604: Based on the actual rendering start position, calculate the intersection of the rendering rectangle corresponding to the cursor image and the visible area rectangle of the target display through system boundary clipping. If the intersection is empty, skip rendering; if the intersection is not empty, calculate the source region offset and target rendering position of the cursor image, and render the cursor image pixels in the intersection area into the output image.
[0084] In one embodiment, the boundary intersection is calculated, and cropping and rendering are performed. Optionally, a cursor image rendering rectangle is constructed. The cursor image source region is set to a rectangle (0, 0, display width, display height) and the target display's visible area rectangle. The intersection of the two rectangles is calculated using a rectangle intersection algorithm. If the intersection is empty, rendering is skipped; otherwise, the cursor image source region offset (the offset of the top-left corner of the intersection relative to the top-left corner of the rendering rectangle) and the target rendering position (the coordinates of the top-left corner of the intersection relative to the top-left corner of the display) are calculated. Only the cursor image pixels within the intersection area are rendered to their corresponding positions in the output image, avoiding rendering anomalies (such as pixel overflow or incomplete display) that occur when the cursor image extends beyond the screen boundaries.
[0085] Display handle identification matching enables precise cross-screen positioning, coordinate transformation and hotspot calibration ensure accurate rendering position, boundary clipping avoids rendering anomalies that exceed the screen, solves cursor flickering and offset issues in multi-monitor scenarios, and improves the cross-screen interaction experience.
[0086] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 7 As shown, the device includes a processor 901, a memory 902, an input device 903, and an output device 904.
[0087] The number of processors 901 can be one or more. Figure 7 Taking a processor 901 as an example; the processor 901, memory 902, input device 903, and output device 904 can be connected via a bus or other means. Figure 7Taking a bus connection as an example, the memory 902, as a computer-readable storage medium, can be configured to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the cursor acquisition and rendering method in this embodiment. The processor 901 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 902, thereby realizing the aforementioned cursor acquisition and rendering method. The input device 903 can be configured to receive input digital or character information and generate key signal inputs related to user settings and function control of the device. The output device 904 may include a display screen or other display device.
[0088] Hardware components work together to adapt to the entire cursor image processing workflow, processor scheduling optimization ensures real-time performance, memory partitioning management enhances data security, input / output devices provide flexible interaction and feedback, and hardware acceleration and resource optimization support high concurrency and multi-scenario requirements, providing a stable hardware foundation for cursor image processing.
[0089] This application embodiment also provides a non-volatile storage medium containing computer-executable instructions, which, when executed by a computer processor, are configured to execute the cursor acquisition and rendering method described in the above embodiments. The method includes: establishing a cursor state cache structure, which remains valid during the acquisition session; acquiring frame data from the session through a desktop copy interface, and performing multi-level differential update verification processing on the frame data based on the cursor state cache structure; rendering the cursor image after the multi-level differential update verification processing, and simultaneously performing pixel feature statistical processing on different types of pixels in the cursor image during the rendering process; performing cursor image hiding detection and determination based on the result of the pixel feature statistical processing and in conjunction with preset multi-dimensional detection rules, determining whether the cursor image is hidden by an application; if the cursor image is determined not to be hidden, locating the acquisition target display by matching the display handle identifier, converting the virtual screen coordinates of the cursor image into relative coordinates of the acquisition target display, calibrating the rendering position, and completing cross-screen rendering of the cursor image based on the rendering position.
[0090] The storage medium uses high-speed Flash memory, SSD, or cloud storage media, with a capacity of no less than 256GB (terminal devices) or no less than 4TB (server devices). It supports a wide operating temperature range of -40℃ to 85℃ (industrial-grade scenarios) and features power-loss protection, electromagnetic interference resistance, and high durability (flash memory ≥ 100,000 erase / write cycles). The computer-readable instructions stored on the storage medium are organized in a modular structure. The core includes the execution code for modules such as cursor cache management, multi-level differential verification, rendering and statistics, hidden detection, and cross-screen rendering. It also stores basic data such as system configuration parameters, threshold configurations, and log templates. When the processor executes the above instructions, it initiates differentiated operating logic according to the device role. On the terminal device side, the cursor state cache structure is initialized, and multi-level differential update verification, rendering synchronization statistics, hidden detection, and cross-screen rendering are executed to reduce resource consumption. On the server device side, a distributed cache management module is initiated to support cursor processing for massive concurrent sessions. Hardware resources are allocated through load balancing technology to ensure processing efficiency and stability in high-concurrency scenarios. This storage medium supports hot-swapping (terminal devices) and online expansion (server devices), adapting to the deployment needs of applications of different scales; encrypted storage and backup mechanisms ensure data security and prevent leakage and loss; it is compatible with multiple operating systems such as Windows, Linux, and macOS, and can be directly deployed on various electronic devices without additional driver installation, effectively supporting the stable implementation of cursor acquisition and rendering functions.
[0091] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments provided herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the claims.
Claims
1. A cursor acquisition and rendering method, characterized in that, The method includes: Establish a cursor state cache structure, which remains valid throughout the acquisition session; The frame data in the session is obtained through the desktop copy interface, and multi-level differential update verification processing is performed on the frame data based on the cursor state cache structure. The cursor image after the multi-level differential update and verification process is rendered. During the rendering process, the pixel feature statistical processing of different types of pixels in the cursor image is completed simultaneously. Based on the results of the pixel feature statistical processing, and combined with the preset multi-dimensional detection rules, the cursor image hiding detection and determination are performed to determine whether the cursor image is hidden by the application. If it is determined that the cursor image is not hidden, the target display is located by matching the display handle identifier, and the virtual screen coordinates of the cursor image are converted into relative coordinates of the target display. The rendering position is then calibrated, and cross-screen rendering of the cursor image is completed based on the rendering position.
2. The cursor acquisition and rendering method according to claim 1, characterized in that, The establishment of the cursor state cache structure includes: The cursor state cache structure is created during system initialization. The cursor state cache structure includes the virtual screen absolute coordinates of the cursor image, the display relative coordinates, the display handle identifier where the cursor image is located, the display index, the cursor image shape identifier hash value, the cursor image hotspot coordinate offset, and the cursor image update timestamp. The cursor state cache structure is a semantic-level storage. The cursor state cache structure is used to distinguish the update types of the cursor image's position change, shape change, and cross-screen movement state. The cursor state cache structure updates the corresponding cache fields when the corresponding state of the cursor image changes.
3. The cursor acquisition and rendering method according to claim 1, characterized in that, The multi-level differential update process performed on the frame data based on the cursor state cache structure includes: The cursor image update timestamp of the frame data returned by the desktop copy interface is compared with the timestamp of the cursor image cached in the cursor state cache structure. If the timestamp comparison is consistent, all cursor cache information in the cursor state cache structure is reused. If the timestamp verification comparison is inconsistent, the current position coordinates of the cursor image in the frame data are obtained and the position coordinates of the cursor image cached in the cursor state cache structure are compared. If the position coordinate verification comparison is consistent, the cursor position information in the cursor state cache structure is reused. If the position coordinates of the cursor image have not changed and the shape of the cursor image has changed, the cursor image timestamp and cursor image shape information in the cursor state cache structure are updated. If the position coordinate verification comparison is inconsistent, the display handle identifier of the current display of the cursor image in the frame data is compared with the display handle identifier cached in the cursor state cache structure. If the display handle identifier verification comparison is consistent, the display information in the cursor state cache structure is reused, the relative coordinates of the cursor image relative to the display are recalculated, and the virtual screen absolute coordinates, display relative coordinates, and timestamp fields of the cursor image in the cursor state cache structure are updated. If the display handle identifier verification and comparison are inconsistent, the new display information acquisition, coordinate transformation and display index update process will be executed.
4. The cursor acquisition and rendering method according to claim 1, characterized in that, The rendering process of the cursor image after the multi-level differential update and verification processing includes, during the rendering process, synchronously performing pixel feature statistical processing on different types of pixels in the cursor image, including: Identify the cursor format type of the cursor image in the frame data, including mask-defined cursors and ARGB format cursors; Pixel classification statistics are performed based on the cursor format type. In the same traversal loop that renders the cursor image, the pixel type is counted according to the classification rules corresponding to the cursor format type. The step of classifying pixel types according to the corresponding cursor format type includes: If it is a mask-defined cursor, pixel determination is performed based on the combination of AND and XOR mask bits, including: When the AND mask bit is 1 and the XOR mask bit is 0, it is determined to be a transparent pixel; When both the AND mask bit and the XOR mask bit are 0, the pixel is determined to be black. When the XOR mask bit is 1, all are determined to be valid color pixels; If the cursor is in ARGB format, pixel determination is performed based on the relationship between the Alpha channel value and the RGB value, including: When the alpha channel value is 0, it is determined to be the transparent pixel; If the Alpha channel value is greater than 0 and all RGB values are 0, it is determined to be a black pixel; If the Alpha channel value is greater than 0 and the RGB values are not all 0, it is determined to be a valid color pixel; The number of transparent pixels, black pixels, and effective color pixels are recorded synchronously, and the proportion of each type of pixel to the total number of pixels in the cursor image is calculated.
5. The cursor acquisition and rendering method according to claim 1, characterized in that, The step of performing cursor image hiding detection and determination based on the result of the pixel feature statistical processing and in combination with preset multi-dimensional detection rules to determine whether the cursor image is hidden by the application includes: If the percentage of transparent pixels exceeds a preset full transparency threshold, the image is determined to be a hidden cursor image; if the percentage of transparent pixels does not exceed the preset full transparency threshold, the image is then judged according to the full black anomaly detection rule. In the all-black anomaly detection rule judgment, when the proportion of black pixels exceeds the preset all-black threshold and the number of effective color pixels is lower than the preset effective color pixel number threshold, the shape features of the cursor image are detected. If the aspect ratio of the cursor image does not conform to the preset aspect ratio range of the type cursor image, it is determined to be the hidden cursor image; otherwise, it enters the effective color pixel insufficient rule judgment. In the determination of insufficient effective color pixels, if the number of effective color pixels is lower than the preset effective color pixel threshold and the total number of pixels in the cursor image exceeds the preset total pixel threshold, then it is determined to be the hidden cursor image; otherwise, it is determined to be the visible cursor image.
6. The cursor acquisition and rendering method according to claim 1, characterized in that, The step of matching and locating the target display by identifying the display handle, converting the virtual screen coordinates of the cursor image into relative coordinates of the target display, calibrating the rendering position, and completing cross-screen rendering of the cursor image based on the rendering position includes: Obtain the target display handle identifier and the display handle identifier where the cursor image is currently located. Determine whether the cursor image is within the current acquisition range by comparing the handle identifiers. The display handle identifier is reused from the cursor state cache structure or obtained through the display query interface. If the cursor image is within the acquisition range of the target display, obtain the position information of the target display on the virtual desktop, and convert the absolute virtual screen coordinates of the cursor image into relative coordinates relative to the upper left corner of the target display; Extract the hotspot coordinate offset of the cursor image stored in the cursor state cache structure, subtract the hotspot coordinate offset from the relative coordinate to obtain the calculation result, and determine the actual rendering start position of the cursor image based on the calculation result; Based on the actual rendering start position, the intersection of the rendering rectangle corresponding to the cursor image and the visible area rectangle of the target display is calculated by system boundary clipping. If the intersection is empty, rendering is skipped; if the intersection is not empty, the source region offset and target rendering position of the cursor image are calculated, and the cursor image pixels in the intersection area are rendered into the output image.
7. The cursor acquisition and rendering method according to claim 1, characterized in that, In the multi-level differential update verification, each level of verification is executed sequentially in order of increasing computational cost. When any level of the multi-level differential update verification passes, the data of the cursor state cache structure is reused and the subsequent update verification levels are terminated.
8. The cursor acquisition and rendering method according to claim 1, characterized in that, The method is compatible with all cursor format types, including monochrome cursors, colored cursors, colored cursors with an alpha channel, and cursors defined using a mask.
9. An electronic device, characterized in that, include: Memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the cursor acquisition and rendering method as described in any one of claims 1-8.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions, which, when executed by a processor, implement the cursor acquisition and rendering method as described in any one of claims 1-8.