Animation frame skipping method and related device
By triggering the frame skipping by the choreographer based on the flag bits of the animation frame data and the Vsync signal, the problem of increasing power consumption when displaying the animation interface is solved, and the effect of reducing power consumption and improving user experience is achieved.
Patent Information
- Application Number
- CN202310854795.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-12
- Publication Date
- 2025-05-20
- Estimated Expiration
- 2043-07-12
AI Technical Summary
When electronic devices display an animation interface, frequent drawing, rendering and sending graphics lead to an increase in power consumption, affecting the user experience.
The choreographer uses the flag bits of the animation frame data to trigger the jump frame to draw, render and send one or more loop animation animation frames according to the flag bits of the animation frame data, reducing the frequency of drawing, rendering and sending.
It effectively reduces the power consumption of electronic devices, reduces heat generation, and improves the user's experience of using the application.
Smart Images

Figure CN117689774B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular, to an animation frame skipping method and related devices. Background Art
[0002] With the popularization of electronic devices such as smart phones, tablet computers, and wearable devices, when a user uses an electronic device such as a smart phone, the electronic device can display an interface with animations on the display screen. The electronic device will schedule system resources such as processing power and storage capacity, and frequently draw, render, and synthesize and send the animations for display. In this way, it will bring a lot of power consumption to the electronic device, resulting in an increase in the heat generation of the electronic device, which affects the user experience of using the application. Summary of the Invention
[0003] This application provides an animation frame skipping method and related devices, which can enable the Choreographer to trigger frame skipping according to the flag bits of the animation frame data, and cooperate with the Vsync signal to draw, render, and send the animation frames of one or more loop animations, so as to reduce the frequency of drawing, rendering, and synthesizing and sending, and reduce the power consumption of the electronic device.
[0004] In a first aspect, this application provides an animation frame skipping method, including: receiving a first operation for opening a first interface, where the first interface includes a first loop animation, the first loop animation has animation frames corresponding to timestamps, and the first interface is an interface of a first application; after receiving the first operation, receiving a first vertical synchronization signal by the Choreographer at a first moment, and in response to the flag bits of the animation frames before the first moment being a first preset value, drawing and rendering the animation frames before the first moment by the first application; and, in response to the flag bits of the animation frames before the first moment not being the first preset value, not drawing and rendering the animation frames before the first moment; performing layer composition on the drawn and rendered animation frames by a layer compositor, and displaying the first loop animation in the first interface.
[0005] Through the animation frame skipping method provided in the embodiments of this application, when an electronic device displays a first interface of a first application including a loop animation, the Choreographer of the electronic device can trigger frame skipping according to the flag bits of the loop animation, and cooperate with the Vsync signal to draw, render, and send the animation frames of one or more loop animations, so as to reduce the frequency of drawing, rendering, and synthesizing and sending. In this way, the power consumption of the electronic device can be reduced.
[0006] In a possible implementation, the first interface further includes a second loop animation, and the second loop animation has animation frames corresponding to timestamps; the animation frames of the second loop animation before the first moment include the animation frames of the first loop animation and the animation frames of the second loop animation; the method further includes: after layer composition of the drawn and rendered animation frames by a layer compositor, displaying the second loop animation in the first interface.
[0007] In this way, when there are multiple loop animations in the first interface, according to the flag bits of the multiple loop animations, in cooperation with the Vsync signal, frame skipping is triggered to draw, render, and display the animation frames of the multiple loop animations, so as to reduce the frequencies of drawing, rendering, and compositing and displaying, thereby reducing the power consumption of the electronic device.
[0008] In a possible implementation, the method further includes: after receiving the first operation, creating N callback records in the callback queue of the choreographer, where the callback records include the timestamps and flag bits of the animation frames; the flag bit is greater than or equal to the first preset value, and N is a positive integer.
[0009] In a possible implementation, in response to the flag bit of the animation frame before the first moment being the first preset value, drawing and rendering the animation frame by the first application specifically includes: if there is a callback record in M callback records in the callback queue whose timestamp is before the first moment and the flag bit of the animation frame is equal to the first preset value, drawing and rendering the M animation frames corresponding to the M callback records by the first application, where 1 < M ≤ N and M is an integer.
[0010] In this way, when there are callback records of animation frames that need to be drawn, rendered, and composited and displayed in M callback records before the first moment, all the M callback records are drawn, rendered, and composited and displayed. While reducing the power consumption of the electronic device, the display effect of the loop animation is also taken into account.
[0011] In a possible implementation, the method further includes: after drawing and rendering the M animation frames corresponding to the M callback records by the first application, deleting the M callback records from the callback queue.
[0012] In this way, the callback records of the animation frames that trigger drawing and rendering can be deleted from the callback queue in a timely manner, preventing the choreographer from repeatedly triggering the drawing and rendering of animation frames.
[0013] In a possible implementation, the layer composition of the drawn and rendered animation frames by the layer compositor specifically includes: after the layer compositor obtains a second vertical synchronization signal, performing layer composition on the M rendered animation frames, where the second vertical synchronization signal is the next vertical synchronization signal of the first vertical synchronization signal.
[0014] In a possible implementation, if the flag bit of the animation frame whose timestamp is before the first moment is not the first preset value, the animation frame is not drawn and rendered. Specifically, if the flag bits of the animation frames in the M callback records whose timestamps are before the first moment in the callback queue are not equal to the first preset value, the M animation frames corresponding to the M callback records are not drawn and rendered.
[0015] In this way, the choreographer can be used to skip frames for drawing, rendering, and compositing and sending the animation frames for display.
[0016] In a possible implementation, the method further includes: if the flag bit of the animation frame whose timestamp is before the first moment is not the first preset value, subtracting a fixed value from the flag bits of all the animation frames whose timestamps are before the first moment; when the choreographer receives a second vertical synchronization signal at a second moment, if the flag bit of the animation frame whose timestamp is before the second moment is the first preset value, drawing and rendering the animation frames whose timestamps are before the second moment by the first application; and if the flag bit of the animation frame whose timestamp is before the second moment is not the first preset value, not drawing and rendering the animation frames whose timestamps are before the second moment; where the second vertical synchronization signal is the next vertical synchronization signal of the first vertical synchronization signal.
[0017] In a possible implementation, subtracting a fixed value from the flag bits of all the animation frames whose timestamps are before the first moment if the flag bit of the animation frame whose timestamp is before the first moment is not the first preset value specifically includes: if the flag bits of the animation frames in the M callback records whose timestamps are before the second moment in the callback queue are not equal to the first preset value, subtracting the fixed value from the flag bits of the animation frames in the M callback records; drawing and rendering the animation frames whose timestamps are before the second moment by the first application if the flag bit of the animation frame whose timestamp is before the second moment is the first preset value specifically includes: if there is a callback record whose flag bit of the animation frame is equal to the first preset value among the K callback records whose timestamps are before the second moment in the callback queue, drawing and rendering the K animation frames corresponding to the K callback records by the first application, the K animation frames including the M animation frames, K≥M, and K is an integer; not drawing and rendering the animation frames whose timestamps are before the second moment if the flag bit of the animation frame whose timestamp is before the second moment is not the first preset value specifically includes: if the flag bits of the animation frames in the K callback records whose timestamps are before the second moment in the callback queue are not equal to the first preset value, not drawing and rendering the K animation frames corresponding to the K callback records.
[0018] In a possible implementation, the method further includes: after the first application draws and renders the K animation frames corresponding to the K callback records, deleting the K callback records from the callback queue.
[0019] In a possible implementation, after the first application draws and renders the K animation frames corresponding to the K callback records, the method further includes: after the layer compositor obtains a third vertical synchronization signal, performing layer composition on the drawn and rendered K animation frames, where the third vertical synchronization signal is the next vertical synchronization signal of the second vertical synchronization signal.
[0020] In a second aspect, the present application provides an electronic device, including a display screen, one or more processors, and one or more memories; wherein, the display screen, the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions, and when the one or more processors execute the computer instructions, the method in any possible implementation manner of the first aspect is executed.
[0021] In a third aspect, the present application provides another electronic device, including one or more functional modules, and the one or more functional modules are used to execute the method in any possible implementation manner of the first aspect.
[0022] In a fourth aspect, the present application provides a chip, which is applied to an electronic device, wherein the chip includes a processing circuit and an interface circuit, the interface circuit is used to receive instructions and transmit them to the processing circuit, and the processing circuit is used to run the instructions to execute the method in any possible implementation manner of any aspect above.
[0023] In a fifth aspect, the present application provides a computer-readable storage medium, including instructions, and when the instructions run on an electronic device, the method in any possible implementation manner of the first aspect is executed.
[0024] In a sixth aspect, an embodiment of the present application provides a computer program product, and when the computer program product runs on a computer, the computer is caused to execute the method in any possible implementation manner of any aspect above. Description of the Drawings
[0025] Figure 1 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application;
[0026] Figure 2 It is a timing diagram of the animation frames from drawing to display in the interface provided by an embodiment of the present application;
[0027] Figures 3A - 3DThe display scenario of multiple loop animations provided by the embodiments of the present application;
[0028] Figure 4 The sending display timing diagram when the interface provided by the embodiments of the present application includes multiple animations;
[0029] Figure 5 The schematic diagram of the software system architecture of an electronic device provided by the embodiments of the present application;
[0030] Figure 6 The schematic flowchart of an animation frame skipping method provided by the embodiments of the present application;
[0031] Figure 7 The process for the choreographer to determine whether to draw animation frames provided by the embodiments of the present application;
[0032] Figure 8 The process for the choreographer to generate and process callback records provided by the embodiments of the present application;
[0033] Figure 9 The animation sending display timing diagram of the animation frame skipping method provided by the embodiments of the present application. Detailed implementation manners
[0034] Next, the technical solutions in the embodiments of the present application will be clearly and elaborately described with reference to the accompanying drawings. Among them, in the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B may mean A or B; "and / or" in the text is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B may mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0035] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as implying or suggesting relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" is two or more than two.
[0036] Next, the hardware structure of an electronic device provided by the embodiments of the present application will be introduced.
[0037] Figure 1 The schematic diagram of the structure of an electronic device 100 provided by the embodiments of the present application is shown.
[0038] It should be understood that Figure 1 The illustrated electronic device 100 is only an example, and the electronic device 100 may have moreFigure 1 More or fewer components shown therein may combine two or more components, or may have different component configurations. Figure 1 The various components shown therein may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.
[0039] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a touch sensor 180K, etc.
[0040] It can be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0041] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices, or may be integrated in one or more processors.
[0042] Among them, the controller may be the nerve center and command center of the electronic device 100. The controller may generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching instructions and executing instructions.
[0043] A memory can also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0044] The wireless communication function of the electronic device 100 can be implemented by the antenna 1, antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.
[0045] The antenna 1 and the antenna 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example, the antenna 1 can be multiplexed as the diversity antenna of the wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0046] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc. applied to the electronic device 100. The mobile communication module 150 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves through the antenna 1, filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor and convert it into electromagnetic waves through the antenna 1 for radiation. In some embodiments, at least some functional modules of the mobile communication module 150 can be provided in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 can be provided in the same device.
[0047] The modulation and demodulation processor can include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194. In some embodiments, the modulation and demodulation processor can be an independent device. In some other embodiments, the modulation and demodulation processor can be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
[0048] The wireless communication module 160 may provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSSs), frequency modulation (FM), near field communication (NFC), infrared (IR), and so on. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 may also receive signals to be sent from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 2 for radiation.
[0049] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technologies. The wireless communication technologies may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS may include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), BeiDou Navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS), and / or Satellite Based Augmentation Systems (SBAS).
[0050] The electronic device 100 implements the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change the display information.
[0051] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can adopt a liquid crystal display (LCD). The display screen panel can also adopt an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniLED, a microLED, a micro-OLED, a quantum dot light-emitting diode (QLED), etc. to manufacture. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.
[0052] The electronic device 100 can implement the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.
[0053] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and the light passes through the lens and is transmitted to the camera photosensitive element. The optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0054] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in standard RGB, YUV, etc. formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0055] The digital signal processor is used to process digital signals. Besides being able to process digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.
[0056] The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0057] The NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission pattern between human brain neurons, it can quickly process input information and can also continuously self-learn. Through the NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as: image recognition, face recognition, voice recognition, text understanding, etc.
[0058] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to achieve the data storage function. For example, files such as music and videos are saved in the external memory card.
[0059] The internal memory 121 can be used to store computer-executable program code, and the executable program code includes instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, image playback function, etc.). The data storage area can store the data created during the use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 can include high-speed random access memory and can also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0060] The electronic device 100 can implement audio functions through the audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and the application processor, etc. For example, music playback, recording, etc.
[0061] The audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be disposed in the processor 110, or some functional modules of the audio module 170 can be disposed in the processor 110.
[0062] The speaker 170A, also referred to as a "loudspeaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or hands-free calls through the speaker 170A.
[0063] The receiver 170B, also referred to as an "earpiece", is used to convert an audio electrical signal into a sound signal. When the electronic device 100 answers a call or a voice message, the voice can be listened to by placing the receiver 170B close to the human ear.
[0064] The microphone 170C, also referred to as a "microphone" or "transmitter", is used to convert a sound signal into an electrical signal. When making a call or sending a voice message, the user can speak by placing the mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In some other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also implement a noise reduction function. In some other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to implement functions such as collecting sound signals, noise reduction, identifying the sound source, and implementing a directional recording function.
[0065] The headphone jack 170D is used to connect a wired headphone. The headphone jack 170D can be a USB interface, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0066] The touch sensor 180K, also referred to as a "touch panel". The touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 together form a touch screen, also referred to as a "touch display screen". The touch sensor 180K is used to detect a touch operation acting thereon or nearby. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In some other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100 at a position different from that of the display screen 194.
[0067] The button 190 includes a power button, volume buttons, etc. The button 190 can be a mechanical button or a touch button. The electronic device 100 can receive button inputs and generate key signal inputs related to the user settings and function control of the electronic device 100. The motor 191 can generate a vibration prompt. The SIM card interface 195 is used to connect a SIM card. The SIM card can be in contact with and separated from the electronic device 100 by being inserted into or removed from the SIM card interface 195.
[0068] In the embodiments of the present application, the device type of the electronic device 100 can be a mobile phone, a tablet computer, a handheld computer, a desktop computer, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), and smart home devices such as a smart large screen and a smart speaker, wearable devices such as a smart bracelet, a smart watch, and smart glasses, extended reality (XR) devices such as augmented reality (AR), virtual reality (VR), and mixed reality (MR), in-vehicle devices or smart city devices, etc., any one of them.
[0069] The following introduces some noun concepts involved in the rendering and display of animation frames in the embodiments of the present application.
[0070] 1. Screen refresh rate: It represents the number of times the display screen on the electronic device 100 refreshes and displays animation frames within 1 second. Generally, the refresh rate of the display screen of the electronic device 100 is related to the fixed parameters of the display screen. For example, the refresh rate can be 60 Hertz (Hz), 90 Hz, 120 Hz, etc.
[0071] 2. Vertical Synchronization (Vsync) Signal: Since the application needs to first draw an animation frame and call the GPU to render the frame, then the application can store the rendered animation frame in a layer buffer and provide it to the layer compositor (SurfaceFlinger) for layer composition. After SurfaceFlinger takes the rendered animation frame from the buffer for layer composition and obtains an image frame, it will send the image frame after layer composition to the display screen for refreshing and display. When the timing of SurfaceFlinger sending the image frame to the display screen is during the screen refresh process, it is easy to occur the phenomenon that two different image frames before and after overlap and display, causing the screen displayed on the display to tear. Therefore, in order to prevent this screen tearing phenomenon, the hardware module corresponding to the display screen can generate a Vsync signal with the same period as the refresh rate and give it to SurfaceFlinger. After receiving the Vsync signal each time, SurfaceFlinger can take the animation frame from the buffer for layer composition and send it to the display screen for refreshing and display.
[0072] 3. Choreographer: A class in the operating system, used to request a vertical synchronization signal and perform drawing operations in response to the obtained vertical synchronization signal. Among them, a class is a data structure used to define the state and behavior of an object. Among them, the vertical synchronization signal is provided by the operating system and is used to coordinate and synchronize the operations of the choreographer and SurfaceFlinger.
[0073] When the application is started, the choreographer will be initialized. The process of initializing the choreographer includes: the Activity will generate an instantiated choreographer object according to the choreographer class. After the application is started by the user, when the application first needs to display a visual interface or view, at least one choreographer belonging to the application will be generated. Among them, the number of choreographers can be related to the number of threads used by the application. Among them, a thread is the smallest resource scheduled by the operating system. For example, the UI thread of the application will generate a choreographer bound to this thread. The UI thread can also be called the main thread, which is mainly used to bear the computational overhead for functions such as interface display, update, and control interaction.
[0074] When the application needs to refresh the interface, the Choreographer requests a Vertical Sync (Vsync) signal from the SurfaceFlinger to find an appropriate time to perform the drawing operation. After receiving the Vsync signal sent by the SurfaceFlinger, the Choreographer starts to execute the drawing operation. Among them, the Choreographer uses the OnVsync callback method to receive the Vsync signal, and this OnVsync callback method is the callback method provided by the internal class FrameDisplayEventReceiver of the Choreographer. After successfully receiving the Vsync signal using the OnVsync callback method, the Choreographer notifies the application to start drawing and rendering the animation frames in the interface, and stores the rendered animation frames in the buffer for the SurfaceFlinger to perform layer composition on the image frames including the animation frames. The SurfaceFlinger can send the image frames after layer composition to the display screen for display.
[0075] Figure 2 The timing diagram of the animation frames from drawing to display in the interface provided in the embodiments of the present application is shown.
[0076] As Figure 2 shown, when the Choreographer obtains the Vsync signal, it can send a callback notification to the application (such as the control center application) by processing the callback of the animation frame to trigger the application to draw the animation frame. After the application obtains the callback notification for the animation frame from the Choreographer, it can draw the animation frame through the UI thread and send a rendering instruction to the GPU through the Render Thread to call the GPU to render the animation frame. The application can send a frame sending instruction for the animation frame to the SurfaceFlinger. After the GPU renders the animation frame, the GPU can store the animation frame in the buffer indicated by the rendering instruction. After the SurfaceFlinger obtains the frame sending instruction, it can obtain the buffer of the animation frame. After the SurfaceFlinger detects that the buffer of the animation frame is filled with the rendered animation frame, it can wait for the arrival of the next Vsync signal, take out the animation frame from the buffer of the animation frame for layer composition to obtain an image frame. The SurfaceFlinger can send the image frame to the display screen for refreshing and display.
[0077] For example, when the Choreographer receives the Vertical Sync signal 1 (VSYNC1), it can process the callback of the animation frame 1, and then send the callback notification 1 to the application. After the application obtains the callback notification 1, it can start to draw the animation frame 1 through the UI thread and send the rendering instruction 1 ([ Figure 2(not shown in the figure) to the GPU, and send frame instruction 1 to SurfaceFlinger. After the GPU obtains rendering instruction 1, it can render animation frame 1 and store the rendered frame 1 of the picture into the buffer of animation frame 1 indicated by rendering instruction 1. SurfaceFlinger can obtain the buffer of animation frame 1 through frame sending instruction 1, and after detecting that the buffer of animation frame 1 is filled with the rendered animation frame 1, when the vertical synchronization signal 2 (VSYNC2) arrives, take out animation frame 1 from the buffer of animation frame 1 for layer composition processing to obtain image frame 1. SurfaceFlinger can send image frame 1 to the display screen. The display screen can refresh and display image frame 1 when the vertical synchronization signal 3 (VSYNC3) arrives.
[0078] When the choreographer receives the vertical synchronization signal 2 (VSYNC2), it can process the callback of animation frame 2, and then send callback notification 2 to the application. After the application obtains callback notification 2, it can start to draw animation frame 2 through the UI thread and send rendering instruction 2 ( Figure 2 not shown in the figure) to the GPU, and send frame instruction 2 to SurfaceFlinger. After the GPU obtains rendering instruction 2, it can render animation frame 2 and store the rendered frame 2 of the picture into the buffer of animation frame 2 indicated by rendering instruction 2. SurfaceFlinger can obtain the buffer of animation frame 2 through frame sending instruction 2, and after detecting that the buffer of animation frame 2 is filled with the rendered animation frame 2, when the vertical synchronization signal 3 (VSYNC3) arrives, take out animation frame 2 from the buffer of animation frame 2 for layer composition processing to obtain image frame 2. SurfaceFlinger can send image frame 2 to the display screen. The display screen can refresh and display image frame 2 when the vertical synchronization signal 4 (VSYNC4) arrives.
[0079] When the choreographer receives the vertical synchronization signal 3 (VSYNC3), it can process the callback of animation frame 3, and then send callback notification 3 to the application. After the application obtains callback notification 3, it can start to draw animation frame 3 through the UI thread and send rendering instruction 3 ( Figure 2(not shown in the figure) to the GPU, and send frame instruction 3 to SurfaceFlinger. After obtaining the rendering instruction 3, the GPU can render animation frame 3 and store the rendered frame 3 of the picture into the buffer of animation frame 3 indicated by the rendering instruction 3. SurfaceFlinger can obtain the buffer of animation frame 3 through the frame sending instruction 3, and after detecting that the buffer of animation frame 3 is filled with the rendered animation frame 3, wait until the vertical synchronization signal 4 (VSYNC3) arrives, and take out animation frame 3 from the buffer of animation frame 3 for layer composition processing to obtain image frame 3. SurfaceFlinger can send image frame 3 to the display screen. The display screen can refresh and display image frame 3 when the vertical synchronization signal 5 (VSYNC5) arrives.
[0080] Figures 3A - 3D The figure shows the display scenarios of multiple loop animations provided in the embodiments of the present application.
[0081] As Figure 3A shown, the electronic device 100 can display a desktop 310. Among them, a page with application icons is displayed on the desktop 310. This page includes multiple application icons (for example, weather application icon, stock application icon, calculator application icon, settings application icon, mail application icon, gallery application icon, music application icon, video application icon, browser application icon, etc.). A page indicator is also displayed below the multiple application icons to indicate the positional relationship between the currently displayed page and other pages. There are multiple tray icons (such as dial application icon, message application icon, contacts application icon, camera application icon) below the page indicator, and the tray icons remain displayed during page switching. In some embodiments, the above page may also include multiple application icons and a page indicator. The page indicator may not be part of the page and exists separately. The above picture icons are also optional, and the embodiments of the present application do not limit this. In the upper part area of the desktop 310, a status bar 311 is displayed. The status bar 311 may include: one or more signal strength indicators of mobile communication signals (also known as cellular signals), a battery status indicator, a time indicator, a Wi-Fi signal indicator, and so on.
[0082] The electronic device 100 can receive the user's operation on the status bar 311 (such as swiping down), and in response to this operation, the electronic device 100 can display a control center interface 320 as Figure 3B shown.
[0083] As Figure 3BAs shown, the control center interface 320 may include one or more function controls (e.g., a wireless local area network (WLAN) switch control, a Bluetooth switch control, a low battery mode switch control, a brightness adjustment control, a sound adjustment control), a music control card, and a smart connection control card 321.
[0084] The electronic device 100 may receive an operation (e.g., a click) of the user on the smart connection control card 321. In response to this operation, the electronic device 100 may display a smart connection interface 330 as Figure 3C shown.
[0085] As Figure 3C 、 Figure 3D shown, the smart connection interface 330 may include a plurality of loop-playing animations (abbreviation: loop animations), where the plurality of loop animations may include loop animation 331, loop animation 332, and loop animation 333. Among them, the animation effect of the loop animation 331 may be continuous rotation in a clockwise or counterclockwise direction. The animation effect of the loop animation 332 may be continuous rotation in a counterclockwise or clockwise direction, and the animation effect of the loop animation 333 may be that the center of the circle is fixed, continuously expanding from the initial size to the target size, and then repeating the continuous expansion from the initial size to the target size.
[0086] Figure 4 shows the display timing diagram when the interface provided in the embodiment of the present application includes a plurality of animations.
[0087] As Figure 4 shown, the first interface may include a plurality of animations, where the plurality of animations may include animation A, animation B, and animation C.
[0088] Before receiving the vertical synchronization signal 1 (VSYNC1), the Choreographer may generate callback records of the animation frame A1 of animation A, the animation frame B1 of animation B, and the animation frame C1 of animation C. Among them, the timestamps of the animation frame A1, the animation frame B1, and the animation frame C1 are before the arrival time of VSYNC1.
[0089] When the choreographer receives the vertical synchronization signal 1 (VSYNC1), it can execute the callback records of animation frame A1, animation frame B1, and animation frame C1, and then send multiple callback notifications to the application. After the application obtains these multiple callback notifications, it can start to draw animation frame A1, animation frame B1, and animation frame C1 through the UI thread, and call the GPU to render animation frame A1, animation frame B1, and animation frame C1 through the render thread. The application can send the buffers of animation frame A1, animation frame B1, and animation frame C1 to SurfaceFlinger. The GPU can store the rendered animation frame A1 into the buffer of animation frame A1, store the rendered animation frame B1 into the buffer of animation frame B1, and store the rendered animation frame C1 into the buffer of animation frame C1. After SurfaceFlinger detects that the buffer of animation frame A1 is filled with the rendered animation frame A1, the buffer of animation frame B1 is filled with the rendered animation frame B1, and the buffer of animation frame C1 is filled with the rendered animation frame C1, when the vertical synchronization signal 2 (VSYNC2) arrives, it takes out animation frame A1 from the buffer of animation frame A1, takes out animation frame B1 from the buffer of animation frame B1, and takes out animation frame C1 from the buffer of animation frame C1, and performs layer composition processing to obtain the image frame 1 of the first interface. SurfaceFlinger can send the image frame 1 to the display screen. The display screen can refresh and display the image frame 1 when the vertical synchronization signal 3 (VSYNC3) arrives.
[0090] Before the arrival of the vertical synchronization signal 2 (VSYNC2), the choreographer can generate callback records for the animation frame A2 with animation A and the animation frame B2 with animation B. Among them, the timestamps of the animation frame A2 and the animation frame B2 are between the arrival time of VSYNC1 and the arrival time of VSYNC2. When the choreographer receives the vertical synchronization signal 2 (VSYNC2), it can process the callback records of the animation frame A2 and the animation frame B2, and then send multiple callback notifications to the application. After obtaining these multiple callback notifications, the application can start to draw the animation frame A2 and the animation frame B2 through the UI thread, and call the GPU to render the animation frame A2 and the animation frame B2 through the rendering thread (Render Thread). The application can send the buffer of the animation frame A2 and the buffer of the animation frame B2 to SurfaceFlinger. The GPU can store the rendered animation frame A2 into the buffer of the animation frame A2, and store the rendered animation frame B2 into the buffer of the animation frame B2. After SurfaceFlinger detects that the buffer of the animation frame A2 is filled with the rendered animation frame A2 and the buffer of the animation frame B2 is filled with the rendered animation frame B2, when the vertical synchronization signal 3 (VSYNC3) arrives, it takes out the animation frame A2 from the buffer of the animation frame A2 and takes out the animation frame B2 from the buffer of the animation frame B2, performs layer composition processing, and obtains the image frame 2. SurfaceFlinger can send the image frame 2 to the display screen. The display screen can refresh and display the image frame 2 when the vertical synchronization signal 4 (VSYNC4) arrives.
[0091] Before the arrival of the vertical synchronization signal 3 (VSYNC3), the choreographer can generate callback records for the animation frame A3 with animation A and the animation frame C2 with animation C. Among them, the timestamps of the animation frame A3 and the animation frame C2 are between the timestamp of VSYNC2 and the timestamp of VSYNC3. When the choreographer receives the vertical synchronization signal 3 (VSYNC1), it can process the callback records of the animation frame A3 and the animation frame C2, and then send multiple callback notifications to the application. After obtaining these multiple callback notifications, the application can start to draw the animation frame A3 and the animation frame C2 through the UI thread, and call the GPU through the Render Thread to render the animation frame A3 and the animation frame C2. The application can send the buffer of the animation frame A3 and the buffer of the animation frame C2 to SurfaceFlinger. The GPU can store the rendered animation frame A3 into the buffer of the animation frame A3 and the rendered animation frame C2 into the buffer of the animation frame C2. After SurfaceFlinger detects that the buffer of the animation frame A3 is filled with the rendered animation frame A3 and the buffer of the animation frame C2 is filled with the rendered animation frame C2, when the vertical synchronization signal 4 (VSYNC4) arrives, it takes out the animation frame A3 from the buffer of the animation frame A3 and the animation frame C2 from the buffer of the animation frame C2, and performs layer composition processing to obtain the image frame 3. SurfaceFlinger can send the image frame 3 to the display screen. The display screen can refresh and display the image frame 3 when the vertical synchronization signal 5 (VSYNC5) arrives.
[0092] From the above Figure 4 process, it can be seen that when there are multiple loop animations in the interface displayed by the electronic device, almost in each Vsync signal cycle, the application needs to draw and render the animation frames and perform layer composition through SurfaceFlinger. Among them, when rendering the animation frames and performing layer composition, data operations can be performed through the GPU to improve the rendering speed and the layer composition speed. In this way, when the electronic device displays an interface with multiple loop animations, the burden on the GPU is relatively heavy, and the power consumption of the electronic device is relatively high.
[0093] Therefore, in the embodiments of the present application, an animation frame skipping method is provided. When the electronic device displays a first interface of a first application including one or more animations, the first application in the electronic device can set flag bits for the one or more animations. After receiving the animation frame data of the multiple animations, the Choreographer of the electronic device can, according to the flag bits of the animation frame data, cooperate with the Vsync signal to trigger frame skipping to draw, render, and display the animation frames of the one or more animations, so as to reduce the frequencies of drawing, rendering, and compositing and displaying. In this way, the power consumption of the electronic device can be reduced.
[0094] It should be noted that since the flag bit of the animation is used for frame skipping, in the subsequent embodiments of the present application, for the convenience of narration, the flag bit of the animation will also be referred to as the frame skipping flag bit.
[0095] Compared with skipping and compositing at the SurfaceFlinger layer, which can only reduce the frame rate of compositing and displaying but not the frame rate of drawing and rendering, by the Choreographer triggering frame skipping of the animation frames of multiple animations for drawing, rendering, and displaying according to the frame skipping flag bits of the animation frame data and cooperating with the Vsync signal, the power consumption of the electronic device can be further reduced. Moreover, since the animation frames of the loop animation are played in a loop when the loop animation is displayed, frame skipping for drawing, rendering, and displaying the animation frames of the loop animation has little impact on the user experience of watching the loop animation while reducing the power consumption of the electronic device.
[0096] Figure 5 The schematic diagram of the software system architecture of an electronic device provided in the embodiments of the present application is shown.
[0097] As Figure 5 shown, the software system architecture of the electronic device 100 may include an application (APP) layer, an application framework (FWK) layer, a native service (Native) layer, and a kernel (Kernel) layer.
[0098] Among them, the application layer includes one or more applications, for example, a control center application, etc.
[0099] The application framework layer may include modules such as Animation, Choreographer, and SurfaceFlinger. Among them, the animation module can be used to generate animation frame data according to the instructions of the application. The Choreographer is used to generate a callback record (CallbackRecord) for the animation frame based on the animation frame data, store the callback record of the animation frame in the callback queue, and when the Vsync signal arrives, retrieve the callback record of the animation frame from the callback queue, process the callback of the animation frame to trigger the application to start drawing and rendering the animation frame, and send the rendered animation frame to the SurfaceFlinger for layer composition. The SurfaceFlinger is used to perform layer composition processing on the animation frames rendered by the GPU, generate image frames including the animation frames, and send the image frames including the animation frames to the display screen for display.
[0100] The native service layer may include one or more graphics interfaces. Among them, the one or more graphics interfaces may include one or more of the open graphics library (OpenGL), the open graphics library for embedded systems (OpenGL ES), and the graphics drawing application programming interface (Vulkan), etc. Among them, the graphics interface can be used to configure the GPU to render animation frames.
[0101] The kernel layer may include drivers such as the graphics processing unit driver (GPU Driver) and the display screen driver. Among them, the GPU Driver is used to drive the GPU to execute upper-layer operations (for example, the operation of rendering animation frames configured by the graphics interface). The display screen driver can be used to drive the display screen to display the image frames after composition by the SurfaceFlinger.
[0102] Next, a method for skipping animation frames provided in the embodiments of the present application will be introduced in combination with the above software system architecture.
[0103] Figure 6 The flowchart of a method for skipping animation frames provided in the embodiments of the present application is shown.
[0104] As Figure 6 shown, the method may include the following steps:
[0105] S601. The application can detect the operation of the user opening the first interface, and the first interface includes one or more animations.
[0106] For example, the first interface may be the above Figure 3C 、Figure 3D In the control center interface 330, the one or more loop animations may include the above-mentioned Figure 3C , Figure 3D The loop animations 331, 332, and 333 shown in. For specific animation effects, reference may be made to the foregoing Figure 3C , Figure 3D The embodiments shown will not be elaborated herein.
[0107] S602. The application determines the skip frame flag bits of one or more animations.
[0108] Among them, the skip frame flag bit of each animation may be preset. For example, the skip frame flag bit of the loop animation 331 may be 0, the skip frame flag bit of the loop animation 332 may be 1, and the skip frame flag bit of the loop animation 333 may be 2. Among them, the larger the value of the skip frame flag bit, the more times the loop animation skips frames.
[0109] In a possible implementation manner, after opening the first interface including the animation, the application may determine the skip frame flag bit of the animation according to the identifier of the animation, and when calling the animation module to construct the animation frame data, set the skip frame flag bit for the animation. Among them, the corresponding relationship between the identifier of the animation and the skip frame flag bit of the animation may be saved in the application. The application may determine the skip frame flag bit of the animation in the first interface from the corresponding relationship between the identifier of the animation and the skip frame flag bit of the animation.
[0110] In a possible implementation manner, the application may determine the attributes of the animation and / or the load of the electronic device 100 and / or the hardware capabilities of the electronic device 100, determine whether to set the skip frame flag bit, and determine the size of the skip frame flag bit of the animation.
[0111] Among them, the attributes of the animation may include one or more of the data source of the animation, the resolution of the animation, the type of the animation, etc. The data source of the animation includes the network, local, etc. The type of the animation may include any one of loop animation, single-time animation, etc. The hardware capabilities of the electronic device 100 include the refresh rate of the display screen. For example, the refresh rate of the display screen may be 60 Hertz (Hz), 90 Hz, 120 Hz, etc.
[0112] For example, when the type of the animation is a loop animation, and / or, the resolution of the animation is greater than the preset resolution (for example, 320*320), and / or, the data source of the animation is local, and / or, the load of the electronic device 100 is higher than the specified load threshold (for example, 50% of the maximum load), and / or the refresh rate of the display screen of the electronic device 100 is greater than the specified frequency (for example, 60 Hz), the application may set the skip frame flag bit of the animation to be greater than 0.
[0113] For another example, when the type of the animation is a single animation, the application may not set the frame skipping flag for the animation or set the frame skipping flag of the animation to 0.
[0114] S603. The application sends the frame skipping flags of one or more animations to the animation module.
[0115] Among them, when the application calls the Animation to construct the animation frame data, it can send the frame skipping flags of one or more animations in the first interface to the animation module.
[0116] S604. The animation module can generate the screen data and time stamps of the animation frames of one or more animations.
[0117] Among them, since there are multiple animation frames in the animation, the animation module can generate multiple animation frame data for each animation.
[0118] The animation module can determine the time stamp of the animation frame according to the frame position of the animation frame in the animation, the refresh rate of the display screen, and the start time of the animation. The time stamp is used to represent the default playback time of the animation frame.
[0119] Specifically, the animation module can determine the time position of the animation frame in the animation according to the frame position of the animation frame in the animation and the screen refresh rate. Then, the animation module can determine the time stamp of the animation frame according to the time position of the animation frame in the animation and the start time of the animation.
[0120] For example, the refresh rate of the display screen can be 60Hz, that is, the display screen is refreshed 60 times in 1 second. Therefore, the frame interval can be 1 / 60ms, that is, 16.6ms. The animation frame A1 can be at the 11th frame of the animation A. Therefore, there are 10 intervals between the animation frame A1 and the first frame in the animation A. Therefore, the time position of the animation frame A1 can be 166ms. Among them, the start time of the animation A is at 8:30:12.020, so the time stamp of the animation frame A1 can be 8:30:12.186.
[0121] S605. The animation module sends the animation frame data of one or more animations to the Choreographer. The animation frame data includes the screen data, time stamp, and frame skipping flag of the animation frame.
[0122] S606. Based on the animation frame data, the Choreographer generates a callback record of the animation frame and stores the callback record of the animation frame in the callback queue.
[0123] Among them, the choreographer can store the callback records of the animation frames into the callback queue (CallbackQueue) according to the sorting of the timestamps of the animation frames. Among them, the earlier the timestamp, the higher the priority for the callback records of the animation frames to be stored into the callback queue.
[0124] S607. The choreographer receives the Vsync signal sent by the layer compositor (SurfaceFlinger).
[0125] Among them, the choreographer can use the OnVsync callback method to receive the Vsync signal. For the specific process of the choreographer receiving the Vsync signal, reference can be made to the explanation part of the choreographer in the above embodiments, which will not be elaborated here.
[0126] S608. After receiving the Vsync signal, the choreographer can determine whether to draw the animation frame according to the skip frame flag bit and the timestamp of the callback record in the callback queue.
[0127] S609. When the choreographer determines to draw the animation frame according to the skip frame flag bit and the timestamp of the callback record in the callback queue, process the callback records whose timestamps are before the Vsync signal.
[0128] Among them, for the process of the choreographer determining whether to draw the animation frame according to the skip frame flag bit and the timestamp of the callback record in the callback queue, reference can be made to the Figure 7 、 Figure 8 illustrated embodiments below, which will not be elaborated here.
[0129] S610. When processing the callback records whose timestamps are before the Vsync signal, the choreographer sends one or more callback notifications to the application.
[0130] S611. After obtaining one or more callback notifications, the application draws and renders the animation frames whose timestamps are before the arrival time of the Vsync signal.
[0131] Among them, the callback notification carries the memory address of the picture data of the animation frame. After obtaining one or more callback notifications, the application can retrieve the picture data of one or more animation frames according to the memory addresses of the picture data of one or more animation frames, draw them through the UI thread, and after drawing, call the GPU through the render thread (Render Thread) to render one or more animation frames.
[0132] S612. The application can provide the rendered animation frames to the layer compositor (SurfaceFlinger).
[0133] Among them, after an application renders one or more animation frames by calling the GPU through a rendering thread, it can transfer the buffer of one or more animation frames to SurfaceFlinger. After the GPU finishes rendering an animation frame, it can store the rendered animation frame in the buffer of this animation frame.
[0134] S613. The layer compositor can perform layer composition processing on the rendered picture frames to obtain the image frames of the first interface.
[0135] After obtaining the buffer of one or more animation frames, SurfaceFlinger can wait for the next Vsync signal to arrive, and then take out the rendered one or more animation frames from the buffer of one or more animation frames for layer composition processing to obtain image frames.
[0136] Among them, the image frame is a frame of the first interface.
[0137] In a possible implementation, the buffer of one or more animation frames obtained by SurfaceFlinger may include the buffers of multiple animation frames of the same animation. Therefore, when SurfaceFlinger performs layer composition processing, it can take out the last animation frame passed to SurfaceFlinger from the buffers of multiple animation frames of this animation, and perform layer composition processing based on the last animation frame passed to SurfaceFlinger.
[0138] For example, animation A may include animation frame A1, animation frame A2, and animation frame A3. When the Vsync signal 1 arrives, the choreographer can trigger the application to sequentially draw and render animation frame A1, animation frame A2, and animation frame A3, and sequentially send frame delivery instructions A1, A2, and A3 to SurfaceFlinger. Among them, the frame delivery instruction A1 is used to give the buffer of animation frame A1 in animation A to SurfaceFlinger, the frame delivery instruction A2 is used to give the buffer of animation frame A2 in animation A to SurfaceFlinger, and the frame delivery instruction A3 is used to give the buffer of animation frame A3 in animation A to SurfaceFlinger. Among them, the sending time of the frame delivery instruction A3 is later than the sending time of the frame delivery instruction A2, and the sending time of the frame delivery instruction A2 is later than the sending time of the frame delivery instruction A1. Therefore, SurfaceFlinger can take out animation frame A3 of animation A as the current animation frame of animation A when the Vsync signal 2 arrives, and perform layer composition processing with the animation frames of other animations to obtain image frame 1.
[0139] Among them, SurfaceFlinger can perform layer composition processing on the rendered frame of the screen through the processing power of the CPU to obtain an image frame.
[0140] In a possible implementation, SurfaceFlinger can also perform layer composition processing on the rendered frame of the screen through the processing power of the GPU to obtain an image frame.
[0141] In a possible implementation, SurfaceFlinger can perform layer composition processing on the rendered frame of the screen through the combined processing power of the CPU and the GPU to obtain an image frame.
[0142] S614. The layer compositor can send the image frame to the display driver.
[0143] S615. The display driver can drive the display screen to display the image frame of the first interface.
[0144] Among them, for the timing of SurfaceFlinger to perform layer composition and the timing of the display screen to display the image frame of the first interface, reference can be made to the above Figure 2 illustrated embodiments, which will not be elaborated here.
[0145] Through an animation frame skipping method provided by an embodiment of the present application, when the electronic device displays a first interface of a first application including one or more animations, the first application in the electronic device can set different frame skipping flag bits for the multiple animations. After receiving the animation frame data of the multiple animations, the Choreographer of the electronic device can, according to the frame skipping flag bits in the animation frame data, cooperate with the Vsync signal to trigger frame skipping of the animation frames of one or more animations for drawing, rendering, and sending display, so as to reduce the frame rate of drawing, rendering, and sending display. In this way, the power consumption of the electronic device can be reduced.
[0146] One or more of the animations may be loop animations. The electronic device 100 may receive a first operation for opening a first interface, where the first interface includes a first loop animation that has animation frames corresponding to timestamps, and the first interface is an interface of a first application. After receiving the first operation, the electronic device 100 receives a first vertical synchronization signal at a first moment by a choreographer. The electronic device 100 may, in response to the flag bit of the animation frames before the first moment being a first preset value (e.g., 0), draw and render the animation frames before the first moment through the first application. Also, the electronic device 100 may, in response to the flag bit of the animation frames before the first moment not being the first preset value, not draw and render the animation frames before the first moment. The electronic device 100 may perform layer composition on the drawn and rendered animation frames through a layer compositor and display the first loop animation in the first interface.
[0147] In some embodiments, the first interface further includes a second loop animation that has animation frames corresponding to timestamps. The animation frames before the first moment include the animation frames of the first loop animation and the animation frames of the second loop animation. After performing layer composition on the drawn and rendered animation frames through the layer compositor, the electronic device 100 may display the first loop animation and the second loop animation in the first interface.
[0148] The following describes the process in which the choreographer in the embodiments of the present application determines whether to draw an animation frame according to the frame skipping flag bit and the timestamp in the callback queue.
[0149] Figure 7 FIG. shows the process in which the choreographer in the embodiments of the present application determines whether to draw an animation frame.
[0150] As Figure 7 shown, the process may include the following steps:
[0151] S701. The animation starts.
[0152] Among them, in response to a user operation of opening a first interface including one or more animations, the application may trigger the animation module to generate animation frame data of one or more animations. Each animation may have multiple pieces of animation frame data.
[0153] S702. The choreographer obtains the animation frame data, where the animation frame data includes the picture data, timestamp, and frame skipping flag bit of the animation frame.
[0154] Among them, for the determination process of the timestamp, reference may be made to step S604 in the above Figure 6 shown embodiment, which will not be elaborated here.
[0155] S703. The choreographer encapsulates the obtained animation frame data into callback records and adds them to the callback queue of the animation in the order of the timestamps.
[0156] For example, the timestamp of callback record A is before the timestamp of callback record B. Therefore, in the callback queue, callback record A is before callback record B. When retrieving callback records from the callback queue, callback record A will be retrieved before callback record B.
[0157] S704. When the choreographer obtains a Vsync signal, it uses the docallback method to retrieve M callback record objects from the callback queue whose timestamps are before the acquisition time of the Vsync signal.
[0158] S705. The choreographer can determine whether there is a callback record in the retrieved M callback records whose frame skip flag is greater than 0.
[0159] If there is a callback record in the retrieved M callback records whose frame skip flag is greater than 0, then step S706 is executed.
[0160] If there is no callback record in the retrieved M callback records whose frame skip flag is greater than 0, then step S707 is executed.
[0161] S706. The choreographer can determine whether the minimum frame skip flag in the retrieved M callback records is 0.
[0162] If the minimum frame skip flag in the M callback records is 0, then step S707 is executed.
[0163] If the minimum frame skip flag in the M callback records is not 0, then step S709 is executed.
[0164] S707. The choreographer triggers the application to draw and render M animation frames based on the retrieved M callback records, and the SurfaceFlinger performs layer composition processing according to the rendered M animation frames to obtain the image frames of the first interface.
[0165] Among them, after the choreographer triggers the application to draw and render M animation frames based on the retrieved M callback records, these M callback records in the callback queue can be deleted.
[0166] S708. Display the image frames of the first interface.
[0167] S709. The choreographer reduces the frame skip flags of the retrieved M callback records by a fixed value (for example, reduce by 1), and re-deposits the retrieved M callback records into the callback queue in the order of the timestamps.
[0168] After step S709 is executed, wait for the next Vsync signal to arrive and execute step S704 above.
[0169] In the embodiment of the present application, after step S704 above, if the frame skipping flag bits of the M callback records taken out are all greater than the first preset value (for example, 0), then the frame skipping flag bits of the M callback records taken out are all reduced by a fixed value (for example, reduced by 1), and the M callback records taken out are re-stored in the callback queue in the order of time stamps. If there is a callback record with the frame skipping flag bit being the first preset value (for example, 0) among the M callback records taken out, the choreographer can trigger the application to draw and render M animation frames based on the M callback records taken out, and the SurfaceFlinger performs layer composition processing according to the rendered M animation frames to obtain the image frames of the first interface. The above Figure 7 The judgment logics of steps S705 and S706 in the above embodiment are only examples and are not limited.
[0170] In some embodiments, in response to the flag bits of the animation frames with time stamps before the first moment not being the first preset value (for example, 0), the flag bits of the animation frames with time stamps before the first moment are all subtracted by a fixed value (for example, 1). The choreographer can receive the second vertical synchronization signal at the second moment. In response to the flag bits of the animation frames with time stamps before the second moment being the first preset value, the first application is used to draw and render the animation frames with time stamps before the second moment. And, in response to the flag bits of the animation frames with time stamps before the second moment not being the first preset value, the animation frames with time stamps before the second moment are not drawn and rendered. Wherein, the second vertical synchronization signal is the next vertical synchronization signal of the first vertical synchronization signal. If the flag bits of the animation frames in the M callback records with time stamps before the second moment in the callback queue are not equal to the first preset value, the flag bits of the animation frames in the M callback records are all subtracted by the fixed value.
[0171] Exemplarily, if there is a callback record with the flag bit of the animation frame equal to the first preset value among the K callback records with time stamps before the second moment in the callback queue, the first application is used to draw and render the K animation frames corresponding to the K callback records. The K animation frames include the above M animation frames, K≥M, and K is an integer.
[0172] If the flag bits of the animation frames in the K callback records with time stamps before the second moment in the callback queue are not equal to the first preset value, the K animation frames corresponding to the K callback records are not drawn and rendered.
[0173] In some embodiments, after the choreographer notifies the first application to draw and render the M animation frames corresponding to the M callback records, the choreographer can delete the M callback records from the callback queue.
[0174] In some embodiments, after the choreographer notifies the first application to draw and render the K animation frames corresponding to the K callback records, the choreographer may delete the K callback records from the callback queue.
[0175] After the layer compositor obtains the second vertical synchronization signal, it may perform layer composition on the M animation frames that have been drawn and rendered, where the second vertical synchronization signal is the next vertical synchronization signal after the first vertical synchronization signal.
[0176] After the layer compositor obtains the third vertical synchronization signal, it may perform layer composition on the above-mentioned K animation frames that have been drawn and rendered, where the third vertical synchronization signal is the next vertical synchronization signal after the second vertical synchronization signal.
[0177] Figure 8 Exemplarily, the process of the choreographer generating and processing callback records provided in the embodiments of the present application is shown.
[0178] As Figure 8 shown, the process of the choreographer generating and processing callback records may be as follows:
[0179] 1. The choreographer generates callback records.
[0180] The choreographer may generate a callback record for each piece of animation frame data passed into the choreographer. Among them, the animation frame data includes picture data, a timestamp, and a frame skipping flag bit. The picture data is used to represent the picture content of the animation frame. The timestamp is used to represent the default playback time of the animation frame. The frame skipping flag bit is used to represent the number of frame skips of the animation frame.
[0181] For example, the callback queue may include Callback Record A (CallbackRecord-A), Callback Record B (CallbackRecord-B), Callback Record C (CallbackRecord-C), Callback Record D (CallbackRecord-D), Callback Record E (CallbackRecord-E), Callback Record F (CallbackRecord-F), Callback Record G (CallbackRecord-G), and Callback Record H (CallbackRecord-H).
[0182] Among them, Callback Records A to I are sorted in ascending order of timestamps. The timestamp of Callback Record A is the earliest, and the timestamp of Callback Record I is the latest. Therefore, Callback Record A is arranged at the front of the callback queue, and Callback Record H is arranged at the end of the callback queue.
[0183] Before the choreographer obtains the Vsync signal 1, the dropped frame flag bits of callback record A is 1, the dropped frame flag bit of callback record B is 2, the dropped frame flag bit of callback record C is 1, the dropped frame flag bit of callback record D is 0, the dropped frame flag bit of callback record E is 3, the dropped frame flag bit of callback record F is 1, the dropped frame flag bit of callback record G is 1, and the dropped frame flag bit of callback record H is 1.
[0184] 2. At time T1, the choreographer obtains the Vsync signal 1.
[0185] 3. After the choreographer obtains the Vsync signal 1, the callback records in the callback queue with timestamps before T1 are taken out.
[0186] For example, the callback records in the callback queue with timestamps before T1 include callback record A, callback record B, and callback record C.
[0187] 4. When the dropped frame flag bits in the callback records with timestamps before T1 are all greater than 0, the choreographer performs dropped frame processing on the callback records with timestamps before T1.
[0188] Since the dropped frame flag bits of callback record A, callback record B, and callback record C are all greater than 1, the choreographer determines not to execute callback record A, callback record B, and callback record C, and performs dropped frame processing on callback record A, callback record B, and callback record C.
[0189] Among them, the dropped frame processing includes: subtracting 1 from the dropped frame flag bits in callback record A, callback record B, and callback record C.
[0190] 5. After the choreographer performs dropped frame processing on the taken-out callback records, they are put back into the callback queue in the order of the animation timestamps again.
[0191] For example, after the dropped frame processing, the dropped frame flag bit of callback record A is 0, the dropped frame flag bit of callback record B is 1, and the dropped frame flag bit of callback record C is 0. Then, the choreographer can put callback record A, callback record B, and callback record C back into the callback queue. Among them, callback record A is still at the beginning of the callback queue, callback record B is after callback record A, and callback record C is after callback record B in the callback queue.
[0192] At this time, optionally, new callback records may be generated and added to the swap queue. For example, the choreographer newly generates callback record I (CallbackRecord-I). Among them, the dropped frame flag bit of callback record I is 1, and the timestamp of callback record I is after the timestamp of callback record H. Therefore, callback record I is ranked after callback record H in the callback queue.
[0193] 6. At time T1, the choreographer obtains the Vsync signal 2.
[0194] 7. After the choreographer obtains the Vsync signal 2, the choreographer retrieves the callback records in the callback queue whose timestamps are before time T2.
[0195] For example, the callback records in the callback queue whose timestamps are before time T2 include callback record A, callback record B, callback record C, and callback record D.
[0196] 8. When there is a dropped frame flag bit equal to 0 in the callback records whose timestamps are before time T2, the choreographer executes the callback records whose timestamps are before time T2 to trigger the application to draw and render the animation frames whose timestamps are before time T2, and passes them to SurfaceFlinger for composition and display.
[0197] Since the dropped frame flag bit of callback record A is 0, the dropped frame flag bit of callback record B is 1, the dropped frame flag bit of callback record C is 0, and the dropped frame flag bit of callback record D is 0. Therefore, the choreographer determines to execute callback record A, callback record B, callback record C, and callback record D.
[0198] When the choreographer executes callback record A, callback record B, callback record C, and callback record D, it can trigger the application to draw and render the animation frames corresponding to callback record A, callback record B, callback record C, and callback record D respectively, and pass the drawn and rendered animation frames to SurfaceFlinger for layer composition and display.
[0199] Among them, the process of the application drawing and rendering animation frames, and SurfaceFlinger performing layer composition and display can refer to the above Figure 6 or Figure 7 the illustrated embodiments, which will not be elaborated here.
[0200] 9. After the choreographer executes the callback records whose timestamps are before time T2, the choreographer deletes the callback records in the callback queue whose timestamps are before time T2.
[0201] For example, after the choreographer executes callback record A, callback record B, callback record C, and callback record D, the choreographer can delete callback record A, callback record B, callback record C, and callback record D from the callback queue. Among them, after deleting callback record A, callback record B, callback record C, and callback record D from the callback queue, the callback queue includes callback record E, callback record F, callback record G, callback record H, and callback record I.
[0202] The above examples in the embodiments of this application are only used to explain this application and should not constitute a limitation.
[0203] Figure 9 The animation display timing diagram of the animation frame skipping method provided in the embodiment of the present application is shown.
[0204] As Figure 9 shown, the first interface may include multiple animations, where the multiple animations may include Animation A, Animation B, and Animation C.
[0205] Before receiving the vertical synchronization signal 1 (VSYNC1), the Choreographer may generate callback records for animation frame A1 of Animation A, callback records for animation frame B1 of Animation B, and callback records for animation frame C1 of Animation C. Among them, the timestamps of animation frame A1, animation frame B1, and animation frame C1 are before the timestamp of VSYNC1.
[0206] When the Choreographer receives the vertical synchronization signal 1 (VSYNC1), since the frame skipping flag bits of the callback records with timestamps before the arrival time of VSYNC1 in the callback queue are 0, the Choreographer may execute all the callback records in the callback queue with timestamps before the arrival time of VSYNC1, and then send multiple callback notifications to the application. After executing all the callback records in the callback queue with timestamps before the arrival time of VSYNC1, the Choreographer deletes all the callback records in the callback queue with timestamps before the arrival time of VSYNC1.
[0207] After the application obtains these multiple callback notifications, it can start to draw animation frames A1, B1, and C1 through the UI thread, and call the GPU through the Render Thread to render animation frames A1, B1, and C1. The application can send the buffers of animation frame A1, animation frame B1, and animation frame C1 to SurfaceFlinger. The GPU can store the rendered animation frame A1 into the buffer of animation frame A1, store the rendered animation frame B1 into the buffer of animation frame B1, and store the rendered animation frame C1 into the buffer of animation frame C1. After SurfaceFlinger detects that the buffer of animation frame A1 is filled with the rendered animation frame A1, the buffer of animation frame B1 is filled with the rendered animation frame B1, and the buffer of animation frame C1 is filled with the rendered animation frame C1, when the vertical synchronization signal 2 (VSYNC2) arrives, it takes out animation frame A1 from the buffer of animation frame A1, takes out animation frame B1 from the buffer of animation frame B1, and takes out animation frame C1 from the buffer of animation frame C1, and performs layer composition processing to obtain image frame 1. SurfaceFlinger can send image frame 1 to the display screen. The display screen can refresh and display image frame 1 of the first interface when the vertical synchronization signal 3 (VSYNC3) arrives.
[0208] Before the arrival time of the vertical synchronization signal 2 (VSYNC2), the choreographer can generate a callback record for animation frame A2 of animation A and a callback record for animation frame B2 of animation B. The timestamps of animation frame A2 and animation frame B2 are between the arrival time of VSYNC1 and the arrival time of VSYNC2.
[0209] When the choreographer receives the vertical synchronization signal 2 (VSYNC2), since the skip flag bit of the callback record whose timestamp is before the arrival time of VSYNC2 does not exist in the callback queue is 0, the choreographer does not execute the callback, and subtracts 1 from the skip flag bits of the callback records whose timestamps are before VSYNC2 in the callback queue, and then stores them back into the callback queue in the order of timestamps again.
[0210] Therefore, between the arrival time of the vertical synchronization signal 2 (VSYNC2) and the arrival time of the vertical synchronization signal 3 (VSYNC3), the application does not draw and render the animation of the first interface. Between the arrival time of the vertical synchronization signal 3 (VSYNC3) and the arrival time of the vertical synchronization signal 4 (VSYNC4), SurfaceFlinger also does not perform layer composition processing. Since the display screen does not obtain a new image frame before the arrival time of the vertical synchronization signal 4 (VSYNC4), the display screen continues to display the image frame 1 between the arrival time of the vertical synchronization signal 4 (VSYNC4) and the arrival time of the vertical synchronization signal 5 (VSYNC5).
[0211] Before the arrival time of the vertical synchronization signal 3 (VSYNC3), the choreographer can generate callback records for the animation frame A3 of animation A and the animation frame C2 of animation C. Among them, the timestamps of the animation frame A3 and the animation frame C2 are between the arrival time of VSYNC2 and the arrival time of VSYNC3.
[0212] When the choreographer receives the vertical synchronization signal 3 (VSYNC3), since the skip frame flag bit of the callback record with a timestamp before the arrival time of VSYNC3 in the callback queue is 0, the choreographer can execute all the callback records in the callback queue with timestamps before VSYNC3, and then send multiple callback notifications to the application. After the choreographer executes all the callback records in the callback queue with timestamps before the arrival time of VSYNC3, the choreographer deletes all the callback records in the callback queue with timestamps before the arrival time of VSYNC3.
[0213] After the application obtains these multiple callback notifications, it can start to draw the animation frames A2, A3, B2, and C2 through the UI thread, and call the GPU through the Render Thread to render the animation frames A2, A3, B2, and C2. The application can send the buffers of the animation frame A2, the animation frame A3, the animation frame B2, and the animation frame C2 to SurfaceFlinger. The GPU can store the rendered animation frame A2 into the buffer of the animation frame A2, store the rendered animation frame A3 into the buffer of the animation frame A3, store the rendered animation frame B2 into the buffer of the animation frame B2, and store the rendered animation frame C2 into the buffer of the animation frame C2.
[0214] Since both animation frame A2 and animation frame A3 belong to animation A, and the timestamp of animation frame A3 is after the timestamp of animation frame A4, when SurfaceFlinger detects that the buffer of animation frame A2 is filled with the rendered animation frame A2, the buffer of animation frame A3 is filled with the rendered animation frame A3, the buffer of animation frame B2 is filled with the rendered animation frame B2, and the buffer of animation frame C2 is filled with the rendered animation frame C2, when the vertical synchronization signal 4 (VSYNC4) arrives, it takes out animation frame A3 from the buffer of animation frame A3, takes out animation frame B2 from the buffer of animation frame B2, and takes out animation frame C2 from the buffer of animation frame C2, and performs layer composition processing to obtain the image frame 2 of the first interface. SurfaceFlinger can send the image frame 2 to the display screen. The display screen can refresh and display the image frame 2 of the first interface when the vertical synchronization signal 5 (VSYNC5) arrives.
[0215] Comparing the above Figure 4 illustrated embodiments and Figure 9 the illustrated embodiments, in the embodiments of the present application, an animation frame skipping method is provided. When an electronic device displays a first interface of a first application including multiple loop animations, the first application in the electronic device can set different frame skipping flag bits for the multiple animations. After the choreographer in the electronic device receives the animation frame data of the multiple animations, it can, according to the frame skipping flag bits of the animation frame data, cooperate with the Vsync signal to trigger the frame skipping of the animation frames of the multiple animations for drawing, rendering, and sending to the display, so as to reduce the frame rate of drawing, rendering, and sending to the display. In this way, the power consumption of the electronic device can be reduced.
[0216] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments can be implemented.
[0217] The embodiments of the present application also provide a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above method embodiments.
[0218] The embodiments of the present application also provide a chip system. The chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the steps in any method embodiment of the present application. The chip system can be a single chip or a chip module composed of multiple chips.
[0219] In the description and drawings of this application, the term "user interface (UI)" is a media interface for interaction and information exchange between an application or an operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface of an application is the source code written in specific computer languages such as Java and Extensible Markup Language (XML). The interface source code is parsed and rendered on a terminal device and finally presented as content recognizable by the user, such as controls like pictures, texts, and buttons. A control (also known as a widget) is a basic element of the user interface. Typical controls include a toolbar, a menubar, a text box, a button, a scrollbar, pictures, and texts. The attributes and content of the controls in the interface are defined through tags or nodes. For example, XML uses <textview> 、 <imgview> 、 <videoview>Nodes such as these are used to define the controls included in the interface. One node corresponds to one control or property in the interface, and after being parsed and rendered, the node presents visible content to the user. In addition, in the interfaces of many applications, such as hybrid applications, there are usually web pages included. A web page, also known as a page, can be understood as a special control embedded in the application interface. A web page is source code written in a specific computer language, such as hyper text markup language (HTML), cascading style sheets (CSS), JavaScript (JS), etc. The web page source code can be loaded and displayed as recognizable content to the user by a browser or a web page display component similar to the browser in function. The specific content included in the web page is also defined by tags or nodes in the web page source code. For example, HTML uses 、 、 <video> 、 <canvas>to define the elements and attributes of a web page.
[0220] A commonly used form of the user interface is the graphical user interface (GUI), which refers to the user interface related to computer operations displayed in a graphical manner. It can be an interface element such as an icon, window, control, etc. displayed on the display screen of an electronic device, where the control can include visible interface elements such as icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, Widgets, etc.
[0221] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive), etc.
[0222] Those of ordinary skill in the art can understand all or part of the processes in the methods of the above embodiments. These processes can be completed by relevant hardware instructed by a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The aforementioned storage medium includes: ROM or random access memory RAM, magnetic disks, or optical discs and other media that can store program codes.
[0223] As described above, the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.< / canvas> < / video> < / videoview> < / imgview> < / textview>
Claims
1. An animation frame skipping method, characterized in that: include: Receiving a first operation for opening a first interface, the first interface includes a first looping animation, the first looping animation has animation frames corresponding to a timestamp, and the first interface is an interface of a first application; After receiving the first operation, the choreographer receives a first vertical synchronization signal at a first moment, and in response to a flag bit of the animation frame with a timestamp before the first moment being a first preset value, the first application draws and renders the animation frame with a timestamp before the first moment; And, in response to the flag bit of the animation frame with a time stamp before the first moment not being the first preset value, not drawing and rendering the animation frame with a time stamp before the first moment; The drawn and rendered animation frames are layer synthesized by a layer synthesizer, and the first loop animation is displayed in the first interface.
2. The method according to claim 1, characterized in that The first interface further includes a second loop animation, the second loop animation having animation frames corresponding to the timestamp; the animation frames with the timestamp before the first moment include animation frames of the first loop animation and animation frames of the second loop animation; The method further comprises: After layer synthesis is performed on the drawn and rendered animation frames through a layer synthesizer, the second loop animation is displayed in the first interface.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: After receiving the first operation, N callback records are created in the callback queue of the choreographer, the callback records including the timestamp and flag of the animation frame; the flag is greater than or equal to the first preset value, and N is a positive integer.
4. The method according to claim 3, characterized in that In response to the flag bit of the animation frame whose timestamp is before the first moment being a first preset value, drawing and rendering the animation frame by the first application specifically includes: If there is a callback record whose animation frame flag is equal to the first preset value among the M callback records with timestamps before the first moment in the callback queue, the M animation frames corresponding to the M callback records are drawn and rendered by the first application, 1<M≤N, and M is an integer.
5. The method according to claim 4, characterized in that The method further comprises After drawing and rendering the M animation frames corresponding to the M callback records through the first application, the M callback records are deleted from the callback queue.
6. The method according to claim 4 or 5, characterized in that: The layer synthesis of the drawn and rendered animation frames by the layer synthesizer specifically includes: After acquiring the second vertical synchronization signal, the layer synthesizer performs layer synthesis on the M animation frames after drawing and rendering, wherein the second vertical synchronization signal is the next vertical synchronization signal of the first vertical synchronization signal.
7. The method according to any one of claims 3 to 6, characterized in that: In response to the flag bit of the animation frame whose timestamp is before the first moment not being the first preset value, not drawing and rendering the animation frame specifically includes: If, in the M callback records in the callback queue whose timestamps are before the first moment, the flag bits of the animation frames are not equal to the first preset value, the M animation frames corresponding to the M callback records are not drawn and rendered.
8. The method according to any one of claims 3 to 7, characterized in that: The method further comprises: In response to the flag bit of the animation frame with a timestamp before the first moment not being the first preset value, subtracting a fixed value from the flag bits of the animation frame with a timestamp before the first moment; A second vertical synchronization signal is received by the choreographer at a second moment, and in response to the flag of the animation frame with a timestamp before the second moment being the first preset value, the animation frame with a timestamp before the second moment is drawn and rendered by the first application; and in response to the flag of the animation frame with a timestamp before the second moment not being the first preset value, the animation frame with a timestamp before the second moment is not drawn and rendered; wherein the second vertical synchronization signal is the next vertical synchronization signal of the first vertical synchronization signal.
9. The method according to claim 8, characterized in that In response to the flag bit of the animation frame with a timestamp before the first moment not being the first preset value, subtracting a fixed value from the flag bits of the animation frame with a timestamp before the first moment specifically includes: If the flag bits of the animation frames in the M callback records in the callback queue whose timestamps are before the second moment are not equal to the first preset value, subtract the fixed value from the flag bits of the animation frames in the M callback records; In response to the flag bit of the animation frame with a timestamp before the second moment being the first preset value, drawing and rendering the animation frame with a timestamp before the second moment by the first application specifically includes: If there is a callback record whose flag bit of the animation frame is equal to the first preset value among the K callback records whose timestamps in the callback queue are before the second moment, draw and render K animation frames corresponding to the K callback records by the first application, where the K animation frames include the M animation frames, K≥M, and K is an integer; In response to the flag bit of the animation frame with a timestamp before the second moment not being the first preset value, not drawing and rendering the animation frame with a timestamp before the second moment specifically includes: If the flag bits of the animation frames in the K callback records in the callback queue whose timestamps are before the second moment are not equal to the first preset value, the K animation frames corresponding to the K callback records are not drawn and rendered.
10. The method according to claim 9, characterized in that The method further comprises: After the first application draws and renders the K animation frames corresponding to the K callback records, the K callback records are deleted from the callback queue.
11. The method according to claim 9 or 10, characterized in that: After drawing and rendering the K animation frames corresponding to the K callback records through the first application, the method further includes: After acquiring the third vertical synchronization signal, the layer synthesizer performs layer synthesis on the K animation frames after drawing and rendering, wherein the third vertical synchronization signal is the next vertical synchronization signal of the second vertical synchronization signal.
12. An electronic device, characterized in that: It includes a display screen, one or more processors and one or more memories; wherein the display screen, the one or more memories are coupled to the one or more processors, the one or more memories are used to store computer program codes, and the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the method as described in any one of claims 1-11.
13. An electronic device, characterized in that: The method comprises one or more functional modules, wherein the one or more functional modules are used to execute the method according to any one of claims 1 to 11.
14. A chip, characterized in that: The chip is applied to an electronic device, and includes a processor and an interface circuit, wherein the interface circuit is used to receive instructions and transmit them to a processing circuit, and the processor is used to execute instructions, so that the chip executes the method as described in any one of claims 1-11.
15. A computer-readable storage medium, characterized in that: The method comprises instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 11.
Citation Information
Patent Citations
Image processing method and computer system
CN111768330A
Image display method and device, electronic equipment and storage medium
CN112767524A