Graph rendering method, device and equipment based on Electron multiple processes

By utilizing Electron's multi-process architecture and WebGL technology, and employing a main process and a second process to handle batch processing and graphics picking calculations respectively, the problem of low WebGL rendering efficiency is solved, achieving efficient, accurate, and real-time graphics rendering and improving the user experience.

CN118916106APending Publication Date: 2024-11-08XIAMEN YUANTING INFORMATION TECH CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410921691.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

In existing technologies, the WebGL rendering process is time-consuming and cannot fully utilize the performance of CPU multi-core processors and the acceleration capabilities of Node.js native modules, resulting in low rendering efficiency and affecting user experience.

Method used

By using the Electron multi-process architecture, a main process, a first process, and a second process are created, which are responsible for batch processing and graphics picking calculations, respectively. Graphics data is synchronized using IPC communication, and WebGL contexts are created in each process to achieve parallel processing and GPU acceleration.

Benefits of technology

It improves graphics rendering efficiency and performance, reduces the load on the main process, provides a smooth, accurate, and highly interactive graphical interface experience, and has good cross-platform compatibility and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916106A_ABST
    Figure CN118916106A_ABST
Patent Text Reader

Abstract

The invention discloses a graphic rendering method, device and equipment based on Electron multiple processes and a storage medium. The graphic rendering method comprises the steps that a rendering process window, a first process and a second process are created through a main process, webgl contexts are created in the first process and the second process, canvas is created in the rendering process window, and the webgl contexts are initialized; when the graphic data in the rendering process window is changed, sending the updated graphic data to the host process for synchronization, and starting the first process for batch processing to obtain a batch processing result; whether the graphic data of the corresponding coordinate position is modified or not is judged before rendering is conducted on the rendering process window, if yes, the second process is started to conduct graphic pickup calculation, and an obtained calculation result is sent to the rendering process window; and performing graphic rendering through the rendering process window according to the batch processing result and by utilizing the initialized webgl context. The efficient, accurate and real-time performance of graphic rendering is realized, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a graphics rendering method, device and equipment based on Electron multi-process. Background Art

[0002] As the demand for graphics processing continues to grow, WebGL (Web Graphics Library) is increasingly used in web applications. However, when processing large amounts of graphics data, the WebGL rendering process can become very time-consuming, especially in batch processing and mouse interaction picking calculations. This can not only cause page freezes, but can also affect the user experience, while also limiting the application of WebGL in a wider range of scenarios. The multi-process capabilities of the Electron framework offer the possibility of solving this problem, but how to efficiently utilize these capabilities and work with GPU acceleration to achieve a smoother rendering experience remains a technical problem to be solved.

[0003] One existing solution is to use Web Worker technology. Web Worker can execute JavaScript code in a background thread to avoid blocking the UI thread, thereby alleviating the computing pressure of the page. However, Web Worker still has some limitations. First, it cannot fully utilize the advantages of CPUs with multiple cores, because Web Workers usually only run on a single CPU core; second, Web Workers cannot take advantage of Node.js's ability to call native modules to accelerate computing, because the operating environment of Web Workers is limited and cannot directly access system-level APIs.

[0004] Therefore, how to combine Electron's multi-process capabilities and WebGL's GPU acceleration, while taking advantage of the CPU's multi-core performance and Node.js's native module acceleration capabilities to achieve a more efficient and smoother graphics rendering experience, has become a technical problem that needs to be solved at present. Summary of the invention

[0005] In view of this, the purpose of the present invention is to propose a graphics rendering method, device and equipment based on Electron multi-process, aiming to solve the problem that existing rendering tasks are usually performed in one process, resulting in reduced rendering efficiency and affecting user experience when the graphics data is complex or updated frequently.

[0006] To achieve the above object, the present invention provides a graphics rendering method based on Electron multi-process, the method comprising:

[0007] Create a rendering process window, a first process and a second process through a main process, create a webgl context in the first process and the second process, and create a canvas in the rendering process window and initialize the webgl context;

[0008] When the graphic data in the rendering process window changes, the updated graphic data is sent to the main process for synchronization, and the first process is started for batch processing to obtain a batch processing result;

[0009] Before rendering in the rendering process window, determining whether to modify the graphic data at the corresponding coordinate position, if so, starting the second process to perform graphic picking calculation, and sending the obtained calculation result to the rendering process window;

[0010] Graphics rendering is performed through the rendering process window according to the batch processing result and using the initialized webgl context.

[0011] Preferably, the creating a webgl context in the first process and the second process includes:

[0012] The webgl context in the nodejs environment is created using the third-party dependency headless-gl in the first process and the second process.

[0013] Preferably, when the graphic data in the rendering process window changes, the updated graphic data is sent to the main process for synchronization, including:

[0014] When a graphic is created in the rendering process window, the graphic data obtained by creating the graphic is sent to the main process by using IPC communication;

[0015] When a graphic is deleted in the rendering process window, the graphic ID corresponding to the deleted graphic is sent to the main process using IPC communication;

[0016] When the vertex coordinates of a graphic are modified or the vertex index of a graphic is modified in the rendering process window, the graphic data obtained after the modification is sent to the main process by using IPC communication.

[0017] Preferably, after sending the updated graphic data to the main process for synchronization, the method further includes:

[0018] The main process stores the received updated graphic data into a graphic list to establish a mapping between the graphic ID and the graphic data.

[0019] Preferably, starting the first process to perform batch processing and obtaining batch processing results includes:

[0020] After receiving the graphics list sent by the main process, the first process groups the graphics according to the graphics drawing method in combination with the GPU to obtain grouping results of multiple groups;

[0021] Create a corresponding batch structure for each of the groups, the batch structure including a vertex data array, a vertex index data array, a corresponding graphics list, a starting position of each corresponding graphics data in the vertex data array, a Uint8Array array for storing the merged image, and a position of the image data of each graphics data in the merged image list;

[0022] Initialize the vertex data array, fill the vertex data of all graphics in each group into the vertex data array in order, and record the starting position of each graphic data in the vertex data array in the batch structure;

[0023] Initialize the vertex index data array, generate vertex indexes according to the original vertex index of each figure and the position of each vertex in the vertex data array, and fill them into the vertex index data array;

[0024] Create one or more Uint8Array objects of preset length, and merge the picture data on the graphic data into the corresponding Uint8Array objects.

[0025] Preferably, the starting the second process to perform graphics picking calculation and sending the obtained calculation result to the rendering process window includes:

[0026] Sending the modified coordinate position to the main process, and sending the coordinate position and the graphic list to the second process through the main process;

[0027] By traversing the graphics list, each graphic is detected using the ray method, all graphics containing the coordinate position are found, and the graphic ID corresponding to the graphic is sent to the main process, and the main process sends the corresponding graphic ID to the rendering process window.

[0028] To achieve the above object, the present invention also provides a graphics rendering device based on Electron multi-process, the device comprising:

[0029] A creation unit, configured to create a rendering process window, a first process, and a second process through a main process, create a WebGL context in the first process and the second process, and create a canvas in the rendering process window and initialize the WebGL context;

[0030] A batch processing unit, configured to send the updated graphic data to the main process for synchronization when the graphic data in the rendering process window changes, and start the first process for batch processing to obtain a batch processing result;

[0031] a calculation unit, used for determining whether to modify the graphic data at the corresponding coordinate position before rendering in the rendering process window, and if so, starting the second process to perform graphic picking calculation, and sending the obtained calculation result to the rendering process window;

[0032] A rendering unit is used to perform graphics rendering according to the batch processing result and using the initialized webgl context through the rendering process window.

[0033] In order to achieve the above-mentioned objectives, the present invention also proposes a graphics rendering device based on Electron multi-process, including a processor, a memory, and a computer program stored in the memory, wherein the computer program is executed by the processor to implement the steps of a graphics rendering method based on Electron multi-process as described in the above-mentioned embodiment.

[0034] In order to achieve the above objectives, the present invention also proposes a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the steps of a graphics rendering method based on Electron multi-process as described in the above embodiment.

[0035] Beneficial effects:

[0036] The above scheme, by creating a first process and a second process, places the batch processing and graphics picking calculation tasks in the graphics rendering process in different processes for execution, thereby realizing parallel processing, thereby improving the efficiency and performance of graphics rendering; and, distributing the complex calculation tasks of graphics rendering to multiple processes for execution, reducing the load of the main process, so that it can focus more on the processing of other tasks. The graphics rendering method based on Electron multi-process of the present invention realizes the efficiency, accuracy and real-time performance of graphics rendering by utilizing Electron's multi-process architecture and WebGL technology, improves the user experience, and has good scalability and flexibility.

[0037] The above solution uses the Electron framework and WebGL technology, which makes this method cross-platform and scalable, and can be applied to different operating systems and graphics hardware environments; by creating a WebGL context in Electron's multi-process and using the third-party dependency headless-gl, it provides more flexibility and possibilities for graphics rendering.

[0038] In the above scheme, when the graphics data in the rendering process window changes, the updated graphics data is sent to the main process for synchronization through IPC communication, ensuring the consistency and accuracy of the graphics data; a copy of the graphics data is jointly maintained between the rendering process and the main process, reducing unnecessary data transmission and repeated calculations, and further improving the overall rendering performance.

[0039] In the above scheme, the main process stores the received graphic data into the graphic list, and establishes a mapping between the graphic ID and the graphic data, which facilitates the rapid access and management of the graphic data.

[0040] The above scheme, by starting the second process to perform graphic picking calculation, can quickly and accurately find and return the graphic ID containing the specific coordinate position, thereby enhancing the real-time and accuracy of graphic interaction; and thus can provide users with a smoother, more accurate and interactive graphical interface experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0042] Figure 1 A flowchart of a graphics rendering method based on Electron multi-process is provided for one embodiment of the present invention.

[0043] Figure 2 A schematic diagram of the structure of a graphics rendering device based on Electron multi-process provided by an embodiment of the present invention.

[0044] The realization of the purpose, functional features and advantages of the invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention claimed for protection, but merely represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0046] The content of the present invention is described in detail below with reference to embodiments.

[0047] Reference Figure 1 The figure is a flowchart of a graphics rendering method based on Electron multi-process provided by an embodiment of the present invention.

[0048] In this embodiment, the method includes:

[0049] S11, creating a rendering process window, a first process and a second process through a main process, creating a webgl context in the first process and the second process, and creating a canvas in the rendering process window and initializing the webgl context.

[0050] Further, in step S11, creating a webgl context in the first process and the second process includes:

[0051] The webgl context in the nodejs environment is created using the third-party dependency headless-gl in the first process and the second process.

[0052] In this embodiment, the main process creates a rendering process window and simultaneously creates two processes, including a first process and a second process, and uses a third-party dependency headless-gl in the first process and the second process to create a webgl context in a nodejs environment to assist in calculations. A canvas is then created in the rendering process window and webgl is used as a drawing context.

[0053] In the specific implementation, the multi-process capability of Electron is utilized, and GPU acceleration technology is combined to maximize the rendering performance of WebGL. Specifically, the first process is responsible for batch processing using GPU acceleration processing, and the second process is responsible for graphics picking calculations; in the first process, by using the GPU for batch processing, by sending the graphics data to the first process, the efficient parallel processing capabilities of the GPU can be used to quickly group and pre-process the graphics data, which can significantly reduce the CPU load and improve the efficiency of batch processing. However, in terms of graphics picking calculations, by sending the coordinate position and the graphics data list to the second process, the process of finding the target graphics by using the ray method for each graphic by traversing the graphics list (the graphics list is a collection of multiple graphics data).

[0054] S12, when the graphic data in the rendering process window changes, the updated graphic data is sent to the main process for synchronization, and the first process is started for batch processing to obtain a batch processing result.

[0055] Further, in step S12, when the graphic data in the rendering process window changes, the updated graphic data is sent to the main process for synchronization, including:

[0056] When a graphic is created in the rendering process window, the graphic data obtained by creating the graphic is sent to the main process by using IPC communication;

[0057] When a graphic is deleted in the rendering process window, the graphic ID corresponding to the deleted graphic is sent to the main process using IPC communication;

[0058] When the vertex coordinates of a graphic are modified or the vertex index of a graphic is modified in the rendering process window, the graphic data obtained after the modification is sent to the main process by using IPC communication.

[0059] Furthermore, after sending the updated graphic data to the main process for synchronization, the method further includes:

[0060] The main process stores the received updated graphic data into a graphic list to establish a mapping between the graphic ID and the graphic data.

[0061] Further, in step S12, starting the first process for batch processing to obtain batch processing results includes:

[0062] After receiving the graphics list sent by the main process, the first process groups the graphics according to the graphics drawing method in combination with the GPU to obtain grouping results of multiple groups;

[0063] Create a corresponding batch structure for each of the groups, the batch structure including a vertex data array, a vertex index data array, a corresponding graphics list, a starting position of each corresponding graphics data in the vertex data array, a Uint8Array array for storing the merged image, and a position of the image data of each graphics data in the merged image list;

[0064] Initialize the vertex data array, fill the vertex data of all graphics in each group into the vertex data array in order, and record the starting position of each graphic data in the vertex data array in the batch structure;

[0065] Initialize the vertex index data array, generate vertex indexes according to the original vertex index of each figure and the position of each vertex in the vertex data array, and fill them into the vertex index data array;

[0066] Create one or more Uint8Array objects of preset length, and merge the picture data on the graphic data into the corresponding Uint8Array objects.

[0067] In this embodiment, in the rendering process window, graphics are created or deleted according to business needs, or vertex coordinates, vertex indexes or image data of graphics are modified. At the same time, the rendering process window sends the graphic data obtained by the created graphics or the modified graphic data to the main process using IPC communication; if the graphics are deleted, the graphic ID corresponding to the deleted graphics is sent to the main process. The graphic data sent to the main process includes: a uniquely identified graphic ID, vertex coordinates, vertex indexes, and drawing method types, and may further include image data. Among them, the graphics are unstructured, scattered, and not organized into a form that can be directly used by the program (referring to an original state); the image data includes an array composed of all pixels on the image, each pixel contains numerical information representing its color, and also contains the width and height of the image; the graphic data is a data structure, which includes a uniquely identified graphic ID, vertex coordinates, vertex indexes, drawing method types, and image data (if any).

[0068] After the main process receives the graphic data of the newly created graphic, it writes it into the graphic list and establishes a mapping between the graphic ID and the graphic data. When the main process receives the modified graphic data, it finds the previously saved original graphic data according to the graphic ID and overwrites the original graphic data with the received graphic data. When the main process receives the graphic ID of the deleted graphic, it deletes the corresponding graphic data in the graphic list and deletes the mapping relationship between the graphic ID and the graphic data. This ensures that the graphic data saved by the main process is consistent with the graphic data in the rendering process window.

[0069] When the graphics data in the rendering process window changes (i.e., creating new graphics, deleting graphics, or modifying graphics data, etc. as mentioned above), the rendering process window will start rendering. In order to improve the efficiency of rendering, the rendering process window sends a batch processing message to notify the main process to batch process the graphics data. After receiving the message for batch processing, the main process sends all the graphics data in the graphics list to the first process, which performs batch processing while waiting for the results of the batch processing. When the first process completes the batch processing, the batch processing results are sent back to the main process, and the main process sends the results to the rendering process window. After obtaining the batch processing results, the rendering process window uses the drawing capabilities of webgl combined with the batch processing results for rendering. Among them, the batch processing steps include:

[0070] Group the graphics according to the drawing method, and group the graphics data with the same drawing method into the same group (if the width or height of the image in the graphics data exceeds 4096, it will form a group by itself), and then perform the following steps for each group, and finally organize all batch structures into an array as the batch processing result;

[0071] Create a batch structure for each group, including the vertex data array, the vertex index data array, the graphics data list, the starting position of each graphics data in the vertex data array, the Uint8Array array for storing the merged image, and the position of the image data in each graphics data in the merged image list (the image list is a collection of multiple image data);

[0072] Initialize the vertex data array to make it large enough to hold all the graphics vertices in a group; then fill the vertex data of all the graphics in each group into the vertex data array in order, and record the starting position of each graphics data in the vertex data array in the batch structure;

[0073] Initialize the vertex index data array to be large enough to hold the vertex indices of all the graphics data in a group; based on the original vertex index of each graphic and the position of each vertex in the vertex data array, regenerate the vertex index and fill it into the vertex index array;

[0074] Next, the image data on these graphic data are concentrated as much as possible into one or more 4096x4096 large images. Each large image is represented by a Uint8Array object with a length of 4096x4096x4 (because a pixel contains 4 channels R, G, B, A, and the data type of each channel is Uint8, so this place needs to be multiplied by 4 to accommodate the color values ​​of all pixels). Filter out the graphic data with image data (for example, draw a triangle on the canvas, and fill the inside of the triangle with an image instead of a simple color. At this time, the graphic data corresponding to the triangle will have image data), and then create one or more Uint8Array objects with a length of 4096x4096x4. Combine the width and height of each image data to plan the Uint8Array object to which it belongs and its position in the large image (the image data here is called a small image, and the image represented by the Uint8Array object is called a large image. In order to collect many small images on the large image, it is necessary to arrange the small images on the large image in order. If a small image exceeds the boundary of the large image, the bottom of the small image starting from this row is used as the vertical coordinate of the new row, and the small images are arranged in a new row starting from this position. If the large image has no extra space to accommodate the new small image, a new large image, namely a Uint8Array object, is created, and then this process is repeated until all image data have corresponding Uint8Arrays and coordinate positions to which they belong); next, if it is the first batch processing, initialize the webgl context in the first process.

[0075] The process of initializing the webgl context of the first process:

[0076] var width=4096

[0077] var height = 4096

[0078] var gl=require('gl')(width,height,{preserveDrawingBuffer:true})

[0079] gl.clearColor(0,0,0,0)

[0080] gl.clear(gl.COLOR_BUFFER_BIT)

[0081] Then traverse the image data and do the following:

[0082] 1. Create a rectangle whose size is consistent with the width and height of the image data, and set the position of the rectangle to ensure that it does not overlap with other rectangles;

[0083] 2. Pass the image data into the webgl interface to get a reference to a texture object and bind it to the rectangle;

[0084] 3. Call the webgl interface to render the rectangle and texture into the buffer inside webgl;

[0085] 4. Check whether the picture data has been traversed or whether the next picture data belongs to the same Uint8Array object as the current picture data. If the picture data has not been traversed and belongs to the same Uint8Array object, directly traverse the next picture data, otherwise execute step 5;

[0086] 5. Call the webgl interface to write the data in the webgl buffer into the Uint8Array object to which the current image data belongs, and then clear the data in the webgl buffer;

[0087] When the above steps are completed, the positions of these Uint8Array objects and image data after merging are saved in the batch structure (that is, the Uint8Array array that saves the merged image in the batch structure above and the position of the image data in each graphic data in the merged image list).

[0088] S13, before rendering in the rendering process window, determine whether to modify the graphic data of the corresponding coordinate position, and if so, start the second process to perform graphic picking calculation, and send the obtained calculation result to the rendering process window.

[0089] Further, in step S13, starting the second process to perform graphic picking calculation and sending the obtained calculation result to the rendering process window includes:

[0090] Sending the modified coordinate position to the main process, and sending the coordinate position and the graphic list to the second process through the main process;

[0091] By traversing the graphics list, each graphic is detected using the ray method, all graphics containing the coordinate position are found, and the graphic ID corresponding to the graphic is sent to the main process, and the main process sends the corresponding graphic ID to the rendering process window.

[0092] S14, performing graphics rendering through the rendering process window according to the batch processing result and using the initialized webgl context.

[0093] In this embodiment, if the graphic data at a specific coordinate position needs to be modified before rendering, the second process performs graphic picking calculation, and after obtaining those graphic IDs, the graphic data corresponding to the graphic ID is found and modified as needed, and the modified part of the graphic data is synchronized to the main process. Among them, graphic picking calculation: when it is known which graphics exist at a certain position on the canvas according to business needs, or which graphics exist at the position where the mouse is located, the following steps are performed:

[0094] The coordinate position is passed to the main process; after receiving the coordinate position, the main process passes the coordinate position and the graphics list to the second process; the ray method is used in the second process to detect whether the coordinate position is within the graphics; the graphics list is traversed, and each graphic is detected using the ray method. In this way, all graphics containing the specified coordinate position are found, and the graphics IDs of these graphics are passed to the main process. If no graphics contain the specified coordinate position, an empty array is passed to the main process. After receiving the calculation result of the second process, the main process sends the calculation result to the rendering process window. Among them, the ray method: refers to drawing a ray from the specified coordinate position (usually a horizontal ray to the right is selected), and then calculating the number of intersections between this ray and the graphics; if the number of intersections is an odd number, the point is inside the graphics; if it is an even number, the point is outside the graphics.

[0095] Reference Figure 2 The figure is a schematic diagram of the structure of a graphics rendering device based on Electron multi-process provided by an embodiment of the present invention.

[0096] In this embodiment, the device 20 includes:

[0097] A creation unit 21 is used to create a rendering process window, a first process and a second process through a main process, create a WebGL context in the first process and the second process, and create a canvas in the rendering process window and initialize the WebGL context;

[0098] A batch processing unit 22 is used to send the updated graphic data to the main process for synchronization when the graphic data in the rendering process window changes, and start the first process for batch processing to obtain a batch processing result;

[0099] The calculation unit 23 is used to determine whether to modify the graphic data at the corresponding coordinate position before rendering in the rendering process window, and if so, start the second process to perform graphic picking calculation, and send the obtained calculation result to the rendering process window;

[0100] The rendering unit 24 is used to perform graphics rendering according to the batch processing result and using the initialized webgl context through the rendering process window.

[0101] Each unit module of the device 20 can respectively execute the corresponding steps in the above method embodiment, so each unit module will not be described in detail here. Please refer to the description of the above corresponding steps for details.

[0102] The embodiment of the present invention further provides a graphics rendering device based on Electron multi-process, the device comprising the graphics rendering device based on Electron multi-process as described above, wherein the graphics rendering device based on Electron multi-process can adopt Figure 2 The structure of the embodiment can be executed accordingly. Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects. For details, please refer to the relevant records in the above embodiments, which will not be repeated here.

[0103] The device includes: a mobile phone, a digital camera, a tablet computer, or other devices with a camera function, or a device with an image processing function, or a device with an image display function. The device may include components such as a memory, a processor, an input unit, a display unit, and a power supply.

[0104] Among them, the memory can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as an image playback function, etc.), etc.; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory may also include a memory controller to provide the processor and the input unit with access to the memory.

[0105] The input unit can be used to receive input digital or character or image information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Specifically, the input unit of this embodiment includes not only a camera, but also a touch-sensitive surface (such as a touch display) and other input devices.

[0106] The display unit can be used to display information input by the user or information provided to the user and various graphical user interfaces of the device, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit may include a display panel, and optionally, the display panel may be configured in the form of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc. Further, the touch-sensitive surface may cover the display panel, and when the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor to determine the type of touch event, and then the processor provides a corresponding visual output on the display panel according to the type of touch event.

[0107] The embodiment of the present invention further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the memory in the above embodiment; or a computer-readable storage medium that exists independently and is not installed in a device. The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement Figure 1 The graphics rendering method based on Electron multi-process is shown. The computer-readable storage medium can be a read-only memory, a disk or an optical disk, etc.

[0108] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, equipment embodiment and storage medium embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0109] Furthermore, in this document, the terms "comprises," "comprising," or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device that includes the element.

[0110] The above description shows and describes the preferred embodiments of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the invention, through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not depart from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.

Claims

1. A graphics rendering method based on Electron multi-process, characterized in that: The method comprises: Create a rendering process window, a first process and a second process through a main process, create a webgl context in the first process and the second process, and create a canvas in the rendering process window and initialize the webgl context; When the graphic data in the rendering process window changes, the updated graphic data is sent to the main process for synchronization, and the first process is started for batch processing to obtain a batch processing result; Before rendering in the rendering process window, determining whether to modify the graphic data at the corresponding coordinate position, if so, starting the second process to perform graphic picking calculation, and sending the obtained calculation result to the rendering process window; Graphics rendering is performed through the rendering process window according to the batch processing result and using the initialized webgl context.

2. According to claim 1, a graphics rendering method based on Electron multi-process is characterized in that: The creating a webgl context in the first process and the second process includes: The webgl context in the nodejs environment is created using the third-party dependency headless-gl in the first process and the second process.

3. According to the method for graphics rendering based on Electron multi-process according to claim 1, it is characterized in that: When the graphic data in the rendering process window changes, the updated graphic data is sent to the main process for synchronization, including: When a graphic is created in the rendering process window, the graphic data obtained by creating the graphic is sent to the main process by using IPC communication; When a graphic is deleted in the rendering process window, the graphic ID corresponding to the deleted graphic is sent to the main process using IPC communication; When the vertex coordinates of a graphic are modified or the vertex index of a graphic is modified in the rendering process window, the graphic data obtained after the modification is sent to the main process by using IPC communication.

4. A graphics rendering method based on Electron multi-process according to claim 1 or 3, characterized in that: After sending the updated graphic data to the main process for synchronization, the method further includes: The main process stores the received updated graphic data into a graphic list to establish a mapping between the graphic ID and the graphic data.

5. According to the method for graphics rendering based on Electron multi-process according to claim 1, it is characterized in that: The starting the first process to perform batch processing and obtain the batch processing result includes: After receiving the graphics list sent by the main process, the first process groups the graphics according to the graphics drawing method in combination with the GPU to obtain grouping results of multiple groups; Create a corresponding batch structure for each of the groups, the batch structure including a vertex data array, a vertex index data array, a corresponding graphics list, a starting position of each corresponding graphics data in the vertex data array, a Uint8Array array for storing the merged image, and a position of the image data of each graphics data in the merged image list; Initialize the vertex data array, fill the vertex data of all graphics in each group into the vertex data array in order, and record the starting position of each graphic data in the vertex data array in the batch structure; Initialize the vertex index data array, generate vertex indexes according to the original vertex index of each figure and the position of each vertex in the vertex data array, and fill them into the vertex index data array; Create one or more Uint8Array objects of preset length, and merge the picture data on the graphic data into the corresponding Uint8Array objects.

6. According to claim 1, a graphics rendering method based on Electron multi-process is characterized in that: The starting the second process to perform graphics picking calculation and sending the obtained calculation result to the rendering process window includes: Sending the modified coordinate position to the main process, and sending the coordinate position and the graphic list to the second process through the main process; By traversing the graphics list, each graphic is detected using the ray method, all graphics containing the coordinate position are found, and the graphic ID corresponding to the graphic is sent to the main process, and the main process sends the corresponding graphic ID to the rendering process window.

7. A graphics rendering device based on Electron multi-process, characterized in that: The device comprises: A creation unit, configured to create a rendering process window, a first process, and a second process through a main process, create a WebGL context in the first process and the second process, and create a canvas in the rendering process window and initialize the WebGL context; A batch processing unit, configured to send the updated graphic data to the main process for synchronization when the graphic data in the rendering process window changes, and start the first process for batch processing to obtain a batch processing result; a calculation unit, used for determining whether to modify the graphic data at the corresponding coordinate position before rendering in the rendering process window, and if so, starting the second process to perform graphic picking calculation, and sending the obtained calculation result to the rendering process window; A rendering unit is used to perform graphics rendering through the rendering process window according to the batch processing result and using the initialized webgl context.

8. A graphics rendering device based on Electron multi-process, characterized in that: It includes a processor, a memory, and a computer program stored in the memory, wherein the computer program is executed by the processor to implement the steps of a graphics rendering method based on Electron multi-process as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: A computer program is stored on the computer-readable storage medium, and the computer program is executed by the processor to implement the steps of a graphics rendering method based on Electron multi-process as described in any one of claims 1 to 6.

Citation Information

Cited By

  • Selectron-based super-large scale raster image file dynamic rendering method

    CN120525778A

  • An electron-based method for dynamic rendering of very large raster image files

    CN120525778B

  • Method for optimizing Electron screen heater based on polymorphic rendering and state awareness

    CN121658738A

  • An Electron screen optimization method based on polymorphic rendering and state awareness

    CN121658738B