Screen drawing method, device, storage medium and terminal
By performing the animation callback and interface drawing of the next synchronization cycle in advance in the free time of the current synchronization cycle in the Android system, the interface drawing timeout and frame dropping caused by the animation callback time is solved, and the stability and fluency of screen refresh are improved.
Patent Information
- Application Number
- CN202210169858.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-23
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2042-02-23
AI Technical Summary
In Android systems, animation callbacks take too long to cause interface drawing timeout, which in turn causes application refresh timeout and frame dropping problems.
The animation callback of the next synchronization cycle is executed in advance during the free time of the current synchronization cycle, and the interface drawing is performed after the animation callback is completed, reducing the probability of interface drawing timeout caused by the animation callback taking too long.
It effectively reduces the probability of interface drawing timeout and application refresh timeout, thereby reducing the occurrence of frame drops, and improving the stability and fluency of picture drawing.
Smart Images

Figure CN114610255B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a screen drawing method, device, storage medium, and terminal. Background Art
[0002] In Android, the screen refresh process can be summarized into three main steps: the central processing unit (CPU) calculates screen data, the graphics processing unit (GPU) further processes and caches the data, and finally, the display displays the cached data. Typically, at a 60Hz screen refresh rate, the terminal refreshes the screen approximately every 16ms. This means that the underlying layer sends a vsync signal approximately every 16ms. Whenever a vsync signal arrives, the display displays the cached data. Simultaneously, the processor begins calculating the data for the next frame and stores it in the cache. When another vsync signal arrives, the display displays the data from the cache. Summary of the Invention
[0003] The embodiments of the present application provide a screen drawing method, device, computer storage medium, and terminal, which can reduce the probability of interface drawing timeout due to animation callback taking too long, thereby reducing the probability of application refresh timeout and frame drop. The technical solution is as follows:
[0004] In a first aspect, an embodiment of the present application provides a method for drawing a picture, the method comprising:
[0005] Determine the time when the current interface drawing is completed in the current synchronization cycle, and determine the time when the next synchronization signal arrives in the next synchronization cycle;
[0006] During the idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives, the animation callback of the next synchronization cycle is started to be executed, and after the animation callback is completed, the interface drawing of the next synchronization cycle is executed.
[0007] In a second aspect, an embodiment of the present application provides a screen drawing device, the device comprising:
[0008] The time determination module is used to determine the time when the current interface drawing is completed in the current synchronization cycle, and to determine the time when the next synchronization signal arrives in the next synchronization cycle;
[0009] The screen drawing module is used to start executing the animation callback of the next synchronization cycle in the idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives, and execute the interface drawing of the next synchronization cycle after the animation callback is completed.
[0010] In a third aspect, an embodiment of the present application provides a computer storage medium, which has multiple instructions, and the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.
[0011] In a fourth aspect, an embodiment of the present application provides a terminal, which may include: a memory and a processor; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the memory and executing the above-mentioned method steps.
[0012] The beneficial effects of the technical solutions provided in the embodiments of the present application include at least:
[0013] When the scheme of the embodiment of the present application is executed, the time when the current interface drawing of the current synchronization cycle is completed and the time when the next synchronization signal of the next synchronization cycle arrives are determined. In the idle time between the time when the current interface drawing is completed and the time when the next synchronization signal arrives, the animation callback of the next synchronization cycle is started to be executed, and the interface drawing of the next synchronization cycle is executed after the animation callback is completed. The present application reduces the probability of the interface drawing timeout due to the animation callback taking too long, thereby reducing the probability of application refresh timeout, and thereby reducing the probability of frame drops. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0015] Figure 1 This is a flow chart of a screen drawing method provided by an embodiment of the present application;
[0016] Figure 2 This is a schematic diagram of the principle of screen drawing provided by an embodiment of the present application;
[0017] Figure 3 This is a flowchart of another screen drawing method provided by an embodiment of the present application;
[0018] Figure 4 This is a schematic diagram of another principle of screen drawing provided by an embodiment of the present application;
[0019] Figure 5 This is another schematic diagram of the principle of screen drawing provided by an embodiment of the present application;
[0020] Figure 6 This is another schematic diagram of the principle of screen drawing provided by an embodiment of the present application;
[0021] Figure 7 This is another schematic diagram of the principle of screen drawing provided by an embodiment of the present application;
[0022] Figure 8 This is a structural diagram of a screen drawing device provided in an embodiment of the present application;
[0023] Figure 9 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, features, and advantages of the embodiments of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of this application.
[0025] In the description of this application, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance. In the description of this application, it should be noted that, unless otherwise expressly specified and limited, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to the specific circumstances. In addition, in the description of this application, unless otherwise specified, "multiple" refers to two or more. "and / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0026] In the Android system, the existing user interface (UI) refresh scheme primarily refreshes the screen at regular intervals. For example, at a 60Hz refresh rate, the underlying layer sends a vsync signal approximately every 16ms. The display retrieves data from the buffer and displays a frame. When the vsync signal arrives, the processor begins processing the next frame, primarily executing application animation callbacks and rendering the UI. These tasks must be completed within a specified timeframe (approximately 16ms at a 60Hz refresh rate). If the animation callbacks and UI rendering don't complete within the 16ms timeframe, the process is considered a timeout. When the next vsync signal arrives, the display cannot retrieve the frame data from the buffer and cannot display it, resulting in frame drops. Timeouts are primarily caused by animation callbacks taking too long. In many cases, this delay prevents UI rendering from completing when the next vsync signal arrives, causing the application refresh to timeout and cause frame drops.
[0027] The present application is described in detail below with reference to specific embodiments.
[0028] In the following method embodiments, for ease of description, only the execution subject of each step is introduced and described as the terminal.
[0029] See Figure 1 , is a flow chart of a method for drawing a picture provided by an embodiment of the present application. Figure 1 As shown, the method of the embodiment of the present application may include the following steps:
[0030] S101, determining the time when the current interface drawing of the current synchronization cycle is completed, and determining the time when the next synchronization signal of the next synchronization cycle arrives.
[0031] It can be understood that the synchronization cycle refers to a time period corresponding to the time period between two vsync signals. The current synchronization cycle can be a synchronization cycle that is currently being experienced. The next synchronization cycle can be the next synchronization cycle after the current synchronization cycle. During the UI refresh process, for example, the screen refresh rate is 60Hz, and a vsync synchronization signal arrives every 16ms or so. When each vsync synchronization signal arrives, the display needs to obtain the data of the current frame from the buffer and then display the current frame. At the same time, the processor needs to prepare for the refresh of the next frame, mainly including animation callback and UI drawing. Therefore, the current interface drawing can be the UI drawing that the terminal needs to execute within the current synchronization cycle, and the moment when the current interface drawing is completed can be the time point corresponding to the completion of the current UI drawing. The next synchronization signal can be the next vsync signal, and the moment when the next synchronization signal arrives can be the time point corresponding to the arrival of the next vsync signal.
[0032] For example, see Figure 2 The schematic diagram of the screen drawing shown in Figure 2 In the video, the synchronization signal represents the vsync signal. When each synchronization signal arrives, the display needs to obtain the data of the "current frame" from the buffer and then display the "current frame". At the same time, the processor needs to start preparing for the "next frame", which mainly includes animation callback and interface drawing. When the next synchronization signal arrives, the display can obtain the data of the "next frame" and then display the "next frame". The processor performs the corresponding work at the same time. Repeating the above operations can achieve screen refresh. Figure 2 In the example, the time period between synchronization signal 1 and synchronization signal 2 can be called the current synchronization period, then the time period between synchronization signal 2 and synchronization signal 3 is called the next synchronization period, and the arrival time of synchronization signal 2 is the arrival time of the next synchronization signal.
[0033] In some embodiments, during the terminal screen refresh process, the terminal can directly obtain the time point when the current interface drawing is completed within the current synchronization cycle, that is, the current interface drawing completion moment. The terminal can also calculate the time point when the next synchronization signal of the next synchronization cycle arrives, that is, the next synchronization signal arrival time. Generally, the duration corresponding to a synchronization cycle can be the inverse of the screen refresh rate, and the next synchronization signal arrival time can be obtained by adding the duration corresponding to a synchronization cycle to the current synchronization signal arrival time.
[0034] S102, starting to execute the animation callback of the next synchronization cycle in the idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives, and executing the interface drawing of the next synchronization cycle after the animation callback is completed.
[0035] In some embodiments, within the current synchronization cycle, the processor usually executes the animation callback first. After the animation callback is completed, the current interface drawing will begin. After the current interface drawing is completed, the current synchronization cycle has not yet ended, that is, the time point corresponding to the completion of the current interface drawing is still within the time of the current synchronization cycle. Then the time period between the moment the current interface drawing is completed and the moment the next synchronization signal arrives can be called idle time, and the moment the next synchronization signal arrives is the starting point of the next synchronization cycle. In the related art, within the current synchronization cycle, if there is idle time, the processor will wait until the next synchronization signal arrives to start executing the animation callback of the next synchronization cycle, and execute the interface drawing of the next synchronization cycle after the animation callback of the next synchronization cycle is completed. In the solution of the embodiment of the present application, within the current synchronization cycle, if there is idle time, the animation callback of the next synchronization cycle can be started during the idle time, and the interface drawing of the next synchronization cycle can be executed after the animation callback is completed.
[0036] When the scheme of the embodiment of the present application is executed, the time when the current interface drawing of the current synchronization cycle is completed and the time when the next synchronization signal of the next synchronization cycle arrives are determined. In the idle time between the time when the current interface drawing is completed and the time when the next synchronization signal arrives, the animation callback of the next synchronization cycle is started to be executed, and the interface drawing of the next synchronization cycle is executed after the animation callback is completed. The present application reduces the probability of the interface drawing timeout due to the animation callback taking too long, thereby reducing the probability of application refresh timeout, and thereby reducing the probability of frame drops.
[0037] See Figure 3 , is a flow chart of a method for drawing a picture provided by an embodiment of the present application. Figure 3 As shown, the method of the embodiment of the present application may include the following steps:
[0038] S301, receiving a sliding operation on a display interface, and obtaining the number of executions of the animation callback in the current synchronization cycle.
[0039] It is understood that the display interface may be a UI interface displayed on the terminal. The sliding operation may be a touch operation performed on the user UI interface. For example, the sliding operation may be a touch operation of sliding in a vertical direction, a touch operation of sliding in a horizontal direction, or a touch operation of sliding in any direction and at any angle.
[0040] The number of executions can be expressed as how many times the animation callback is executed in the current synchronization cycle.
[0041] The synchronization period may be a time period corresponding to the time period between two vsync signals.
[0042] In some embodiments, the applicable application scenario may be that the user performs a sliding operation on the display interface. Usually, the user performs a sliding operation on the display interface. In response to the sliding operation, the terminal needs to load a large amount of content and display it. If the application design is not optimized well, when the screen is refreshed in this scenario, the animation callback will take too long, causing the application refresh to time out and frame drops. In order to reduce the probability of frame drops in this scenario, the number of executions of the animation callback in the current synchronization cycle can be obtained when the user's sliding operation on the display interface is received. In specific scenarios, executing the steps of this solution can save terminal resources and avoid resource consumption caused by executing this solution in some scenarios where frame drops do not need to be optimized.
[0043] S302: If the execution times are less than the preset times, determining the time when the current interface drawing of the current synchronization cycle is completed, and determining the time when the next synchronization signal of the next synchronization cycle arrives.
[0044] It is understandable that the preset number of times can be set to 2 times, then the number of executions can only be 1 time or 0 times, ensuring that before the steps of this solution are executed, only the animation callback of the current synchronization cycle can be executed in the current synchronization cycle.
[0045] The current synchronization cycle may be a synchronization cycle currently being experienced.
[0046] The next synchronization cycle may be the next synchronization cycle after the current synchronization cycle. The next synchronization signal is the starting point of the next synchronization cycle, and the next synchronization signal is also a vsync signal.
[0047] In some embodiments, when it is determined that the number of executions meets the preset conditions, that is, it is less than the preset number of times, the terminal can directly obtain the time point corresponding to the completion of the current drawing interface, that is, the moment when the current interface drawing is completed. Furthermore, since the screen refresh rate is known, the screen refresh cycle can naturally be known. The duration of the screen refresh cycle is the duration of the synchronization cycle. Based on the known duration of the current synchronization cycle, the time point corresponding to the starting point of the next synchronization cycle can naturally be known, that is, the arrival time of the next synchronization signal can be known.
[0048] It should be noted that when the number of executions is greater than or equal to the preset number of times, there is no need to execute the steps of determining the time when the current interface drawing is completed in the current synchronization cycle, and determining the time when the next synchronization signal arrives in the next synchronization cycle. You can wait for the current synchronization cycle to pass, and when the next synchronization cycle arrives, treat the next synchronization cycle as the current synchronization cycle, and execute the steps of receiving the sliding operation on the display interface and obtaining the number of executions of the animation callback in the current synchronization cycle.
[0049] S303: within the current synchronization period, obtaining a first working duration corresponding to the animation callback of the current synchronization period, and obtaining a second working duration corresponding to the current interface drawing of the current synchronization period.
[0050] S304, calculating the sum of the first working duration and the second working duration, and determining the idle time between the current interface drawing completion time and the next synchronization signal arrival time based on the total duration of the current synchronization cycle and the sum.
[0051] S303 and S304 are explained below.
[0052] It is understandable that the first working time may be the duration for the terminal to complete the animation callback of the current synchronization cycle, and the second working time may be the duration for the terminal to complete the current interface drawing of the current synchronization cycle.
[0053] The total duration of the current synchronization cycle can be the duration within the cycle corresponding to the current synchronization cycle. For example, when the screen refresh rate is 60 Hz, the duration within a synchronization cycle is approximately 16 ms.
[0054] Idle time can be the time period during the current synchronization cycle when no tasks need to be executed (no animation callbacks or UI drawing are required).
[0055] In some embodiments, within the current synchronization cycle, the terminal should execute the animation callback of the current synchronization cycle, and after the animation callback of the current synchronization cycle is completed, the current interface drawing of the current synchronization cycle should be executed. Furthermore, the first working time corresponding to the execution of the animation callback of the current synchronization cycle and the second working time corresponding to the current interface drawing of the current synchronization cycle can be obtained. Since only one animation callback is executed within the current synchronization cycle, usually the animation callback of the current synchronization cycle starts to execute when the current synchronization signal of the current synchronization cycle arrives, then the sum of the first working time and the second working time can be calculated. Naturally, the time period corresponding to the total duration of the current synchronization cycle can be subtracted from the time period corresponding to the sum value starting from the starting point within the current synchronization cycle to obtain the idle time period within the current synchronization cycle, that is, the idle time between the moment the current interface drawing is completed and the moment the next synchronization signal arrives.
[0056] S305 , starting to execute the animation callback of the next synchronization cycle during the idle time, and starting to execute the interface drawing of the next synchronization cycle after the animation callback is completed.
[0057] In some embodiments, the animation callback of the next synchronization cycle can be started during the idle time of the current synchronization cycle, that is, the animation callback of the next synchronization cycle can be advanced to the idle time of the current synchronization cycle for execution. Further, after the animation callback of the next synchronization cycle is completed, it is still in the idle time of the current synchronization cycle, and the interface drawing of the next synchronization cycle can be started, that is, the interface drawing of the next synchronization cycle can be advanced to the idle time of the current synchronization cycle for execution. For example, see Figure 4 The diagram below shows the principle of drawing the screen. Figure 4 In the figure, the solid-line frame between synchronization signal 1 and synchronization signal 3 represents the animation callback and interface drawing of the current synchronization cycle, and the dotted-line frame represents the animation callback and interface drawing of the next synchronization cycle. After the animation callback and interface drawing in the current synchronization cycle are completed, the animation callback of the next synchronization cycle will be started during the idle time, and after the animation callback of the next synchronization cycle is completed, the interface drawing of the next synchronization cycle will be started.
[0058] S306 , determining, within the idle time, the interface drawing completion time of the next synchronization cycle, and determining the remaining idle time between the interface drawing completion time and the arrival time of the next synchronization signal.
[0059] S307, if the duration of the remaining idle time is greater than the preset duration, then within the remaining idle time, start executing the animation callback of the adjacent synchronization cycle after the next synchronization cycle, and execute the interface drawing of the adjacent synchronization cycle after the animation callback of the adjacent synchronization cycle is completed.
[0060] S308, if the duration of the remaining idle time is less than or equal to the preset duration, then within the next synchronization cycle, start executing the animation callback of the adjacent synchronization cycle after the next synchronization cycle, and execute the interface drawing of the adjacent synchronization cycle after the animation callback of the adjacent synchronization cycle is completed.
[0061] S306 to S308 are explained below.
[0062] In some embodiments, the interface drawing of the next synchronization cycle is started during the idle time of the current synchronization cycle. After the interface drawing of the next synchronization cycle is completed, if it is still within the idle time of the current synchronization cycle, the remaining idle time between the two moments can be determined based on the moment when the interface drawing of the next synchronization cycle is completed and the moment when the next synchronization signal arrives. Furthermore, on the one hand, if it is determined that the duration of the remaining idle time is greater than the preset duration (indicating that the remaining idle time is sufficient and the animation callback of the subsequent synchronization cycle can be executed in advance), the animation callback of the next synchronization cycle after the next synchronization cycle (i.e., the adjacent synchronization cycle) can be started within the remaining idle time. After the animation callback of the adjacent synchronization cycle is completed, the interface drawing of the adjacent synchronization cycle can be started within the adjacent synchronization cycle regardless of whether it is currently in the current synchronization cycle or in the next synchronization cycle. For example, see Figure 5 The diagram below shows the principle of drawing the screen. Figure 5 In the figure, the solid-line frame between synchronization signal 1 and synchronization signal 3 represents the animation callback and interface drawing in the current synchronization cycle, the dotted-line frame represents the animation callback and interface drawing in the next synchronization cycle, and the gray frame represents the animation callback and interface drawing of the adjacent synchronization cycle. The animation callback and interface drawing of the next synchronization cycle are all completed within the idle time, and there is sufficient remaining idle time within the idle time. The animation callback of the adjacent synchronization cycle can be started within the remaining idle time. Using the above method, on the basis of sufficient time, the animation callbacks of the two synchronization cycles after the current synchronization cycle are selected to be executed in advance, which can further reduce the probability of the animation callback in the subsequent synchronization cycle being completed due to timeout, and thus can further reduce the probability of frame drops caused by animation callback timeout.
[0063] On the other hand, if it is determined that the duration of the remaining idle time is less than or equal to the preset duration (indicating that the remaining idle time is insufficient and there is no need to execute the animation callback of the subsequent synchronization cycle in advance), the animation callback of another synchronization cycle after the next synchronization cycle (i.e., the adjacent synchronization cycle) can be advanced to the next synchronization cycle for execution, and the interface drawing of the adjacent synchronization cycle can be executed after the animation callback of the adjacent synchronization cycle is completed. In this case, the animation callback of the adjacent synchronization cycle is executed in the next synchronization cycle, and when the time enters the next synchronization cycle, this scheme can be executed with reference to steps S301 to S307. At this time, the next synchronization cycle is the current synchronization cycle in the above steps, and the adjacent synchronization cycle is the adjacent synchronization cycle in the above steps. For example, see Figure 6 The diagram shown is a schematic diagram of the principle of screen drawing. Figure 6 In the figure, the solid-line frame between synchronization signal 1 and synchronization signal 3 represents the animation callback and interface drawing in the current synchronization cycle, the dotted-line frame represents the animation callback and interface drawing in the next synchronization cycle, and the gray frame represents the animation callback and interface drawing of the adjacent synchronization cycle. The animation callback and interface drawing of the next synchronization cycle are all completed within the idle time of the current synchronization cycle. At this time, the remaining idle time is insufficient, and the animation callback of the adjacent synchronization cycle can no longer be executed in advance. The animation callback of the adjacent synchronization cycle can be executed in the next synchronization cycle. By adopting the above method, on the basis of insufficient time, the animation callback of the next synchronization cycle is guaranteed to be executed in advance, which can reduce the probability of interface drawing timeout due to the animation callback taking too long, thereby reducing the probability of application refresh timeout, thereby reducing the probability of frame drop, and thereby reducing the probability of freeze caused by frame drop.
[0064] S309, during the idle time, the animation callback of the next synchronization cycle is started to be executed, the animation callback of the next synchronization cycle is completed during the idle time, and during the next synchronization cycle, and when the next synchronization signal of the next synchronization cycle arrives, the interface drawing of the next synchronization cycle is started to be executed.
[0065] In some embodiments, the animation callback of the next synchronization cycle can be started during the idle time of the current synchronization cycle, that is, the animation callback of the next synchronization cycle is advanced to the idle time of the current synchronization cycle. Furthermore, after the animation callback of the next synchronization cycle is completed, while it is still within the idle time of the current synchronization cycle, the terminal may no longer execute any animation callback or interface drawing of any synchronization cycle until entering the next synchronization cycle. When the next synchronization signal of the next synchronization cycle arrives, the interface drawing of the next synchronization cycle will be started.
[0066] Optionally, in another embodiment, the animation callback of the next synchronization cycle can be started during the idle time of the current synchronization cycle, that is, the animation callback of the next synchronization cycle can be advanced to the idle time of the current synchronization cycle for execution. Furthermore, after the animation callback of the next synchronization cycle is completed, while it is still within the idle time of the current synchronization cycle, the terminal can start executing the animation callback of the next synchronization cycle after the next synchronization cycle, that is, advance the animation callback of the next synchronization cycle after the next synchronization cycle to the idle time of the current synchronization cycle for execution, until entering the next synchronization cycle, and when the next synchronization signal of the next synchronization cycle arrives, start executing the interface drawing of the next synchronization cycle. By adopting the above method, choosing to execute the animation callbacks of the two synchronization cycles after the current synchronization cycle in advance, the probability of the interface drawing timing out due to the animation callback taking too long can be further reduced, thereby further reducing the problem of frame drops caused by interface drawing timeout.
[0067] S310, starting to execute the animation callback of the next synchronization cycle during the idle time, and starting to execute the interface drawing of the next synchronization cycle during the next synchronization cycle and after the animation callback of the next synchronization cycle is completed.
[0068] In some embodiments, the animation callback of the next synchronization cycle can be started during the idle time of the current synchronization cycle, that is, the animation callback of the next synchronization cycle is advanced to the idle time of the current synchronization cycle. Further, after the animation callback of the next synchronization cycle is completed, it is already in the next synchronization cycle, and the interface drawing of the next synchronization cycle can be started. For example, see Figure 7 The diagram below shows the principle of drawing the screen. Figure 7 In the figure, the solid-line frame between synchronization signal 1 and synchronization signal 3 represents the animation callback and interface drawing of the current synchronization cycle, and the dotted-line frame represents the animation callback and interface drawing of the next synchronization cycle. The animation callback of the next synchronization cycle is started during the idle time of the current synchronization cycle. After the animation callback of the next synchronization cycle is completed, it is already in the next synchronization cycle, so the animation callback of the next synchronization cycle can be started. Using the above method, the animation callback of the next synchronization cycle is executed in advance in the current synchronization cycle, which can reduce the probability of interface drawing timeout due to the animation callback taking too long, and thus reduce the probability of frame drops caused by interface drawing timeout, and thus reduce the probability of freezes caused by frame drops.
[0069] When receiving a sliding operation on the display interface, the embodiment of the present application obtains the number of executions of the animation callback in the current synchronization cycle. This solution can be executed while saving terminal resources. Then, when it is determined that the number of executions is less than the preset number, the animation callback of the next synchronization cycle is advanced to the idle time of the current synchronization cycle for execution. Then, after the animation callback of the next synchronization cycle is completed, the interface drawing of the next synchronization cycle is executed. On the basis of ensuring that the terminal memory is not affected, the probability of the interface drawing timeout due to the animation callback taking too long can be reduced, thereby reducing the probability of application refresh timeout, thereby reducing the probability of frame drop, thereby reducing the probability of freeze caused by frame drop. Moreover, the present application advances the execution timing of the animation callback, and does not involve adjusting the frequency of the processor. There is no need to solve the freeze problem by increasing the processor frequency as in the related art. Increasing the processor frequency will increase the power consumption of the terminal, while the present application does not affect the power consumption of the terminal. In addition, this application advances the execution timing of the animation callback. In addition to executing the animation callback of the next synchronization cycle in advance within the current synchronization cycle, the animation callback and interface drawing of the next synchronization cycle can also be executed in advance within the current synchronization cycle. It can even execute the animation callback of the next synchronization cycle and the animation callback of the next synchronization cycle in the current synchronization cycle. This can further reduce the probability of interface drawing timeout due to the animation callback taking too long, and thus further reduce the problem of frame drops caused by interface drawing timeout.
[0070] See Figure 8 , is a schematic diagram of the structure of a screen drawing device provided in an embodiment of the present application. Screen drawing device 800 can be implemented as all or part of a terminal through software, hardware, or a combination of both. Device 800 includes:
[0071] The time determination module 810 is used to determine the time when the current interface drawing is completed in the current synchronization cycle, and to determine the time when the next synchronization signal arrives in the next synchronization cycle;
[0072] The screen drawing module 820 is used to start executing the animation callback of the next synchronization cycle in the idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives, and execute the interface drawing of the next synchronization cycle after the animation callback is completed.
[0073] Optionally, the time determination module 810 includes:
[0074] The time determination unit is used to receive a sliding operation on the display interface, determine the time when the current interface drawing is completed in the current synchronization cycle, and determine the time when the next synchronization signal arrives in the next synchronization cycle.
[0075] Optionally, the apparatus 800 further includes:
[0076] The number judgment module is used to obtain the number of executions of the animation callback in the current synchronization cycle; if the number of executions is less than the preset number, the steps of determining the completion time of the current interface drawing of the current synchronization cycle and determining the arrival time of the next synchronization signal of the next synchronization cycle are executed.
[0077] Optionally, the screen drawing module 820 includes:
[0078] The duration calculation unit is used to obtain, within the current synchronization period, a first working duration corresponding to the animation callback of the current synchronization period, and obtain a second working duration corresponding to the current interface drawing of the current synchronization period;
[0079] an idle time determining unit, configured to calculate a sum of the first working duration and the second working duration, and determine an idle time between a moment when the current interface drawing is completed and a moment when the next synchronization signal arrives based on a total duration of the current synchronization cycle and the sum;
[0080] The screen drawing unit is used to start executing the animation callback of the next synchronization cycle during the idle time, and execute the interface drawing of the next synchronization cycle after the animation callback is completed.
[0081] Optionally, the screen drawing module 820 includes:
[0082] A first drawing unit is configured to start executing interface drawing of the next synchronization cycle during the idle time and after the animation callback of the next synchronization cycle is completed;
[0083] or,
[0084] A second drawing unit, wherein the animation callback of the next synchronization cycle is completed within the idle time, and is used to start executing the interface drawing of the next synchronization cycle within the next synchronization cycle and when the next synchronization signal of the next synchronization cycle arrives;
[0085] or,
[0086] The third drawing unit is configured to start executing the interface drawing of the next synchronization period within the next synchronization period and after the animation callback of the next synchronization period is completed.
[0087] Optionally, the first drawing unit further includes:
[0088] A first drawing sub-unit is configured to determine, within the idle time, a time at which the interface drawing of the next synchronization cycle is completed;
[0089] The second drawing sub-unit is used to determine the remaining idle time between the moment when the interface drawing is completed and the moment when the next synchronization signal arrives;
[0090] The third drawing sub-unit is used to start executing the animation callback of the adjacent synchronization cycle after the next synchronization cycle within the remaining idle time if the duration of the remaining idle time is greater than the preset duration, and to execute the interface drawing of the adjacent synchronization cycle after the animation callback of the adjacent synchronization cycle is completed.
[0091] Optionally, the first drawing unit further includes:
[0092] The fourth drawing sub-unit is used to start executing the animation callback of the adjacent synchronization cycle after the next synchronization cycle within the next synchronization cycle if the duration of the remaining idle time is less than or equal to the preset duration, and to execute the interface drawing of the adjacent synchronization cycle after the animation callback of the adjacent synchronization cycle is completed.
[0093] Please refer to Figure 9 , Figure 9 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present application. Figure 9 As shown, the terminal 1300 may include: at least one processor 1301 , at least one network interface 1304 , a user interface 1303 , a memory 1305 , a display screen component 1306 , and at least one communication bus 1302 .
[0094] The communication bus 1302 is used to implement the connection and communication between these components.
[0095] The user interface 1303 may include a display screen (Display) and a camera (Camera). The optional user interface 1303 may also include a standard wired interface and a wireless interface.
[0096] The network interface 1304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0097] The processor 1301 may include one or more processing cores. The processor 1301 utilizes various interfaces and circuits to connect various components within the terminal 1300. It executes instructions, programs, code sets, or instruction sets stored in the memory 1305, and accesses data stored in the memory 1305 to perform various functions and process data for the terminal 1300. Optionally, the processor 1301 may be implemented using at least one of the following hardware forms: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor 1301 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing content displayed on the display screen; and the modem handles wireless communications. It is understood that the modem may not be integrated into the processor 1301 but implemented as a separate chip.
[0098] Among them, the memory 1305 may include a random access memory (RAM) or a read-only memory (Read-Only Memory). Optionally, the memory 1305 includes a non-transitory computer-readable storage medium. The memory 1305 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 1305 may also be optionally at least one storage device located away from the aforementioned processor 1301. As Figure 9 As shown, the memory 1305 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a program of a screen drawing method.
[0099] exist Figure 9In the terminal 1300 shown, the user interface 1303 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 1301 can be used to call the program of the screen drawing method stored in the memory 1305 and specifically perform the following operations:
[0100] Determine the time when the current interface drawing is completed in the current synchronization cycle, and determine the time when the next synchronization signal arrives in the next synchronization cycle;
[0101] During the idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives, the animation callback of the next synchronization cycle is started to be executed, and after the animation callback is completed, the interface drawing of the next synchronization cycle is executed.
[0102] In one embodiment, the processor 1301 performs the following operations during the steps of determining the time when the current interface drawing of the current synchronization cycle is completed and determining the time when the next synchronization signal of the next synchronization cycle arrives:
[0103] A sliding operation on the display interface is received, and a current interface drawing completion time of the current synchronization cycle is determined, as well as a next synchronization signal arrival time of the next synchronization cycle is determined.
[0104] In one embodiment, before determining the current interface drawing completion time of the current synchronization cycle and determining the next synchronization signal arrival time of the next synchronization cycle, the processor 1301 further performs the following operations:
[0105] Get the number of animation callback executions in the current synchronization cycle;
[0106] If the execution times are less than the preset times, the steps of determining the time when the current interface drawing of the current synchronization cycle is completed and determining the time when the next synchronization signal of the next synchronization cycle arrives are performed.
[0107] In one embodiment, the processor 1301, during the idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives, starts executing the animation callback of the next synchronization cycle, and executes the interface drawing of the next synchronization cycle after the animation callback is completed, specifically performs the following operations:
[0108] In the current synchronization cycle, obtaining a first working duration corresponding to the animation callback of the current synchronization cycle, and obtaining a second working duration corresponding to the current interface drawing of the current synchronization cycle;
[0109] Calculating a sum of the first working duration and the second working duration, and determining an idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives based on the total duration of the current synchronization cycle and the sum;
[0110] During the idle time, the animation callback of the next synchronization cycle is started to be executed, and after the animation callback is completed, the interface drawing of the next synchronization cycle is executed.
[0111] In one embodiment, when executing the step of executing the interface drawing of the next synchronization cycle after the animation callback is completed, the processor 1301 specifically performs the following operations:
[0112] During the idle time, and after the animation callback of the next synchronization cycle is completed, starting to execute the interface drawing of the next synchronization cycle;
[0113] or,
[0114] The animation callback of the next synchronization cycle is completed within the idle time, and the interface drawing of the next synchronization cycle is started in the next synchronization cycle and when the next synchronization signal of the next synchronization cycle arrives;
[0115] or,
[0116] In the next synchronization cycle, and after the animation callback of the next synchronization cycle is completed, the interface drawing of the next synchronization cycle begins to be executed.
[0117] In one embodiment, after executing the above steps within the idle time and after the animation callback of the next synchronization cycle is completed and the interface drawing of the next synchronization cycle is started, the processor 1301 further performs the following operations:
[0118] Determining the interface drawing completion time of the next synchronization cycle during the idle time;
[0119] Determine the remaining idle time between the moment when the interface drawing is completed and the moment when the next synchronization signal arrives;
[0120] If the duration of the remaining idle time is greater than the preset duration, the animation callback of the adjacent synchronization cycle after the next synchronization cycle will be executed during the remaining idle time, and the interface drawing of the adjacent synchronization cycle will be executed after the animation callback of the adjacent synchronization cycle is completed.
[0121] In one embodiment, the processor 1301 further performs the following operations:
[0122] If the duration of the remaining idle time is less than or equal to the preset duration, then within the next synchronization cycle, the animation callback of the adjacent synchronization cycle after the next synchronization cycle will be executed, and the interface drawing of the adjacent synchronization cycle will be executed after the animation callback of the adjacent synchronization cycle is completed.
[0123] In addition, those skilled in the art will appreciate that the structure of terminal 1300 shown in the above figures does not limit terminal 1300. A user terminal may include more or fewer components than shown, or may combine certain components or arrange the components differently. For example, terminal 1300 also includes components such as radio frequency circuits, audio circuits, WiFi components, power supplies, and Bluetooth components, which will not be described in detail here.
[0124] An embodiment of the present application further provides a computer-readable storage medium, which stores at least one instruction, and the at least one instruction is used to be executed by a processor to implement the screen drawing method described in the above embodiments.
[0125] An embodiment of the present application further provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the screen drawing method described in the above embodiments.
[0126] Those skilled in the art will appreciate that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any media that facilitates the transmission of computer programs from one place to another. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0127] The above description is merely an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for drawing a picture, characterized in that: The method comprises: Receive the sliding operation on the display interface and obtain the number of executions of the animation callback in the current synchronization cycle; If the execution count is less than the preset count, the current interface drawing completion time of the current synchronization cycle is determined, and the next synchronization signal arrival time of the next synchronization cycle is determined; in the idle time between the current interface drawing completion time and the next synchronization signal arrival time, the animation callback of the next synchronization cycle is started to be executed, and the interface drawing of the next synchronization cycle is executed after the animation callback is completed; If the number of executions is greater than or equal to the preset number of times, the steps of determining the time when the current interface drawing is completed in the current synchronization cycle and determining the time when the next synchronization signal arrives in the next synchronization cycle are canceled. When the next synchronization cycle arrives, the next synchronization cycle is regarded as the current synchronization cycle, and the step of receiving the sliding operation on the display interface and obtaining the number of executions of the animation callback in the current synchronization cycle is executed.
2. The method according to claim 1, characterized in that Determining the current interface drawing completion time of the current synchronization cycle and determining the next synchronization signal arrival time of the next synchronization cycle includes: A sliding operation on the display interface is received, and a current interface drawing completion time of the current synchronization cycle is determined, as well as a next synchronization signal arrival time of the next synchronization cycle is determined.
3. The method according to any one of claims 1-2, characterized in that The method starts executing the animation callback of the next synchronization cycle in the idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives, and executes the interface drawing of the next synchronization cycle after the animation callback is completed, including: In the current synchronization cycle, obtaining a first working duration corresponding to the animation callback of the current synchronization cycle, and obtaining a second working duration corresponding to the current interface drawing of the current synchronization cycle; Calculating a sum of the first working duration and the second working duration, and determining an idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives based on the total duration of the current synchronization cycle and the sum; During the idle time, the animation callback of the next synchronization cycle is started to be executed, and after the animation callback is completed, the interface drawing of the next synchronization cycle is executed.
4. The method according to any one of claims 1-2, characterized in that The execution of the interface drawing of the next synchronization cycle after the animation callback is completed includes: During the idle time, and after the animation callback of the next synchronization cycle is completed, starting to execute the interface drawing of the next synchronization cycle; or, The animation callback of the next synchronization cycle is completed within the idle time, and the interface drawing of the next synchronization cycle is started in the next synchronization cycle and when the next synchronization signal of the next synchronization cycle arrives; or, In the next synchronization cycle, and after the animation callback of the next synchronization cycle is completed, the interface drawing of the next synchronization cycle begins to be executed.
5. The method according to claim 4, characterized in that The method further includes: during the idle time, and after the animation callback of the next synchronization cycle is completed and the interface drawing of the next synchronization cycle is started, Determining the interface drawing completion time of the next synchronization cycle during the idle time; Determine the remaining idle time between the moment when the interface drawing is completed and the moment when the next synchronization signal arrives; If the duration of the remaining idle time is greater than the preset duration, the animation callback of the adjacent synchronization cycle after the next synchronization cycle will be executed during the remaining idle time, and the interface drawing of the adjacent synchronization cycle will be executed after the animation callback of the adjacent synchronization cycle is completed.
6. The method according to claim 5, characterized in that The method further comprises: If the duration of the remaining idle time is less than or equal to the preset duration, then within the next synchronization cycle, the animation callback of the adjacent synchronization cycle after the next synchronization cycle will be executed, and the interface drawing of the adjacent synchronization cycle will be executed after the animation callback of the adjacent synchronization cycle is completed.
7. A screen drawing device, characterized in that: The device comprises: A time determination module is configured to receive a sliding operation on the display interface and obtain the number of executions of the animation callback in the current synchronization cycle; if the execution number is less than a preset number, determine the time when the current interface drawing is completed in the current synchronization cycle, and determine the time when the next synchronization signal arrives in the next synchronization cycle; The screen drawing module is used to start executing the animation callback of the next synchronization cycle in the idle time between the moment when the current interface drawing is completed and the moment when the next synchronization signal arrives, and execute the interface drawing of the next synchronization cycle after the animation callback is completed; The device is also used to: if the number of executions is greater than or equal to the preset number of times, cancel the steps of determining the time when the current interface drawing of the current synchronization cycle is completed, and determining the time when the next synchronization signal of the next synchronization cycle arrives. When the next synchronization cycle arrives, the next synchronization cycle is regarded as the current synchronization cycle, and the steps of receiving the sliding operation on the display interface and obtaining the number of executions of the animation callback in the current synchronization cycle are executed.
8. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, which are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 6.
9. A terminal, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image processing method and electronic device
WO2022021895A1