Animation rendering method and device, equipment and storage medium
By receiving synchronization signals in electronic devices and passing frame time, the frame layer animation module is called for animation calculation, which solves the interface lag caused by the main UI thread and improves animation refresh efficiency and system reuse rate.
Patent Information
- Application Number
- CN202411041038.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-12-06
AI Technical Summary
In electronic devices, during the display of animation effects, the calculation tasks undertaken by the main UI thread are too large, which can easily cause the application interface to be stuck and affect the user experience.
The rendering thread receives the synchronization signal sent by the display module, passes the frame time to the rendered animation objects of the service layer and the frame layer, calls the animation module of the frame layer for animation calculation, avoiding the main UI thread participating in animation refresh, and directly calling the native animation module for Animation refresh.
In the process of rendering and displaying the current frame screen, there is no need to participate in the UI main thread, which avoids interface lag, improves the reuse rate of native code, and reduces system complexity.
Smart Images

Figure CN119091017A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of display technology, and in particular to an animation rendering method and apparatus, device, and storage medium. Background Art
[0002] As the resolution and size of electronic device screens become higher and higher, more and more content can be displayed on electronic devices. Applications can display animation effects to users by adjusting the size, color, transparency and other attributes of interface elements displayed on the interface. However, in related technologies, during the display of animation effects, the main thread of the user interface (UI) usually undertakes the animation calculation task. If there are many calculation tasks in the main thread of the UI, the interface of the application is prone to freeze. Summary of the invention
[0003] The present application provides an animation rendering method and apparatus, a device, and a storage medium, which can alleviate the problem of application interface freeze.
[0004] A first aspect of an embodiment of the present application provides an animation rendering method, comprising:
[0005] Receiving, through the rendering thread, a synchronization signal sent by the display module and determining a frame time of a current frame corresponding to the synchronization signal;
[0006] Sending the frame time to a first rendering animation object in a service layer through the rendering thread;
[0007] Sending the frame time to a second rendering animation object in a framework layer through the first rendering animation object;
[0008] By means of the second rendering animation object, the animation module in the framework layer is driven to refresh the animation picture according to the frame time, so as to obtain the first animation data corresponding to the current frame picture;
[0009] The current frame is rendered according to the first animation data by the rendering thread, and the current frame is displayed by the display module.
[0010] A second aspect of an embodiment of the present application provides an animation rendering device, the device comprising:
[0011] A determination unit, configured to receive a synchronization signal sent by a display module through a rendering thread and determine a frame time of a current frame corresponding to the synchronization signal;
[0012] A sending unit, configured to send the frame time to a first rendering animation object in a service layer through the rendering thread;
[0013] The sending unit is further used to send the frame time to the second rendering animation object in the framework layer through the first rendering animation object;
[0014] A data calculation unit, configured to drive the animation module in the framework layer to refresh the animation screen according to the frame time through the second rendering animation object, and obtain first animation data corresponding to the current frame screen;
[0015] A rendering unit is used to render the current frame image according to the first animation data through the rendering thread, and display the current frame image through the display module.
[0016] A third aspect of the embodiments of the present application provides an electronic device,
[0017] A memory storing executable program code;
[0018] and a processor coupled to the memory;
[0019] The processor calls the executable program code stored in the memory, and when the executable program code is executed by the processor, the processor implements the method disclosed in the first aspect of the embodiment of the present application.
[0020] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium having executable program code stored thereon. When the executable program code is executed by a processor, the method disclosed in the first aspect of the embodiment of the present application is implemented.
[0021] The fifth aspect of the embodiments of the present application discloses a computer program product. When the computer program product runs on a computer, the computer executes the method disclosed in the first aspect of the embodiments of the present application.
[0022] A sixth aspect of an embodiment of the present application discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer executes the method disclosed in the first aspect of the embodiment of the present application.
[0023] It can be seen from the above technical solutions that the embodiments of the present application have at least the following advantages:
[0024] The rendering thread receives the synchronization signal sent by the display module, determines the frame time of the current frame corresponding to the synchronization signal, and sends the frame time to the first rendering animation object in the service layer. The first rendering animation object sends the frame time to the second rendering animation object in the framework layer, and the second rendering animation object drives the animation module in the framework layer to refresh the animation according to the frame time to obtain the first animation data corresponding to the current frame. Finally, the rendering thread renders the current frame according to the first animation data, and the current frame is displayed by the display module.
[0025] By implementing this method, when the rendering thread receives a synchronization signal, the rendering thread can pass the frame time of the current frame through the first rendering animation object of the service layer and the second rendering animation object of the framework layer, thereby calling the animation module of the framework layer to perform animation calculations to obtain animation data corresponding to the current frame. In the process of rendering and displaying the current frame, there is no need for the UI main thread to participate, which can avoid the interface freeze problem of the application caused by the UI main thread, and directly calling the native animation module to refresh the animation can improve the reuse rate of the native code, which is conducive to reducing the complexity of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a flowchart of the rendering method disclosed in the embodiment of the present application;
[0027] Figure 2A It is a system framework diagram of the electronic device disclosed in the embodiment of the present application;
[0028] Figure 2B is another system framework diagram of the electronic device disclosed in the embodiment of the present application;
[0029] Figure 3 is another flowchart of the animation rendering method disclosed in the embodiment of the present application;
[0030] Figure 4 It is another flowchart of the animation rendering method disclosed in the embodiment of the present application;
[0031] Figure 5 It is another system framework diagram of the electronic device disclosed in the embodiment of the present application;
[0032] Figure 6 It is another flowchart of the animation rendering method disclosed in the embodiment of the present application;
[0033] Figure 7 It is a structural diagram of the animation rendering device disclosed in the embodiment of the present application;
[0034] Figure 8It is a structural diagram of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The present application provides an animation rendering method and apparatus, a device, and a storage medium, which can alleviate the problem of application interface freeze.
[0036] In order to make the technical personnel in the technical field better understand the scheme of the present application, the technical scheme in the embodiment of the present application will be described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, not all of the embodiments. Based on the embodiments in the present application, they should all fall within the scope of protection of the present application.
[0037] It should be noted that, in this application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0038] "At least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can mean: a, or b, or c, or a and b, or a and c, or b and c, or a, b and c, where a, b, c can be single or plural.
[0039] The following first introduces some of the specific terms involved in the embodiments of the present application:
[0040] Service layer: The service layer is responsible for handling tasks such as underlying hardware access and high-performance computing.
[0041] Framework layer: The framework layer is responsible for handling upper-level business logic and interface display and other tasks.
[0042] Display module: refers to a service process responsible for graphics synthesis, which is mainly responsible for the synthesis and display of screen display content.
[0043] UI main thread: It is a thread created at the framework layer when the application is started. The UI main thread is the main execution thread of the application and is responsible for handling user interface updates and event responses.
[0044] Rendering thread: A thread created in the service layer when the application is started. The rendering thread is mainly responsible for graphics rendering tasks.
[0045] Render tree: The render tree is a tree structure generated according to the Document Object Model (DOM) and Cascading Style Sheet (CSS) style, which contains all element nodes that need to be displayed and their style information and geometric information.
[0046] Rendering node: A rendering node is a node in the rendering tree. Each node represents an element that needs to be drawn on the frame.
[0047] Rendering root node: The rendering root node is the root node of the rendering tree. It is the starting point for frame layout and drawing. In the rendering tree, all rendering child nodes are descendant nodes of the rendering root node.
[0048] Frame time: Frame time refers to the time it takes to render or update one frame of animation, usually measured in seconds.
[0049] In the embodiments of the present application, the electronic device may include a general handheld screen electronic device, such as a mobile phone, a smart phone, a portable terminal, a terminal, a personal digital assistant (PDA), a portable multimedia player (Personal Media Player, PMP) device, a laptop computer, a notebook (Note Pad), a wireless broadband (Wireless Broadband, Wibro) terminal, a tablet computer (Personal Computer, PC), a smart PC and a car computer, etc.
[0050] Electronic devices may also include wearable devices. Wearable devices are portable electronic devices that can be worn directly on the user or integrated into the user's clothes or accessories. Wearable devices are not just hardware devices, but can also achieve powerful intelligent functions through software support, data interaction, and cloud server interaction, such as: computing function, positioning function, and alarm function. They can also be connected to mobile phones and various terminals. Wearable devices may include but are not limited to watches supported by the wrist (such as watches, wrists, etc.), shoes supported by the feet (such as shoes, socks, or other products worn on the legs), glasses supported by the head (such as glasses, helmets, headbands, etc.), as well as smart clothing, school bags, crutches, accessories and other non-mainstream product forms.
[0051] At present, the way electronic devices implement animation on the application interface is usually that the UI main thread first calculates the animation data of each frame and generates the corresponding drawing commands, then the rendering thread executes the drawing commands to obtain the picture data of each frame, and finally the display module displays each frame according to the picture data.
[0052] Combine the following Figure 1 , introduces the rendering process of a frame, such as Figure 1 The rendering process shown may include the following steps:
[0053] 101. The UI main thread receives a synchronization signal sent by the display module.
[0054] 102. The UI main thread performs animation calculations to obtain animation data.
[0055] 103. The UI main thread creates drawing commands based on the animation data.
[0056] 104. The UI main thread sends drawing commands to the rendering thread and synchronizes animation data with the rendering thread.
[0057] 105. The rendering thread executes the drawing command sent by the UI main thread, renders the animation data, obtains the screen data, and stores the screen data in the cache.
[0058] 106. The display module reads the screen data from the cache.
[0059] 107. The display module performs image synthesis and other processing according to the image data to obtain a frame image to be displayed, and sends it to the display screen for display.
[0060] It can be seen that in the process of implementing animation of controls on the application interface of an electronic device, the animation calculation tasks corresponding to each frame of the picture are executed by the UI main thread. If the calculation tasks of the UI main line are too large, it will usually cause the UI main line to be blocked, which will cause the application interface to become stuck and affect the user experience.
[0061] To solve this problem, the embodiments of the present application provide an animation rendering method and apparatus, a device, and a storage medium, which can alleviate the problem of freezing of the application interface.
[0062] The following first introduces the system architecture of the electronic device.
[0063] See also Figure 2A , Figure 2A 1 is a diagram of the system architecture of the electronic device disclosed in the embodiment of the present application. Figure 2A As shown, the system architecture of the electronic device includes an application layer 20, a framework layer 21, a service layer 22, and a kernel layer 23. Among them, the application layer 20 is the topmost part of the system architecture, which can directly interact with the user, and the application layer 20 can include all user-oriented applications. The framework layer 21 is located below the application layer 20 and provides a set of basic architectures and tool sets for application development. The service layer 22 is located below the framework layer 21 and provides a series of service support for upper-layer applications. The kernel layer 23 is the bottommost part of the system architecture, which is mainly responsible for managing the hardware resources of the system and providing the bottom-level services of the system.
[0064] It should be noted that the rendering method provided in the embodiment of the present application mainly involves the interaction between the framework layer 21 and the service layer 22. Figure 2B The framework layer 21 and the service layer 22 are introduced. Figure 2B As shown, the framework layer 21 includes a second rendering animation object 211 and an animation module 212 , and the service layer 22 includes a rendering thread 221 , a first rendering animation object 222 and a display module 223 .
[0065] In the animation rendering method provided by the present application, when the rendering thread 221 receives a synchronization signal, the rendering thread 221 can pass the frame time of the current frame through the first rendering animation object 222 of the service layer 22 and the second rendering animation object 211 of the framework layer 21, thereby calling the animation module 212 of the framework layer 21 to perform animation calculations to obtain the animation data corresponding to the current frame. It can be seen that in the process of rendering and displaying the current frame, the UI main thread does not need to participate, which can avoid the interface freeze problem of the application caused by the UI main thread, and directly calling the native animation module 212 for animation refresh can improve the reuse rate of native code, which is conducive to reducing system complexity.
[0066] For example, in an Android system, the service layer 22 may be a native layer, and the framework layer 21 may be a Java layer. It is understandable that in other systems, the service layer 22 and the framework layer 21 may have other names, which are not limited in the embodiments of the present application.
[0067] It should be noted that in the embodiments of the present application, the electronic device is based on Figure 2B The system framework shown can achieve the following Figure 3-Figure 4 Animation rendering method shown.
[0068] See also Figure 3 , Figure 3 It is a flowchart of the animation rendering method disclosed in the embodiment of the present application.
[0069] like Figure 3 The animation rendering method shown may include the following steps:
[0070] 301. A rendering thread receives a synchronization signal sent by a display module and determines a frame time of a current frame corresponding to the synchronization signal.
[0071] In an embodiment of the present application, both the rendering thread and the display module can run in the service layer, and the display module can send a synchronization signal to the rendering thread each time the interface is refreshed.
[0072] Among them, the synchronization signal is a timing pulse, which is mainly used to ensure that the update of the video frame is synchronized with the refresh cycle of the display to avoid screen tearing and other problems with display synchronization.
[0073] The frequency of the synchronization signal matches the refresh rate of the display of the electronic device. For example, if the refresh rate of the display is 60Hz, the synchronization signal will be sent 60 times per second, each time at an interval of about 16.67 milliseconds (1 second / 60).
[0074] In an embodiment of the present application, before step 301, the rendering thread can call the frame callback interface to trigger the display module to refresh the next frame, and when the frame callback interface is called, send a synchronization request to the display module, and the synchronization request is used to request the display module to send a synchronization signal to the rendering thread. When the display module receives the synchronization request, it sends a synchronization signal to the rendering thread in response to the synchronization request.
[0075] Exemplarily, the frame callback interface may be a frameCallback interface.
[0076] By implementing this method, the rendering thread obtains the synchronization signal by sending a synchronization request to the display module, which is conducive to timely triggering the rendering of the current frame.
[0077] The frame time of the current frame may include the frame number corresponding to the current frame, or the time position of the current frame in the entire animation.
[0078] In some embodiments, the current frame picture may be any frame picture. For example, the current frame picture may be the first frame picture, the second frame picture or the third frame picture.
[0079] As an implementation method, starting from the first frame corresponding to the animation, the animation calculation corresponding to each frame is executed by the rendering thread, that is, the entire animation rendering process does not require the participation of the UI main thread, and the display process of each frame in the entire animation process is shown in steps 301-306.
[0080] As another implementation, the first frame corresponding to the animation can be refreshed by the UI main thread, and the other frames in the animation except the first frame are refreshed by the rendering thread, and the rendering thread performs the animation calculations corresponding to the other frames except the first frame. Except the first frame, the rendering and display of the other frames do not require the participation of the UI main thread, and the display process of each other frame is shown in steps 301 to 306.
[0081] 302. The rendering thread sends a frame time to a first rendering animation object.
[0082] In an embodiment of the present application, the first rendering animation object and the rendering thread can both run in the service layer. After receiving the synchronization signal, in order to drive the first rendering animation object to refresh the animation, the rendering thread sends the frame time to the first rendering animation.
[0083] 303. The first rendering animation object sends a frame time to the second rendering animation object.
[0084] In the embodiment of the present application, the second rendering animation object runs in the framework layer, and the first rendering animation object sends the above frame time to the second rendering animation object after performing animation refresh.
[0085] It should be noted that the existence of the first rendering animation object and the second rendering animation object is to enable the rendering thread to transfer the frame time from the service layer to the framework layer.
[0086] In the embodiment of the present application, the first rendering object and the second rendering object may be preset rendering objects, that is, objects originally existing in the operating system, or may be objects created in real time by the electronic device.
[0087] In the case where the first rendering object and the second rendering object are objects created in real time by the electronic device, such as Figure 2B The system architecture diagram shown may also include a first rendering animation module in the framework layer 21 and a second rendering animation module in the service layer 22 (not shown in the diagram).
[0088] The first rendering animation module is a module running on the framework layer and used to create a rendering animation object on the framework layer, and the second rendering animation module is a module running on the service layer and used to create a rendering animation object on the service layer.
[0089] Specifically, the electronic device may create a first rendering object and a second rendering object in a manner that may include: a first rendering animation module, creating a second rendering animation object in a framework layer; and a second rendering animation module, creating a first rendering animation object corresponding to the second rendering animation object in a service layer.
[0090] In some embodiments, the first rendering animation module may create the second rendering animation object through the new method, and correspondingly, the second rendering animation module may create the first rendering animation object in the constructor of the second rendering animation object by calling the jin interface.
[0091] By implementing the method, the electronic device creates the first rendering animation object and the second rendering animation object in real time, which is helpful to reduce memory usage.
[0092] 304. A second rendering animation object drives the animation module to refresh the animation picture according to the frame time, and obtains first animation data corresponding to the current frame picture.
[0093] In the embodiment of the present application, the animation module is also in the framework layer like the second rendering animation object. The animation module is a module in the native system of the electronic device for performing animation calculations.
[0094] It should be noted that the rendering thread passes the frame time from the service layer to the framework layer in order to call the animation module of the framework layer to perform animation calculations corresponding to the current frame. Therefore, after receiving the frame time, the second rendering animation object needs to send the frame time to the animation module, and the animation module refreshes the animation screen according to the frame time.
[0095] In the embodiment of the present application, when the animation module receives the frame time, it can calculate the first animation data corresponding to the current picture frame according to the preset animation curve and frame time.
[0096] The animation curve is used to describe how the attributes of the rendering node change over time from the start of the animation to the end of the animation. The first animation data may include target attribute information of each rendering node of the rendering tree corresponding to the current picture frame.
[0097] 305. The rendering thread renders the current frame according to the first animation data.
[0098] It should be noted that after obtaining the first animation data, the animation module sends the first animation data to the rendering thread, and then the rendering thread renders the current frame according to the first animation data.
[0099] In some embodiments, the rendering thread rendering the current frame according to the first animation data may include:
[0100] The rendering thread traverses the rendering nodes of the rendering tree corresponding to the current frame according to the first animation data to obtain a traversal result;
[0101] The rendering thread creates drawing instructions based on the traversal results, and executes the drawing instructions to obtain the drawing results;
[0102] The rendering thread sends the drawing result to the display module, so that the display module displays the current frame according to the drawing result.
[0103] In the embodiment of the present application, the traversal result may include the latest attribute information of each rendering node. It should be noted that the attribute information may be used to determine the display mode of the rendering node, and the display mode includes but is not limited to at least one of the following: animation effects acting on appearance, animation effects acting on position, animation effects acting on transformation, and animation effects acting on content, etc.
[0104] In some embodiments, the rendering node may include layers and / or controls in the current frame, wherein the layers may include but are not limited to images, video clips, texts, etc., and the controls may include but are not limited to buttons, text boxes, etc.
[0105] It is understandable that, when the rendering node includes a layer and a control, the electronic device can process the attribute animation of the layer and the control at the same time, which is conducive to improving the processing efficiency of the attribute animation.
[0106] In the embodiment of the present application, the drawing instruction may include but is not limited to at least one of the following: vertex data (such as position, color, texture coordinates, etc.), shader program (vertex shader and fragment shader) and rendering state setting, etc. The drawing result may include the picture data corresponding to the current frame.
[0107] In an embodiment of the present application, the rendering thread executing the drawing instruction may include: the rendering thread submitting the drawing instruction to a graphics processing unit (GPU), and the GPU executing the drawing instruction.
[0108] In some embodiments, Figure 2B The service layer 22 shown may also include a buffer queue ( Figure 2B (not shown), the buffer queue provides a bidirectional queue, allowing the rendering thread and the display module to exchange image buffers in an asynchronous manner, so as to enable the rendering thread to send the drawing result to the display module. Based on this, the rendering thread can send the drawing result to the display module in the following ways:
[0109] After creating a drawing instruction based on the traversal results, the rendering thread can request an image buffer from the buffer queue, execute the drawing instruction, store the obtained drawing results in the image buffer, and put the image buffer back into the buffer queue. The display module can obtain the image buffer storing the drawing results from the buffer queue and read the drawing results from the image buffer.
[0110] 306. The display module displays the current frame.
[0111] By implementing the above method, when the rendering thread receives a synchronization signal, the rendering thread can pass the frame time of the current frame through the first rendering animation object of the service layer and the second rendering animation object of the framework layer, thereby calling the animation module of the framework layer to perform animation calculations to obtain the animation data corresponding to the current frame. In the process of rendering and displaying the current frame, there is no need for the UI main thread to participate, which can avoid the interface freeze problem of the application caused by the UI main thread, and directly calling the native animation module to refresh the animation can improve the reuse rate of the native code, which is beneficial to reduce the complexity of the system.
[0112] It should be noted that, in the above step 302, the rendering thread sending the frame time to the first rendering animation object may occur before the rendering thread traverses the rendering nodes included in the rendering tree corresponding to the current frame, or may occur when the rendering thread traverses to the rendering root node of the rendering tree corresponding to the current frame, which is not limited in the embodiment of the present application.
[0113] The embodiments of the present application are mainly combined with the following Figure 4 The case where the rendering thread sends the frame time to the first rendering animation object occurs when the rendering thread traverses to the rendering root node of the rendering tree corresponding to the current frame screen is introduced.
[0114] See also Figure 4 , Figure 4 It is a flowchart of the animation rendering method disclosed in the embodiment of the present application.
[0115] like Figure 4 The animation rendering method shown may include the following steps:
[0116] 401. The rendering thread receives a synchronization signal sent by a display module and determines a frame time of a current frame corresponding to the synchronization signal.
[0117] It should be noted that for a detailed description of step 401, reference may be made to the description of step 301 above, which will not be repeated here.
[0118] 402. The rendering thread traverses the rendering nodes included in the rendering tree corresponding to the current frame in response to the synchronization signal.
[0119] 403. When the rendering thread traverses to the rendering root node in the rendering tree, the rendering thread sends a frame time to the first rendering animation object.
[0120] 404. The first rendering animation object sends a frame time to the second rendering animation object.
[0121] 405. Second rendering animation object, driving the animation module to refresh the animation picture according to the frame time, and obtaining the first animation data corresponding to the current frame picture.
[0122] For instructions on steps 404-405, see Figure 3 The introduction of step 303-step 304 in will not be repeated here.
[0123] In some embodiments, after step 405, the animation module can also determine whether the current frame is the last frame, and if the current frame is the last frame, send target information indicating the end of the animation to the second rendering animation object, and then the second rendering animation object sends the target information to the first rendering animation object. Finally, the first rendering animation object sends the target information to the rendering thread. When the rendering thread receives the target information, it stops sending synchronization requests to the display module.
[0124] In an embodiment of the present application, the animation module may also store attribute information of each rendering node corresponding to the last frame, and the way in which the animation module determines whether the current frame is the last frame may include: the animation module compares the attribute information of each rendering node in the first animation data with the attribute information of each rendering node corresponding to the last frame; if they are the same, it is determined that the current frame is the last frame; if they are not the same, it is determined that the current frame is not the last frame.
[0125] In some embodiments, the target information may be information preset in the animation module for indicating the end of the animation, and the information may include but is not limited to at least one of the following: numbers, letters, special characters, etc.
[0126] Exemplarily, the target information is "1" or "0".
[0127] By implementing this method, when the animation module determines that the current frame is the last frame, the animation module sends target information to the rendering thread through the second rendering animation object and the first rendering animation object, so that the rendering thread stops sending synchronization requests to the display module, which helps to reduce the error probability of the system.
[0128] 406. The rendering thread obtains target attribute information of the rendering root node from the first animation data. If the target attribute information of the rendering root node is different from the current attribute information of the rendering root node, the current attribute information of the rendering root node is updated to the target attribute information corresponding to the rendering root node.
[0129] 407. When the rendering thread traverses to a rendering subnode in the rendering tree, the rendering thread obtains target attribute information of the rendering subnode from the first animation data. If the target attribute information of the rendering subnode is different from the current attribute information of the rendering subnode, the current attribute information of the rendering subnode is updated to the target attribute information corresponding to the rendering subnode.
[0130] When the rendering thread traverses the rendering nodes contained in the rendering tree corresponding to the current frame, if the rendering thread traverses to the rendering root node, the target attribute information corresponding to the rendering root node calculated by the animation module can be obtained. The rendering thread can determine whether the attributes of the rendering root node need to be updated based on the target attribute information corresponding to the rendering root node. If the target attribute information of the rendering root node is different from the current attribute information of the rendering root node, it is determined that it needs to be updated, and the attribute information corresponding to the rendering root node is updated to the target attribute information.
[0131] In the process of the rendering thread traversing the rendering sub-nodes, the target attribute information of the current rendering sub-node calculated by the animation module can be obtained, and based on the target attribute information corresponding to the current rendering sub-node, it is determined whether the attributes of the current rendering sub-node need to be updated. If the target attribute information of the current rendering sub-node is different from the current attribute information of the current rendering sub-node, it is determined that an update is required, and the attribute information corresponding to the current rendering sub-node is updated to the target attribute information.
[0132] Then, the next rendering child node is traversed according to this method until the attributes of all rendering nodes in the rendering tree are traversed, which is beneficial to improving the traversal accuracy of the rendering nodes.
[0133] 408. When the rendering thread has finished traversing the rendering tree, the rendering thread creates a drawing instruction according to the traversal result, and executes the drawing instruction to obtain a drawing result.
[0134] The traversal result may include current attribute information of each rendering node in the rendering tree after traversal.
[0135] 409. The rendering thread sends the drawing result to the display module.
[0136] 410. The display module displays the current frame according to the drawing result.
[0137] It should be noted that for the introduction of steps 408 to 410, please refer to the above Figure 3The relevant instructions in will not be repeated here.
[0138] By implementing the above method, when the rendering thread receives a synchronization signal, the rendering thread can pass the frame time of the current frame through the first rendering animation object of the service layer and the second rendering animation object of the framework layer, thereby calling the animation module of the framework layer to perform animation calculations to obtain the animation data corresponding to the current frame. In the process of rendering and displaying the current frame, there is no need for the UI main thread to participate, which can avoid the interface freeze problem of the application caused by the UI main thread, and directly calling the native animation module to refresh the animation can improve the reuse rate of the native code, which is beneficial to reduce the complexity of the system.
[0139] In addition, when the rendering thread traverses to the rendering root node, triggering the sending of frame time to the first rendering animation object can also further improve the reuse rate of the native code, which is conducive to further reducing the complexity of the system.
[0140] In some embodiments, Figure 5 It is another system framework of the electronic device disclosed in the embodiment of this application. Figure 5 The system framework shown may include a service layer 22 and a framework layer 21. The service layer 22 includes a rendering thread 221, a first rendering animation object 222, a display module 223 and a first cache 224, and the framework layer 21 may include a second rendering animation object 211 and an animation module 212.
[0141] It should be noted that electronic devices are based on Figure 5 The system framework shown can achieve the following Figure 6 Animation rendering method shown.
[0142] 601. The rendering thread receives a synchronization signal sent by a display module and determines a frame time of a current frame corresponding to the synchronization signal.
[0143] It should be noted that for a detailed description of step 601, please refer to the description of step 301 above, which will not be repeated here.
[0144] In some embodiments, the current frame is not the first frame, and the display process of the first frame involves the participation of the UI main thread, which can further improve the reuse rate of the native code.
[0145] It is understandable that before step 601, the electronic device can also calculate the second animation data corresponding to the first frame through the UI main thread, synchronize the second animation data to the rendering thread, render the first frame according to the second animation data through the rendering thread, and display the first frame through the display module.
[0146] It should be noted that, regarding the rendering and display of the first frame, reference may be made to the above rendering and display of the current frame, which will not be repeated here.
[0147] In some embodiments, the UI main thread may also calculate the second animation data corresponding to the first frame through the animation module. Specifically, the way in which the UI main thread calculates the second animation data corresponding to the first frame through the animation module can refer to the way in which the rendering thread calculates the first animation data corresponding to the current frame through the animation module, which will not be repeated here.
[0148] 602. The rendering thread traverses the rendering nodes included in the rendering tree corresponding to the current frame in response to the synchronization signal.
[0149] 603. When the rendering thread traverses to the rendering root node in the rendering tree, the rendering thread sends a frame time to the first rendering animation object in the service layer.
[0150] 604. The first rendering animation object sends a frame time to the second rendering animation object.
[0151] 605. A second rendering animation object drives the animation module to refresh the animation picture according to the frame time, and obtains the first animation data corresponding to the current frame picture.
[0152] Among them, for the introduction of steps 601 to 605, please refer to the above description of steps 401 to 405, which will not be repeated here.
[0153] 606. The animation module stores the first animation data in a first cache.
[0154] In an embodiment of the present application, the first cache is in the service layer. After the animation module obtains the first animation data according to the frame time, the first animation data can be stored in the first cache so that the rendering thread can read it.
[0155] In an embodiment of the present application, the animation module can write the first animation data into the first cache through the jin interface.
[0156] 607 . The rendering thread obtains target attribute information of the rendering root node from the first cache. If the target attribute information of the rendering root node is different from the current attribute information of the rendering root node, the current attribute information of the rendering root node is updated to the target attribute information corresponding to the rendering root node.
[0157] 608. When the rendering thread traverses to a rendering subnode in the rendering tree, the rendering thread obtains target attribute information of the rendering subnode from the first cache. If the target attribute information of the rendering subnode is different from the current attribute information of the rendering subnode, the current attribute information of the rendering subnode is updated to the target attribute information corresponding to the rendering subnode.
[0158] It is understandable that, in the process of the rendering thread traversing the rendering nodes included in the rendering tree corresponding to the current frame, when the rendering thread traverses to the rendering root node, the target attribute information corresponding to the rendering root node can be obtained from the first cache, and the rendering thread can determine whether the attributes of the rendering root node need to be updated based on the target attribute information corresponding to the rendering root node. If the target attribute information of the rendering root node is different from the current attribute information of the rendering root node, it is determined that it needs to be updated, and the attribute information corresponding to the rendering root node is updated to the target attribute information.
[0159] In the process of the rendering thread traversing the rendering sub-nodes, the target attribute information of the current rendering sub-node can be obtained from the first cache, and according to the target attribute information corresponding to the current rendering sub-node, it is determined whether the attributes of the current rendering sub-node need to be updated; if the target attribute information of the current rendering sub-node is different from the current attribute information of the current rendering sub-node, it is determined that it needs to be updated, and the attribute information corresponding to the current rendering sub-node is updated to the target attribute information.
[0160] Then, the next rendering child node is traversed in this way until the attributes of all rendering nodes in the rendering tree are traversed.
[0161] 609. When the rendering thread has finished traversing the rendering tree, the rendering thread creates a drawing instruction according to the traversal result, and executes the drawing instruction to obtain a drawing result.
[0162] 610. The rendering thread sends the drawing result to the display module.
[0163] 611. The display module displays the current frame according to the drawing result.
[0164] It should be noted that, for the introduction of steps 609 to 611, reference may be made to the above description of steps 408 to 410, which will not be repeated here.
[0165] By implementing the above method, when the rendering thread receives a synchronization signal, the rendering thread can pass the frame time of the current frame through the first rendering animation object of the service layer and the second rendering animation object of the framework layer, thereby calling the animation module of the framework layer to perform animation calculations to obtain the animation data corresponding to the current frame. In the process of rendering and displaying the current frame, there is no need for the UI main thread to participate, which can avoid the interface freeze problem of the application caused by the UI main thread, and directly calling the native animation module to refresh the animation can improve the reuse rate of the native code, which is beneficial to reduce the complexity of the system.
[0166] In addition, when the rendering thread traverses to the rendering root node, triggering the sending of frame time to the first rendering animation object can also further improve the reuse rate of the native code, which is conducive to further reducing the complexity of the system.
[0167] In addition, the animation module stores the first animation data in the first cache in the service layer, which facilitates the rendering thread to update the attribute information of the rendering node, and is beneficial to improving the traversal efficiency of the rendering node.
[0168] See also Figure 7 , Figure 7 is a structural diagram of the animation rendering device disclosed in the embodiment of the present application. Figure 7 The animation rendering device shown may include a determining unit 701, a sending unit 702, a data calculating unit 703 and a rendering unit 704; wherein:
[0169] The determination unit 701 is used to receive a synchronization signal sent by the display module through a rendering thread and determine a frame time of a current frame corresponding to the synchronization signal;
[0170] A sending unit 702, configured to send a frame time to a first rendering animation object in a service layer through a rendering thread;
[0171] The sending unit 702 is further used to send the frame time to the second rendering animation object in the framework layer through the first rendering animation object;
[0172] The data calculation unit 703 is used to drive the animation module in the framework layer to refresh the animation picture according to the frame time through the second rendering animation object, and obtain the first animation data corresponding to the current frame picture;
[0173] The rendering unit 704 is used to render the current frame according to the first animation data through the rendering thread, and display the current frame through the display module.
[0174] In some embodiments, Figure 7The animation rendering device shown may also include a traversal unit (not shown in the figure), which is used to traverse the rendering nodes included in the rendering tree corresponding to the current frame screen through the rendering thread in response to the synchronization signal after the determination unit 701 receives the synchronization signal sent by the display module through the rendering thread.
[0175] Furthermore, the method in which the determination unit 701 is used to send the frame time to the first rendering animation object in the service layer through the rendering thread can specifically include: the determination unit 701 is used to send the frame time to the first rendering animation object in the service layer through the rendering thread when the rendering thread traverses to the rendering root node in the rendering tree.
[0176] In some embodiments, the first animation data includes target attribute information corresponding to each rendering node of the rendering tree; the traversal unit is used to traverse the rendering nodes included in the rendering tree corresponding to the current frame screen through the rendering thread. Specifically, the traversal unit is used to traverse the rendering nodes included in the rendering tree corresponding to the current frame screen through the rendering thread; and, obtain the target attribute information corresponding to the current rendering node from the first animation data; and, if the current attribute information corresponding to the current rendering node is different from the target attribute information corresponding to the current rendering node, update the current attribute information of the current rendering node to the target attribute information corresponding to the current rendering node.
[0177] In some embodiments, the data calculation unit 703 is further configured to store the first animation data in the first cache through the animation module after obtaining the first animation data corresponding to the current frame;
[0178] Correspondingly, the rendering unit 704 is used to render the current frame according to the first animation data through the rendering thread, which may specifically include: the rendering unit 704 is used to obtain the first animation data from the first cache through the rendering thread, and render the current frame according to the first animation data.
[0179] In some embodiments, Figure 7 The animation rendering device shown may also include an object creation unit ( Figure 7 (not shown), a creation unit is used to determine that before the unit 701 receives the synchronization signal sent by the display module through the rendering thread, a second rendering animation object is created in the framework layer through a first rendering animation module in the framework layer; and a first rendering animation object corresponding to the second rendering animation object is created in the service layer through a second rendering animation module in the service layer.
[0180] In some embodiments, the sending unit 702 is further used to send a synchronization request to the display module through the rendering thread before the determining unit 701 receives the synchronization signal sent by the display module through the rendering thread, and the synchronization request is used to request the display module to send a synchronization signal to the rendering thread.
[0181] In some embodiments, the sending unit 702 is also used to send target information to the second rendering animation object through the animation module after the data calculation unit 703 obtains the first animation data corresponding to the current frame, when the current frame is the last frame, and to send target information to the first rendering animation object through the second rendering animation object; and to send target information to the rendering thread through the first rendering animation object; and, when the rendering thread receives the target information, stop sending synchronization requests to the display module.
[0182] In some embodiments, the current frame is not the first frame, and the data calculation unit 703 is further configured to calculate the second animation data corresponding to the first frame through the user interface UI main thread before the determination unit 701 receives the synchronization signal sent by the display module through the rendering thread, and synchronize the second animation data to the rendering thread;
[0183] Furthermore, the rendering unit 704 is further configured to render the first frame according to the second animation data through a rendering thread, and display the first frame through a display module.
[0184] See also Figure 8 , Figure 8 FIG. 1 is a structural diagram of an electronic device disclosed in an embodiment of the present application. Figure 8 The electronic device shown may include components such as a processor 801 , a memory 802 , a display unit 803 , an input unit 804 , a sensor 805 , and an audio circuit 806 .
[0185] The processor 801 is the control center of the electronic device, which uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 802, and calling data stored in the memory 802, so as to monitor the electronic device as a whole. Optionally, the processor 801 may include one or more processing units; optionally, the processor 801 may integrate an application processor, which mainly processes operating devices, user interfaces, and application programs, etc. Of course, other processors may also be included, which are not listed here one by one.
[0186] The memory 802 can be used to store software programs and modules. The processor 801 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 802. The memory 802 can mainly include a program storage area and a data storage area, wherein the program storage area can store operating devices, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the memory 802 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0187] The display unit 803 can be used to display information input by the user or information provided to the user and various menus of the electronic device. The display unit 803 may include a display panel. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel may cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 801 to determine the type of touch event. Then, the processor 801 provides a corresponding visual output on the display panel according to the type of touch event. Among them, the touch panel and the display panel are not in contact with each other. Figure 8 The touch panel and the display panel can be used as two independent components to realize the input and output functions of the electronic device, or the touch panel and the display panel can be integrated to realize the input and output functions of the electronic device.
[0188] The input unit 804 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the input unit 804 may include a touch panel and other input devices. A touch panel, also referred to as a touch screen, can collect user touch operations on or near it (such as operations performed by a user using any suitable object or accessory such as a finger, stylus, etc. on or near the touch panel), and drive the corresponding connection device according to a pre-set program. In addition, a variety of types such as resistive, capacitive, infrared, and surface acoustic waves can be used to implement the touch panel. In addition to the touch panel, the input unit 804 may also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of function keys (such as volume control keys, switch keys, etc.), trackballs, joysticks, etc.
[0189] The electronic device may also include at least one sensor 805, such as a magnetometer, a gyroscope sensor, a motion sensor, and other sensors. Specifically, the magnetometer is used to determine the orientation of the electronic device, and the gyroscope sensor can be used to determine the motion posture of the electronic device. It can be used for anti-shake shooting, and can also be used for navigation and somatosensory game scenes. As a type of motion sensor, the acceleration sensor can detect the magnitude of acceleration in all directions, and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the electronic device, such as horizontal and vertical screen switching, related games, magnetometer posture calibration, etc.; as for other sensors that the electronic device can also be configured with, such as pressure gauges, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0190] The audio circuit 806 may include a speaker and a microphone, and may provide an audio interface between a user and an electronic device. The audio circuit 806 may transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 806 and converted into audio data, and then the audio data is output to the processor 801 for processing, and then sent to another device through the video circuit, or the audio data is output to the memory 802 for further processing.
[0191] Although not shown, the electronic device may further include a power supply and a camera. Optionally, the camera may be located at the front or rear of the electronic device, which is not limited in the present embodiment.
[0192] It is to be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0193] In the embodiment of the present application, the processor 801 also has the following functions:
[0194] Through the rendering thread, a synchronization signal sent by the display module is received and a frame time of the current frame corresponding to the synchronization signal is determined;
[0195] Sending the frame time to the first rendering animation object in the service layer through the rendering thread;
[0196] Sending frame time to a second rendering animation object at the framework layer through the first rendering animation object;
[0197] By means of the second rendering animation object, the animation module in the framework layer is driven to refresh the animation picture according to the frame time, and the first animation data corresponding to the current frame picture is obtained;
[0198] The current frame is rendered according to the first animation data through the rendering thread, and the current frame is displayed through the display module.
[0199] In the embodiment of the present application, the processor 801 also has the following functions:
[0200] In response to the synchronization signal, traverse the rendering nodes included in the rendering tree corresponding to the current frame through the rendering thread;
[0201] Sending the frame time to the first rendering animation object in the service layer through the rendering thread includes:
[0202] When the rendering thread traverses to the rendering root node in the rendering tree, the rendering thread sends the frame time to the first rendering animation object in the service layer.
[0203] In the embodiment of the present application, the first animation data includes target attribute information corresponding to each rendering node of the rendering tree; the processor 801 also has the following functions:
[0204] The rendering nodes contained in the rendering tree corresponding to the current frame are traversed through the rendering thread;
[0205] Acquire target attribute information corresponding to the current rendering node from the first animation data;
[0206] If the current attribute information corresponding to the current rendering node is different from the target attribute information corresponding to the current rendering node, the current attribute information of the current rendering node is updated to the target attribute information corresponding to the current rendering node.
[0207] In the embodiment of the present application, the processor 801 also has the following functions:
[0208] storing the first animation data in a first cache through the animation module;
[0209] The first animation data is obtained from the first cache through the rendering thread, and the current frame is rendered according to the first animation data.
[0210] In the embodiment of the present application, the processor 801 also has the following functions:
[0211] Creating a second rendering animation object in the framework layer through a first rendering animation module in the framework layer;
[0212] A first rendering animation object corresponding to the second rendering animation object is created in the service layer through the second rendering animation module in the service layer.
[0213] In the embodiment of the present application, the processor 801 also has the following functions:
[0214] A synchronization request is sent to the display module through the rendering thread, and the synchronization request is used to request the display module to send a synchronization signal to the rendering thread.
[0215] In the embodiment of the present application, the processor 801 also has the following functions:
[0216] When the current frame is the last frame, target information is sent to the second rendering animation object through the animation module, where the target information is used to indicate the end of the animation;
[0217] Sending target information to the first rendering animation object through the second rendering animation object;
[0218] Sending target information to the rendering thread through the first rendering animation object;
[0219] When the rendering thread receives the target information, it stops sending synchronization requests to the display module.
[0220] In the embodiment of the present application, the current frame is not the first frame; the processor 801 also has the following functions:
[0221] Calculate the second animation data corresponding to the first frame through the user interface UI main thread, and synchronize the second animation data to the rendering thread;
[0222] The first frame is rendered according to the second animation data through the rendering thread, and the first frame is displayed through the display module.
[0223] An embodiment of the present application discloses a computer-readable storage medium having executable program code stored thereon. When the executable program code is executed by a processor, the method executed by the electronic device in the embodiment of the present application is implemented.
[0224] The embodiment of the present application discloses a computer program product. When the computer program product is executed on a computer, the computer implements the method executed by the electronic device in the embodiment of the present application.
[0225] An embodiment of the present application discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer implements the method executed by the electronic device in the embodiment of the present application.
[0226] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium, storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0227] It should be understood that "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in one embodiment" or "in some embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments. The above description of each embodiment tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. For the sake of brevity, this article will not repeat them.
[0228] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, object A and / or object B can represent three situations: object A exists alone, object A and object B exist at the same time, and object B exists alone.
[0229] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0230] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical or other forms.
[0231] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed on multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0232] In addition, all functional modules in the embodiments of the present application may be integrated into one processing unit, or each module may be a separate unit, or two or more modules may be integrated into one unit; the above-mentioned integrated modules may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0233] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0234] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0235] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0236] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0237] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0238] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An animation rendering method, characterized in that: include: Receiving, through the rendering thread, a synchronization signal sent by the display module and determining a frame time of a current frame corresponding to the synchronization signal; Sending the frame time to a first rendering animation object in a service layer through the rendering thread; Sending the frame time to a second rendering animation object in a framework layer through the first rendering animation object; By means of the second rendering animation object, the animation module in the framework layer is driven to refresh the animation picture according to the frame time, so as to obtain the first animation data corresponding to the current frame picture; The current frame is rendered according to the first animation data by the rendering thread, and the current frame is displayed by the display module.
2. The method according to claim 1, characterized in that: After receiving the synchronization signal sent by the display module through the rendering thread, the method further includes: In response to the synchronization signal, traversing the rendering nodes included in the rendering tree corresponding to the current frame through the rendering thread; The sending the frame time to the first rendering animation object in the service layer through the rendering thread includes: When the rendering thread traverses to the rendering root node in the rendering tree, the frame time is sent to the first rendering animation object in the service layer through the rendering thread.
3. The method according to claim 2, characterized in that The first animation data includes target attribute information corresponding to each rendering node of the rendering tree; and traversing the rendering nodes included in the rendering tree corresponding to the current frame through the rendering thread includes: Traversing the rendering nodes included in the rendering tree corresponding to the current frame through the rendering thread; Acquire target attribute information corresponding to the current rendering node from the first animation data; If the current attribute information corresponding to the current rendering node is different from the target attribute information corresponding to the current rendering node, the current attribute information of the current rendering node is updated to the target attribute information corresponding to the current rendering node.
4. The method according to any one of claims 1 to 3, characterized in that: After obtaining the first animation data corresponding to the current frame, the method further includes: storing the first animation data in a first cache through the animation module; The rendering of the current frame according to the first animation data by the rendering thread includes: The first animation data is obtained from the first cache through the rendering thread, and the current frame is rendered according to the first animation data.
5. The method according to claim 1, characterized in that Before receiving the synchronization signal sent by the display module through the rendering thread, the method further includes: Creating a second rendering animation object in the framework layer through a first rendering animation module in the framework layer; A first rendering animation object corresponding to the second rendering animation object is created in the service layer through a second rendering animation module in the service layer.
6. The method according to claim 1, characterized in that Before receiving the synchronization signal sent by the display module through the rendering thread, the method further includes: A synchronization request is sent to a display module through the rendering thread, where the synchronization request is used to request the display module to send a synchronization signal to the rendering thread.
7. The method according to claim 6, characterized in that After obtaining the first animation data corresponding to the current frame, the method further includes: In a case where the current frame is the last frame, sending target information to the second rendering animation object through the animation module, wherein the target information is used to indicate the end of the animation; sending the target information to the first rendering animation object through the second rendering animation object; Sending the target information to the rendering thread through the first rendering animation object; When the rendering thread receives the target information, it stops sending synchronization requests to the display module.
8. The method according to claim 1, characterized in that The current frame is not the first frame; before receiving the synchronization signal sent by the display module through the rendering thread, the method further includes: Calculate the second animation data corresponding to the first frame through the user interface UI main thread, and synchronize the second animation data to the rendering thread; The first frame is rendered according to the second animation data by the rendering thread, and the first frame is displayed by the display module.
9. An animation rendering device, characterized in that: The device comprises: A determination unit, configured to receive a synchronization signal sent by a display module through a rendering thread and determine a frame time of a current frame corresponding to the synchronization signal; A sending unit, configured to send the frame time to a first rendering animation object in a service layer through the rendering thread; The sending unit is further used to send the frame time to the second rendering animation object in the framework layer through the first rendering animation object; A data calculation unit, configured to drive the animation module in the framework layer to refresh the animation screen according to the frame time through the second rendering animation object, and obtain first animation data corresponding to the current frame screen; A rendering unit is used to render the current frame image according to the first animation data through the rendering thread, and display the current frame image through the display module.
10. An electronic device, characterized in that: include: A memory storing executable program code; and a processor coupled to the memory; The processor calls the executable program code stored in the memory, and when the executable program code is executed by the processor, the processor implements the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having executable program code stored thereon, characterized in that: When the executable program code is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
