Picture drawing method and device, electronic equipment, storage medium and program product
By recognizing the first frame event and drawing the image directly, and then continuously drawing subsequent events, the problem of low efficiency caused by waiting for the vertical synchronization signal in graphics rendering is solved, and a more efficient image drawing process is achieved.
Patent Information
- Application Number
- CN202511447837.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-10
- Publication Date
- 2026-01-23
AI Technical Summary
In existing technologies, the graphics rendering process requires waiting for the vertical synchronization signal (Vsync-app signal) to be triggered before the image can be drawn, resulting in low rendering efficiency.
By extracting the event description information of the input event, the first frame event is identified and the screen is drawn directly without waiting for the vertical synchronization signal. A preset number of subsequent events are drawn continuously, and the continuous drawing mode is stopped when the drawing time exceeds a threshold to avoid system load.
It improves the efficiency of image rendering, reduces the time spent waiting for vertical synchronization signals, and enhances the system's response speed and processing capabilities.
Smart Images

Figure CN121387153A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of graphics rendering technology, specifically to methods, apparatuses, electronic devices, storage media, and program products for drawing images. Background Technology
[0002] In the field of graphics rendering technology, rendering efficiency is one of the key factors affecting user experience. In related technologies, when an application process handles input events such as swipe events, it must wait for the vertical synchronization signal (Vsync-app signal) to be triggered before it can render the corresponding screen. For example, the application's UI (User Interface) thread requests a vertical synchronization signal based on the received input event, and the UI thread waits for the vertical synchronization signal to be triggered before it can start rendering. However, this method limits rendering efficiency. Therefore, how to improve the efficiency of screen rendering has become an urgent technical problem to be solved. Summary of the Invention
[0003] In view of this, the present disclosure provides a method, apparatus, electronic device, storage medium, and program product for drawing a screen, in order to solve the problem of low rendering efficiency in the related art.
[0004] In a first aspect, this disclosure provides a method for drawing a screen, the method comprising: acquiring an input event, the input event representing an operation performed on the screen of a terminal device; extracting event description information from the input event, the event description information representing the position of the input event in an event sequence, the event sequence including the input event; and if the event description information includes first target information, drawing the screen corresponding to the input event, the first target information being used to indicate that the input event is the first frame event.
[0005] Secondly, this disclosure provides a screen drawing apparatus, which includes: an acquisition module for acquiring an input event, the input event representing an operation performed on the screen of a terminal device; an extraction module for extracting event description information from the input event, the event description information representing the position of the input event in an event sequence, the event sequence including the input event; and a drawing module for drawing the screen corresponding to the input event if the event description information includes first target information, the first target information being used to indicate that the input event is the first frame event.
[0006] Thirdly, this disclosure provides an electronic device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the screen drawing method of the first aspect or any corresponding embodiment described above.
[0007] Fourthly, this disclosure provides a computer-readable storage medium storing computer instructions for causing a computer to execute the screen drawing method of the first aspect or any corresponding embodiment described above.
[0008] Fifthly, this disclosure provides a computer program product, including computer instructions for causing a computer to execute a screen drawing method according to the first aspect or any corresponding embodiment described above.
[0009] The screen drawing method provided in this disclosure takes into account the following situation: In related technologies, when it is necessary to operate on an input event, the operation on the input event can only be performed after the vertical synchronization signal is received, so as to draw the screen corresponding to the input event, thereby wasting a lot of drawing time.
[0010] This disclosure takes into account the above situation. When an input event is obtained, that is, when the screen of the terminal device needs to be operated, it is necessary to extract the event description information from the input event and identify whether the event description information includes the first target information, that is, to identify whether the event description information includes the first frame event. If the event description information includes the first frame event, the screen corresponding to the input event is drawn without waiting for the vertical synchronization signal, thereby improving the drawing efficiency of the screen corresponding to the input event. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the specific embodiments or related technologies of this disclosure, the accompanying drawings used in the description of the specific embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram illustrating an application scenario according to an embodiment of this disclosure; Figure 2 This is a schematic diagram of the structure rendered in graphical form according to the related technologies provided in the embodiments of this disclosure; Figure 3 This is a schematic flowchart of a first method for drawing a screen according to an embodiment of the present disclosure; Figure 4 This is a schematic diagram of a second method for drawing a screen according to an embodiment of the present disclosure; Figure 5 This is a schematic diagram of a third method for drawing a screen according to an embodiment of the present disclosure; Figure 6 This is a schematic diagram of the structure of a screen drawing system provided according to an embodiment of the present disclosure; Figure 7 This is a fourth flowchart illustrating the method for drawing a screen according to an embodiment of this disclosure; Figure 8 This is a structural block diagram of a screen drawing apparatus provided according to an embodiment of the present disclosure; Figure 9 This is a schematic diagram of the hardware structure of an electronic device provided according to an embodiment of the present disclosure. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0014] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0015] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this disclosure, "a plurality of" means two or more, unless otherwise expressly specified.
[0016] As one optional application scenario of this disclosure embodiment, such as Figure 1 As shown, the game system may include at least one terminal device and at least one server. Figure 1 The system is illustrated in the example, which includes a computer 101, a mobile terminal 102, and a server 103, and the terminal devices such as the computer 101 and the mobile terminal 102 are connected to the server 103 through a network 110.
[0017] Specifically, terminal devices can be smartphones (such as Android phones), tablets, laptops, PDAs, desktop computers, game consoles, smart TVs, smart wearable devices, in-vehicle terminals, VR (Virtual Reality) devices, AR (Augmented Reality) devices, etc. Server 103 can be a standalone physical server, a server cluster, a distributed system, or a cloud server providing cloud services. Network 110 can be a wired or wireless network, examples of which include, but are not limited to, the Internet, corporate intranets, local area networks, wide area networks, mobile communication networks, and combinations thereof.
[0018] Taking the information browsing scenario in the game as an example, when the user swipes their finger across the screen, the UI thread receives the operation on the terminal device's screen and extracts the event description information from the input event. When the event description information indicates a Down type input event and the input event includes the first target information, the screen corresponding to the input event can be drawn to start updating the interface view.
[0019] For some graphics rendering, please refer to Figure 2 , Figure 2 This is a schematic diagram of the structure rendered in a graphic rendering based on the related technology provided in the embodiments of this disclosure.
[0020] Combination Figure 2 As shown, graphics rendering can include software rendering and hardware rendering. Software rendering is based on the 2D graphics library Skia and can be implemented using the Central Processing Unit (CPU). Hardware rendering is based on the hardware user interface. All ordinary 2D UI applications running on the Android system, or 3D game applications with UI components created using WebView, primarily rely on the UI Thread, Render Thread, and SurfaceFlinger to render and composite each frame. In the native system rendering process, the presence of dirty areas in the image is crucial in determining when a frame update is triggered; rendering requires the existence of dirty areas in the current interface, i.e., changes in the content or layout of UI elements.
[0021] For example, in a game, when the user opens the Game UI 2D interface to browse information, when the user swipes their finger across the screen, the UIThread receives a Down input event dispatched by the system and requests a vertical synchronization (Vsync-app) signal. After the Vsync-app signal is triggered, the UIThread draws the screen corresponding to the input event to update the View. The UIThread requests an update to the interface layout through the RequestLayout method, and the main thread remeasures the layout content.
[0022] Native 2D applications or components use the Skia OpenGL rendering engine. When the application process uses hardware-accelerated rendering, the UI thread converts the View into a DisplayList and synchronizes this DisplayList data to the Render thread via the SyncFrameState surface thrower. The Render thread is then awakened by the UI thread and requests a Buffer from the created Buffer Queue to render the current UI data. The Render thread uses the DisplayList passed from the UI thread to further convert it into a rendering type (RenderOp type) data structure. This data is then used by the cross-platform Skia 2D graphics engine for merging or batch processing. Finally, the RenderOp is converted into OpenGL instructions and sent to the Graphics Processing Unit (GPU) for rendering via a forced flush. In the native system, each frame's rendering requires this process: from receiving the update event to requesting and waiting for the Vsync-app signal, the UI thread is awakened, which in turn wakes up the RenderThread to render the image.
[0023] However, in the above graphics rendering process, the following situation exists: the operation on the input event can only be executed after the vertical synchronization signal is received, so as to draw the corresponding screen of the input event, thus wasting a lot of drawing time.
[0024] The screen drawing method provided in this embodiment takes into account the above situation. When an input event is obtained, that is, when the screen of the terminal device needs to be operated, the event description information needs to be extracted from the input event and the event description information needs to be identified as including the first target information, that is, whether the event description information includes the first frame event. If the event description information includes the first frame event, the screen corresponding to the input event is drawn without waiting for the vertical synchronization signal, thereby improving the drawing efficiency of the screen corresponding to the input event.
[0025] Please refer to Figure 3 , Figure 3 This is a schematic flowchart of a first method for drawing a screen according to an embodiment of the present disclosure.
[0026] According to an embodiment of this disclosure, a method for drawing a screen is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0027] This embodiment provides a method for drawing a screen, which can be used in the aforementioned terminal devices, such as computer 101, mobile terminal 102, etc. Figure 3 This is a flowchart of a method for drawing a screen according to an embodiment of the present disclosure, such as... Figure 3 As shown, the process includes the following steps: Step S301: Obtain an input event, which represents an operation performed on the screen of the terminal device.
[0028] Input events represent operations performed on the screen of a terminal device.
[0029] As an example, input events can include press events and movement events. A press event can indicate a user touching the screen or clicking the mouse. For example, the initial contact of a user's finger, stylus, or mouse pointer with the screen. A movement event can indicate an action performed when a user's finger, stylus, or mouse pointer continuously slides across the screen. For example, in a touchscreen, a movement event can indicate actions such as continuously detecting changes in the coordinates of the touch point.
[0030] Step S302: Extract event description information from the input event. The event description information indicates the position of the input event in the event sequence, which includes the input event.
[0031] The event description information indicates the position of the input event in the event sequence. The event sequence can indicate the sequence numbers of multiple events, and the position of the input event in the event sequence can be indicated by its sequence number among these events. For example, the sequence number can be 1 or 2.
[0032] Each input event can be labeled with its sequence number. When an input event is obtained, the event description information can be extracted from it.
[0033] As an example, a text pattern matching tool can be used to analyze the characteristics of the input event text, determine the type of information to be extracted (such as event description information), and then extract the event description information from the input event.
[0034] As an example, a dictionary containing words related to various input events is pre-built, and then event description information is extracted by finding parts that match words in the dictionary.
[0035] Step S303: If the event description information includes the first target information, then the screen corresponding to the input event is drawn. The first target information is used to indicate that the input event is the first frame event.
[0036] The first target information is used to indicate that the input event is the first frame event, which can be indicated as the event with the sequence number 1.
[0037] If the event description information includes the first target information, it indicates that the input event is the first frame event, and the screen corresponding to the input event can be drawn directly.
[0038] As an example, the screen corresponding to the input event can be drawn using the functions built into the terminal device itself.
[0039] As an example, the UI thread is used to draw the screen corresponding to the input event.
[0040] The screen drawing method provided in this embodiment of the present disclosure, when an input event is obtained, that is, when the screen of the terminal device needs to be operated, needs to extract event description information from the input event and identify whether the event description information includes first target information, that is, whether the event description information includes the first frame event. If the event description information includes the first frame event, the screen corresponding to the input event is drawn without waiting for the vertical synchronization signal, thereby improving the drawing efficiency of the screen corresponding to the input event.
[0041] This embodiment provides a method for drawing a screen, which can be used in the aforementioned terminal devices, such as computer 101, mobile terminal 102, etc. Figure 4 This is a second flowchart illustrating the method for drawing a screen according to an embodiment of this disclosure, as shown below. Figure 4 As shown, the process includes the following steps: Step S401: Obtain an input event. The input event represents an operation performed on the screen of the terminal device. For details, please refer to [link to relevant documentation]. Figure 3 Step S301 of the illustrated embodiment will not be described again here.
[0042] Step S402: Extract event description information from the input event. The event description information indicates the position of the input event in the event sequence, which includes the input event. For details, please refer to [link to relevant documentation]. Figure 3 Step S302 of the illustrated embodiment will not be described again here.
[0043] Step S403: If the event description information includes first target information, then the screen corresponding to the input event is drawn. The first target information is used to indicate that the input event is a first frame event. For details, please refer to [link to relevant documentation]. Figure 3 Step S303 of the illustrated embodiment will not be described again here.
[0044] Step S404: Continuously draw the frames corresponding to a preset number of subsequent events, where the subsequent events occur after the first frame event; wherein, the event sequence includes the first frame event and subsequent events.
[0045] Subsequent events can indicate input events that occur after the first frame event. These subsequent events and the first frame event belong to the same operation sequence (e.g., swipe, drag, etc.).
[0046] It should be noted that subsequent events must be logically continuous with the events in the first frame (such as the movement of the same finger or the continuation of the same gesture). For example, if a user taps the screen and then slides their finger, triggering multiple touchmove events in succession, each event carrying the current finger coordinates (x1, y1), (x2, y2), ..., these events are all subsequent events.
[0047] The preset quantity can be a pre-defined number. This preset quantity can be 3, 4, etc., without specific limitation. Specifically, after the frame corresponding to the first event is drawn, the frames corresponding to the preset number of subsequent events are drawn. During the drawing of the frames corresponding to subsequent events, there is still no need to wait for a signal; the frames corresponding to the subsequent events can be drawn directly.
[0048] For example, input events include press events and move events. Among them, the move event with sequence number 1 and the press event are the first frame events, ensuring that only one continuous drawing is triggered within a complete input event cycle, preventing frequent continuous drawing from overloading the system. A complete input event cycle is defined as the event press, move, and release.
[0049] The screen drawing method provided in this embodiment of the present disclosure, by drawing the screen corresponding to the first event and then continuously drawing the screen corresponding to a preset number of subsequent events, can complete the drawing of the screen corresponding to the preset number of subsequent events without waiting for the vertical synchronization signal, thereby improving the drawing efficiency of the screen corresponding to subsequent events.
[0050] In one possible implementation, the above method also includes: Step S51: Obtain the drawing duration; where the drawing duration is the time from the moment the first frame event is drawn to the current moment.
[0051] The rendering duration can be defined as the time elapsed from the moment the first frame corresponding to the event is rendered to the current moment. In other words, it's the time interval elapsed from the start of rendering the first frame corresponding to the event to the current moment, used to quantify the rendering process. The first frame corresponding to the event can be indicated as the initial frame generated based on the state of the first frame event (such as touch point coordinates, gesture type), containing all visual elements that need to be rendered.
[0052] Once the current moment and the moment corresponding to the first frame event are determined, the drawing duration can be determined.
[0053] As an example, the current moment—the moment when the image corresponding to the first frame event is drawn—is equal to the drawing duration.
[0054] Step S52: When the drawing duration exceeds the duration threshold, stop executing the continuous drawing mode; wherein, the continuous drawing mode indicates that the screen corresponding to a preset number of subsequent events is drawn continuously.
[0055] The duration threshold can be a preset threshold. The duration threshold can be 3 vysnc cycles, 4 vysnc cycles, etc., and is not specifically limited here.
[0056] After obtaining the drawing duration, it can be checked whether the drawing duration is greater than a duration threshold. If the drawing duration is greater than the duration threshold, the continuous drawing mode can be stopped. If the drawing duration is not greater than the duration threshold, step S404 can be executed.
[0057] For example, the threshold for continuous drawing duration is 3 VSync cycles. If the drawing duration exceeds 3 VSync cycles, continuous drawing mode will stop, and the current frame will need to wait for the VSync-App signal to be triggered before drawing can begin. If the continuous drawing duration does not exceed the threshold, there is no need to wait for the VSync-App signal; the UI Thread will be woken up directly to perform the drawing.
[0058] For example, the threshold for continuous drawing duration is 4 VSync cycles. If the drawing duration exceeds 4 VSync cycles, continuous drawing mode is stopped, and the current frame needs to wait for the VSync-App signal to be triggered before drawing can begin. If the continuous drawing duration does not exceed the threshold, there is no need to wait for the VSync-App signal; the UI Thread is directly awakened to perform drawing.
[0059] The screen drawing method provided in this embodiment of the present disclosure can avoid the problem of heavy system load caused by continuous drawing by stopping the execution of continuous drawing mode when the drawing duration exceeds the duration threshold.
[0060] In one possible implementation, the above method also includes: Step S61: Store the images corresponding to subsequent events in the target queue.
[0061] The target queue is used to store the frames corresponding to subsequent events. When frames corresponding to subsequent events are rendered consecutively, they can be temporarily stored in the target queue.
[0062] The number of frames corresponding to subsequent events stored in the target queue can be preset. For example, the number of frames corresponding to subsequent events stored in the target queue can be 5.
[0063] After storing the images corresponding to subsequent events in the target queue, if the application rendering thread lags, the images corresponding to the stored subsequent events can be selected from the target queue.
[0064] In one possible implementation, the target storage queue may include an enqueue buffer and a dequeue buffer. The frames corresponding to subsequent events after the first frame event can be stored in the enqueue buffer of the target storage queue; when it is necessary to retrieve the frames corresponding to subsequent events from the target storage queue, they can be retrieved from the dequeue buffer of the target storage queue.
[0065] Specifically, step S61 includes: Step S611: Store the images corresponding to subsequent events in the target queue in a first-to-last order; wherein, the first-to-last order indicates that the storage time of the image corresponding to the previous subsequent event is before the storage time of the image corresponding to the next subsequent event.
[0066] Retrieving subsequent event frames from the target queue can be done in a front-to-back order. This front-to-back order means that the frame corresponding to the previous subsequent event was stored before the frame corresponding to the next subsequent event. In other words, the target storage queue must strictly adhere to the first-in, first-out (FIFO) principle. That is, the frames corresponding to subsequent events stored first in the target queue must be retrieved first when retrieving subsequent event frames from the target queue.
[0067] Specifically, the target storage queue may include an enqueue buffer and a dequeue buffer. When the frames corresponding to subsequent events after the first frame are stored in the enqueue buffer of the target storage queue, they may carry the corresponding storage timestamps. When it is necessary to retrieve the frames corresponding to subsequent events from the target storage queue, the frames corresponding to the subsequent events with the earliest timestamps can be retrieved from the dequeue buffer of the target storage queue.
[0068] For example, in a game scene, if the current frame of a character's attack animation stutters, the screen corresponding to the earliest stored subsequent event can be selected from the screens corresponding to subsequent events.
[0069] The rendering method provided in this embodiment stores the frames corresponding to subsequent events in the target queue in order of first to last when the application thread experiences lag, so as to alleviate the frame dropping problem caused by rendering thread timeout.
[0070] In one possible implementation, the above method also includes: Step S71: If the event description information is the second target information, in response to the first vertical synchronization signal, the screen corresponding to the input event is drawn; wherein, the second target information indicates that the input event is not the first frame event.
[0071] The first vertical synchronization signal can indicate a signal to draw the screen corresponding to the input event.
[0072] The second target information can indicate that the input event is not a first-frame event. Specifically, if the event description information is detected as the second target information, the screen corresponding to the input event cannot be drawn directly. Instead, the screen corresponding to the input event can only be drawn after the first vertical synchronization signal is received.
[0073] Step S72: When the drawing duration exceeds the duration threshold, in response to the second vertical synchronization signal, draw subsequent events.
[0074] When the drawing duration exceeds the duration threshold, the continuous drawing mode is stopped. That is, subsequent events are not drawn continuously, but only after the second vertical synchronization signal is received. In other words, after the first frame event is detected, only one continuous drawing is performed to avoid excessive load on the system due to frequent continuous drawing.
[0075] This embodiment provides a method for drawing a screen, which can be used in the aforementioned terminal devices, such as computer 101, mobile terminal 102, etc. Figure 5 This is a schematic diagram of the third process of drawing a screen according to an embodiment of the present disclosure, such as... Figure 5 As shown, the process includes the following steps: Step S501: Obtain an input event, which represents an operation performed on the screen of the terminal device. For details, please refer to [link to relevant documentation]. Figure 4 Step S401 of the illustrated embodiment will not be described again here.
[0076] Step S502: Extract event description information from the input event. The event description information indicates the position of the input event in the event sequence, which includes the input event.
[0077] Specifically, the event description information includes a serial number; step S502 above includes: Step S5021: Extract the serial number from the input event.
[0078] The sequence number indicates the order of input events. Each input event has a corresponding sequence number. For example, the sequence number of input event A1 is 1, the sequence number of input event A2 is 2, and so on.
[0079] After receiving the input event, the sequence number can be extracted from it. This sequence number can be used to determine whether the input event is a first-frame event.
[0080] Step S503: If the event description information includes first target information, then the screen corresponding to the input event is drawn. The first target information is used to indicate that the input event is a first frame event. For details, please refer to [link to relevant documentation]. Figure 4 Step S403 of the illustrated embodiment will not be described again here.
[0081] The screen drawing method provided in this embodiment of the disclosure assigns a sequence number to each input event and sorts them according to the sequence number, which reduces the complexity of the processing logic. Furthermore, the sequence number provides a unique identifier for each input event, avoiding data confusion caused by similar event names or other reasons during event processing.
[0082] Please refer to Figure 6 and Figure 7 , Figure 6 This is a schematic diagram of the structure of a screen drawing system provided according to an embodiment of the present disclosure. Figure 7 This is a schematic diagram of the fourth process of drawing a screen according to an embodiment of the present disclosure.
[0083] Combination Figure 6 and Figure 7 As shown, the graphics rendering system used by the game system can include an application layer and a system layer. The game system can include an application layer, which can be used to execute the aforementioned graphics rendering methods.
[0084] The specific implementation at the application layer can include: After receiving an input event, the Input-vsync module determines whether the current input event is a first-frame event based on the event description information. If the current input event is a first-frame event, the Input-vsync module is triggered, and continuous drawing mode can be activated. That is, when operating the screen of the terminal device, the event description information needs to be extracted from the input event and it needs to be identified whether the event description information includes the first target information. When the event description information includes the first target information, the Input-vsync module is triggered, and continuous drawing mode can be activated.
[0085] In response to the triggering of continuous rendering mode, the UI Thread can be woken up directly. This means the UI Thread can be woken up without waiting for the Vsync-app signal. After being woken up, the UI Thread can begin drawing the screen corresponding to the input event without waiting for the Vsync-app signal. If the continuous rendering duration exceeds three Vsync cycles while the UI Thread is drawing the screen corresponding to the input event, the execution of continuous rendering mode will stop. Upon receiving the Vsync-app signal, the drawing of the screen corresponding to the input event can resume.
[0086] In this embodiment, in continuous rendering mode, the frames corresponding to subsequent events after the first frame event can be stored in the enqueue buffer of the target storage queue (e.g., ...). Figure 6 In the QueueBuffer, when it is necessary to retrieve the screen corresponding to a subsequent event from the target storage queue, it can be retrieved from the dequeue buffer (such as...) in the target storage queue. Figure 6 Extract the image corresponding to the subsequent event using the DequeueBuffer in the DequeueBuffer.
[0087] As an example, the target storage queue can include not only the screen corresponding to the currently stored subsequent events, but also the screen corresponding to other input events preceding the current input event—that is, the screen corresponding to events that have not yet been used in the target storage queue.
[0088] More specifically, when the main thread (UI Thread) requests the Vsync-app signal from the Vsync module and waits for Vsync to trigger, the UI Thread begins its work. Then, the application process's main thread (UI Thread) synchronizes data with the rendering thread (Render Thread). The rendering thread requests a buffer from the BufferQueue and sends rendering instructions to the GPU to render the image and queues a buffer in the BufferQueue. Simultaneously, the SurfaceFlinger requests the Vsync-sf signal from the vertical synchronization Vsync module, that is, it synchronizes the DisplayList data to the rendering thread (Render Thread) through the SyncFrameState of the surface thrower. At this point, the Render Thread is awakened by the UI thread and requests a buffer from the created target storage queue (Buffer Queue) to render the current UI data, waiting for Vsync-sf to trigger. When Vsync-sf is triggered, the SurfaceFlinger retrieves the rendered buffer from the BufferQueue, composites it, and then displays the composite image on the screen.
[0089] This embodiment also provides a screen drawing device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0090] This embodiment provides a drawing device for a screen, such as... Figure 8 As shown, it includes: an acquisition module 801, used to acquire input events, the input events representing operations performed on the screen of the terminal device; an extraction module 802, used to extract event description information from the input events, the event description information representing the position of the input event in the event sequence, the event sequence including the input events; and a drawing module 803, used to draw the screen corresponding to the input event if the event description information includes first target information, the first target information being used to indicate that the input event is the first frame event.
[0091] In one possible implementation, the device further includes a continuous drawing module for continuously drawing frames corresponding to a preset number of subsequent events, wherein the subsequent events occur after the first frame event.
[0092] In one possible implementation, the above device further includes: a duration acquisition module for acquiring the drawing duration; wherein the drawing duration is the duration from the moment the frame corresponding to the first frame event is drawn to the current moment; and a stop execution module for stopping the execution of the continuous drawing mode when the drawing duration exceeds a duration threshold; wherein the continuous drawing mode indicates that the frames corresponding to a preset number of subsequent events are drawn continuously.
[0093] In one possible implementation, the above-mentioned device further includes a storage module for storing the images corresponding to subsequent events in the target queue.
[0094] In one possible implementation, a storage module is used to store the images corresponding to subsequent events in a target queue in a first-to-last order; wherein the first-to-last order indicates that the storage time of the image corresponding to the previous subsequent event is before the storage time of the image corresponding to the next subsequent event.
[0095] In one possible implementation, the above apparatus further includes: a first response drawing module, configured to draw the screen corresponding to the input event in response to a first vertical synchronization signal if the event description information is second target information; wherein the second target information indicates that the input event is not the first frame event; and a second response drawing module, configured to draw subsequent events in response to a second vertical synchronization signal when the drawing duration is greater than a duration threshold.
[0096] In one possible implementation, extraction module 802 is used to extract the serial number from the input event.
[0097] In one possible implementation, input events include: press events and move events.
[0098] The screen drawing apparatus provided in this disclosure can execute the screen drawing method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the various modules and units described above are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0099] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure.
[0100] The following is a detailed reference. Figure 9The diagram illustrates a structural schematic suitable for implementing an electronic device according to embodiments of the present disclosure. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 901, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 902 or a program loaded from memory 908 into random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the electronic device. The processor 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0101] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0102] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a memory 908, or installed from a ROM 902. When the computer program is executed by the processor 901, it performs the functions defined in the screen drawing method of embodiments of this disclosure.
[0103] Figure 9 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0104] This disclosure also provides a computer-readable storage medium in which the methods described in this disclosure can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium may also include combinations of the above types of memory. It is understood that a computer, processor, microprocessor controller, or programmable hardware includes storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the screen drawing method shown in the above embodiments is implemented.
[0105] A portion of this disclosure can be applied to computer program products, such as computer program instructions, which, when executed by a computer, can invoke or provide methods and / or technical solutions according to this disclosure through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, and installation package files. Accordingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions; the computer compiling the instructions and then executing the corresponding compiled program; the computer reading and executing the instructions; or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0106] Although embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for drawing a picture, characterized in that, The method includes: Acquire input events, where the input events represent operations performed on the screen of the terminal device; Event description information is extracted from the input event, the event description information indicating the position of the input event in the event sequence, the event sequence including the input event; If the event description information includes first target information, then the screen corresponding to the input event is drawn, and the first target information is used to indicate that the input event is a first frame event.
2. The method for drawing a picture according to claim 1, characterized in that, The event sequence includes the first frame event and subsequent events. After rendering the image corresponding to the input event, the method further includes: The frames corresponding to a preset number of subsequent events are continuously drawn, and the subsequent events occur after the first frame event.
3. The method for drawing a picture according to claim 2, characterized in that, The method further includes: Obtain the drawing duration; wherein, the drawing duration is the time from the moment the frame corresponding to the first frame event is drawn to the current moment; When the drawing duration exceeds a duration threshold, the continuous drawing mode is stopped; wherein, the continuous drawing mode indicates that the screen corresponding to a preset number of subsequent events is drawn continuously.
4. The method for drawing a picture according to claim 2, characterized in that, The method further includes: The images corresponding to the subsequent events are stored in the target queue.
5. The method for drawing a picture according to claim 4, characterized in that, The step of storing the images corresponding to the subsequent events in the target queue includes: The images corresponding to the subsequent events are stored in the target queue in a first-to-last order; wherein, the first-to-last order indicates that the storage time of the image corresponding to the previous subsequent event is before the storage time of the image corresponding to the next subsequent event.
6. The method for drawing a picture according to claim 3, characterized in that, The method further includes: If the event description information is the second target information, in response to the first vertical synchronization signal, the frame corresponding to the input event is drawn; wherein, the second target information indicates that the input event is not a first frame event; When the drawing duration exceeds the duration threshold, the subsequent events are drawn in response to the second vertical synchronization signal.
7. The method for drawing a picture according to any one of claims 1-6, characterized in that, The event description information includes a serial number; the extraction of event description information from the input event includes: Extract the serial number from the input event.
8. The method for drawing a picture according to any one of claims 1-6, characterized in that, The input events include: press events and move events.
9. A device for drawing images, characterized in that, The device includes: The acquisition module is used to acquire input events, which represent operations performed on the screen of the terminal device; An extraction module is used to extract event description information from the input event, wherein the event description information indicates the position of the input event in an event sequence, and the event sequence includes the input event; A drawing module is used to draw the screen corresponding to the input event if the event description information includes first target information, wherein the first target information is used to indicate that the input event is a first frame event.
10. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the drawing method of any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to execute the drawing method of any one of claims 1 to 8.
12. A computer program product, characterized in that, Includes computer instructions, which are used to cause a computer to execute the drawing method of the screen according to any one of claims 1 to 8.