CN116166257A - Interface generation method and electronic equipment - Google Patents
Interface generation method and electronic equipment Download PDFInfo
- Publication number
- CN116166257A CN116166257A CN202111410746.6A CN202111410746A CN116166257A CN 116166257 A CN116166257 A CN 116166257A CN 202111410746 A CN202111410746 A CN 202111410746A CN 116166257 A CN116166257 A CN 116166257A
- Authority
- CN
- China
- Prior art keywords
- rendering
- interface
- animation
- application
- tree
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/38—Creation or generation of source code for implementing user interfaces
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T13/00—Animation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Human Computer Interaction (AREA)
- Computer Graphics (AREA)
- Processing Or Creating Images (AREA)
Abstract
本申请公开了界面生成方法及电子设备。本申请提供的界面生成方法,可以在基于渲染树生成界面的过程中,确定需要被动画渲染的内容并对该内容进行动画渲染,通过一次连续的渲染生成有动画效果的界面,不需要在基于渲染树生成界面前提前准备好以及被动画渲染后的内容,降低了生成具有动画效果的界面的需要的渲染次数,简化了生成具有动画效果的界面的流程,降低了电子设备生成动画效果的界面的开销。
The application discloses an interface generation method and an electronic device. The interface generation method provided by this application can determine the content that needs to be rendered by animation and perform animation rendering on the content in the process of generating the interface based on the rendering tree, and generate an interface with animation effect through one continuous rendering The content prepared in advance before the rendering tree generates the interface and rendered by animation reduces the number of renderings required to generate an interface with animation effects, simplifies the process of generating an interface with animation effects, and reduces the need for electronic devices to generate animation effects. s expenses.
Description
技术领域technical field
本申请涉及电子技术领域,尤其涉及界面生成方法及电子设备。The present application relates to the field of electronic technology, in particular to an interface generation method and electronic equipment.
背景技术Background technique
随着电子技术的发展,越来越多的电子设备参与到用户的日常生活中。用户在使用电子设备如智能手机时,应用程序的UI界面的动画效果直接影响到用户的体验。With the development of electronic technology, more and more electronic devices are involved in users' daily life. When a user uses an electronic device such as a smart phone, the animation effect of the UI interface of the application program directly affects the user's experience.
例如,在用户切换应用程序时,或者通过导航栏或全面屏手势切换出多任务窗口时,电子设备会呈现出模糊的背景;又例如,用户在桌面应用程序上长按其他应用程序的图标后,除该图标外的界面会变得模糊;这种模糊的效果能够使得用户感知到连贯的切换动画,进而提升了用户的体验。For example, when the user switches applications, or switches out of the multitasking window through the navigation bar or full-screen gestures, the electronic device will present a blurred background; another example, after the user presses and holds the icons of other applications on the desktop application , the interface other than the icon will become blurred; this blurring effect can make the user perceive a coherent switching animation, thereby improving the user experience.
但是,很显然的,包括模糊在内的多种动画效果的实现涉及到对视图的多次渲染,实现较为复杂,消耗的计算资源和内存资源较大,耗费的时间较长,容易造成界面的卡顿,并且会增加电子设备的功耗、发热。However, it is obvious that the realization of various animation effects including blurring involves multiple renderings of the view, the realization is more complicated, the computing resources and memory resources are consumed, and the time is longer, which is easy to cause the interface to be blurred. Caton, and will increase the power consumption and heat generation of electronic equipment.
发明内容Contents of the invention
本申请实施例提供了界面生成方法及电子设备。本申请实施例确定的界面生成方法,在对控件或任意区域实现包括模糊在内的动画效果时,无需预先生成动画后的内容,而是通过修改渲染树的渲染节点、渲染属性,并且在基于渲染树生成界面的过程中基于修改的渲染节点、渲染属性完成对控件、任意区域的动画渲染,进而生成带有动画效果的界面。本申请实施例提供的界面生成方法,通过一次连续的GPU调用减少了渲染的次数,无需在渲染阶段开始前就准备好界面中动画效果的内容,进而降低电子设备的功耗、发热。Embodiments of the present application provide a method for generating an interface and an electronic device. The interface generation method determined in the embodiment of this application does not need to pre-generate the content after animation when implementing animation effects including blurring on controls or arbitrary areas, but by modifying the rendering nodes and rendering properties of the rendering tree, and based on In the process of generating the interface by the rendering tree, the animation rendering of the control and any area is completed based on the modified rendering nodes and rendering properties, and then an interface with animation effects is generated. The interface generation method provided by the embodiment of the present application reduces the number of times of rendering through a continuous GPU call, and does not need to prepare the content of the animation effect in the interface before the rendering phase, thereby reducing power consumption and heat generation of electronic devices.
第一方面,本申请实施例提供的界面生成方法,该方法包括:第一进程确定目标渲染树,该目标渲染树用于绘制目标界面;在该第一进程基于该目标渲染树生成该目标界面的过程中,该第一进程基于该目标渲染树中的至少一个渲染节点确定第一内容,并对该第一内容执行基于第一动画参数的动画渲染以得到该第二内容,该至少一个渲染节点的动画参数为该第一动画参数;或者,在该第一进程基于该目标渲染树生成该目标界面的过程中,该第一进程基于第一表面上的第一区域确定第一内容,并对该第一内容执行基于第一动画参数的动画渲染以得到该第二内容,该第一进程基于该目标渲染树在该第一表面上生成该目标界面,该第一动画参数为该第一进程确定的;该第一进程生成该目标界面,该目标界面包括该第二内容,该动画渲染为在离屏缓冲中进行的渲染。In the first aspect, the interface generation method provided by the embodiment of the present application, the method includes: the first process determines the target rendering tree, and the target rendering tree is used to draw the target interface; in the first process, the target interface is generated based on the target rendering tree In the process, the first process determines the first content based on at least one rendering node in the target rendering tree, and performs animation rendering based on the first animation parameters on the first content to obtain the second content, and the at least one rendering The animation parameter of the node is the first animation parameter; or, during the process of the first process generating the target interface based on the target rendering tree, the first process determines the first content based on the first area on the first surface, and performing animation rendering on the first content based on the first animation parameter to obtain the second content, the first process generating the target interface on the first surface based on the target rendering tree, the first animation parameter being the first The process is determined; the first process generates the target interface, the target interface includes the second content, and the animation rendering is performed in an off-screen buffer.
在上述实施例中,电子设备在基于渲染树生成界面的过程中,可以绘制出需要动画渲染的内容,对该内容进行动画渲染得到渲染后的内容,进而得到目标界面。首先,可以不需要进程在渲染阶段前就准备好渲染后的内容,减少了多次渲染的开销,进而降低电子设备的开销。In the above embodiment, in the process of generating the interface based on the rendering tree, the electronic device may draw the content that requires animation rendering, perform animation rendering on the content to obtain the rendered content, and then obtain the target interface. First of all, it does not require the process to prepare the rendered content before the rendering stage, reducing the overhead of multiple renderings, thereby reducing the overhead of electronic equipment.
结合第一方面的一些实施例,在一些实施例中,在该第一进程确定目标渲染树前,该方法还包括:该第一进程在该目标渲染树中增加该至少一个渲染节点,该至少一个渲染节点被配置有该第一动画参数;或者,该第一进程为该至少一个渲染节点配置该第一动画参数。With reference to some embodiments of the first aspect, in some embodiments, before the first process determines the target rendering tree, the method further includes: the first process adds the at least one rendering node in the target rendering tree, the at least A rendering node is configured with the first animation parameter; or, the first process configures the first animation parameter for the at least one rendering node.
在上述实施例中,第一进程可以修改目标渲染树中的参数,例如,可以将需要动画渲染的控件对应的渲染节点配置动画参数,以使得在基于渲染树生成界面的过程中,第一进程可以将需要动画渲染的控件进行动画渲染;或者,又例如,进程可以在渲染树中插入一个或多个配置有动画参数的渲染节点,该一个或多个渲染节点的自己以及自己的子节点为动画渲染的内容,进而进行动画渲染。In the above embodiment, the first process can modify the parameters in the target rendering tree. For example, the rendering node corresponding to the control that needs animation rendering can be configured with animation parameters, so that in the process of generating the interface based on the rendering tree, the first process Animation rendering can be performed on controls that require animation rendering; or, for another example, the process can insert one or more rendering nodes configured with animation parameters in the rendering tree, and the one or more rendering nodes themselves and their own child nodes are The content of the animation rendering, and then the animation rendering.
结合第一方面的一些实施例,在一些实施例中,在该至少一个渲染节点的动画参数指示前景模糊的情况下,该第一内容包括该至少一个渲染节点对应的视图;在该至少一个渲染节点的动画参数指示背景模糊的情况下,该第一内容包括该至少一个渲染节点在该第一表面上对应的区域的内容。With reference to some embodiments of the first aspect, in some embodiments, when the animation parameter of the at least one rendering node indicates that the foreground is blurred, the first content includes the view corresponding to the at least one rendering node; When the animation parameter of the node indicates that the background is blurred, the first content includes the content of the region corresponding to the at least one rendering node on the first surface.
在上述实施例中,在动画参数指示前景模糊的情况下,被动画渲染的内容为被配置动画参数的渲染节点对应的视图;在动画参数指示背景模糊的情况下,被动画渲染的内容为被配置动画参数的渲染节点在第一表面对应的区域的内容,只有在本申请提供的界面生成方法,才能实现基于动画参数的值任意选择被动画的内容,进而实现各种不同的动画效果。In the above embodiment, when the animation parameter indicates that the foreground is blurred, the content rendered by animation is the view corresponding to the rendering node configured with animation parameters; when the animation parameter indicates that the background is blurred, the content rendered by animation is For the content of the area corresponding to the first surface of the rendering node configured with animation parameters, only the interface generation method provided by this application can arbitrarily select the content to be animated based on the value of the animation parameters, and then realize various animation effects.
结合第一方面的一些实施例,在一些实施例中,该第一进程确定目标渲染树前,该方法还包括:该第一进程基于第二渲染树和第三渲染树生成该目标渲染树,其中,该第二渲染树为由第二进程生成的用于绘制该第二进程的一帧界面的渲染树;该第三渲染树为由第三进程生成的用于绘制该第三进程的一帧界面的渲染树。With reference to some embodiments of the first aspect, in some embodiments, before the first process determines the target rendering tree, the method further includes: the first process generates the target rendering tree based on the second rendering tree and the third rendering tree, Wherein, the second rendering tree is a rendering tree generated by the second process for drawing a frame interface of the second process; the third rendering tree is a rendering tree generated by the third process for drawing the third process The rendering tree of the frame interface.
在上述实施例中,目标渲染树可以由多个应用程序的渲染树合成,进而通过一次GPU调用即一次渲染生成包含多个应用程序界面的目标界面。In the foregoing embodiments, the target rendering tree may be synthesized by rendering trees of multiple application programs, and then a target interface including multiple application program interfaces is generated through one GPU call, that is, one rendering.
结合第一方面的一些实施例,在一些实施例中,该至少一个渲染节点包括该第二渲染树中的渲染节点和该第三渲染树中的渲染节点,该第一内容包括该第二进程的一帧界面的部分或全部内容和该第三进程的一帧界面的部分或全部内容。With reference to some embodiments of the first aspect, in some embodiments, the at least one rendering node includes rendering nodes in the second rendering tree and rendering nodes in the third rendering tree, and the first content includes the second process part or all of the content of the one-frame interface of the third process and part or all of the content of the one-frame interface of the third process.
在上述实施例中,目标渲染中包括不同应用程序的渲染节点,进而可以一次选取多个应用程序界面中的部分或全部内容进行动画渲染,进而得到目标界面。In the above-mentioned embodiments, the target rendering includes rendering nodes of different application programs, and then part or all of the contents of multiple application program interfaces can be selected at one time for animation rendering, and then the target interface can be obtained.
结合第一方面的一些实施例,在一些实施例中,该第二渲染树中的第一渲染节点被该第二进程配置有该第一动画参数;该第三渲染树中的第二渲染节点被该第三进程配置有该第一动画参数;该至少一个渲染节点包括该第一渲染节点和该第二渲染节点。With reference to some embodiments of the first aspect, in some embodiments, the first rendering node in the second rendering tree is configured with the first animation parameter by the second process; the second rendering node in the third rendering tree The first animation parameter is configured by the third process; the at least one rendering node includes the first rendering node and the second rendering node.
在上述实施例中,应用程序可以自己决定哪些控件需要动画效果,则为这些控件对应的渲染节点配置动画参数,第一进程会在基于目标渲染树生成界面的过程中,识别到这些动画参数,确定被动画渲染的内容,完成动画渲染,进而生成界面。In the above embodiment, the application can decide which controls need animation effects, and then configure animation parameters for the rendering nodes corresponding to these controls. The first process will recognize these animation parameters during the process of generating the interface based on the target rendering tree. Determine the content rendered by the animation, complete the animation rendering, and then generate the interface.
结合第一方面的一些实施例,在一些实施例中,在该动画参数指示背景模糊或前景模糊的情况下,该动画参数还包括模糊程度、模糊精度、模糊半径中的至少一个。With reference to some embodiments of the first aspect, in some embodiments, when the animation parameter indicates background blur or foreground blur, the animation parameter further includes at least one of blur degree, blur precision, and blur radius.
在上述实施例中,在动画参数指示背景模糊或前景模糊的情况下,还可以进一步的配置模糊程度、模糊精度、模糊半径,这些参数可以被应用程序配置,也可以被第一进程配置,能实现不同种类、不同效果的模糊,进而提升用户的体验。In the above-mentioned embodiment, in the case that the animation parameter indicates that the background is blurred or the foreground is blurred, the blur degree, blur precision, and blur radius can be further configured. These parameters can be configured by the application program or by the first process. Realize different types of blur with different effects, thereby improving the user experience.
第二方面,本申请实施例提供了一种电子设备,该电子设备包括:一个或多个处理器和存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该电子设备执行:第一进程确定目标渲染树,该目标渲染树用于绘制目标界面;在该第一进程基于该目标渲染树生成该目标界面的过程中,该第一进程基于该目标渲染树中的至少一个渲染节点确定第一内容,并对该第一内容执行基于第一动画参数的动画渲染以得到该第二内容,该至少一个渲染节点的动画参数为该第一动画参数;或者,在该第一进程基于该目标渲染树生成该目标界面的过程中,该第一进程基于第一表面上的第一区域确定第一内容,并对该第一内容执行基于第一动画参数的动画渲染以得到该第二内容,该第一进程基于该目标渲染树在该第一表面上生成该目标界面,该第一动画参数为该第一进程确定的;该第一进程生成该目标界面,该目标界面包括该第二内容,该动画渲染为在离屏缓冲中进行的渲染。In a second aspect, an embodiment of the present application provides an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program codes, The computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the electronic device to execute: the first process determines the target rendering tree, and the target rendering tree is used to draw the target interface; in the first process based on When the target rendering tree generates the target interface, the first process determines first content based on at least one rendering node in the target rendering tree, and performs animation rendering based on first animation parameters on the first content to obtain the The second content is that the animation parameter of the at least one rendering node is the first animation parameter; or, when the first process generates the target interface based on the target rendering tree, the first process based on the first surface on the first surface An area determines first content, and performs animation rendering on the first content based on first animation parameters to obtain the second content, the first process generates the target interface on the first surface based on the target rendering tree, the The first animation parameter is determined by the first process; the first process generates the target interface, the target interface includes the second content, and the animation rendering is performed in an off-screen buffer.
在上述实施例中,电子设备在基于渲染树生成界面的过程中,可以绘制出需要动画渲染的内容,对该内容进行动画渲染得到渲染后的内容,进而得到目标界面。首先,可以不需要进程在渲染阶段前就准备好渲染后的内容,减少了多次渲染的开销,进而降低电子设备的开销。In the above embodiment, in the process of generating the interface based on the rendering tree, the electronic device may draw the content that requires animation rendering, perform animation rendering on the content to obtain the rendered content, and then obtain the target interface. First of all, it does not require the process to prepare the rendered content before the rendering stage, reducing the overhead of multiple renderings, thereby reducing the overhead of electronic equipment.
结合第二方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该电子设备执行:该第一进程在该目标渲染树中增加该至少一个渲染节点,该至少一个渲染节点被配置有该第一动画参数;或者,该第一进程为该至少一个渲染节点配置该第一动画参数。With reference to some embodiments of the second aspect, in some embodiments, the one or more processors are further configured to call the computer instruction to make the electronic device execute: the first process adds the at least A rendering node, the at least one rendering node is configured with the first animation parameter; or, the first process configures the at least one rendering node with the first animation parameter.
在上述实施例中,第一进程可以修改目标渲染树中的参数,例如,可以将需要动画渲染的控件对应的渲染节点配置动画参数,以使得在基于渲染树生成界面的过程中,第一进程可以将需要动画渲染的控件进行动画渲染;或者,又例如,进程可以在渲染树中插入一个或多个配置有动画参数的渲染节点,该一个或多个渲染节点的自己以及自己的子节点为动画渲染的内容,进而进行动画渲染。In the above embodiment, the first process can modify the parameters in the target rendering tree. For example, the rendering node corresponding to the control that needs animation rendering can be configured with animation parameters, so that in the process of generating the interface based on the rendering tree, the first process Animation rendering can be performed on controls that require animation rendering; or, for another example, the process can insert one or more rendering nodes configured with animation parameters in the rendering tree, and the one or more rendering nodes themselves and their own child nodes are The content of the animation rendering, and then the animation rendering.
结合第二方面的一些实施例,在一些实施例中,在该至少一个渲染节点的动画参数指示前景模糊的情况下,该第一内容包括该至少一个渲染节点对应的视图;在该至少一个渲染节点的动画参数指示背景模糊的情况下,该第一内容包括该至少一个渲染节点在该第一表面上对应的区域的内容。With reference to some embodiments of the second aspect, in some embodiments, when the animation parameter of the at least one rendering node indicates that the foreground is blurred, the first content includes the view corresponding to the at least one rendering node; When the animation parameter of the node indicates that the background is blurred, the first content includes the content of the region corresponding to the at least one rendering node on the first surface.
在上述实施例中,在动画参数指示前景模糊的情况下,被动画渲染的内容为被配置动画参数的渲染节点对应的视图;在动画参数指示背景模糊的情况下,被动画渲染的内容为被配置动画参数的渲染节点在第一表面对应的区域的内容,只有在本申请提供的界面生成方法,才能实现基于动画参数的值任意选择被动画的内容,进而实现各种不同的动画效果。In the above embodiment, when the animation parameter indicates that the foreground is blurred, the content rendered by animation is the view corresponding to the rendering node configured with animation parameters; when the animation parameter indicates that the background is blurred, the content rendered by animation is For the content of the area corresponding to the first surface of the rendering node configured with animation parameters, only the interface generation method provided by this application can arbitrarily select the content to be animated based on the value of the animation parameters, and then realize various animation effects.
结合第二方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该电子设备执行:该第一进程基于第二渲染树和第三渲染树生成该目标渲染树,其中,该第二渲染树为由第二进程生成的用于绘制该第二进程的一帧界面的渲染树;该第三渲染树为由第三进程生成的用于绘制该第三进程的一帧界面的渲染树。With reference to some embodiments of the second aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the electronic device to execute: the first process is based on the second rendering tree and the third rendering tree to generate the target rendering tree, wherein the second rendering tree is a rendering tree generated by the second process for drawing a frame interface of the second process; the third rendering tree is a rendering tree generated by the third process for Draw a rendering tree of a frame interface of the third process.
在上述实施例中,目标渲染树可以由多个应用程序的渲染树合成,进而通过一次GPU调用即一次渲染生成包含多个应用程序界面的目标界面。In the foregoing embodiments, the target rendering tree may be synthesized by rendering trees of multiple application programs, and then a target interface including multiple application program interfaces is generated through one GPU call, that is, one rendering.
结合第二方面的一些实施例,在一些实施例中,该至少一个渲染节点包括该第二渲染树中的渲染节点和该第三渲染树中的渲染节点,该第一内容包括该第二进程的一帧界面的部分或全部内容和该第三进程的一帧界面的部分或全部内容。With reference to some embodiments of the second aspect, in some embodiments, the at least one rendering node includes rendering nodes in the second rendering tree and rendering nodes in the third rendering tree, and the first content includes the second process part or all of the content of the one-frame interface of the third process and part or all of the content of the one-frame interface of the third process.
在上述实施例中,目标渲染中包括不同应用程序的渲染节点,进而可以一次选取多个应用程序界面中的部分或全部内容进行动画渲染,进而得到目标界面。In the above-mentioned embodiments, the target rendering includes rendering nodes of different application programs, and then part or all of the contents of multiple application program interfaces can be selected at one time for animation rendering, and then the target interface can be obtained.
结合第二方面的一些实施例,在一些实施例中,该第二渲染树中的第一渲染节点被该第二进程配置有该第一动画参数;该第三渲染树中的第二渲染节点被该第三进程配置有该第一动画参数;该至少一个渲染节点包括该第一渲染节点和该第二渲染节点。With reference to some embodiments of the second aspect, in some embodiments, the first rendering node in the second rendering tree is configured with the first animation parameter by the second process; the second rendering node in the third rendering tree The first animation parameter is configured by the third process; the at least one rendering node includes the first rendering node and the second rendering node.
在上述实施例中,应用程序可以自己决定哪些控件需要动画效果,则为这些控件对应的渲染节点配置动画参数,第一进程会在基于目标渲染树生成界面的过程中,识别到这些动画参数,确定被动画渲染的内容,完成动画渲染,进而生成界面。In the above embodiment, the application can decide which controls need animation effects, and then configure animation parameters for the rendering nodes corresponding to these controls. The first process will recognize these animation parameters during the process of generating the interface based on the target rendering tree. Determine the content rendered by the animation, complete the animation rendering, and then generate the interface.
结合第二方面的一些实施例,在一些实施例中,在该动画参数指示背景模糊或前景模糊的情况下,该动画参数还包括模糊程度、模糊精度、模糊半径中的至少一个。With reference to some embodiments of the second aspect, in some embodiments, when the animation parameter indicates background blur or foreground blur, the animation parameter further includes at least one of blur degree, blur precision, and blur radius.
在上述实施例中,在动画参数指示背景模糊或前景模糊的情况下,还可以进一步的配置模糊程度、模糊精度、模糊半径,这些参数可以被应用程序配置,也可以被第一进程配置,能实现不同种类、不同效果的模糊,进而提升用户的体验。In the above-mentioned embodiment, in the case that the animation parameter indicates that the background is blurred or the foreground is blurred, the blur degree, blur precision, and blur radius can be further configured. These parameters can be configured by the application program or by the first process. Realize different types of blur with different effects, thereby improving the user experience.
第三方面,本申请实施例提供了一种芯片系统,该芯片系统应用于电子设备,该芯片系统包括一个或多个处理器,该处理器用于调用计算机指令以使得该电子设备执行如第一方面以及第一方面中任一可能的实现方式描述的方法。In the third aspect, the embodiment of the present application provides a chip system, the chip system is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to invoke computer instructions so that the electronic device executes the first Aspect and the method described in any possible implementation manner of the first aspect.
第四方面,本申请实施例提供一种包含指令的计算机程序产品,当上述计算机程序产品在电子设备上运行时,使得上述电子设备执行如第一方面以及第一方面中任一可能的实现方式描述的方法。In the fourth aspect, the embodiment of the present application provides a computer program product containing instructions, when the above computer program product is run on the electronic device, the above electronic device is made to execute any possible implementation of the first aspect and the first aspect described method.
第五方面,本申请实施例提供一种计算机可读存储介质,包括指令,当上述指令在电子设备上运行时,使得上述电子设备执行如第一方面以及第一方面中任一可能的实现方式描述的方法。In the fifth aspect, the embodiment of the present application provides a computer-readable storage medium, including instructions, which, when the above-mentioned instructions are run on the electronic device, cause the above-mentioned electronic device to execute any possible implementation of the first aspect and the first aspect. described method.
可以理解地,上述第二方面提供的电子设备、第三方面提供的芯片系统、第四方面提供的计算机程序产品和第五方面提供的计算机存储介质均用于执行本申请实施例所提供的方法。因此,其所能达到的有益效果可参考对应方法中的有益效果,此处不再赘述。It can be understood that the above-mentioned electronic device provided in the second aspect, the chip system provided in the third aspect, the computer program product provided in the fourth aspect, and the computer storage medium provided in the fifth aspect are all used to execute the method provided in the embodiment of the present application . Therefore, the beneficial effects that it can achieve can refer to the beneficial effects in the corresponding method, and will not be repeated here.
附图说明Description of drawings
图1A-图1D为本申请涉及的单个应用程序的动画效果的一个示例性示意图。1A-1D are exemplary diagrams of animation effects of a single application involved in the present application.
图2为本申请实施例提供的单个应用程序的界面生成的一个示例性示意图。FIG. 2 is an exemplary schematic diagram of interface generation of a single application program provided by the embodiment of the present application.
图3为本申请实施例提供的动画渲染实现过渡界面的一个示例性示意图。FIG. 3 is an exemplary schematic diagram of an animation rendering implementation transition interface provided by an embodiment of the present application.
图4A、图4B为本申请实施例提供的跨窗口/跨应用的动画效果的界面的一个示例性示意图。FIG. 4A and FIG. 4B are exemplary schematic diagrams of interfaces for cross-window/cross-application animation effects provided by the embodiment of the present application.
图5A、图5B为本申请实施例提供的跨窗口/跨应用的动画效果的界面的另一个示例性示意图。FIG. 5A and FIG. 5B are another exemplary schematic diagrams of an interface for cross-window/cross-application animation effects provided by the embodiment of the present application.
图6A、图6B为本申请实施例提供的跨窗口/跨应用的动画效果的界面的另一个示例性示意图。FIG. 6A and FIG. 6B are another exemplary schematic diagrams of an interface for cross-window/cross-application animation effects provided by the embodiment of the present application.
图7A为本申请实施例提供的跨窗口/跨应用的动画效果的实现的一个示例性示意图。FIG. 7A is an exemplary schematic diagram of the implementation of the cross-window/cross-application animation effect provided by the embodiment of the present application.
图7B为图7A所示方法过程中位图变化的一个示例性示意图。FIG. 7B is an exemplary schematic diagram of bitmap changes during the method shown in FIG. 7A .
图7C为本申请实施例提供的跨窗口/跨应用的动画效果的实现的另一个示例性示意图。FIG. 7C is another exemplary schematic diagram of realizing the cross-window/cross-application animation effect provided by the embodiment of the present application.
图7D为图7C所示方法过程中位图变化的一个示例性示意图。FIG. 7D is an exemplary schematic diagram of bitmap changes during the method shown in FIG. 7C .
图8为本申请实施例提供的界面生成方法的一个示例性示意图。FIG. 8 is an exemplary schematic diagram of an interface generation method provided by an embodiment of the present application.
图9为本申请实施例提供的渲染树生成的一个示例性示意图。FIG. 9 is an exemplary schematic diagram of rendering tree generation provided by the embodiment of the present application.
图10为本申请实施例提供的共享内存传递渲染树的一个示例性示意图。FIG. 10 is an exemplary schematic diagram of a shared memory transfer rendering tree provided by an embodiment of the present application.
图11A、图11B为本申请实施例提供的共享内存中渲染树的存储结构的一个示例性示意图。FIG. 11A and FIG. 11B are exemplary schematic diagrams of a storage structure of a rendering tree in a shared memory provided by an embodiment of the present application.
图12为本申请实施例提供的UniRender的架构的一个示例性示意图。FIG. 12 is an exemplary schematic diagram of the architecture of UniRender provided by the embodiment of the present application.
图13为本申请实施例提供的应用程序往共享内存中写入渲染树的一个示例性示意图。FIG. 13 is an exemplary schematic diagram of an application program writing a rendering tree into a shared memory provided by an embodiment of the present application.
图14为本申请实施例提供的应用程序往共享内存中写入渲染树的另一个示例性示意图。FIG. 14 is another exemplary schematic diagram of the application program writing the rendering tree into the shared memory provided by the embodiment of the present application.
图15为本申请实施例提供的渲染树合成为目标渲染树的一个示例性示意图。FIG. 15 is an exemplary schematic diagram of synthesizing a rendering tree into a target rendering tree according to an embodiment of the present application.
图16为本申请实施例提供的渲染树合成为目标渲染树的另一个示例性示意图。FIG. 16 is another exemplary schematic diagram of synthesizing a rendering tree into a target rendering tree according to an embodiment of the present application.
图17本申请实施例提供的电子设备构建、渲染生成界面过程的另一个示例性示意图。Fig. 17 is another exemplary schematic diagram of the process of constructing, rendering and generating an interface of an electronic device provided by the embodiment of the present application.
图18A为本申请实施例提供的前景模糊实现的一个示例性示意图。FIG. 18A is an exemplary schematic diagram of the implementation of foreground blur provided by the embodiment of the present application.
图18B为本申请实施例提供的背景模糊实现的一个示例性示意图。FIG. 18B is an exemplary schematic diagram of the implementation of background blur provided by the embodiment of the present application.
图19为本申请实施例提供的跨应用/跨窗口动画渲染的一个示例性示意图。FIG. 19 is an exemplary schematic diagram of cross-application/cross-window animation rendering provided by the embodiment of the present application.
图20为本申请实施例提供的跨应用/跨窗口动画渲染的另一个示例性示意图。FIG. 20 is another exemplary schematic diagram of cross-application/cross-window animation rendering provided by the embodiment of the present application.
图21为本申请实施例提供的模糊渲染对像素处理的一个示例性示意图。FIG. 21 is an exemplary schematic diagram of pixel processing by blur rendering provided by the embodiment of the present application.
图22A、图22B为本申请实施例提供的模糊动画的一个示例性示意图。FIG. 22A and FIG. 22B are exemplary schematic diagrams of the blur animation provided by the embodiment of the present application.
图23A、图23B为本申请实施例提供的跨应用/跨窗口界面动画效果实现的一个实例示意图。FIG. 23A and FIG. 23B are schematic diagrams of an example of the implementation of cross-application/cross-window interface animation effects provided by the embodiment of the present application.
图24为本申请实施例提供的电子设备的硬件结构的一个示例性示意图。FIG. 24 is an exemplary schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application.
图25为本申请实施例提供的电子设备的软件结构的一个示例性示意图。FIG. 25 is an exemplary schematic diagram of a software structure of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
本申请以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“该”、“上述”、“该”和“这一”旨在也包括复数表达形式,除非其上下文中明确地有相反指示。还应当理解,本申请中使用的术语“和/或”是指并包含一个或多个所列出项目的任何或所有可能组合。The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. As used in the specification and appended claims of this application, the singular expressions "a", "an", "the", "above", "the" and "this" are intended to also include Plural expressions, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in this application refers to and includes any and all possible combinations of one or more of the listed items.
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。Hereinafter, the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as implying or implying relative importance or implicitly specifying the quantity of indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of these features. In the description of the embodiments of the present application, unless otherwise specified, the "multiple" The meaning is two or more.
本申请以下实施例中的术语“用户界面(userinterface,UI)”,是应用程序或操作系统与用户之间进行交互和信息交换的介质接口,它实现信息的内部形式与用户可以接受形式之间的转换。用户界面是通过java、可扩展标记语言(extensible markup language,XML)等特定计算机语言编写的源代码,界面源代码在电子设备上经过解析,渲染,最终呈现为用户可以识别的内容。用户界面常用的表现形式是图形用户界面(graphic userinterface,GUI),是指采用图形方式显示的与计算机操作相关的用户界面。它可以是在电子设备的显示屏中显示的文本、图标、按钮、菜单、选项卡、文本框、对话框、状态栏、导航栏、Widget等可视的界面元素。The term "user interface (UI)" in the following embodiments of this application is a medium interface for interaction and information exchange between an application program or an operating system and a user, and it realizes the communication between the internal form of information and the form acceptable to the user. conversion. The user interface is the source code written in specific computer languages such as java and extensible markup language (XML). The source code of the interface is parsed and rendered on the electronic device, and finally presented as content that can be recognized by the user. A commonly used representation form of a user interface is a graphical user interface (graphic user interface, GUI), which refers to a user interface related to computer operations displayed in a graphical manner. It may be text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, Widgets, and other visible interface elements displayed on the display screen of the electronic device.
为了便于理解,下面先对本申请实施例涉及的相关术语及相关概念进行介绍。本发明的实施方式部分使用的术语仅用于对本发明的具体实施例进行解释,而非旨在限定本发明。For ease of understanding, the following first introduces related terms and concepts involved in the embodiments of the present application. The terms used in the embodiments of the present invention are only used to explain specific examples of the present invention, and are not intended to limit the present invention.
为了提高用户的体验,用户在使用电子设备的过程中,响应于用户的交互操作,电子设备在切换页面、应用程序时,可以显示过渡界面以提高UI的流畅性,进而提高用户的体验。其中,过渡界面需要通过如模糊(高斯模糊、径向模糊、镜头模糊等)、锐化、扭曲、风格化(如浮雕效果、油画效果、3D效果等)、镜头光晕、添加杂色等动画效果组合实现,其中动画效果需要电子设备进行动画渲染。In order to improve the user's experience, when the user is using the electronic device, in response to the user's interactive operation, the electronic device may display a transition interface when switching pages and applications to improve the fluency of the UI, thereby improving the user's experience. Among them, the transition interface needs to go through animations such as blurring (Gaussian blur, radial blur, lens blur, etc.), sharpening, distortion, stylization (such as relief effect, oil painting effect, 3D effect, etc.), lens flare, and noise addition. Combination of effects is realized, wherein animation effects require electronic equipment for animation rendering.
(1)首先,下面示例性的介绍不同情况下,本申请实施例涉及的几种情况下动画效果的界面和实现。(1) First, the interface and implementation of animation effects in several situations involved in the embodiments of the present application will be exemplarily introduced below.
(1.1)单个应用程序的动画效果的界面(1.1) Animated interface for a single application
图1A-图1D为本申请涉及的单个应用程序的动画效果的一个示例性示意图。1A-1D are exemplary diagrams of animation effects of a single application involved in the present application.
用户在使用应用程序的过程中,可以通过点击、长按等方式与电子设备交互,进而使得应用程序改变显示的内容或切换页面等。During the process of using the application program, the user can interact with the electronic device by clicking, long pressing, etc., so that the application program changes the displayed content or switches pages.
例如,用户在使用音乐应用的过程中,可以通过点击控件1A01切换播放的歌曲,如从歌曲1切换到歌曲2。如图1A所示,在用户点击控件1A01前,电子设备显示的音乐应用的界面包括多个控件、歌曲名称“歌曲1”和歌手的照片等。如图1D所示,在用户点击控件1A01后,电子设备播放下一首歌曲,并且电子设备显示的音乐应用的界面包括多个控件、歌曲名称“歌曲2”和歌手的照片等。For example, the user can click the control 1A01 to switch the played song, such as switching from
电子设备显示的应用程序的界面直接从图1A所示的内容变化为图1D所示的内容,但是,这种直接切换界面的方式非常生硬,用户的体验较差。The interface of the application program displayed on the electronic device directly changes from the content shown in FIG. 1A to the content shown in FIG. 1D . However, this way of directly switching the interface is very blunt, and the user experience is poor.
为了提高用户的体验,在应用程序的界面发生改变的时候,通过过渡界面实现界面切换能够更符合人的视觉特征。例如,过渡界面可以如图1B和图1C所示的内容。其中,过渡界面为动画渲染后的界面。In order to improve the user's experience, when the interface of the application program changes, the transition interface can be used to achieve interface switching, which can be more in line with human visual characteristics. For example, the transition interface may be as shown in FIG. 1B and FIG. 1C. Wherein, the transition interface is an interface after animation rendering.
对于第一种动画切换方式,即如图1A、图1B、图1D所示,响应于用户点击控件1A01,电子设备模糊除控件1A01外的画面,如图1B所示;然后,如图1D所示,电子设备显示的音乐应用的界面包括多个控件、歌曲名称“歌曲2”和歌手的照片等。For the first animation switching method, as shown in Figure 1A, Figure 1B, and Figure 1D, in response to the user clicking on the control 1A01, the electronic device blurs the screen except for the control 1A01, as shown in Figure 1B; then, as shown in Figure 1D As shown, the interface of the music application displayed by the electronic device includes a plurality of controls, the name of the song "
或者,对于第二种动画切换方式,如图1A、图1B、图1C所示,响应于用户点击控件1A01,电子设备放大控件1A01,并更改控件1A01的颜色,如图1C所示;然后,如图1D所示,电子设备显示的音乐应用的界面包括多个控件、歌曲名称“歌曲2”和歌手的照片等。Or, for the second animation switching mode, as shown in FIGS. 1A, 1B, and 1C, in response to the user clicking on the control 1A01, the electronic device enlarges the control 1A01 and changes the color of the control 1A01, as shown in FIG. 1C; then, As shown in FIG. 1D , the interface of the music application displayed by the electronic device includes a plurality of controls, a song name "
很显然的,对于第一种动画切换方式,由于需要被改变的界面上的内容是通过模糊这种动画效果切换的,用户不会感觉到界面切换的撕裂感,提升了界面切换的连续性,进而提升了用户的体验。类似的,对于第二种动画切换方式,响应于用户点击控件1A01,电子设备对控件1A01进行大小、颜色、形状等属性的变换,以提示用户电子设备已经接收到用户的点击操作,进而提升了用户的体验。Obviously, for the first animation switching method, since the content on the interface that needs to be changed is switched by blurring the animation effect, the user will not feel the tearing of the interface switching, which improves the continuity of the interface switching , thereby improving the user experience. Similarly, for the second animation switching method, in response to the user clicking on the control 1A01, the electronic device transforms the size, color, shape and other attributes of the control 1A01 to remind the user that the electronic device has received the user's click operation, thereby improving the user experience. user experience.
(1.2)单个应用程序的动画效果的实现(1.2) Realization of the animation effect of a single application
在开启硬件加速的情况下,单个应用程序的动画效果的实现如图2和图3所示。When hardware acceleration is turned on, the realization of the animation effect of a single application is shown in Figure 2 and Figure 3 .
图2为本申请实施例提供的单个应用程序的界面生成的一个示例性示意图。FIG. 2 is an exemplary schematic diagram of interface generation of a single application program provided by the embodiment of the present application.
如图2所示,单个应用程序的界面生成可以包括三个步骤:As shown in Figure 2, the interface generation of a single application can include three steps:
①让视图结构(view hierarchy)失效,主线程(UI线程,UI Thread)遍历该应用程序的视图(view),确定并保存每个视图的绘制操作,并将视图和该视图涉及的绘制操作涉及的绘制操作(drawoperationstruct,DrawOP)录制到渲染树的渲染节点(RenderNode)的绘制指令列表(displaylist)中。① Invalidate the view hierarchy, and the main thread (UI thread, UI Thread) traverses the views of the application, determines and saves the drawing operation of each view, and relates the view and the drawing operation involved in the view The drawing operation (drawoperationstruct, DrawOP) recorded in the rendering instruction list (displaylist) of the rendering node (RenderNode) of the rendering tree.
其中,渲染节点还包括有渲染属性,渲染节点的绘制指令列表中还包括有子渲染节点绘制指令列表的入口。渲染属性用于确定绘制内容在surface上的位置、透明度等属性,绘制指令列表用于确定绘制内容,例如矩形、线条、圆形等。Wherein, the rendering node also includes rendering attributes, and the rendering instruction list of the rendering node also includes the entry of the sub-rendering node drawing instruction list. The rendering attribute is used to determine the position and transparency of the drawing content on the surface, and the drawing instruction list is used to determine the drawing content, such as rectangles, lines, circles, etc.
其中,视图是构成应用程序界面的基本元素,界面上的一个控件可以对应于一个或多个视图。Wherein, a view is a basic element constituting an application program interface, and a control on the interface may correspond to one or more views.
其中,绘制操作为一个数据结构体,用于绘制图形,例如绘制线条、绘制变宽、绘制矩形、绘制文本等。绘制操作在渲染节点会被转换为图像处理库的API调用,如OpenGL的接口调用。例如DrawLineOp是一个数据结构体,数据结构体里面包含有绘制的数据如线的长度、宽度等信息。Among them, the drawing operation is a data structure, which is used to draw graphics, such as drawing lines, drawing widening, drawing rectangles, and drawing text. The drawing operation will be converted to the API call of the image processing library in the rendering node, such as the interface call of OpenGL. For example, DrawLineOp is a data structure, which contains the drawn data such as the length and width of the line.
其中,绘制指令列表可以是一个缓冲区,该缓冲区中记录有应用程序一帧界面所包括的所有绘制操作或是所有绘制操作的标识。当应用程序有多个窗口、或者在不同的显示区域(display)上显示时,需要独立的生成多个渲染树,其中,会独立的生成多个对应不同窗口、显示区域的绘制指令列表。Wherein, the drawing instruction list may be a buffer, which records all drawing operations included in one frame interface of the application program or identifiers of all drawing operations. When an application has multiple windows or is displayed on different display areas (displays), multiple rendering trees need to be independently generated, wherein multiple drawing command lists corresponding to different windows and display areas will be independently generated.
在本申请实施例中,显示区域可以是一块屏幕、或者可以是虚拟屏幕(VirtualDisplay)等。虚拟屏幕可以是录屏时,电子设备用于承载屏幕上显示的内容的区域。In this embodiment of the present application, the display area may be a screen, or may be a virtual screen (Virtual Display) or the like. The virtual screen may be an area used by the electronic device to carry content displayed on the screen when recording the screen.
其中,渲染树是UI线程生成的,用于生成应用程序界面的一个数据结构体,渲染树可以包括多个渲染节点,每个渲染节点包括渲染属性和绘制指令列表。渲染树记录有生成应用程序一帧界面的所有信息。Wherein, the rendering tree is generated by the UI thread, and is used to generate a data structure of the application program interface. The rendering tree may include multiple rendering nodes, and each rendering node includes a rendering attribute and a drawing instruction list. The rendering tree records all the information for generating a frame of the application interface.
②UI线程将渲染树传递/同步给渲染线程(Render Thread)。其中,渲染树位于应用程序对应的进程的栈(stack)中,并且在物理地址上可以不是连续分布的。② The UI thread passes/synchronizes the rendering tree to the rendering thread (Render Thread). Wherein, the rendering tree is located in the stack (stack) of the process corresponding to the application program, and the physical addresses may not be continuously distributed.
③Render线程首先获取一个硬件画布(HardwareCanvas),并在该硬件画布上执行渲染树中的绘制操作。其中,该硬件画布位于该应用程序持有的表面(surface)中,该surface中承载有位图(bitmap)或者其他格式的用于保存图像信息的数据。其中,该surface是由表面合成器(SurfaceFlinger)向应用程序提供的。③ The Render thread first obtains a hardware canvas (HardwareCanvas), and performs the drawing operation in the rendering tree on the hardware canvas. Wherein, the hardware canvas is located in a surface (surface) held by the application program, and the surface carries bitmap (bitmap) or data for storing image information in other formats. Among them, the surface is provided to the application by the Surface Composer (SurfaceFlinger).
可以认为①为构建阶段,主要负责确定该应用程序中每个view的大小、位置、透明度等属性,并对绘制操作进行录制并且封装到绘制指令列表。It can be considered that ① is the construction phase, which is mainly responsible for determining the size, position, transparency and other attributes of each view in the application, recording the drawing operation and encapsulating it into the drawing instruction list.
例如,视图中的view中drawLine,构建中可以被封装成一个DrawLineOp,里面包含有绘制的数据如线的长度、宽度等,还可以包含有底层图形处理库的drawLine对应的接口调用。For example, the drawLine in the view in the view can be encapsulated into a DrawLineOp in the construction, which contains the drawn data such as the length and width of the line, and can also contain the interface call corresponding to the drawLine of the underlying graphics processing library.
类似的,可以认为③为渲染阶段,主要负责在surface上执行渲染树中的绘制操作进而生成位图,在该过程中,Render线程通过调用底层图形处理库,如OpenGL,进而调用GPU完成渲染以生成位图。Similarly, it can be considered that ③ is the rendering stage, which is mainly responsible for performing the drawing operation in the rendering tree on the surface to generate a bitmap. In this process, the Render thread calls the underlying graphics processing library, such as OpenGL, and then calls the GPU to complete the rendering. Generate a bitmap.
其中,UI线程为应用程序的主线程,Render线程为负责渲染的线程。其中,位图作为一个类,可以承载图像信息,例如可以包含有像素的位置和像素的值等信息。Among them, the UI thread is the main thread of the application program, and the Render thread is the thread responsible for rendering. Among them, a bitmap, as a class, can carry image information, for example, it can contain information such as the position of a pixel and the value of a pixel.
其中,渲染阶段生成的位图即为用于呈现过渡界面的位图,如图1B所示。Wherein, the bitmap generated in the rendering stage is the bitmap used to present the transition interface, as shown in FIG. 1B .
其中,SurfaceFlinger是系统级别的服务,用于管理和消费当前可用的surface,该surface上承载有应用程序Render线程生成的位图。SurfaceFlinger还可以用于将多个surface作为图层(layer)进行图层合成。Among them, SurfaceFlinger is a system-level service for managing and consuming the currently available surface, which carries the bitmap generated by the application Render thread. SurfaceFlinger can also be used to combine multiple surfaces as layers.
其中,构建阶段需要占用CPU的计算资源,渲染阶段需要占用GPU的资源。Among them, the construction phase needs to occupy the computing resources of the CPU, and the rendering phase needs to occupy the resources of the GPU.
值得说明的是,若不开启硬件加速,即软件绘制的情况下,则通过UI线程完成构建阶段、渲染阶段的所有操作,并且不需要生成渲染树,在遍历应用程序的视图后以及视图的绘制操作后,向SurfaceFlinger申请一块匿名共享内存,在该内存上通过调用底层图形库,如skia库,提供的接口直接进行渲染,生成一个位图或者其他格式的用于保存图像信息的数据。It is worth noting that if hardware acceleration is not enabled, that is, in the case of software drawing, all operations in the construction phase and rendering phase are completed through the UI thread, and there is no need to generate a rendering tree. After traversing the views of the application and drawing the views After the operation, apply for an anonymous shared memory from SurfaceFlinger, and directly render on the memory by calling the interface provided by the underlying graphics library, such as the skia library, to generate a bitmap or other format data for storing image information.
对于图1C所示的过渡界面,响应于用户对控件1A01点击,应用程序可以通过修改渲染树中与控件1A01对应的渲染节点的渲染属性和绘制操作,进而使得Render线程在执行绘制指令列表中的绘制操作时,可以在surface上绘制出放大且颜色改变的控件1A01。For the transition interface shown in Figure 1C, in response to the user clicking on control 1A01, the application program can modify the rendering properties and drawing operations of the rendering node corresponding to control 1A01 in the rendering tree, and then make the Render thread execute the drawing command list. During the drawing operation, the control 1A01 which is enlarged and whose color changes can be drawn on the surface.
值得说明的,在只改变应用程序的界面中控件的颜色、大小、透明度,可以通过修改该控件对应的渲染节点的渲染属性,生成过渡界面。但是,很显然的,应用程序无法实现任意划定区域的颜色、大小、透明度的改变。It is worth noting that if you only change the color, size, and transparency of a control in the interface of the application, you can generate a transitional interface by modifying the rendering properties of the rendering node corresponding to the control. However, obviously, the application program cannot change the color, size, and transparency of any delimited area.
对于图1B所示的过渡界面,过渡界面需要通过动画渲染来实现,具体的过程如图3所示。For the transition interface shown in FIG. 1B , the transition interface needs to be realized through animation rendering, and the specific process is shown in FIG. 3 .
图3为本申请实施例提供的动画渲染实现过渡界面的一个示例性示意图。FIG. 3 is an exemplary schematic diagram of an animation rendering implementation transition interface provided by an embodiment of the present application.
如图3所示:As shown in Figure 3:
①首先,应用程序的UI线程绘制背景位图。其中,背景位图不包括控件1A01。① First, the UI thread of the application draws the background bitmap. Wherein, the background bitmap does not include the control 1A01.
②其次,应用程序的UI线程对背景位图进行动画渲染,对背景位图进行逐像素处理,实现如模糊在内的动画效果。其中UI线程可以调用CPU进行动画渲染。②Secondly, the UI thread of the application performs animation rendering on the background bitmap, and performs pixel-by-pixel processing on the background bitmap to achieve animation effects such as blurring. Among them, the UI thread can call the CPU for animation rendering.
③再次,应用程序的UI线程在生成渲染树时,增加绘制操作或渲染节点。该绘制操作,如drawBitmap,可以将动画渲染后的背景位图作为背景导入到渲染阶段生成的位图中;或者,该渲染节点对应动画渲染后的背景位图,在渲染阶段该渲染节点会使得Render线程将动画渲染后的背景位图作为背景导入到surface上。③ Again, when the UI thread of the application generates the rendering tree, it adds drawing operations or rendering nodes. The drawing operation, such as drawBitmap, can import the background bitmap after animation rendering as the background into the bitmap generated in the rendering stage; or, the rendering node corresponds to the background bitmap after animation rendering, and in the rendering stage, this rendering node will make The Render thread imports the animated background bitmap as the background to the surface.
④最后,应用程序的Render线程在基于渲染树生成位图时,生成如图1B所示的过渡界面。④ Finally, when the Render thread of the application generates a bitmap based on the rendering tree, it generates a transition interface as shown in Figure 1B.
很显然的,实现应用程序内的动画渲染需要由UI线程在渲染阶段开始前准备好动画渲染后的位图,使得UI线程被动画渲染这种耗时操作占用,容易造成应用程序卡顿。除此之外,UI线程调用CPU进行动画渲染,但是CPU执行图像处理类操作的效率较低,进一步加剧应用程序的卡顿。Obviously, to realize the animation rendering in the application, the UI thread needs to prepare the bitmap after the animation rendering before the rendering phase starts, so that the UI thread is occupied by the time-consuming operation of animation rendering, which may easily cause the application to freeze. In addition, the UI thread calls the CPU to perform animation rendering, but the efficiency of the CPU to perform image processing operations is low, which further aggravates the freeze of the application.
(1.3)跨窗口/跨应用的动画效果的界面(1.3) Cross-window/cross-application animation interface
图4A、图4B为本申请实施例提供的跨窗口/跨应用的动画效果的界面的一个示例性示意图。FIG. 4A and FIG. 4B are exemplary schematic diagrams of interfaces for cross-window/cross-application animation effects provided by the embodiment of the present application.
如图4A所示,电子设备显示的界面包括桌面(launcher)应用的界面和壁纸应用的界面。桌面应用的界面包括若干个应用的图标控件,如阅读应用的图标控件4A01。As shown in FIG. 4A , the interface displayed by the electronic device includes an interface of a desktop (launcher) application and an interface of a wallpaper application. The interface of the desktop application includes several application icon controls, such as the icon control 4A01 of the reading application.
响应于用户对图标控件4A01的交互如长按等,电子设备显示的界面为:模糊的壁纸应用的界面和部分模糊的桌面应用的界面,具体的如图4B所示。其中,桌面应用的界面中阅读应用的图标控件4A01以及控件栏4A02的界面没有模糊。In response to the user's interaction with the icon control 4A01 , such as long pressing, the electronic device displays the interface of a blurred wallpaper application and a partially blurred interface of a desktop application, as shown in FIG. 4B . Wherein, in the interface of the desktop application, the icon control 4A01 of the reading application and the interface of the control bar 4A02 are not blurred.
图5A、图5B为本申请实施例提供的跨窗口/跨应用的动画效果的界面的另一个示例性示意图。FIG. 5A and FIG. 5B are another exemplary schematic diagrams of an interface for cross-window/cross-application animation effects provided by the embodiment of the present application.
如图5A所示,电子设备显示图库应用程序的界面。响应于用户的交互,如全面屏的手势(如从底部向上滑动至屏幕中央)或者点击底部导航栏的多任务控件,电子设备显示多任务界面如图5B所示。As shown in FIG. 5A , the electronic device displays an interface of a gallery application program. In response to user interaction, such as a full-screen gesture (such as sliding up from the bottom to the center of the screen) or clicking the multitasking control on the bottom navigation bar, the electronic device displays a multitasking interface as shown in FIG. 5B .
如图5B所示,多任务界面包括图库的界面以及模糊的壁纸界面。As shown in FIG. 5B , the multitasking interface includes a gallery interface and a blurry wallpaper interface.
图6A、图6B为本申请实施例提供的跨窗口/跨应用的动画效果的界面的另一个示例性示意图。FIG. 6A and FIG. 6B are another exemplary schematic diagrams of an interface for cross-window/cross-application animation effects provided by the embodiment of the present application.
在分屏场景下,如图6A所示,电子设备的屏幕上半部分显示桌面应用程序的界面,下半部分显示音乐应用程序的界面。其中,音乐应用程序的界面上包括控件6A01。In a split-screen scenario, as shown in FIG. 6A , the upper half of the screen of the electronic device displays an interface of a desktop application, and the lower half displays an interface of a music application. Wherein, the interface of the music application program includes a control 6A01.
在用户点击控件6A01后,电子设备的呈现的界面如图6B或图6A所示。After the user clicks the control 6A01, the interface presented by the electronic device is as shown in FIG. 6B or FIG. 6A.
如图6B所示,当用户点击控件6A01后,电子设备显示模糊的桌面应用程序的界面,以及部分模糊的音乐应用程序的界面。其中,音乐应用程序的界面中控件6A01的界面没有模糊。As shown in FIG. 6B , after the user clicks the control 6A01 , the electronic device displays a blurred interface of a desktop application program and a partially blurred interface of a music application program. Wherein, the interface of the control 6A01 in the interface of the music application program is not blurred.
很显然的,电子设备通过动画效果如模糊等其他方式向用户展示应用程序的界面,有助于提高用户的体验。Apparently, the electronic device displays the interface of the application program to the user through animation effects such as blurring and other means, which helps to improve the user experience.
值得说明的是,单个应用程序多个窗口(window)的动画效果的界面与跨应用程序的界面类似,此处不再赘述。It is worth noting that the interface of the animation effect of multiple windows (windows) of a single application is similar to the interface of cross-applications, and will not be repeated here.
(1.4)跨窗口/跨应用的动画效果的实现(1.4) Implementation of cross-window/cross-application animation effects
与单个应用程序的动画效果的实现不同的是,多个应用程序的动画效果的实现涉及到不同应用程序的图层合成的过程。Different from the realization of the animation effect of a single application, the realization of the animation effect of multiple applications involves the process of layer composition of different applications.
下面结合图7A所示的内容,示例性的介绍多个应用程序的动画效果的实现:Combining with the content shown in FIG. 7A, the realization of the animation effect of multiple application programs is exemplarily introduced below:
图7A为本申请实施例提供的跨窗口/跨应用的动画效果的实现的一个示例性示意图。FIG. 7A is an exemplary schematic diagram of the implementation of the cross-window/cross-application animation effect provided by the embodiment of the present application.
如图7A所示,多个应用程序的动画效果的实现可以包括:As shown in FIG. 7A, the realization of animation effects of multiple application programs may include:
①应用程序1的UI线程拷贝应用程序2的界面,例如应用程序1通过截图(screenshot)接口获取应用程序2的界面,记为位图1。其中,截图接口会触发应用程序2重新构建、渲染生成位图1。其中,位图1可以在应用程序1的堆内存中。或者,截图接口可以获取应用程序2上一帧的界面。②应用程序1的UI线程在对位图1做动画渲染,生成位图2。其中,动画渲染可以调用CPU的计算资源完成。③应用程序1的UI线程软件绘制应用程序1的界面,该界面只包括需要做动画渲染的部分,记为位图3。④UI线程对位图3做动画渲染,生成位图4。⑤应用程序1的UI线程叠加位图2和位图4的内容,生成位图5,并将位图5作为动画层插入到应用程序的界面view结构中。⑥应用程序1的Render线程基于渲染树生成位图过程中导入位图5作为背景,生成位图6。⑦应用程序2的UI线程生成渲染树。⑧应用程序的Render线程基于渲染树生成位图7。① The UI thread of
SurfaceFlinger/硬件合成策略模块(Hardware Composer,HWC)通过surface获取应用程序1生成的位图6和应用程序2生成的位图7,进行图层合成以获得用于送显的位图(也称为用于送显的图层)。SurfaceFlinger/hardware composition strategy module (Hardware Composer, HWC) obtains the
很显然的,图7A所示的动画效果的实现需要UI线程在渲染阶段开始前准备好动画渲染后的位图,使得UI线程被动画渲染这种耗时操作占用,容易造成应用程序卡顿。除此之外,UI线程调用CPU进行动画渲染,但是CPU执行图像处理类操作的效率较低,进一步加剧应用程序的卡顿。Obviously, the realization of the animation effect shown in Figure 7A requires the UI thread to prepare the bitmap after the animation rendering before the rendering stage starts, so that the UI thread is occupied by the time-consuming operation of animation rendering, which may easily cause the application to freeze. In addition, the UI thread calls the CPU to perform animation rendering, but the efficiency of the CPU to perform image processing operations is low, which further aggravates the freeze of the application.
除此之外,通过截图接口获取其他应用程序的界面可能会有延迟,在应用程序2的界面一直变化的情况下(例如,位图1和位图7的内容不同),应用程序1无法拿到最新的应用程序2的界面。并且,截图接口会调用GPU,额外增加了GPU的调用次数,增加计算开销。In addition, there may be a delay in obtaining the interface of other applications through the screenshot interface. In the case that the interface of
下面,以图4B所示的界面为例,结合图7B示例性的介绍图7A中位图1至位图6的内容。Next, taking the interface shown in FIG. 4B as an example, the contents of
图7B为图7A所示方法过程中位图变化的一个示例性示意图。FIG. 7B is an exemplary schematic diagram of bitmap changes during the method shown in FIG. 7A .
在图4B所示的界面中,图7A中的应用程序1为桌面应用程序,应用程序2为壁纸应用程序。In the interface shown in FIG. 4B ,
如图7B所示,位图1为桌面应用程序通过截图接口获取的壁纸应用程序的界面;位图2为对位图1进行模糊渲染后的生成的位图;位图3为不包括控件4A01的桌面应用程序的界面;位图4为对位图3进行模糊渲染后生成的位图;位图5为位图4和位图5的像素叠加生成的位图;位图6为桌面应用程序的界面;位图7为壁纸应用该程序的界面。As shown in Figure 7B,
其中,模糊渲染是一种动画渲染。Among them, blur rendering is a kind of animation rendering.
值得说明的是,图7B中的位图1至位图7中白色(如桌面应用程序上的图标外的内容)为应用程序没有绘制的像素,可以为空,或者可以为默认值,例如黑色像素(255,255,255)。该像素点可以参与到动画渲染的计算中,或者也可以不参与到动画渲染的计算中。It is worth noting that the white in
图7C为本申请实施例提供的跨窗口/跨应用的动画效果的实现的另一个示例性示意图。FIG. 7C is another exemplary schematic diagram of realizing the cross-window/cross-application animation effect provided by the embodiment of the present application.
与图7A所示的内容不同的,图7C所示的动画效果的实现主要依赖于SurfaceFlinger对需要动画渲染的内容进行离屏渲染。Different from the content shown in FIG. 7A , the realization of the animation effect shown in FIG. 7C mainly relies on SurfaceFlinger to perform off-screen rendering of the content requiring animation rendering.
如图7C所示,多个应用程序的动画效果的实现包括:As shown in FIG. 7C, the realization of animation effects of multiple applications includes:
①应用程序1和应用程序2分别独立的构建、渲染生成应用程序1的位图1和应用程序2的位图2。其中,生成位图1和位图2需要分别的调用CPU、GPU。①Application 1 and
②应用程序1的Render线程将位图1传递给SurfaceFlinger,SurfaceFlinger将位图2中需要动画渲染的内容拷贝至离屏缓冲1中。其中离屏缓冲1中内容称为位图3。其中,离屏缓冲可以预先申请、构建的,也可以是响应于动画渲染请求后开申请、构建的。② The Render thread of
③应用程序2的Render线程将位图2传递给SurfaceFlinger,将位图2中需要动画渲染的内容拷贝至离屏缓冲2中。其中离屏缓冲2中内容称为位图4。③ The Render thread of
④SurfaceFlinger分别对离屏缓冲1、离屏缓冲2中的内容进行模糊处理,分别生成位图5、位图6。其中,生成位图5和位图6需要分别的调用GPU。④SurfaceFlinger blurs the content in off-
⑤SurfaceFlinger对位图1、位图2、位图5、位图6进行图层合成。其中,图层合成调用一次GPU。其中,图层合成的内容为位图7,并将位图7拷贝到在屏缓冲(on-screenbuffer)中。⑤SurfaceFlinger performs layer synthesis on
其中,离屏缓冲为SurfaceFlinger开辟的一个非在屏缓冲,用于存储图层/位图的中间状态。在屏缓冲是可以被显示子系统获取的,承载位图并且可以直接送显的GPU内的一块缓冲。Among them, the off-screen buffer is an off-screen buffer developed by SurfaceFlinger, which is used to store the intermediate state of the layer/bitmap. The on-screen buffer is a buffer in the GPU that can be obtained by the display subsystem, carries a bitmap, and can be directly sent to the display.
很显然的,SurfaceFlinger在将多个应用程序的位图作为图层进行图层合成的过程中,通过离屏渲染,完成跨窗口/跨应用的动画效果。但是,SurfaceFlinger通过离屏渲染进行动画渲染,由于动画渲染调用的图形处理库依赖于上下文,在不同的离屏缓冲上进行动画渲染导致的上下文切换导致电子设备的计算开销、内存开销较大。Obviously, SurfaceFlinger completes cross-window/cross-application animation effects through off-screen rendering in the process of compositing bitmaps of multiple applications as layers. However, SurfaceFlinger performs animation rendering through off-screen rendering. Since the graphics processing library called by animation rendering depends on the context, context switching caused by animation rendering on different off-screen buffers leads to large computing and memory overheads for electronic devices.
其次,SurfaceFlinger在实现跨窗口/跨应用的动画效果时,需要生成多个离屏缓冲保存不同的中间结果,并且需要通过图层合成将多个承载中间结果的图层进行合成,计算开销、内存开销较大。进一步的,不同离屏缓冲中的中间结果有大量重复的内容,浪费了电子设备的计算资源、内存资源。Secondly, when SurfaceFlinger implements cross-window/cross-application animation effects, it needs to generate multiple off-screen buffers to save different intermediate results, and it needs to synthesize multiple layers carrying intermediate results through layer composition, which requires computational overhead and memory. The overhead is high. Furthermore, the intermediate results in different off-screen buffers have a large amount of repeated content, which wastes computing resources and memory resources of the electronic device.
下面以图4B所示的界面为例,结合图7D示例性的介绍图7C中位图1至位图7的包括的内容。Taking the interface shown in FIG. 4B as an example, the contents included in
图7D为图7C所示方法过程中位图变化的一个示例性示意图。FIG. 7D is an exemplary schematic diagram of bitmap changes during the method shown in FIG. 7C .
如图7D所示,位图1为桌面应用程序构建、渲染生成的位图;位图2为壁纸应用程序构建、渲染生成的位图;位图3为位图1中需要模糊的内容;位图4为位图2中需要模糊的内容;位图5为对位图3模糊处理后的位图;位图6为对位图4模糊处理后的位图;位图7为位图1、位图2、位图5、位图6合成后用于送显的位图。As shown in Figure 7D,
很显然的,正如上文中图7A所示的内容,应用程序要实现跨窗口/跨应用的动画渲染,需要通过软件绘制完成动画渲染。但是,由于CPU的硬件结构相比于GPU不适合做图形运算,所以软件绘制的能效比低,动画渲染速度慢,容易导致卡顿。Obviously, as shown in FIG. 7A above, in order to achieve cross-window/cross-application animation rendering, the animation rendering needs to be completed through software drawing. However, since the hardware structure of the CPU is not suitable for graphics operations compared to the GPU, the energy efficiency ratio of software rendering is low, and the rendering speed of animation is slow, which may easily cause freezes.
很显然的,正如上文中图7C所示的内容,SurfaceFlinger要实现跨窗口/跨应用的动画渲染,需要开辟多个离屏缓冲,通过离屏渲染完成动画渲染。在该过程中,存在大量重复的操作,动画渲染速度慢,容易导致卡顿。Obviously, as shown in Figure 7C above, in order for SurfaceFlinger to achieve cross-window/cross-application animation rendering, it is necessary to open up multiple off-screen buffers and complete animation rendering through off-screen rendering. In this process, there are a lot of repeated operations, and the animation rendering speed is slow, which may easily lead to freeze.
(2)其次,下面介绍本申请实施例提供的界面生成方法。(2) Next, the interface generation method provided by the embodiment of the present application is introduced below.
本申请实施例提供的界面生成方法,首先,通过UniRender进程获取一个或多个应用程序的渲染树,并将一个或多个渲染树进行重新组合成目标渲染树;其次,UniRender进程基于目标渲染树进行渲染以得到承载有一个或多个应用程序图像信息的位图。UniRender进程可以在渲染生成位图的过程中进行动画渲染。In the interface generation method provided by the embodiment of the present application, firstly, the rendering tree of one or more applications is obtained through the UniRender process, and one or more rendering trees are reassembled into a target rendering tree; secondly, the UniRender process is based on the target rendering tree Renders to a bitmap that carries information about one or more application images. The UniRender process can perform animation rendering during the process of rendering and generating bitmaps.
很显然的,首先,本申请实施例提供的界面生成方法通过将一个或多个应用程序的目标渲染树合并为目标渲染树,通过一次渲染就能够生成承载一个或多个应用程序图像信息的位图,避免了通过截图调用获取其他应用程序的位图,降低GPU的调用次数,进而降低功耗。Obviously, first of all, the interface generation method provided by the embodiment of the present application merges the target rendering tree of one or more application programs into a target rendering tree, and can generate bitmaps carrying image information of one or more application programs through one rendering. image, avoiding the need to obtain bitmaps of other applications through screenshot calls, reducing the number of calls to the GPU, thereby reducing power consumption.
其次,本申请实施例提供的界面生成方法通过在渲染生成位图的过程中进行动画渲染,可以降低需要开辟的离屏缓冲的个数,进而降低计算开销、内存开销。Secondly, the interface generation method provided by the embodiment of the present application can reduce the number of off-screen buffers that need to be opened by performing animation rendering during the process of rendering and generating bitmaps, thereby reducing computing costs and memory costs.
再次,由于渲染生产的位图为承载有一个或多个应用程序图像信息的位图,则可以不需要SurfaceFlinger/HWC进行图层合成,可以至少减少一次GPU调用,进一步节省了计算和内存开销。Thirdly, since the bitmap produced by rendering is a bitmap that carries the image information of one or more applications, SurfaceFlinger/HWC may not be required for layer synthesis, which can reduce at least one GPU call, further saving calculation and memory overhead.
下面示例性的介绍本申请实施例提供的界面生成方法。The interface generation method provided by the embodiment of the present application is exemplarily introduced below.
图8为本申请实施例提供的界面生成方法的一个示例性示意图。FIG. 8 is an exemplary schematic diagram of an interface generation method provided by an embodiment of the present application.
如图8所示,本申请实施例提供的界面生成方法包括:As shown in Figure 8, the interface generation method provided by the embodiment of the present application includes:
S801:接收到垂直信号后,构建生成渲染树。S801: Build and generate a rendering tree after receiving a vertical signal.
应用程序在界面需要更新的时候,可以向UniRender进程请求垂直同步信号(Vsync-APP)。应用程序在接收到垂直同步信号后,在UI线程中执行measure()方法、layout()方法、draw()方法。其中,UI线程在执行draw()方法中,会遍历应用程序的view,确定每个view渲染需要的绘制指令,不断记录/录制到该view对应的渲染节点的绘制指令列表中。When the application needs to update the interface, it can request a vertical synchronization signal (Vsync-APP) from the UniRender process. After the application program receives the vertical synchronization signal, it executes the measure() method, the layout() method, and the draw() method in the UI thread. Among them, when the UI thread executes the draw() method, it traverses the views of the application, determines the drawing instructions required for rendering each view, and continuously records/records them in the drawing instruction list of the rendering node corresponding to the view.
其中,应用程序需要显示的界面由多个view嵌套组成,与根视图(DecorView)对应的绘制指令列表中包括有根视图的子视图的绘制指令列表入口,即绘制指令列表之间的嵌套关系与view的嵌套关系相同,故渲染节点的嵌套关系与view的嵌套关系相同。其中,关于渲染树、渲染节点的相关概念的定义可以参考上文中图3对应的文字描述。Among them, the interface that the application needs to display is composed of multiple view nests, and the drawing instruction list corresponding to the root view (DecorView) includes the entry of the drawing instruction list of the subview of the root view, that is, the nesting between the drawing instruction lists The relationship is the same as the nesting relationship of view, so the nesting relationship of rendering nodes is the same as that of view. Among them, the definition of related concepts of rendering tree and rendering node can refer to the text description corresponding to Figure 3 above.
图9为本申请实施例提供的构建渲染树的一个示例性示意图。FIG. 9 is an exemplary schematic diagram of constructing a rendering tree provided by an embodiment of the present application.
应用程序UI线程在进行measure()、layout()、draw()后,可以得到自己要更新的界面的多个view的父子结构,并在遍历view的过程中,确定每个view上要展示的内容以及生成该内容所需要的接口调用,如drawCircle、drawLine等等。After the application UI thread performs measure(), layout(), and draw(), it can obtain the parent-child structure of multiple views of the interface to be updated, and determine the view to be displayed on each view during the process of traversing the views. The content and the interface calls required to generate the content, such as drawCircle, drawLine, etc.
应用程序在将drawCircle、drawLine等绘制接口调用封装为对应的DrawOp如DrawCircleOp、DrawLineOp,并保存在绘制指令列表中。The application encapsulates drawing interface calls such as drawCircle and drawLine into corresponding DrawOps such as DrawCircleOp and DrawLineOp, and saves them in the drawing instruction list.
如图9所示,应用程序的界面的视图结构为:根视图,根视图的子视图为视图1和视图2,视图2的子视图为视图3。其中,视图2中包括矩形、圆形,则视图2对应的渲染节点2中绘制指令列表中的绘制操作包括:绘制矩形的操作,绘制圆形的操作等。As shown in FIG. 9 , the view structure of the interface of the application program is: a root view, the subviews of the root view are
应用程序的UI线程在执行draw()方法时,可以从根视图开始,依据View之间的父子关系,遍历所有的view,确定每个view中的绘制操作,并将绘制操作封装为DrawOp。应用程序的UI线程在生成绘制指令列表后,会进一步的将绘制指令列表封装为渲染树。When executing the draw() method, the UI thread of the application can start from the root view, traverse all views according to the parent-child relationship between Views, determine the drawing operation in each view, and encapsulate the drawing operation as DrawOp. After the UI thread of the application program generates the drawing instruction list, it will further encapsulate the drawing instruction list into a rendering tree.
渲染树中的渲染节点包括绘制指令列表和渲染属性,其中,渲染属性用于决定该渲染节点要渲染的view在surface中的位置、大小、透明度等属性,绘制指令列表用于决定该渲染节点要渲染的view的内容,如线条、矩形、圆形等。The rendering node in the rendering tree includes a drawing instruction list and rendering attributes, among which, the rendering attribute is used to determine the position, size, transparency and other attributes of the view to be rendered by the rendering node in the surface, and the drawing instruction list is used to determine the rendering node to be rendered. The content of the rendered view, such as lines, rectangles, circles, etc.
该surface为应用程序申请的,应用程序自己决定该surface的大小。在SurfaceFlinger存在的情况下,该surface可以是应用程序向SurfaceFlinger申请的,在SurfaceFlinger不存在的情况下,可以是向UniRender进程申请的。其中,SurfaceFlinger可以不向该应用程序分配surface。The surface is applied for by the application, and the application determines the size of the surface by itself. In the case that SurfaceFlinger exists, the surface can be applied to SurfaceFlinger by the application, and in the absence of SurfaceFlinger, it can be applied to the UniRender process. Among them, SurfaceFlinger may not allocate a surface to the application.
可选的,在本申请一些实施例中,UniRender进程可以确定每个显示区域的屏幕刷新率后,调整每个显示区域上垂直同步信号(Vsync-APP)的频率,使得在显示区域1上显示的应用程序以显示区域1的屏幕刷新率的频率生成渲染树。Optionally, in some embodiments of the present application, the UniRender process may adjust the frequency of the vertical synchronization signal (Vsync-APP) on each display area after determining the screen refresh rate of each display area, so that the
在本申请实施例中,显示区域可以是一块屏幕、或者可以是虚拟屏幕(VirtualDisplay)等。虚拟屏幕可以是录屏时,电子设备用于承载屏幕上显示的内容的区域。In this embodiment of the present application, the display area may be a screen, or may be a virtual screen (Virtual Display) or the like. The virtual screen may be an area used by the electronic device to carry content displayed on the screen when recording the screen.
值得说明的是,一个应用程序的UI线程可以生成多个渲染树,例如在多屏幕、虚拟屏、多窗口场景下等多显示区域(display)场景中。It is worth noting that the UI thread of an application can generate multiple rendering trees, such as in multi-display scenarios such as multi-screen, virtual screen, and multi-window scenarios.
S802:跨进程传递渲染树S802: passing the rendering tree across processes
应用程序的UI线程在生成渲染树后,会将渲染树通过IPC通信传递给UniRender进程。对应的UniRender进程需要接收不同应用程序传递的渲染树,并确定渲染树和应用程序的对应关系。After the UI thread of the application generates the rendering tree, it will pass the rendering tree to the UniRender process through IPC communication. The corresponding UniRender process needs to receive the rendering tree delivered by different applications, and determine the corresponding relationship between the rendering tree and the application.
其中,位于前台的多个应用程序向UniRender进程传递渲染树。若该应用程序满足一下三个条件中的任意一个,该应用程序为前台应用,该应用程序具有可见的活动(Activity)、该应用程序具有前台服务、其他前台应用程序关联到该应用。Among them, multiple applications in the foreground pass the rendering tree to the UniRender process. If the application meets any one of the following three conditions, the application is a foreground application, the application has a visible activity (Activity), the application has a foreground service, and other foreground applications are associated with the application.
由于不同的进程的内存是不共享的,进程之间进行数据交互需要通过进程间通信(InterProcess Communication,IPC)完成。其中,应用程序向UniRender进程传递渲染树可以通过如Binder、AIDL、共享内存、Socket等方式实现IPC通信,在此不作限定。Since the memory of different processes is not shared, data interaction between processes needs to be completed through InterProcess Communication (IPC). Among them, the application program can pass the rendering tree to the UniRender process to realize IPC communication through methods such as Binder, AIDL, shared memory, Socket, etc., which is not limited here.
下面以共享内存作为IPC通信的示例,示例性的介绍跨进程传递渲染树的方式。The following uses shared memory as an example of IPC communication to exemplarily introduce the way to transfer the rendering tree across processes.
(a)应用程序将渲染树写入共享内存(a) The application writes the render tree to shared memory
图10为本申请实施例提供的共享内存传递渲染树的一个示例性示意图。FIG. 10 is an exemplary schematic diagram of a shared memory transfer rendering tree provided by an embodiment of the present application.
如图10所示,首先,应用程序在每次启动时,会向UniRender进程申请共享内存。UniRender进程在接收到应用程序发起的共享内存的请求后,通过匿名共享内存(Anonymous Shared Memory,Ashmem)子系统申请一块共享内存以及与该共享内存对应的句柄。As shown in Figure 10, first, the application will apply for shared memory from the UniRender process each time it starts. After the UniRender process receives the shared memory request initiated by the application program, it applies for a piece of shared memory and a handle corresponding to the shared memory through the anonymous shared memory (Anonymous Shared Memory, Ashmem) subsystem.
其次,UniRender进程在向Ashmem子系统申请共享内存成功后,会收到Ashmem子系统返回的句柄用于读写物理内存。UniRender进程将句柄返回给应用程序,使得应用程序可以使用该句柄往物理内存中写入渲染树。UniRender进程可以直接从自己的进程空间中读取该物理内存,进而直接读取应用程序的渲染树。Secondly, after the UniRender process successfully applies for shared memory from the Ashmem subsystem, it will receive a handle returned by the Ashmem subsystem for reading and writing physical memory. The UniRender process returns the handle to the application, so that the application can use the handle to write the rendering tree into the physical memory. The UniRender process can directly read the physical memory from its own process space, and then directly read the rendering tree of the application.
其中,该共享内存可以是通过临时文件系统(tmpfs)在内存(RAM)中建立的虚拟文件,分别映射到不同进程的用户空间中。Wherein, the shared memory may be a virtual file established in the internal memory (RAM) through a temporary file system (tmpfs), which are respectively mapped to user spaces of different processes.
其中,应用程序向UniRender进程申请共享内存,UniRender进程向Ashmem子系统申请共享内存、UniRender进程向应用程序返回申请获得的共享内存对应的句柄等跨进程通信可以通过Binder通信实现。Among them, the application program applies for shared memory to the UniRender process, the UniRender process applies for the shared memory to the Ashmem subsystem, and the UniRender process returns the handle corresponding to the shared memory obtained by the application to the application program. Cross-process communication can be realized through Binder communication.
可以理解的是,通过共享内存等其他IPC方式,可以将存储于应用进程的栈上的渲染树传递给UniRender进程,在此不做限定。It can be understood that the rendering tree stored on the stack of the application process can be delivered to the UniRender process through other IPC methods such as shared memory, which is not limited here.
可选的,在本申请一些实施例中,应用程序具有多个图层的情况下,即应用程序生成多个渲染树的情况下,应用程序可以向UniRender进程申请两块共享内存,分别用于存储不同的图层,即存储不同的渲染树的数据。Optionally, in some embodiments of the present application, when the application has multiple layers, that is, when the application generates multiple rendering trees, the application can apply to the UniRender process for two pieces of shared memory, which are used for Store different layers, that is, store data of different rendering trees.
(b)渲染树在共享内存的存储数据结构(b) The storage data structure of the rendering tree in shared memory
为了进一步提高IPC通信的效率,在本申请实施例中,渲染树以内存树的形式保存在共享内存中。下面示例性的介绍渲染树在共享内存中的保存的数据结构形式:In order to further improve the efficiency of IPC communication, in the embodiment of the present application, the rendering tree is stored in the shared memory in the form of a memory tree. The following example introduces the data structure format of the rendering tree stored in the shared memory:
其中,内存树可以由多段数据组成,不同段的数据分别存储图层信息、渲染数据等。下面以图11A、图11B的内容为例,示例性的介绍内存树的结构。其中,不同段的数据在共享内存中的偏移可以是固定的,也可以是不固定的、自适应的。Among them, the memory tree can be composed of multiple segments of data, and the data of different segments store layer information, rendering data, etc. respectively. The structure of the memory tree is exemplarily introduced below by taking the contents of FIG. 11A and FIG. 11B as examples. Wherein, the offsets of different segments of data in the shared memory may be fixed, or not fixed, and adaptive.
图11A、图11B为本申请实施例提供的共享内存中渲染树的存储结构的一个示例性示意图。FIG. 11A and FIG. 11B are exemplary schematic diagrams of a storage structure of a rendering tree in a shared memory provided by an embodiment of the present application.
如图11A所示,渲染树的存储结构包括三段数据,分别为HEAD字段、MAPPING字段、NODES字段。As shown in FIG. 11A , the storage structure of the rendering tree includes three pieces of data, namely the HEAD field, the MAPPING field, and the NODES field.
其中,HEAD字段中包括layerkey、rootid;MAPPING字段包括nodeid以及和nodeid对应的address;NODES字段包括currentproperties、stagingproperties、stagingdisplaylist、currentdisplaylist。Among them, the HEAD field includes layerkey and rootid; the MAPPING field includes nodeid and the address corresponding to the nodeid; the NODES field includes currentproperties, stagingproperties, stagingdisplaylist, and currentdisplaylist.
其中,layerkey为渲染树整体作为一个图层的ID;rootid为该渲染树的根节点的ID;nodeid为渲染树的除根节点外的渲染节点的ID,并且一个nodeid与一个address对应,该address为该渲染树节点中的渲染属性(renderproperties/properties)和绘制指令列表(displaylist)的起始地址;stagingproperties为应用程序写入的渲染属性、stagingdisplaylist为应用程序写入的绘制指令列表、currentproperties为UniRender进程读取的渲染属性、currentdisplaylist为UniRender进程读取的绘制指令列表。Among them, layerkey is the ID of the rendering tree as a whole as a layer; rootid is the ID of the root node of the rendering tree; nodeid is the ID of the rendering node of the rendering tree except the root node, and a nodeid corresponds to an address, the address is The starting address of the rendering properties (renderproperties/properties) and the drawing instruction list (displaylist) in the rendering tree node; stagingproperties is the rendering properties written by the application, stagingdisplaylist is the drawing instruction list written by the application, and currentproperties is the UniRender process The read rendering attributes and currentdisplaylist are the list of drawing instructions read by the UniRender process.
值得说明的是,认为“stagingproperties和stagingdisplaylist”为第一组数据,“currentproperties和currentdisplaylist”为第二组数据,则在应用程序写入的数据为第一组数据,下次应用程序写入数据为第二组数据,实现双缓冲机制;类似的,UniRender进程读取的数据为第一组数据,下次读取的数据为第二组数据。It is worth noting that if "stagingproperties and stagingdisplaylist" are regarded as the first set of data, and "currentproperties and currentdisplaylist" are the second set of data, then the data written in the application program is the first set of data, and the next time the application program writes data is The second set of data implements a double-buffering mechanism; similarly, the data read by the UniRender process is the first set of data, and the data read next time is the second set of data.
可选的,在本申请一些实施例中,共享内存中渲染树的存储结构可以如图11B所示,其中NODES字段可以只包括一组数据,即只包括渲染属性和绘制指令列表。Optionally, in some embodiments of the present application, the storage structure of the rendering tree in the shared memory may be as shown in FIG. 11B , where the NODES field may only include a set of data, that is, only include rendering attributes and a drawing instruction list.
layerkey用于:UniRender进程在通过句柄读取共享内存中的图层数据前,可以从WMS获取需要显示应用程序以及该应用程序的需要参与图层合成的图层ID。UniRender进程将该图层ID与从共享内存中layerkey中包括的图层ID进行校验。The layerkey is used for: before the UniRender process reads the layer data in the shared memory through the handle, it can obtain the application that needs to be displayed and the layer ID of the application that needs to participate in layer composition from the WMS. The UniRender process checks the layer ID with the layer ID included in the layerkey from the shared memory.
rootid用于:rootid作为渲染树的入口,存储有其他渲染节点的入口,UniRender进程在得到rootid后可以读取渲染树的数据,并将渲染树的嵌套结构恢复出来。rootid is used: rootid is used as the entry of the rendering tree, which stores the entry of other rendering nodes. After obtaining the rootid, the UniRender process can read the data of the rendering tree and restore the nested structure of the rendering tree.
currentproperties、stagingproperties、stagingdisplaylist、currentdisplaylist用于:应用程序完成写入绘制指令列表和渲染属性后,交换currentproperties、stagingproperties的值,交换currentdisplaylist、stagingdisplaylist的值,UniRender进程从currentproperties和current displaylist中读取渲染属性和绘制指令列表。currentproperties, stagingproperties, stagingdisplaylist, and currentdisplaylist are used for: After the application finishes writing the drawing instruction list and rendering properties, exchange the values of currentproperties and stagingproperties, exchange the values of currentdisplaylist and stagingdisplaylist, and the UniRender process reads the rendering properties and values from currentproperties and current displaylist Draw command list.
例如,应用程序1为在前台显示的应用,应用程序1可以有多个图层,即该应用程序1在接收到垂直同步信号(Vsync-APP)后,会生成多个渲染树,如渲染树1和渲染树2。UniRender进程从WMS中确定参与图层合成的图层对应的渲染树为渲染树1。For example,
由于layerkey和rootid的偏移固定,进而UniRender进程可以确定根节点的地址。UniRender进程在MAPPING段找到根节点在NODES端的位置,读取渲染该节点的渲染指令,如果有子节点,会有对应的DrawRenderNode指令,其中保存着子节点的id,通过哈希值找到子节点在MAPPING段的位置。例如,渲染树的渲染节点的父子关系会保存在DrawOP操作中。例如,渲染节点2的绘制指令列表中包括若干个DrawOP操作以及“Draw RenderNode3”(画渲染节点3)的操作,进而UniRender进程可以确定渲染节点3是渲染节点2的子节点。Since the offset of layerkey and rootid is fixed, the UniRender process can determine the address of the root node. The UniRender process finds the position of the root node at the NODES side in the MAPPING segment, and reads the rendering command for rendering the node. If there is a child node, there will be a corresponding DrawRenderNode command, which stores the id of the child node, and finds the child node at the node through the hash value. The location of the MAPPING segment. For example, the parent-child relationship of the render nodes of the render tree will be saved in the DrawOP operation. For example, the drawing instruction list of the
可以理解的是,共享内存中的渲染树仍然保存有与应用程序的view相同的嵌套关系,所以,UniRender进程可以从根节点开始读取数据,进而读取到全部的渲染树的数据。It is understandable that the rendering tree in the shared memory still has the same nesting relationship as the view of the application, so the UniRender process can read data from the root node, and then read all the data of the rendering tree.
其中,通过划分currentproperties、stagingproperties、stagingdisplaylist、currentdisplaylist,保证UniRender进程读取的送显数据和应用程序写入数据的安全性,避免应用程序写入一半的数据被UniRender进程当做最新的数据读取去渲染生成应用程序的界面。其中,关于渲染树同时读写的安全性保障可以参考下文中(2.3)对在共享内存中的渲染树的读写中的文字描述,此处不在赘述。Among them, by dividing currentproperties, stagingproperties, stagingdisplaylist, and currentdisplaylist, the security of the display data read by the UniRender process and the data written by the application is guaranteed, and half of the data written by the application is prevented from being read and rendered by the UniRender process as the latest data. Generate the application's interface. Among them, for the security guarantee of simultaneous reading and writing of the rendering tree, please refer to the textual description of the reading and writing of the rendering tree in the shared memory in (2.3) below, which will not be repeated here.
可选的,在本申请一些实施例中,三段数据的大小可以是固定的。即,当UniRender进程向Ashmem子系统申请共享内存后,得到共享内存为大小为(a+b+c)大小的内存。其中,从起始地址(物理地址)至起始地址+a为填充HEAD字段的位置;从起始地址+a+1至起始地址+a+b为填充MAPPING字段的位置;从起始地址+a+b+1至起始地址+a+b+c为填充NODES字段的位置。Optionally, in some embodiments of the present application, the sizes of the three pieces of data may be fixed. That is, when the UniRender process applies for shared memory from the Ashmem subsystem, the obtained shared memory is a memory with a size of (a+b+c). Among them, from the start address (physical address) to the start address + a is the position to fill the HEAD field; from the start address + a + 1 to the start address + a + b is the position to fill the MAPPING field; from the start address +a+b+1 to start address +a+b+c are the positions to fill the NODES field.
可以理解的是,三段数据的大小是固定的情况下,UniRender进程可以根据固定的偏移量确定每段数据的起始,进而可以找到Mapping段,Mapping段中保存有渲染树的渲染节点在NODES字段中的偏移,进而可以找到每个渲染节点的数据。It is understandable that when the size of the three pieces of data is fixed, the UniRender process can determine the start of each piece of data according to the fixed offset, and then find the Mapping section, in which the rendering nodes of the rendering tree are stored in The offset in the NODES field, and in turn the data for each render node can be found.
可选的,在本申请一些实施例中,当三段数据的大小是固定的情况下,应用程序写入的渲染节点超过b的大小,则向UniRender进程申请第二块共享内存。其中,第二块共享内存可以与第一块共享内存的格式一样,并在第二块共享内存的NODES字段继续存储渲染节点的绘制指令列表和渲染节点属性。其中,第二块共享内存的HEAD字段和/或MAPPING字段可以为空或者可以不存在。即,在本申请一些实施例中,第二块共享内存中只包括NODES字段。Optionally, in some embodiments of the present application, when the size of the three pieces of data is fixed, and the rendering node written by the application exceeds the size of b, a second piece of shared memory is applied to the UniRender process. Wherein, the format of the second piece of shared memory may be the same as that of the first piece of shared memory, and the NODES field of the second piece of shared memory continues to store the rendering instruction list and the attributes of the rendering node. Wherein, the HEAD field and/or the MAPPING field of the second shared memory may be empty or may not exist. That is, in some embodiments of the present application, only the NODES field is included in the second shared memory.
(c)UniRender读取共享内存中的渲染树(c) UniRender reads the rendering tree in shared memory
(c.1)UniRender架构(c.1) UniRender architecture
图12为本申请实施例提供的UniRender的架构的一个示例性示意图。FIG. 12 is an exemplary schematic diagram of the architecture of UniRender provided by the embodiment of the present application.
如图12所示,本申请提供的UniRender可以包括四部分,分别为NodeManager、LayerManager、DisplayManager、UniRenderCore。As shown in Figure 12, the UniRender provided by this application may include four parts, namely NodeManager, LayerManager, DisplayManager, and UniRenderCore.
其中,NodeManager为UniRender进程内的节点管理模块,负责接收应用程序发送的渲染树等。其中,目标渲染树的合成可以参考步骤S903中的文字描述。Among them, NodeManager is the node management module in the UniRender process, which is responsible for receiving the rendering tree sent by the application program. Wherein, the composition of the target rendering tree can refer to the text description in step S903.
其中,LayerManager为UniRender进程内的图层管理模块,负责从窗口管理服务(Window Manager Service,WMS)同步图层信息如图层创建、销毁、属性变更等。其中,一个位图相当于一个图层。Among them, LayerManager is the layer management module in the UniRender process, which is responsible for synchronizing layer information from the Window Manager Service (WMS), such as layer creation, destruction, property change, etc. Among them, a bitmap is equivalent to a layer.
其中,DisplayerManager为UniRender进程内的显示设备管理模块,负责从显示管理服务(Display Manager Service,DMS)同步显示设备的信息,如屏幕的大小等。Among them, DisplayerManager is a display device management module in the UniRender process, responsible for synchronizing display device information from the Display Manager Service (DMS), such as the size of the screen.
其中,UniRenderCore为UniRender进程内的渲染管理模块,负责:对每个图层建立对应的渲染节点;接收NodeManager中维护的不同应用程序对应的渲染树,从LayerManager中去除该应用程序的图层信息指令化并插入渲染节点;对DisplayManager中维护的处于激活状态的显示设备,将其所有可见的图层对应的渲染树合并;对每个显示区域遍历合并后的渲染树,UniRender为其分配的buffer上生成位图等。Among them, UniRenderCore is the rendering management module in the UniRender process, which is responsible for: establishing a corresponding rendering node for each layer; receiving the rendering tree corresponding to different applications maintained in the NodeManager, and removing the layer information instruction of the application from the LayerManager and insert the rendering node; for the active display device maintained in the DisplayManager, merge the rendering trees corresponding to all the visible layers; traverse the merged rendering tree for each display area, and UniRender assigns it to the buffer Generate bitmaps etc.
(c.2)UniRender读取渲染树(c.2) UniRender reads the rendering tree
UniRender进程首先从DMS和WMS中确定每个显示区域上显示的应用程序,这些应用程序即为参与图层合成的应用程序。其中,UniRender进程可以进一步结合白名单确定在UniRender进程进行图层合成的应用程序。其中,UniRender进程通过WMS可以确定每个应用程序的图层ID。The UniRender process first determines the applications displayed on each display area from the DMS and WMS, and these applications are the applications that participate in layer composition. Among them, the UniRender process can further determine the application program that performs layer composition in the UniRender process in combination with the white list. Among them, the UniRender process can determine the layer ID of each application through WMS.
其中,由UniRender进程中的DisplayerManager负责和DMS进行通信,由UniRender进程中的LayerManager负责和WMS进行通信。Among them, the DisplayerManager in the UniRender process is responsible for communicating with the DMS, and the LayerManager in the UniRender process is responsible for communicating with the WMS.
由于UniRender进程保存有与应用程序对应的共享内存的句柄,UniRender进程在确定参与图层合成的应用程序后,可以通过句柄确定该应用程序对应的共享内存。UniRender进程通过该句柄从共享内存中读取渲染树。Because the UniRender process saves the handle of the shared memory corresponding to the application, after the UniRender process determines the application participating in layer composition, it can determine the shared memory corresponding to the application through the handle. The UniRender process reads the rendering tree from the shared memory through this handle.
其中,由UniRender进程中的NodeManager负责管理共享内存的句柄,并从共享内存中读取渲染树。Among them, the NodeManager in the UniRender process is responsible for managing the handle of the shared memory and reading the rendering tree from the shared memory.
UniRender进程从共享内存中读取渲染树的过程包括:The process of the UniRender process reading the rendering tree from the shared memory includes:
首先,UniRender进程从共享内存的起始地址处读取layer key,校验图层ID。其中,UniRender进程从WMS确定的图层ID去比对从layer key中确定的图层ID,当校验一致后,UniRender进程从根节点root id开始读取渲染树。First, the UniRender process reads the layer key from the starting address of the shared memory, and verifies the layer ID. Among them, the UniRender process compares the layer ID determined from the layer key with the layer ID determined by the WMS. When the verification is consistent, the UniRender process starts to read the rendering tree from the root node root id.
其次,UniRender进程在找到根节点的地址后,在MAPPING段中的address字段确定根节点在NODES段的起始地址,开始读取该渲染节点的绘制指令列表和渲染属性。其中,若根节点具有子节点,则在根节点的绘制列表指令中存有子节点的入口,如DrawRenderNode指令。由于DrawRenderNode指令中包括有子节点的ID,UniRender进程通过哈希运算在MAPPING段找到对应的node id,进而可以确定子节点的绘制指令列表和渲染属性在NODES段的位置,并读取到子节点的绘制指令列表和渲染属性。Secondly, after the UniRender process finds the address of the root node, it determines the starting address of the root node in the NODES segment in the address field in the MAPPING segment, and starts to read the rendering command list and rendering attributes of the rendering node. Wherein, if the root node has a child node, the drawing list instruction of the root node stores the entry of the child node, such as a DrawRenderNode instruction. Since the DrawRenderNode instruction includes the ID of the child node, the UniRender process finds the corresponding node id in the MAPPING section through hash operation, and then can determine the drawing command list of the child node and the position of the rendering attribute in the NODES section, and read the child node A list of drawing instructions and rendering properties.
(d)对在共享内存中的渲染树的读写(d) Reading and writing to the rendering tree in shared memory
位于共享内存中的渲染树可以被两个或更多个进程读写,为了减少、避免读写冲突导致渲染树的数据发生错误,可以通过配置进程间的同步锁来保障渲染树的读写安全。The rendering tree located in the shared memory can be read and written by two or more processes. In order to reduce and avoid read-write conflicts and cause data errors in the rendering tree, you can configure synchronization locks between processes to ensure the read-write security of the rendering tree .
下面结合图13、图14所示的内容示例性的介绍读写渲染树的过程。The process of reading and writing the rendering tree is exemplarily introduced below in conjunction with the contents shown in FIG. 13 and FIG. 14 .
图13为本申请实施例提供的应用程序往共享内存中写入渲染树的一个示例性示意图。FIG. 13 is an exemplary schematic diagram of an application program writing a rendering tree into a shared memory provided by an embodiment of the present application.
每个应用程序保存有至少一个锁变量A,以避免应用程序和UniRender进程同时对共享内存进行读和写。其中,UniRender进程通过IPC通信获取不同应用程序上锁变量的状态(持有或者释放)。Each application saves at least one lock variable A to prevent the application and the UniRender process from reading and writing the shared memory at the same time. Among them, the UniRender process obtains the status (holding or releasing) of the locked variables of different applications through IPC communication.
如图13所示,①首先,当应用程序需要更新界面时,请求并接收垂直同步信号(Vsync-APP),然后拿到本应用程序对应的共享内存的锁变量A,从根节点开始对渲染节点的属性和绘制指令列表进行计算和更新。As shown in Figure 13, ① First, when the application needs to update the interface, it requests and receives the vertical synchronization signal (Vsync-APP), and then obtains the lock variable A of the shared memory corresponding to the application, and starts rendering from the root node. The node's attributes and drawing instruction list are computed and updated.
②其次,应用程序将更新后的渲染节点的属性和绘制指令列表写入到共享内存中NODES段的staging properties和staging displaylist数据段中,并且发生改变的渲染节点id加入到properties_dirty队列和displaylist_dirty队列中,该队列保存在应用侧的共享内存管理类单例中。②Secondly, the application program writes the updated rendering node properties and drawing command list into the staging properties and staging displaylist data segments of the NODES segment in the shared memory, and the changed rendering node id is added to the properties_dirty queue and displaylist_dirty queue , the queue is saved in the shared memory management class singleton on the application side.
可以理解的是,properties_dirty队列和displaylist_dirty队列中标记有改变的渲染节点,可以实现差量的更新渲染树。It is understandable that the changed rendering nodes are marked in the properties_dirty queue and the displaylist_dirty queue, which can achieve differential update of the rendering tree.
可选的,在本申请一些实施例中,可以不保存properties_dirty队列和displaylist_dirty队列,实现全量的渲染树更新。Optionally, in some embodiments of the present application, the properties_dirty queue and the displaylist_dirty queue may not be saved, so as to realize full rendering tree update.
③再次,应用程序将properties_dirty队列中对应渲染节点的stagingproperties段拷贝到current properties段。应用程序将displaylist_dirty队列中对应渲染节点的draw_pointer与record_pointer进行交换,即将displaylist_dirty队列中对应渲染节点的staging displaylist段拷贝到current displaylist;或者应用程序将staging displaylist段拷贝到current displaylist。③ Again, the application copies the stagingproperties segment corresponding to the rendering node in the properties_dirty queue to the current properties segment. The application program exchanges the draw_pointer and record_pointer corresponding to the rendering node in the displaylist_dirty queue, that is, copies the staging displaylist section corresponding to the rendering node in the displaylist_dirty queue to the current displaylist; or the application program copies the staging displaylist section to the current displaylist.
可以理解的是,由于相比上一个垂直同步信号(Vsync-APP),响应于本次垂直同步信号(Vsync-APP),应用程序只改变了displaylist_dirty对应的渲染节点的数据,应用程序将displaylist_dirty队列中对应渲染节点的draw_pointer与record_pointer进行交换,则可以实现差量更新current displaylist。It is understandable that, compared to the previous vertical synchronization signal (Vsync-APP), in response to this vertical synchronization signal (Vsync-APP), the application only changes the data of the rendering node corresponding to displaylist_dirty, and the application queues displaylist_dirty If the draw_pointer and record_pointer corresponding to the rendering node are exchanged, the current displaylist can be updated by difference.
可以理解的是,应用程序将staging displaylist段拷贝到currentdisplaylist,可以实现全量的更新,即将应用程序响应于该垂直同步信号(Vsync-APP)生成的渲染树的全部数据直接写入到共享内存,实现较为简单。It is understandable that the application program copies the staging displaylist segment to the currentdisplaylist to achieve a full update, that is, directly writes all the data of the rendering tree generated by the application program in response to the vertical synchronization signal (Vsync-APP) to the shared memory to realize Simpler.
可选的,在本申请一些实施例中,在不保存properties_dirty队列和displaylist_dirty队列的情况下,应用程序所有渲染节点的staging properties段拷贝到current properties段、staging displaylist段拷贝到current displaylist段。Optionally, in some embodiments of the present application, without saving the properties_dirty queue and the displaylist_dirty queue, the staging properties section of all rendering nodes of the application is copied to the current properties section, and the staging displaylist section is copied to the current displaylist section.
④再次,应用程序通过IPC通信传递锁变量A已经释放的信息至UniRender进程。④Through the IPC communication, the application transmits the information that the lock variable A has been released to the UniRender process.
⑤再次,UniRender进程持有锁变量A。⑤ Again, the UniRender process holds the lock variable A.
⑥最后,与③对应的,UniRender进程从共享内存中读取current displaylist、current properties,或者读取displaylist_dirty队列中对应渲染节点的stagingdisplaylist段拷贝到current displaylist。⑥Finally, corresponding to ③, the UniRender process reads the current displaylist and current properties from the shared memory, or reads the stagingdisplaylist segment corresponding to the rendering node in the displaylist_dirty queue and copies it to the current displaylist.
UniRender进程在读取完数据后,可以释放锁变量A,并通知应用程序锁变量A已经释放。进而在下一个垂直同步信号(Vsync-APP)到来时,持有锁变量A,进而往共享内存中写入渲染树。此时,staging数据段和current数据段的作用互换,UniRender进程最后读取staging displaylist和staging properties段,实现“双缓冲”机制,保证界面生成的稳健性。After the UniRender process reads the data, it can release the lock variable A and notify the application that the lock variable A has been released. Then, when the next vertical synchronization signal (Vsync-APP) arrives, the lock variable A is held, and then the rendering tree is written into the shared memory. At this point, the roles of the staging data segment and the current data segment are switched, and the UniRender process finally reads the staging displaylist and staging properties segments to implement a "double buffering" mechanism to ensure the robustness of interface generation.
可选的,在本申请一些实施例中,在应用程序和UniRender进程之间存在一个锁变量的情况下,NODES字段可以只包括staging displaylist和staging properties,或者只包括current displaylist和current properties。其中,应用程序和UniRender进程通过锁变量实现读写安全,使得UniRender进程读取到正确的渲染树。Optionally, in some embodiments of the present application, if there is a lock variable between the application program and the UniRender process, the NODES field may only include staging displaylist and staging properties, or only include current displaylist and current properties. Among them, the application program and the UniRender process realize read and write security through the lock variable, so that the UniRender process can read the correct rendering tree.
可选的,在本申请一些实施例中,每个应用程序可以持有更多个锁变量,例如,每个应用程序持有锁变量A和锁变量B。进而,在应用程序释放锁A后,无需等待UniRender进程释放锁A,持有锁变量B后,在收到下一个垂直同步信号(Vsync-APP)后,直接往共享内存中写入渲染树数据。Optionally, in some embodiments of the present application, each application program may hold more lock variables, for example, each application program holds lock variable A and lock variable B. Furthermore, after the application program releases the lock A, it does not need to wait for the UniRender process to release the lock A. After holding the lock variable B, after receiving the next vertical synchronization signal (Vsync-APP), it directly writes the rendering tree data into the shared memory .
其中,锁变量B的持有、释放、进程间的同步与锁变量A的持有、释放、进程间的同步相同,具体的可以参考图14所示的文字描述,此处不再赘述。Among them, the holding, release, and inter-process synchronization of the lock variable B are the same as the holding, release, and inter-process synchronization of the lock variable A. For details, please refer to the text description shown in FIG. 14 , and will not repeat them here.
图14为本申请实施例提供的应用程序往共享内存中写入渲染树的另一个示例性示意图。FIG. 14 is another exemplary schematic diagram of the application program writing the rendering tree into the shared memory provided by the embodiment of the present application.
如图14所示,当应用程序保存有一个锁变量A时,在接收到垂直同步信号1(Vsync-APP)后,由应用程序持有锁变量A,并在持有阶段将生成的渲染树写入共享内存中。在应用程序将渲染树写入共享内存后,释放锁变量A。UniRender进程在确定锁变量A被应用程序释放后,持有锁变量A,开始从共享内存中读取应用程序响应于垂直同步信号1生成的渲染树。As shown in Figure 14, when the application saves a lock variable A, after receiving the vertical synchronization signal 1 (Vsync-APP), the application holds the lock variable A, and in the holding phase, the generated rendering tree written to shared memory. After the application writes the render tree to shared memory, release the lock variable A. After the UniRender process determines that the lock variable A is released by the application program, it holds the lock variable A and starts to read the rendering tree generated by the application program in response to the
在UniRender进程持有锁变量A的时间内,应用程序收到垂直同步信号1后的垂直同步信号2(Vsync-APP),由于锁变量A被UniRender持有,应用程序不能及时的将渲染树写入共享内存中,需要等待一段时间直到应用程序确定UniRender进程释放锁A。During the time when the UniRender process holds the lock variable A, the application program receives the vertical synchronization signal 2 (Vsync-APP) after the
但是,很显然的,在图13中内容,UniRender进程读取current displaylist字段、current properties字段,而应用程序写入staging displaylist字段、stagingproperties字段,可以通过增加锁变量的个数实现共享内存中不同字段的并发读写。However, it is obvious that in Figure 13, the UniRender process reads the current displaylist field and the current properties field, while the application program writes the staging displaylist field and the stagingproperties field. You can realize different fields in the shared memory by increasing the number of lock variables concurrent read and write.
如图14所示,当应用程序保存有两个锁变量B时,在接收到垂直同步信号1(Vsync-APP)后,由应用程序持有锁变量A,并在持有阶段将生成的渲染树写入共享内存中。在应用程序将渲染树写入共享内存后,释放锁变量A。UniRender进程在确定锁变量A被应用程序释放后,持有锁变量,开始从共享内存中读取应用程序响应于垂直同步信号1生成的渲染树。As shown in Figure 14, when the application saves two lock variables B, after receiving the vertical synchronization signal 1 (Vsync-APP), the application holds the lock variable A, and the generated rendering The tree is written to shared memory. After the application writes the render tree to shared memory, release the lock variable A. After the UniRender process determines that the lock variable A is released by the application program, it holds the lock variable and starts to read the rendering tree generated by the application program in response to the
在UniRender进程持有锁变量A的时间内,应用程序收到垂直同步信号1后的垂直同步信号2(Vsync-APP),此时持有锁变量B,应用程序可以及时的将渲染树写入共享内存中,不需要等待一段时间直到应用程序确定UniRender进程释放锁A。During the time when the UniRender process holds the lock variable A, the application program receives the vertical synchronization signal 2 (Vsync-APP) after the
对应的,UniRender进程在确定锁变量B被应用程序释放后,持有锁变量B,开始从共享内存中读取应用程序响应于垂直同步信号2生成的渲染树。Correspondingly, after the UniRender process determines that the lock variable B is released by the application program, it holds the lock variable B and starts to read the rendering tree generated by the application program in response to the
值得说明的是,应用程序持有锁变量的个数可以与共享内存中NODES字段中包括的内容有关,或者可以与Vsync-offset的值有关。It should be noted that the number of lock variables held by the application program may be related to the content included in the NODES field in the shared memory, or may be related to the value of Vsync-offset.
例如,认为current displaylist、current properties为第一组、stagingdisplaylist、staging properties为第二组,则可以在应用程序和UniRender进程中配置两个同步锁变量。类似的,又例如,NODES字段中包括三组数据,则可以在则可以在应用程序和UniRender进程中配置三个同步锁变量。For example, consider the current displaylist and current properties as the first group, and the stagingdisplaylist and staging properties as the second group, then you can configure two synchronization lock variables in the application and UniRender processes. Similarly, for another example, if the NODES field includes three sets of data, then three synchronization lock variables can be configured in the application program and the UniRender process.
其中,一个锁变量与一组数据对应,例如,锁变量A与current displaylist、current properties对应,则锁变量A从持有状态到释放状态的变化表示应用程序成功更新共享内存中current displaylist、current properties的数据,current displaylist、current properties的数据可以被UniRender进程读取;或者,锁变量A从持有状态到释放状态的变化表示UniRender进程以及从共享内存中完成对current displaylist、currentproperties的数据的读取,current displaylist、current properties的数据可以被应用程序更新。Among them, a lock variable corresponds to a set of data. For example, lock variable A corresponds to current displaylist and current properties, and the change of lock variable A from the holding state to the release state indicates that the application successfully updates the current displaylist and current properties in the shared memory. The data of the current displaylist and current properties can be read by the UniRender process; or, the change of the lock variable A from the holding state to the release state indicates that the UniRender process and the reading of the data of the current displaylist and current properties are completed from the shared memory , the data of current displaylist and current properties can be updated by the application.
其中,锁变量的个数可以与Vsync-offset的值有关。Wherein, the number of lock variables may be related to the value of Vsync-offset.
即,可以与垂直同步信号(Vsync-APP)与垂直同步信号(Vsync-UR)的差值Vsync-offset有关。在Vsync-offset较大的情况下,可以不配置锁变量。在不配置锁变量的情况下,UniRender进程在接收到垂直同步信号(Vsync-UR)后,从共享内存中读取渲染树。由于Vsync-offset较大,故在UniRender进程读取渲染树的时刻,应用程序已经完整的将渲染树写入到共享内存中。That is, it may be related to the difference Vsync-offset between the vertical synchronization signal (Vsync-APP) and the vertical synchronization signal (Vsync-UR). If the Vsync-offset is large, the lock variable may not be configured. In the case of not configuring the lock variable, the UniRender process reads the rendering tree from the shared memory after receiving the vertical synchronization signal (Vsync-UR). Due to the large Vsync-offset, when the UniRender process reads the rendering tree, the application has completely written the rendering tree into the shared memory.
S803:基于获得的渲染树生成目标渲染树。S803: Generate a target rendering tree based on the obtained rendering tree.
其中,UniRender进程可以在接收到垂直同步信号(Vsync-UR)后,开始从共享内存中读取渲染树,并在获取到一个或多个渲染树后开始进行渲染树的合成。或者,UniRender进程可以在持有锁变量,开始从共享内存中读取渲染树,并在接收到垂直同步信号(Vsync-UR),开始进行渲染树的合成。Among them, the UniRender process can start to read the rendering tree from the shared memory after receiving the vertical synchronization signal (Vsync-UR), and start to synthesize the rendering tree after obtaining one or more rendering trees. Or, the UniRender process can start to read the rendering tree from the shared memory while holding the lock variable, and start compositing the rendering tree after receiving the vertical synchronization signal (Vsync-UR).
在UniRender进程接收到的渲染树的数量为一个的情况下,则该渲染树为目标渲染树;在UniRender进程接收到的渲染树的数量多于一个的情况下,对多个的渲染树进行合成以生成目标渲染树。When the number of rendering trees received by the UniRender process is one, the rendering tree is the target rendering tree; when the number of rendering trees received by the UniRender process is more than one, multiple rendering trees are synthesized to generate a target render tree.
图15为本申请实施例提供的渲染树合成为目标渲染树的一个示例性示意图。FIG. 15 is an exemplary schematic diagram of synthesizing a rendering tree into a target rendering tree according to an embodiment of the present application.
如图15所示,UniRender进程可以新建一个根渲染节点,如图15中的新根渲染节点,并将多个应用程序的处理后的渲染树作为根渲染节点的子节点。即,根渲染节点可以保存有不同的应用程序的处理后的渲染树的父子关系,可以使得UniRender进程从根渲染节点遍历目标渲染树找到不同的应用程序的处理后的渲染树。As shown in Figure 15, the UniRender process can create a new root rendering node, such as the new root rendering node in Figure 15, and use the processed rendering trees of multiple applications as child nodes of the root rendering node. That is, the root rendering node can store the parent-child relationship of the processed rendering trees of different applications, so that the UniRender process can traverse the target rendering tree from the root rendering node to find the processed rendering trees of different applications.
图16为本申请实施例提供的渲染树合成为目标渲染树的另一个示例性示意图。FIG. 16 is another exemplary schematic diagram of synthesizing a rendering tree into a target rendering tree according to an embodiment of the present application.
UniRender进程可以先根据窗口管理服务确定不同应用程序对应的图层的Z序,即确定应用程序的图层之间的上下遮蔽关系。进而,在生成目标渲染树的过程中,将被完全遮蔽的view对应的渲染节点删除,进而降低在步骤S905中生成位图过程中的计算量,提高位图的生成速度。The UniRender process can first determine the Z order of the layers corresponding to different applications according to the window management service, that is, determine the upper and lower masking relationships between the layers of the applications. Furthermore, in the process of generating the target rendering tree, the rendering nodes corresponding to the completely occluded views are deleted, thereby reducing the amount of calculation in the process of generating the bitmap in step S905 and increasing the generation speed of the bitmap.
例如,如图16所示,应用程序1生成的渲染树对应的图层为图层1,应用程序2生成的渲染树对应的图层为图层2。其中,图层1的Z序高于图层2的Z序。其中,图层1对应的渲染树为根渲染节点1、渲染节点1、渲染节点2、渲染节点3,渲染节点1和渲染节点2是根渲染节点1的子渲染节点,渲染节点3是渲染节点2的子渲染节点;图层2对应的渲染树为根渲染节点2、渲染节点4、渲染节点5、渲染节点6,渲染节点4和渲染节点5是新根渲染节点的子渲染节点,渲染节点6是渲染节点5的子渲染节点。For example, as shown in FIG. 16 , the layer corresponding to the rendering tree generated by
UniRender进程可以遍历的图层1对应的渲染树的渲染子节点以及图层2对应的渲染树的子节点,确定每个渲染节点对应的view在(UniRender进程分配的surface)surface中的位置,并结合图层1的图层Z序,图层2的Z序,确定被完全遮蔽的view,以及该被完全遮蔽view的渲染节点。The UniRender process can traverse the rendering sub-nodes of the rendering tree corresponding to
例如,UniRender可以确定图层2的对应的渲染树中的渲染节点6对应的view被完全遮蔽,进而将渲染节点6删除。For example, UniRender can determine that the view corresponding to
UniRender进程在删除被完全遮蔽的view对应的渲染节点后,可以按照如图16所示的内容将所有的触发离屏渲染指令前移处理后的渲染树合并为目标渲染树。After the UniRender process deletes the rendering node corresponding to the completely occluded view, it can merge all rendering trees that trigger off-screen rendering instructions into the target rendering tree as shown in Figure 16.
可选的,在本申请一些实施例中,UniRender还可以遍历渲染节点,从DrawOP绘制操作的粒度去优化目标渲染树的参数。例如,删除掉不影响界面的DrawOP绘制操作,其中不影响可以是DrawOP绘制操作绘制的图形不在界面上显示;又例如,对于不同应用程序,修改DrawOP操作在绘制节点中的位置,使得相同类型的DrawOP绘制操作可以一起执行,比如将应用程序1的渲染节点2的DrawOP绘制操作修改到应用程序2的渲染节点1的绘制指令列表中,在此不作限定。Optionally, in some embodiments of the present application, UniRender can also traverse the rendering nodes, and optimize the parameters of the target rendering tree from the granularity of the DrawOP drawing operation. For example, delete the DrawOP drawing operation that does not affect the interface, which may mean that the graphics drawn by the DrawOP drawing operation are not displayed on the interface; for another example, for different applications, modify the position of the DrawOP operation in the drawing node so that the same type The DrawOP drawing operations can be performed together, for example, modifying the DrawOP drawing operation of the
可选的,在本申请一些实施例中,在步骤S804后,在步骤S805前,UniRender进程生成目标渲染树后对RenderNode的绘制指令列表中进行解封装得到一系列DrawOP,进而将目标渲染树作为整体进行DrawOP操作进行次批次(Batch)和合并(Merge),在步骤S805中得到使用更少计算量就可以生成位图的目标渲染树。Optionally, in some embodiments of the present application, after step S804 and before step S805, after the UniRender process generates the target rendering tree, it decapsulates the RenderNode drawing instruction list to obtain a series of DrawOPs, and then uses the target rendering tree as The DrawOP operation is performed as a whole to perform batch (Batch) and merge (Merge), and in step S805 , a target rendering tree that can generate a bitmap with less computation is obtained.
可以理解的是,通过合并多个渲染树并且对合并后的渲染树进行优化,可以避免或者减少过渡绘制,进而提高步骤S905中生成位图的速度,节约电子设备的功耗,提升用户的体验。It can be understood that by merging multiple rendering trees and optimizing the merged rendering trees, transitional rendering can be avoided or reduced, thereby increasing the speed of bitmap generation in step S905, saving power consumption of electronic devices, and improving user experience .
值得说明的是,UniRender进程还可以在生成目标渲染树的过程中,对目标渲染树的其他参数进行优化,在此不作限定。It is worth noting that the UniRender process can also optimize other parameters of the target rendering tree during the process of generating the target rendering tree, which is not limited here.
S804:生成位图,并完成动画渲染S804: Generate a bitmap and complete animation rendering
UniRender进程在生成目标渲染树后,可以执行渲染树中绘制指令列表中的绘制操作,在UniRender进程为多个应用分配的surface中生成位图的过程中,并在生成位图的过程中完成该位图的动画渲染。其中,该位图承载有一个或多个应用程序的图像信息。After the UniRender process generates the target rendering tree, it can execute the drawing operation in the drawing instruction list in the rendering tree, and complete the process of generating bitmaps in the surface allocated by the UniRender process for multiple applications. Animated rendering of bitmaps. Wherein, the bitmap bears image information of one or more application programs.
其中,该surface可以是与显示区域(display)的大小相同。即surface可以与电子设备的屏幕大小相同。例如,在图6A和图6B所示的场景中,surface的大小与屏幕的大小一致。其中,该surface可以位于在屏缓冲上。Wherein, the surface may be the same size as the display area (display). That is, the surface can be the same size as the screen of the electronic device. For example, in the scenes shown in Figures 6A and 6B, the size of the surface is consistent with the size of the screen. Wherein, the surface can be located on the screen buffer.
图17为本申请实施例提供的在生成位图过程中完成动画渲染的一个示例性示意图。FIG. 17 is an exemplary schematic diagram of animation rendering in the process of generating a bitmap provided by the embodiment of the present application.
如图17所示,UniRender进程通过IPC通信获取一个或多个应用程序的UI线程生成的渲染树后,将一个或多个渲染树合成为目标渲染树,然后通过底层图形库调用GPU执行目标渲染树中的绘制指令列表的绘制操作生成位图,并在生成位图的过程中完成动画渲染。As shown in Figure 17, after the UniRender process obtains the rendering tree generated by the UI thread of one or more applications through IPC communication, it synthesizes one or more rendering trees into a target rendering tree, and then calls the GPU to perform target rendering through the underlying graphics library The drawing operation of the drawing instruction list in the tree generates a bitmap, and animation rendering is completed during the process of generating the bitmap.
下面,分别从动画是否跨窗口/跨应用程序,从两个方面示例性的介绍UniRender进程在生成位图的过程中进行动画渲染的方法。Next, from two aspects, whether the animation is cross-window/cross-application or not, the method of animation rendering by the UniRender process in the process of generating bitmaps is exemplarily introduced.
(a)单应用程序内的动画(a) Animations within a single application
为了方便应用程序开发者开发,本申请实施例提供的界面生成方法,可以使得开发者为应用程序的任意一个view的属性配置不同的动画参数,如前景模糊、背景模糊等其他动画参数。对应的,应用程序的UI线程在生成渲染树的过程中,会在该view对应的渲染节点的渲染属性中增加动画参数。In order to facilitate the development of the application program developers, the interface generation method provided by the embodiment of the present application can enable the developers to configure different animation parameters for any view attribute of the application program, such as foreground blur, background blur and other animation parameters. Correspondingly, during the process of generating the rendering tree, the UI thread of the application will add animation parameters to the rendering properties of the rendering node corresponding to the view.
其中,UniRender进程能够识别与view的动画参数对应的渲染树中渲染节点的渲染属性中的动画参数,并执行对应的动画渲染操作。或者,UniRender进程能为目标渲染树中的任一个渲染节点的渲染属性增加动画参数。Wherein, the UniRender process can identify the animation parameters in the rendering properties of the rendering node in the rendering tree corresponding to the animation parameters of the view, and execute the corresponding animation rendering operation. Alternatively, the UniRender process can add animation parameters to the rendering properties of any rendering node in the target rendering tree.
即动画参数为应用程序开发者可以在view上配置的一个参数,或者为UniRender进程为渲染节点添加的一个参数,用于为界面上被选定的内容添加动画效果。That is, the animation parameter is a parameter that the application developer can configure on the view, or a parameter that the UniRender process adds to the rendering node, and is used to add animation effects to the selected content on the interface.
本申请实施例提供的界面生成方法,还为开发者提供BlurView,BlurView所覆盖的范围为动画生效的范围。其中,BlurView可以继承view,除了具有view所有可配置的属性外,还可以具有其他的属性。The interface generation method provided by the embodiment of the present application also provides developers with a BlurView, and the range covered by the BlurView is the range where the animation takes effect. Among them, BlurView can inherit view, and besides all configurable properties of view, it can also have other properties.
UniRender进程能够识别BlurView在渲染树中的对应的渲染节点,并执行对应的动画渲染操作。该动画渲染操作包括:UniRender进程会将BlurView覆盖范围内的surface上已经绘制的内容拷贝到离屏缓冲中进行动画渲染,然后在拷贝回surface上,或者直接拷贝至在屏缓冲中。The UniRender process can identify the corresponding rendering node of BlurView in the rendering tree, and execute the corresponding animation rendering operation. The animation rendering operation includes: the UniRender process will copy the drawn content on the surface covered by BlurView to the off-screen buffer for animation rendering, and then copy it back to the surface, or directly copy it to the on-screen buffer.
①UniRender进程可以为该应用程序的位图分配一个surface,UniRender进程基于目标渲染树,不断往该surface上绘制该应用程序的view以生成该应用程序的位图。①The UniRender process can allocate a surface for the bitmap of the application, and the UniRender process continuously draws the view of the application on the surface based on the target rendering tree to generate the bitmap of the application.
②当UniRender进程绘制到具有动画参数的渲染节点时,在该动画参数为缩放、简单颜色改变、透明度改变等参数的情况下,会对应的修改该渲染节点中绘制指令列表中的绘制操作的参数,然后执行该绘制操作以实现动画渲染。②When the UniRender process draws to a rendering node with animation parameters, if the animation parameters are parameters such as scaling, simple color change, and transparency change, the parameters of the drawing operation in the drawing command list in the rendering node will be modified accordingly , and then perform that drawing operation for animation rendering.
例如,渲染节点的渲染属性的动画参数为放大2倍,该渲染节点的绘制指令列表中包括DrawCircleOp((x0,y0),3),则UniRender进程在执行绘制操作时,会将DrawCircleOp((x0,y0),3)转换为DrawCircleOp((x0,y0),6)后,执行DrawCircleOp((x0,y0),6)。For example, if the animation parameter of the render attribute of the render node is magnified by 2 times, and the drawing command list of the render node includes DrawCircleOp((x0, y0), 3), then the UniRender process will drawCircleOp((x0) when performing the drawing operation , y0), 3) after converting to DrawCircleOp((x0, y0), 6), execute DrawCircleOp((x0, y0), 6).
其中,DrawCircleOp((x0,y0),3)为:在(x0,y0)为圆心处绘制一个半径为3的圆;DrawCircleOp((x0,y0),6)为:在(x0,y0)为圆心处绘制一个半径为6的圆。Among them, DrawCircleOp((x0, y0), 3) is: draw a circle with a radius of 3 at the center of (x0, y0); DrawCircleOp((x0, y0), 6) is: at (x0, y0) is Draw a circle with a radius of 6 at the center.
在该动画参数为滤镜效果,如模糊(高斯模糊、径向模糊、镜头模糊等)、锐化、扭曲、风格化(如浮雕效果、油画效果、3D效果等)、镜头光晕、添加杂色等参数时,UniRender进程会开启离屏渲染,将该渲染节点位置上的内容拷贝到离屏缓冲中,进行动画渲染后,再拷贝回surface上。The animation parameters are filter effects, such as blur (Gaussian blur, radial blur, lens blur, etc.), sharpening, distortion, stylization (such as embossing effect, oil painting effect, 3D effect, etc.), lens flare, adding noise, etc. When the color and other parameters are selected, the UniRender process will start off-screen rendering, copy the content at the position of the rendering node to the off-screen buffer, perform animation rendering, and then copy it back to the surface.
③继续绘制以生成位图。③ Continue to draw to generate a bitmap.
下面以滤镜效果为前景模糊、背景模糊为例,示例性的介绍UniRender进程动画渲染的过程。The following takes the foreground blur and background blur as the filter effect as an example to introduce the animation rendering process of the UniRender process.
图18A为本申请实施例提供的前景模糊实现的一个示例性示意图。FIG. 18A is an exemplary schematic diagram of the implementation of foreground blur provided by the embodiment of the present application.
如图18A所示,UniRender进程在基于渲染树生成位图的过程中,当遍历到渲染属性包括动画参数的渲染节点时,如RenderNode3,首先确定动画参数的种类,例如确定为前景模糊。其中,RenderNode3对应的view为view3。As shown in FIG. 18A, when the UniRender process traverses to a rendering node whose rendering attribute includes animation parameters, such as RenderNode3, during the process of generating a bitmap based on the rendering tree, it first determines the type of the animation parameter, for example, it is determined as blurred foreground. Among them, the view corresponding to RenderNode3 is view3.
UniRender进程在确定动画参数为前景模糊后,在离屏缓冲3中执行RenderNode3的绘制指令列表中的绘制操作,进而绘制出view3。After the UniRender process determines that the animation parameter is blurred foreground, it executes the drawing operation in the drawing instruction list of RenderNode3 in the off-
UniRender进程对离屏缓冲中的内容进行动画渲染,即进行模糊渲染,生成的内容称为view31。然后,UniRender进程拷贝离屏缓冲中的内容到surface上,并继续遍历渲染树的其他节点。The UniRender process performs animation rendering on the content in the off-screen buffer, that is, blur rendering, and the generated content is called view31. Then, the UniRender process copies the contents of the off-screen buffer to the surface, and continues to traverse other nodes of the rendering tree.
其中,离屏缓冲的大小可以与view3的大小一致,其中UniRender进程可以从RenderNode3的属性中确定view3的大小。Wherein, the size of the off-screen buffer can be consistent with the size of view3, and the UniRender process can determine the size of view3 from the attribute of RenderNode3.
图18B为本申请实施例提供的背景模糊实现的一个示例性示意图。FIG. 18B is an exemplary schematic diagram of the implementation of background blur provided by the embodiment of the present application.
如图18B所示,UniRender进程在基于渲染树生成位图的过程中,当遍历到渲染属性包括动画参数的渲染节点时,如RenderNode3,首先确定动画参数的种类,例如确定为背景模糊。其中,RenderNode3对应的view为view3。As shown in FIG. 18B , in the process of generating bitmaps based on the rendering tree, when the UniRender process traverses to a rendering node whose rendering attributes include animation parameters, such as RenderNode3, it first determines the type of animation parameters, for example, background blur. Among them, the view corresponding to RenderNode3 is view3.
UniRender进程在确定动画参数为背景模糊后,将surface上view3位置的内容拷贝到离屏缓冲中,并且对离屏缓冲中的内容进行动画渲染,即进行模糊渲染。After the UniRender process determines that the animation parameter is background blur, it copies the content at the position of view3 on the surface to the off-screen buffer, and performs animation rendering on the content in the off-screen buffer, that is, performs blur rendering.
然后,UniRender进程拷贝离屏缓冲中的内容到surface上,并执行RenderNode3的绘制指令列表,在surface上继续绘制view3。Then, the UniRender process copies the content in the off-screen buffer to the surface, executes the drawing command list of RenderNode3, and continues to draw view3 on the surface.
UniRender进程继续遍历渲染树的其他节点。The UniRender process continues to traverse other nodes of the render tree.
其中,在绘制view3前,UniRender进程拷贝到离屏缓冲中surface上view3位置的内容为view3的背景。Among them, before drawing view3, the content copied by the UniRender process to the position of view3 on the surface in the off-screen buffer is the background of view3.
可选的,在本申请一些实施例中,在应用程序生成的渲染树依照的参考坐标系与UniRender进程分配的surface的参考坐标系不一致的情况下,UniRender进程在收到应用程序的渲染树后,还会在渲染树的渲染属性中增加坐标变换指令。例如,UniRender进程会将DrawCircleOp((x0,y0),3)转换为DrawCircleOp((x1,y1),3)。Optionally, in some embodiments of the present application, when the reference coordinate system according to which the rendering tree generated by the application program is inconsistent with the reference coordinate system of the surface allocated by the UniRender process, after the UniRender process receives the rendering tree of the application program , will also add coordinate transformation instructions in the rendering attributes of the rendering tree. For example, the UniRender process will convert DrawCircleOp((x0, y0), 3) to DrawCircleOp((x1, y1), 3).
(b)跨应用/跨窗口的动画(b) Cross-app/cross-window animation
跨应用/跨窗口的动画的实现方式与单应用程序的动画的实现方式相同的内容可以参考上文中的文字描述,此处不再赘述。The implementation of the cross-application/cross-window animation is the same as that of the single-application animation, which can be referred to the text description above, and will not be repeated here.
其一,UniRender进程为多个应用程序分配一个surface,并在该surface中生成多个应用程序的位图的过程中,完成该位图的动画渲染。其中,该surface可以位于在屏缓冲中。First, the UniRender process allocates a surface for multiple applications, and completes the animation rendering of the bitmap during the process of generating bitmaps of multiple applications in the surface. Wherein, the surface can be located in the screen buffer.
其二:UniRender进程可以在surface上的任意位置插入一个surface,和/或在目标渲染树中的任意渲染节点之间插入BlurView;UniRender进程也可以识别应用程序的BlurView。其中,该BlurView覆盖的范围为进行动画渲染的内容。Second: The UniRender process can insert a surface anywhere on the surface, and/or insert a BlurView between any rendering nodes in the target rendering tree; the UniRender process can also recognize the BlurView of the application. Wherein, the range covered by the BlurView is the content for animation rendering.
图19为本申请实施例提供的跨应用/跨窗口动画渲染的一个示例性示意图。FIG. 19 is an exemplary schematic diagram of cross-application/cross-window animation rendering provided by the embodiment of the present application.
如图19所示,跨应用/跨窗口的动画渲染可以包括如下三步:As shown in Figure 19, cross-application/cross-window animation rendering may include the following three steps:
①首先,UniRender进程在遍历执行目标渲染树的绘制指令列表后,在surface中生成一个位图,该位图承载有一个或多个应用程序的图像信息。① First, the UniRender process generates a bitmap in the surface after traversing the drawing instruction list of the execution target rendering tree, and the bitmap carries the image information of one or more applications.
②其次,UniRender进程在surface上添加BlurView,将BlurView位置上的内容拷贝到该离屏缓冲中。②Secondly, the UniRender process adds BlurView to the surface, and copies the content at the position of BlurView to the off-screen buffer.
③最后,UniRender进程对离屏缓冲的内容进行动画渲染,并将离屏缓冲中的内容拷贝回surface上。③ Finally, the UniRender process animates and renders the content of the off-screen buffer, and copies the content in the off-screen buffer back to the surface.
其中,离屏缓冲中的内容与surface上原有内容的叠加可以认为是一种图层合成,即,离屏缓冲中的内容可以覆盖surface上的内容,或者,离屏缓冲中的内容可以surface上的内容进行多种方式的叠加。Among them, the superposition of the content in the off-screen buffer and the original content on the surface can be considered as a kind of layer synthesis, that is, the content in the off-screen buffer can cover the content on the surface, or the content in the off-screen buffer can be on the surface The content is superimposed in various ways.
图20为本申请实施例提供的跨应用/跨窗口动画渲染的另一个示例性示意图。FIG. 20 is another exemplary schematic diagram of cross-application/cross-window animation rendering provided by the embodiment of the present application.
如图20所示,跨应用/跨窗口的动画渲染可以包括如下三步:As shown in Figure 20, cross-application/cross-window animation rendering may include the following three steps:
①首先,UniRender进程在遍历执行目标渲染树的绘制指令列表的过程中,可以在渲染树的任意层次上添加BlurView对应的渲染节点(如图20所示)。或者,UniRender进程在遍历执行目标渲染树的绘制指令列表的过程中,可以识别出应用程序的BlurView对应的渲染节点。① First, the UniRender process can add a rendering node corresponding to BlurView at any level of the rendering tree during the process of traversing the drawing instruction list of the execution target rendering tree (as shown in Figure 20). Alternatively, the UniRender process may identify the rendering node corresponding to the BlurView of the application program during the process of traversing the drawing instruction list of the execution target rendering tree.
在BlurView不是目标渲染树的根节点的情况下,UniRender进程会先在surface上执行绘制操作,生成位图。When BlurView is not the root node of the target rendering tree, the UniRender process will first perform drawing operations on the surface to generate a bitmap.
②其次,UniRender进程在离屏缓冲中绘制BlurView的子节点。UniRender进程在绘制完所有BlurView的子节点后,将离屏缓冲中的内容进行动画渲染,并在动画渲染后拷贝回surface上。②Secondly, the UniRender process draws the child nodes of BlurView in the off-screen buffer. After the UniRender process draws all the sub-nodes of BlurView, the content in the off-screen buffer is animated and rendered, and copied back to the surface after the animation is rendered.
③最后,UniRender进程继续遍历目标渲染树,完成位图的绘制。③ Finally, the UniRender process continues to traverse the target rendering tree to complete the drawing of the bitmap.
值得说明的是,应用程序指定的BlurView的位置和大小可以是依据UniRender进程的surface的坐标系生成的,也可以是依据其他坐标系生成的,在此不做限定。It is worth noting that the position and size of the BlurView specified by the application can be generated based on the coordinate system of the surface of the UniRender process, or based on other coordinate systems, which are not limited here.
可选的,在本申请一些实施例中,BlurView还可以被配置有sigma属性,在不同的动画渲染中代表不同的意义。例如,在动画渲染为模糊渲染的情况下,sigma表示模糊程度,取值范围为整数,当sigma=0的时候,BlurView不生效,即不做模糊。其中,模糊程度的定义可以参考(c)模糊动画渲染中的内容,此处不再赘述。Optionally, in some embodiments of the present application, BlurView may also be configured with a sigma attribute, which represents different meanings in different animation renderings. For example, when animation rendering is blurred rendering, sigma represents the degree of blurring, and the value range is an integer. When sigma=0, BlurView does not take effect, that is, no blurring is performed. Wherein, the definition of blur degree can refer to the contents in (c) blur animation rendering, which will not be repeated here.
(c)模糊动画渲染(c) Fuzzy animation rendering
在本申请实施例中,仅需要被动画渲染的内容已经拷贝到离屏缓冲中,或者直接绘制在离屏缓冲中,可以对离屏缓冲中的内容进行动画渲染。In the embodiment of the present application, only the content that needs to be rendered by animation has been copied to the off-screen buffer, or directly drawn in the off-screen buffer, and animation rendering can be performed on the content in the off-screen buffer.
下面以动画为模糊为例,示例性的介绍模糊渲染的过程。The following takes animation as blur as an example to introduce the process of blur rendering.
本申请实施例提供多种模糊程度的模糊渲染,其中模糊程度越低,模糊后的像素的值越接近模糊前的像素的值。The embodiment of the present application provides blurred rendering with various degrees of blurring, wherein the lower the degree of blurring is, the closer the value of the pixel after blurring is to the value of the pixel before blurring.
本申请实施例提供多种精度的模糊渲染,为了方便描述,分别称为高精度的模糊渲染、中精度的模糊渲染、低精度的模糊渲染。本申请实施例在不同精度的模糊渲染下,还提供了不同模糊半径的模糊渲染。The embodiments of the present application provide multiple precision blur renderings, which are respectively referred to as high-precision blur rendering, medium-precision blur rendering, and low-precision blur rendering for convenience of description. The embodiments of the present application also provide blur rendering with different blur radii under blur rendering with different precisions.
其中,模糊程度、模糊精度、模糊半径可以由应用程序或者UniRender进程配置。其中,应用程序配置模糊程度、模糊精度、模糊半径可以通过配置BlurView的属性实现,该BlurView的属性会被封装到该BlurView对应的渲染节点的渲染属性中,进而被UniRender进程获取。当应用程序没有配置BlurView的模糊程度、模糊精度、模糊半径等动画参数,则UniRender进程可以自适应的配置BlurView的模糊程度、模糊精度、模糊半径等动画参数。Among them, the blur degree, blur precision, and blur radius can be configured by the application program or the UniRender process. Among them, the application can configure the blur degree, blur precision, and blur radius by configuring BlurView properties, and the BlurView properties will be encapsulated into the rendering properties of the rendering node corresponding to the BlurView, and then obtained by the UniRender process. When the application program does not configure animation parameters such as blur degree, blur precision, and blur radius of BlurView, the UniRender process can adaptively configure animation parameters such as blur degree, blur precision, and blur radius of BlurView.
本申请实施例提供UniRender进程可以根据当前GPU的负载、GPU的能力,选择不同精度的动画渲染。例如,当电子设备的GPU负载较高时,则选择精度较低的动画渲染;当电子设备的GPU负载较低时,选择高精度的动画渲染。The embodiment of the present application provides that the UniRender process can select animation rendering with different precisions according to the current GPU load and GPU capability. For example, when the GPU load of the electronic device is high, animation rendering with low precision is selected; when the GPU load of the electronic device is low, animation rendering with high precision is selected.
图21为本申请实施例提供的模糊渲染对像素处理的一个示例性示意图。FIG. 21 is an exemplary schematic diagram of pixel processing by blur rendering provided by the embodiment of the present application.
模糊作为一种动画,可以将图像中的每个像素的值进行重置,其中,每个像素重置后的值与该像素重置前该像素周边的像素的值有关。Blur is an animation that resets the value of each pixel in the image, where the value of each pixel after reset is related to the value of the surrounding pixels before the pixel is reset.
例如,如图21所示,模糊前的位图为bitmapA,其中,bitmapA的分辨率为8*8,即每行有8个像素,每列有8个像素,即bitmapA中共有64个像素,分别为A11、A12至A88。For example, as shown in Figure 21, the bitmap before blurring is bitmapA, where the resolution of bitmapA is 8*8, that is, each row has 8 pixels, and each column has 8 pixels, that is, there are 64 pixels in bitmapA. are A 11 , A 12 to A 88 , respectively.
电子设备对bitmapA进行模糊渲染后,生成bitmapB。其中,bitmapB可以与bitmapA的分辨率相同,或者可以与bitmapA的分辨率相同。若,生成bitmapB与bitmapA的分辨率不同,则可以通过降采样、插值使得bitmapB的分辨率与bitmapA相同。The electronic device generates bitmapB after blurring bitmapA. Wherein, bitmapB may have the same resolution as bitmapA, or may have the same resolution as bitmapA. If the resolutions of generated bitmapB and bitmapA are different, downsampling and interpolation can be used to make the resolution of bitmapB the same as that of bitmapA.
电子设备生成bitmapB后,bitmapB中的任一个像素的值与bitmapA中的多个像素值有关。After the electronic device generates bitmapB, the value of any pixel in bitmapB is related to multiple pixel values in bitmapA.
例如,对bitmapB中的像素Bij,其生成过程如下式(1):For example, for pixel B ij in bitmapB, its generation process is as follows (1):
式(1)中,k(r(i,j,k,l))为与距离r(i,j,k,l)有关的系数,其中r(i,j,k,l)表示与(i,j)与(k,l)的距离,Akl为第k行第l列的像素,Bij为第i行第j列的像素。In formula (1), k(r(i,j,k,l)) is the coefficient related to the distance r(i,j,k,l), where r(i,j,k,l) means the distance with ( The distance between i, j) and (k, l), A kl is the pixel in row k and column l, and B ij is the pixel in row i and column j.
其中,k(r(i,j,k,l))可以与配置的模糊半径有关,例如,当r(i,j,k,l)>模糊半径时,k(r(i,j,k,l))=0。即,若Akl与Bij的距离大于模糊半径,则Bij的像素的值不会受到Akl的像素的值影响。Among them, k(r(i,j,k,l)) can be related to the configured blur radius, for example, when r(i,j,k,l)>blur radius, k(r(i,j,k ,l))=0. That is, if the distance between A kl and B ij is greater than the blur radius, the value of the pixel of B ij will not be affected by the value of the pixel of A kl .
例如,模糊半径为2,则B45=avg(A45+0.5*(A35+A44+A46+A55)+0.3*(A34+A36+A54+A56)),其中avg()为取平均数。For example, if the blur radius is 2, then B 45 =avg(A45+0.5*(A35+A44+A46+A55)+0.3*(A34+A36+A54+A56)), where avg() is the average.
其中,k(0)与模糊程度有关。例如,k(0)=1的情况下,B45=avg(A45+0.5*(A35+A44+A46+A55)+0.3*(A34+A36+A54+A56)),k(0)=2的情况下,B45=avg(2*A45+0.5*(A35+A44+A46+A55)+0.3*(A34+A36+A54+A56))。则,k(0)的数值越小,模糊程度越大。Among them, k(0) is related to the degree of blur. For example, when k(0)=1, B 45 =avg(A45+0.5*(A35+A44+A46+A55)+0.3*(A34+A36+A54+A56)), k(0)=2 In the case of B 45 =avg(2*A45+0.5*(A35+A44+A46+A55)+0.3*(A34+A36+A54+A56)). Then, the smaller the value of k(0), the larger the degree of blur.
当k(r(i,j,k,l))的取值与距离之间为高斯函数关系的情况下,则可以实现高斯模糊。When the relationship between the value of k(r(i,j,k,l)) and the distance is a Gaussian function, Gaussian blur can be realized.
考虑到,被模糊的bitmapA中靠近边缘的像素如A18,在模糊渲染时,需要bitmapA外的内容,故从在屏缓冲中拷贝被模糊的内容到离屏缓冲时,可以扩大被拷贝的内容,已实现效果更好的模糊。Considering that the pixels close to the edge of the blurred bitmapA, such as A 18 , need the content outside the bitmapA during blur rendering, so when copying the blurred content from the screen buffer to the off-screen buffer, the copied content can be enlarged , a better blur has been implemented.
图22A、图22B为本申请实施例提供的模糊动画的一个示例性示意图。FIG. 22A and FIG. 22B are exemplary schematic diagrams of the blur animation provided by the embodiment of the present application.
如图22A所示,电子设备在确定BlurView后,根据模糊半径以及BlurView确定BlurView1的大小,然后将BluerView1的划定范围内的内容拷贝到离屏缓冲中。在对离屏缓冲中BlurView中的内容进行模糊后,将模糊后的BlurView划定范围内的内容拷贝到在屏缓冲中。As shown in FIG. 22A , after determining BlurView, the electronic device determines the size of BlurView1 according to the blur radius and BlurView, and then copies the content within the defined range of BlurView1 to the off-screen buffer. After blurring the content in the BlurView in the off-screen buffer, copy the content within the range defined by the blurred BlurView to the on-screen buffer.
如图22B所示,电子设备在获得需要模糊渲染的内容并将渲染渲染的内容拷贝到离屏缓冲后,首先对被模糊渲染的内容进行降采样,并对降采样后的位图进行模糊渲染;然后在得到模糊渲染后的位图后,进行插值已恢复位图的分辨率,进而拷贝回在屏缓冲中。As shown in Figure 22B, after the electronic device obtains the content that requires blur rendering and copies the rendered content to the off-screen buffer, it first down-samples the blurred content, and performs blur rendering on the down-sampled bitmap ; Then after getting the blurred rendered bitmap, perform interpolation to restore the resolution of the bitmap, and then copy it back to the screen buffer.
对于高精度的渲染,在降采样阶段可以通过一次或多次降采样(降采样倍率固定的情况下),并在模糊渲染时逐像素进行计算。最后,通过插值获得拷贝回在屏缓冲的位图。For high-precision rendering, one or more downsampling can be performed in the downsampling stage (when the downsampling ratio is fixed), and the calculation is performed pixel by pixel during blur rendering. Finally, the bitmap copied back to the screen buffer is obtained by interpolation.
对于中精度的渲染,在降采样阶段可以通过一次降采样(降采样倍率固定的情况下),并在模糊渲染时对任意像素的模糊时只计算与该像素同行和同列像素的对该像素的影响。例如,对于B45,只考虑A44、A45、A46、A35、A55的影响。最后,通过插值获得拷贝回在屏缓冲的位图。For medium-precision rendering, one downsampling can be performed in the downsampling stage (when the downsampling ratio is fixed), and when blurring any pixel during blur rendering, only calculate the pixels in the same row and column as the pixel. Influence. For example, for B 45 , only the effects of A 44 , A 45 , A 46 , A 35 , and A 55 are considered. Finally, the bitmap copied back to the screen buffer is obtained by interpolation.
对于低精度的渲染,可以不做降采样,并在模糊渲染时对任意像素的模糊时只计算与该像素同行和同列像素的对该像素的影响。最后,通过插值获得拷贝回在屏缓冲的位图。For low-precision rendering, downsampling may not be performed, and when blurring any pixel during blur rendering, only the influence of pixels in the same row and column as the pixel is calculated. Finally, the bitmap copied back to the screen buffer is obtained by interpolation.
值得说明的是,还可以任意组合降采样的次数、降采样是否执行、模糊渲染时模糊半径、模糊渲染时需要考虑的像素的多少等其他参数,进而实现不同精度的渲染,在此不做限定。It is worth noting that other parameters such as the number of times of downsampling, whether to perform downsampling, the blur radius during blur rendering, the number of pixels to be considered during blur rendering, and other parameters can also be combined arbitrarily to achieve rendering with different precision, which is not limited here. .
(3)再次,以图23A、图23B为例,介绍电子设备构通过动画渲染生成图4B所示界面的过程。(3) Again, taking FIG. 23A and FIG. 23B as examples, the process of generating the interface shown in FIG. 4B by the electronic device through animation rendering is introduced.
图23A、图23B为本申请实施例提供的跨应用/跨窗口界面动画效果实现的一个实例示意图。FIG. 23A and FIG. 23B are schematic diagrams of an example of the implementation of cross-application/cross-window interface animation effects provided by the embodiment of the present application.
①UniRender进程在生成目标渲染树后,可以遍历该目标渲染树中的绘制指令列表,在surface上绘制生成位图1。① After the UniRender process generates the target rendering tree, it can traverse the drawing instruction list in the target rendering tree, and draw the generated
其中,目标渲染树如图23B所示,目标渲染的根节点为1号节点,1号节点的子节点分别为2号节点、3号节点、4号节点、5号节点。其中,2号节点对应的view为壁纸应用程序的界面;3号节点用于确定3号节点的子节点对应的view的布局;4号节点为BlurView对应的渲染节点;5号节点用于确定5号节点的子节点对应的view的布局。3号节点的子节点为6号节点和7号节点,6号节点对应的内容为桌面应用程序上的“图库”的图标和文字;7号节点对应的内容为桌面应用程序上“拨号、信息、联系人”的图标和文字;8号节点对应的内容为图标控件4A01;9号节点对应的内容为控件栏4A02。Wherein, the object rendering tree is shown in FIG. 23B , the root node of the object rendering is
其中,UniRender进程遍历目标渲染树的顺序为:1号节点、2号节点、…、9号节点。Among them, the order of the UniRender process traversing the target rendering tree is:
其中,位图1可以只包括两个及两个以上应用程序的界面中需要被动画渲染的内容,或者是两个及两个以上应用程序的完整界面。Wherein, the
在图23A中,位图1为两个应用程序的界面中需要被动画渲染的内容。In FIG. 23A,
UniRender进程在遍历到4号节点时,确定4号节点为与BlurView对应的渲染节点后,UniRender进程根据BlurView的大小和范围确定需要被动画渲染的内容。When the UniRender process traverses to the No. 4 node, after determining that the No. 4 node is the rendering node corresponding to BlurView, the UniRender process determines the content to be rendered by animation according to the size and range of the BlurView.
在图23A中,BlurView的大小和范围覆盖整个surface。即被动画渲染的内容为位图1。In Figure 23A, BlurView is sized and bounded to cover the entire surface. That is, the content rendered by animation is
②UniRender进程开辟离屏缓冲,将BlurView覆盖的内容拷贝至离屏缓冲中;或者将在BlurView后绘制的内容直接绘制在离屏缓冲中。②The UniRender process creates an off-screen buffer, and copies the content covered by BlurView to the off-screen buffer; or directly draws the content drawn after BlurView in the off-screen buffer.
在图23A中,UniRender进程将位图1拷贝至离屏缓冲中,简称为位图2。In FIG. 23A, the UniRender process copies bitmap 1 to the off-screen buffer, which is referred to as
③UniRender进程对离屏缓冲中的内容进行动画渲染。其中,动画渲染包括模糊渲染。③The UniRender process performs animation rendering on the content in the off-screen buffer. Wherein, animation rendering includes fuzzy rendering.
在图23A中,UniRender进程对位图2进行模糊渲染,得到位图3。In FIG. 23A , the UniRender process performs blur rendering on
④UniRender进程将离屏缓冲中的内容给拷贝回surface上,并继续遍历目标渲染树。在遍历目标渲染树完成后,得到最终用于送显的位图4。④The UniRender process copies the content in the off-screen buffer back to the surface, and continues to traverse the target rendering tree. After traversing the target rendering tree, the
在图23A中,UniRender进程将位图3拷贝回surface上,并继续绘制,完成渲染,生成位图4。其中位图4会被UniRender进程传递给显示子系统以送显。In Figure 23A, the UniRender process copies bitmap 3 back to the surface, and continues to draw, completes rendering, and generates
可以理解的是,本申请实施提供的界面生成方法,可以通过一次连续的渲染(一次GPU调用),生成承载多个应用程序图像信息的位图,避免了图层合成过程对GPU的额外调用。It can be understood that the interface generation method provided by the implementation of this application can generate bitmaps carrying image information of multiple applications through one continuous rendering (one GPU call), avoiding additional calls to the GPU during the layer composition process.
可以理解的是,本申请实施例提供的界面生成方法,可以通过将应用程序的多个渲染树组合为目标渲染树,进而降低重复绘制的区域大小。It can be understood that, the interface generation method provided by the embodiment of the present application can reduce the size of the area for repeated drawing by combining multiple rendering trees of the application program into a target rendering tree.
可以理解的是,本申请实施例提供的view的动画参数以及BlurView,可以实现任意控件、任意区域的动画渲染,降低应用开发者的工作量。It can be understood that the animation parameters of the view and the BlurView provided in the embodiment of the present application can implement animation rendering of any control and any area, reducing the workload of application developers.
值得说明的是,UniRender进程接收到的应用程序的渲染树不局限于RenderNode以树形结构耦合的数据结构体,还可以是包括绘制指令列表和渲染属性的其他数据结构体,在此不做限定。It is worth noting that the rendering tree of the application received by the UniRender process is not limited to the data structure coupled by RenderNode in a tree structure, but can also be other data structures including the drawing instruction list and rendering attributes, which are not limited here .
(4)最后,介绍本申请实施例提供的电子设备的硬件架构和软件架构。(4) Finally, the hardware architecture and software architecture of the electronic device provided by the embodiment of the present application are introduced.
图24为本申请实施例提供的电子设备的硬件结构的一个示例性示意图。FIG. 24 is an exemplary schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application.
下面以电子设备为例对实施例进行具体说明。应该理解的是,电子设备可以具有比图中所示的更多的或者更少的部件,可以组合两个或多个的部件,或者可以具有不同的部件配置。图中所示出的各种部件可以在包括一个或多个信号处理和/或专用集成电路在内的硬件、软件、或硬件和软件的组合中实现。Hereinafter, an electronic device is taken as an example to describe the embodiment in detail. It should be understood that an electronic device may have more or fewer components than shown in the figures, may combine two or more components, or may have a different configuration of components. The various components shown in the figures 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.
电子设备可以包括:处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。The electronic device may include: a
可以理解的是,本发明实施例示意的结构并不构成对电子设备的具体限定。在本申请另一些实施例中,电子设备可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that, the structure shown in the embodiment of the present invention 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 illustrations, or combine certain components, or separate certain components, or arrange different components. The illustrated components can be realized in hardware, software or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processingunit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The
其中,控制器可以是电子设备的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。Wherein, the controller may be the nerve center and command center of the electronic equipment. The controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuitsound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purposeinput/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments,
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备的触摸功能。The I2C interface is a bidirectional synchronous serial bus, including a serial data line (serial data line, SDA) and a serial clock line (derail clock line, SCL). In some embodiments,
I2S接口可以用于音频通信。PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。UART接口是一种通用串行数据总线,用于异步通信。The I2S interface can be used for audio communication. The PCM interface can also be used for audio communication, sampling, quantizing and encoding the analog signal. The UART interface is a universal serial data bus used for asynchronous communication.
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(displayserial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备的显示功能。GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。SIM接口可以被用于与SIM卡接口195通信,实现传送数据到SIM卡或读取SIM卡中数据的功能。USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。The MIPI interface can be used to connect the
可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备的结构限定。在本申请另一些实施例中,电子设备也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules shown in the embodiment of the present invention is only a schematic illustration, and does not constitute a structural limitation of the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
充电管理模块140用于从充电器接收充电输入。电源管理模块141用于连接电池142,充电管理模块140与处理器110。The charging management module 140 is configured to receive a charging input from a charger. The power management module 141 is used for connecting the battery 142 , the charging management module 140 and the
电子设备的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。天线1和天线2用于发射和接收电磁波信号。电子设备中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。移动通信模块150可以提供应用在电子设备上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The wireless communication function of the electronic device can be realized by the
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。A modem processor may include a modulator and a demodulator. Wherein, the modulator is used for modulating 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. Then the demodulator sends the demodulated low-frequency baseband signal to the baseband processor for processing. The low-frequency baseband signal is passed to the application processor after being processed by the baseband processor. The application processor outputs sound signals through audio equipment (not limited to speaker 170A,
无线通信模块160可以提供应用在电子设备上的包括无线局域网(wirelesslocal area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (Wi-Fi) network), bluetooth (bluetooth, BT), global navigation satellite system ( Global navigation satellite system (GNSS), frequency modulation (frequency modulation, FM), near field communication (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. 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
在一些实施例中,电子设备的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code divisionmultiple 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,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(globalnavigation satellite system,GLONASS),北斗卫星导航系统(beidou navigationsatellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the
电子设备通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device realizes the display function through the GPU, the display screen 194, and the application processor. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emittingdiode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrixorganic light emitting diode,AMOLED),柔性发光二极管(flex light-emittingdiode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot lightemitting diodes,QLED)等。在一些实施例中,电子设备可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, videos and the like. The display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light emitting diode). , AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diodes (quantum dot light emitting diodes, QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 194, where N is a positive integer greater than 1.
电子设备可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能,进而获取到实时的视频数据。The electronic device can realize the shooting function through ISP, camera 193 , video codec, GPU, display screen 194 and application processor, and then obtain real-time video data.
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used for processing the data fed back by the camera 193 . For example, when taking a picture, open the shutter, the light is transmitted to the photosensitive element of the camera through the lens, and the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye. ISP can also optimize the algorithm for image noise and brightness. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be located in the camera 193 .
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备可以包括1个或N个摄像头193,N为大于1的正整数。Camera 193 is used to capture still images or video. The object generates an optical image through the lens and projects it to the photosensitive element. The photosensitive element may be a charge coupled device (charge coupled device, CCD) or a complementary metal-oxide-semiconductor (complementary metal-oxide-semiconductor, CMOS) phototransistor. The photosensitive element converts the light 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. DSP converts digital image signals into standard RGB, YUV and other image signals. In some embodiments, the electronic device may include 1 or N cameras 193, where N is a positive integer greater than 1.
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when an electronic device selects a frequency point, a digital signal processor is used to perform Fourier transform on the frequency point energy, etc.
视频编解码器用于对数字视频压缩或解压缩。电子设备可以支持一种或多种视频编解码器。这样,电子设备可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. An electronic device may support one or more video codecs. In this way, the electronic device can play or record videos in various encoding formats, such as: moving picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备的智能认知等应用,例如:图像识别,人脸识别,声音识别,文本理解等。The NPU is a neural-network (NN) computing processor. By referring to the structure of biological neural networks, such as the transfer mode between neurons in the human brain, it can quickly process input information and continuously learn by itself. Applications such as intelligent cognition of electronic devices can be realized through NPU, such as: image recognition, face recognition, voice recognition, text understanding, etc.
内部存储器121可以包括一个或多个随机存取存储器(random access memory,RAM)和一个或多个非易失性存储器(non-volatile memory,NVM)。The internal memory 121 may include one or more random access memories (random access memory, RAM) and one or more non-volatile memories (non-volatile memory, NVM).
随机存取存储器可以包括静态随机存储器(static random-access memory,SRAM)、动态随机存储器(dynamic random access memory,DRAM)、同步动态随机存储器(synchronous dynamic random access memory,SDRAM)、双倍资料率同步动态随机存取存储器(double data rate synchronous dynamic random access memory,DDR SDRAM,例如第五代DDR SDRAM一般称为DDR5 SDRAM)等;Random access memory may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (synchronous dynamic random access memory, SDRAM), double data rate synchronous Dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, such as the fifth generation DDR SDRAM is generally called DDR5 SDRAM), etc.;
非易失性存储器可以包括磁盘存储器件、快闪存储器(flash memory)。Non-volatile memory may include magnetic disk storage devices, flash memory (flash memory).
在本申请实施例中,非实时的视频可以位于非易失性存储器中。In the embodiment of the present application, the non-real-time video may be located in a non-volatile memory.
快闪存储器按照运作原理划分可以包括NOR FLASH、NAND FLASH、3D NAND FLASH等,按照存储单元电位阶数划分可以包括单阶存储单元(single-level cell,SLC)、多阶存储单元(multi-level cell,MLC)、三阶储存单元(triple-level cell,TLC)、四阶储存单元(quad-level cell,QLC)等,按照存储规范划分可以包括通用闪存存储(英文:universalflash storage,UFS)、嵌入式多媒体存储卡(embedded multi media Card,eMMC)等。According to the operating principle, flash memory can include NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. According to the potential order of storage cells, it can include single-level storage cells (single-level cell, SLC), multi-level storage cells (multi-level cell, MLC), triple-level cell (TLC), quad-level cell (QLC), etc., can include universal flash storage (English: universal flash storage, UFS), An embedded multimedia memory card (embedded multi media Card, eMMC), etc.
随机存取存储器可以由处理器110直接进行读写,可以用于存储操作系统或其他正在运行中的程序的可执行程序(例如机器指令),还可以用于存储用户及应用程序的数据等。The random access memory can be directly read and written by the
非易失性存储器也可以存储可执行程序和存储用户及应用程序的数据等,可以提前加载到随机存取存储器中,用于处理器110直接进行读写。The non-volatile memory can also store executable programs and data of users and application programs, etc., and can be loaded into the random access memory in advance for the
外部存储器接口120可以用于连接外部的非易失性存储器,实现扩展电子设备的存储能力。外部的非易失性存储器通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部的非易失性存储器中。The
电子设备可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device can implement audio functions through the
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。The
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。The earphone interface 170D is used for connecting wired earphones. The earphone interface 170D may be the USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。陀螺仪传感器180B可以用于确定电子设备的运动姿态。气压传感器180C用于测量气压。磁传感器180D包括霍尔传感器。加速度传感器180E可检测电子设备在各个方向上(一般为三轴)加速度的大小。距离传感器180F,用于测量距离。接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。环境光传感器180L用于感知环境光亮度。指纹传感器180H用于采集指纹。电子设备可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。温度传感器180J用于检测温度。The pressure sensor 180A is used to sense the pressure signal and convert the pressure signal into an electrical signal. In some embodiments, pressure sensor 180A may be disposed on display screen 194 . The gyro sensor 180B can be used to determine the motion posture of the electronic device. The air pressure sensor 180C is used to measure air pressure. The magnetic sensor 180D includes a Hall sensor. The acceleration sensor 180E can detect the acceleration of the electronic device in various directions (generally three axes). The distance sensor 180F is used to measure the distance. Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes. The ambient light sensor 180L is used for sensing ambient light brightness. The fingerprint sensor 180H is used to collect fingerprints. Electronic devices can use the collected fingerprint features to unlock fingerprints, access application locks, take pictures with fingerprints, answer incoming calls with fingerprints, etc. The temperature sensor 180J is used to detect temperature.
触摸传感器180K,也称“触控面板”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备的表面,与显示屏194所处的位置不同。Touch sensor 180K, also known as "touch panel". The touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”. The touch sensor 180K is used to detect a touch operation on or near it. The touch sensor can pass 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 may also be disposed on the surface of the electronic device, which is different from the position of the display screen 194 .
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备可以接收按键输入,产生与电子设备的用户设置以及功能控制有关的键信号输入。马达191可以产生振动提示。指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。SIM卡接口195用于连接SIM卡。电子设备通过SIM卡和网络交互,实现通话以及数据通信等功能。The keys 190 include a power key, a volume key and the like. The key 190 may be a mechanical key. It can also be a touch button. The electronic device can receive key input and generate key signal input related to user settings and function control of the electronic device. The motor 191 can generate a vibrating reminder. The indicator 192 can be an indicator light, and can be used to indicate charging status, power change, and can also be used to indicate messages, missed calls, notifications, and the like. The
图25为本申请实施例提供的电子设备的软件结构的一个示例性示意图。FIG. 25 is an exemplary schematic diagram of a software structure of an electronic device provided by an embodiment of the present application.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将系统分为四层,从上至下分别为应用程序层,应用程序框架层,系统库,以及内核层。The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate through software interfaces. In some embodiments, the system is divided into four layers, which are application program layer, application program framework layer, system library, and kernel layer from top to bottom.
应用程序层可以包括一系列应用程序包。如图20所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序(也可以称为应用)。The application layer can consist of a series of application packages. As shown in FIG. 20, the application package may include application programs (also called applications) such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
应用程序框架层为应用程序层的应用程序提供应用编程接口(applicationprogramming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
如图25所示,应用程序框架层可以包括窗口管理服务,显示管理服务,内容提供器,视图系统,电话管理器,资源管理器,通知管理器,本地Profile管理助手(LocalProfile Assistant,LPA)等。As shown in Figure 25, the application framework layer can include window management service, display management service, content provider, view system, phone manager, resource manager, notification manager, local profile management assistant (LocalProfile Assistant, LPA), etc. .
窗口管理服务负责窗口的启动、添加、删除等,可以确定窗口上显示的应用程序以及确定应用程序的图层的创建、销毁、属性变更等,判断是否有状态栏,锁定屏幕,截取屏幕等。The window management service is responsible for the startup, addition, and deletion of windows. It can determine the applications displayed on the windows and the creation, destruction, and property changes of the layers of the applications. It can determine whether there is a status bar, lock the screen, and capture the screen.
显示管理服务可以获取显示区域的数量、大小,以及负责显示区域的启动、添加、删除等。The display management service can obtain the number and size of display areas, and is responsible for starting, adding, and deleting display areas.
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。Content providers are used to store and retrieve data and make it accessible to applications. Said data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebook, etc.
电话管理器用于提供电子设备的通信功能。例如通话状态的管理(包括接通,挂断等)。The phone manager is used to provide communication functions of electronic devices. For example, the management of call status (including connected, hung up, etc.).
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话界面形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify the download completion, message reminder, etc. The notification manager can also be a notification that appears on the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog interface. For example, prompting text information in the status bar, issuing a prompt sound, vibrating the electronic device, and flashing the indicator light, etc.
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. The view system can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
视图系统还包括UniRender,UniRender可以接收一个或多个应用程序的渲染树。UniRender可以通过窗口管理服务同步图层信息如图层创建、销毁、属性变更等。UniRender可以从显示管理服务同步显示区域的信息,如屏幕的大小等。The view system also includes UniRender, which can receive one or more application render trees. UniRender can synchronize layer information through the window management service, such as layer creation, destruction, property change, etc. UniRender can synchronize the information of the display area, such as the size of the screen, from the display management service.
可选的,在本申请一些实施例中,视图系统还包括SurfaceFlinger。在配置有白名单的电子设备上,当应用程序不属于白名单的情况下,该应用程序的UI线程生成渲染树后,由该应用程序的Render线程生位图后,交由SurfaceFlinger进行图层的合成。Optionally, in some embodiments of the present application, the view system further includes SurfaceFlinger. On an electronic device configured with a whitelist, when the application does not belong to the whitelist, after the UI thread of the application generates the rendering tree, the Render thread of the application generates the bitmap, and then passes it to SurfaceFlinger for layering Synthesis.
可选的,在本申请一些实施例中,在显示区域上显示的有在白名单内的应用程序和不在白名单内的应用程序的情况下,白名单内得应用程序的位图生成由UniRender负责,UniRender生成位图后,将该位图传递给SurfaceFlinger,SurfaceFlinger再将该位图和其他不在白名单内的应用程序进行图层合成,生成用于送显的位图。Optionally, in some embodiments of the present application, when there are applications in the whitelist and applications not in the whitelist displayed on the display area, the bitmap of the application in the whitelist is generated by UniRender Responsible, after UniRender generates the bitmap, it passes the bitmap to SurfaceFlinger, and SurfaceFlinger then combines the bitmap with other applications not in the whitelist to generate a bitmap for display.
运行时包括核心库和虚拟机。运行时负责操作系统的调度和管理。The runtime includes the core library and virtual machine. The runtime is responsible for the scheduling and management of the operating system.
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是核心库。The core library consists of two parts: one part is the function function that the java language needs to call, and the other part is the core library.
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in virtual machines. The virtual machine executes the java files of the application program layer and the application program framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),图形处理库,其中,图形处理库包括:三维图形处理库(例如:OpenGLES),二维图形引擎(例如:SGL)等。A system library can include multiple function modules. For example: surface manager (surface manager), media library (Media Libraries), graphics processing library, wherein, the graphics processing library includes: 3D graphics processing library (eg: OpenGLES), 2D graphics engine (eg: SGL) and so on.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了二维(2-Dimensional,2D)和三维(3-Dimensional,3D)图层的融合。The surface manager is used to manage the display subsystem, and provides fusion of two-dimensional (2-Dimensional, 2D) and three-dimensional (3-Dimensional, 3D) layers for multiple applications.
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of various commonly used audio and video formats, as well as still image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
三维图形处理库用于实现3D图形绘图,图像渲染,图层合成,和图层处理等。2D图形引擎是2D绘图的绘图引擎。The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, layer composition, and layer processing. 2D graphics engine is a drawing engine for 2D drawing.
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动,虚拟卡驱动。The kernel layer is the layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, a sensor driver, and a virtual card driver.
在本申请实施例中,应用程序层的一个或多个应用程序将各自UI线程生产的渲染树传递到视图系统的UniRender进程中。UniRender进程从窗口管理服务和显示管理服务获取窗口控制信息和显示区域信息,进而将在一个显示区域上的应用程序的渲染树合成为目标渲染树。UniRender进程在生成目标渲染树后,调用图层处理库,执行目标渲染树中的绘制指令列表中的DrawOP操作,进而生成位图。UniRender将生成的位图传递给显示驱动用于送显。In the embodiment of the present application, one or more application programs in the application program layer deliver the rendering trees produced by their respective UI threads to the UniRender process of the view system. The UniRender process obtains window control information and display area information from the window management service and display management service, and then synthesizes the rendering tree of the application program on a display area into a target rendering tree. After the UniRender process generates the target rendering tree, it calls the layer processing library, executes the DrawOP operation in the drawing instruction list in the target rendering tree, and then generates a bitmap. UniRender passes the generated bitmap to the display driver for display.
上述实施例中所用,根据上下文,术语“当…时”可以被解释为意思是“如果…”或“在…后”或“响应于确定…”或“响应于检测到…”。类似地,根据上下文,短语“在确定…时”或“如果检测到(所陈述的条件或事件)”可以被解释为意思是“如果确定…”或“响应于确定…”或“在检测到(所陈述的条件或事件)时”或“响应于检测到(所陈述的条件或事件)”。As used in the above embodiments, depending on the context, the term "when" may be interpreted to mean "if" or "after" or "in response to determining..." or "in response to detecting...". Similarly, depending on the context, the phrase "in determining" or "if detected (a stated condition or event)" may be interpreted to mean "if determining..." or "in response to determining..." or "on detecting (a stated condition or event)" or "in response to detecting (a stated condition or event)".
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。该计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行该计算机程序指令时,全部或部分地产生按照本申请实施例该的流程或功能。该计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。该计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,该计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。该计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。该可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如DVD)、或者半导体介质(例如固态硬盘)等。In the above embodiments, all or part of them may be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it may 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 the computer, the processes or functions according to the embodiments of the present application will be generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, e.g. (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center integrated with one or more available media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid-state hard disk), and the like.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments are realized. The processes can be completed by computer programs to instruct related hardware. The programs can be stored in computer-readable storage media. When the programs are executed , may include the processes of the foregoing method embodiments. The aforementioned storage medium includes: ROM or random access memory RAM, magnetic disk or optical disk, and other various media that can store program codes.
Claims (11)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111410746.6A CN116166257A (en) | 2021-11-25 | 2021-11-25 | Interface generation method and electronic equipment |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111410746.6A CN116166257A (en) | 2021-11-25 | 2021-11-25 | Interface generation method and electronic equipment |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN116166257A true CN116166257A (en) | 2023-05-26 |
Family
ID=86420595
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202111410746.6A Pending CN116166257A (en) | 2021-11-25 | 2021-11-25 | Interface generation method and electronic equipment |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116166257A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118247403A (en) * | 2024-03-31 | 2024-06-25 | 司空定制家居科技有限公司 | Rendering method, device, electronic device and storage medium applied to browser |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2010165344A (en) * | 2008-12-20 | 2010-07-29 | Univ Of Tokyo | Method and device for real time rendering of volume data |
| CA2792900A1 (en) * | 2011-10-18 | 2013-04-18 | Research In Motion Limited | Method of rendering a user interface |
| CN108228121A (en) * | 2016-12-15 | 2018-06-29 | 中科创达软件股份有限公司 | A kind of method, device and mobile terminal of browser split screen |
| CN112486620A (en) * | 2020-12-03 | 2021-03-12 | 广州虎牙科技有限公司 | Cross-process off-screen rendering method and device, electronic equipment and storage medium |
-
2021
- 2021-11-25 CN CN202111410746.6A patent/CN116166257A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2010165344A (en) * | 2008-12-20 | 2010-07-29 | Univ Of Tokyo | Method and device for real time rendering of volume data |
| CA2792900A1 (en) * | 2011-10-18 | 2013-04-18 | Research In Motion Limited | Method of rendering a user interface |
| CN108228121A (en) * | 2016-12-15 | 2018-06-29 | 中科创达软件股份有限公司 | A kind of method, device and mobile terminal of browser split screen |
| CN112486620A (en) * | 2020-12-03 | 2021-03-12 | 广州虎牙科技有限公司 | Cross-process off-screen rendering method and device, electronic equipment and storage medium |
Non-Patent Citations (1)
| Title |
|---|
| 陈莉;: "基于OPENGL的渲染平台设计", 煤炭技术, no. 03, 10 March 2010 (2010-03-10) * |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118247403A (en) * | 2024-03-31 | 2024-06-25 | 司空定制家居科技有限公司 | Rendering method, device, electronic device and storage medium applied to browser |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| EP4411533A1 (en) | Interface generation method and electronic device | |
| CN113553130B (en) | Method for executing drawing operation by application and electronic equipment | |
| CN116166256A (en) | Interface generation method and electronic equipment | |
| CN116166255B (en) | Interface generation method and electronic equipment | |
| WO2022242487A1 (en) | Display method and related device | |
| CN115994007B (en) | Animation effect display method and electronic device | |
| CN117806745B (en) | Interface generation method and electronic device | |
| EP4296845A1 (en) | Screen projection method and system, and related apparatus | |
| WO2023005751A1 (en) | Rendering method and electronic device | |
| WO2023066165A1 (en) | Animation effect display method and electronic device | |
| WO2023016014A1 (en) | Video editing method and electronic device | |
| US20260030040A1 (en) | Interface generation method and electronic device | |
| CN116166257A (en) | Interface generation method and electronic equipment | |
| WO2024067551A1 (en) | Interface display method and electronic device | |
| EP4546127A1 (en) | Interface generation method and electronic device | |
| WO2024061292A1 (en) | Interface generation method and electronic device | |
| CN120669879A (en) | Animation effect display method and electronic equipment | |
| CN120215789A (en) | A graphics drawing method and related device | |
| WO2025201357A1 (en) | Layer synthesis method and related apparatus | |
| WO2025161772A1 (en) | Image display method and electronic device | |
| CN118276716A (en) | Window management method and electronic device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |