Interface generation method and electronic device
By merging and optimizing the rendering tree of electronic devices, the number of rendering operations and resource consumption are reduced, solving the power consumption problem when displaying multiple application interfaces and improving the user experience.
Patent Information
- Application Number
- CN202111410513.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-25
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-11-25
AI Technical Summary
When electronic devices display the interface of multiple applications or windows, they need to spend a lot of computing and storage resources on rendering, which leads to increased power consumption and affects the user experience.
By merging the render trees of multiple applications into a single target render tree and generating an interface containing multiple application interfaces in a single render process, the number of renders is reduced, and parameters in the render tree are optimized, such as removing completely obscured views and graphics, merging or batch drawing operations, and adding off-screen rendering attributes to implement off-screen rendering logic.
It reduces the power consumption of electronic devices, improves the user experience, reduces rendering times and lag, and increases the interface generation rate.
Smart Images

Figure CN116166255B
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to an interface generation method and an electronic device. Background Art
[0002] With the development of electronic technology, more and more electronic devices are involved in the daily life of users. In addition, as the resolution and size of the screens of electronic devices are getting higher and higher, more and more content can be displayed on the electronic devices.
[0003] However, before displaying the interface of an application, the electronic device needs to spend computing resources and storage resources to generate the interface of the application, which increases the power consumption of the electronic device. In addition, when there are multiple applications or multiple windows on the screen of the electronic device, the electronic device needs to spend more computing resources and storage resources to render and generate the interfaces of multiple applications or multiple windows. Summary of the invention
[0004] The embodiments of the present application provide an interface generation method and an electronic device. The interface generation method provided by the present application can merge the rendering trees of one or more applications on a display area, and generate an interface including one or more application interfaces through one rendering based on the merged target rendering tree, thereby reducing the number of rendering times, reducing the power consumption of the electronic device, and improving the user experience.
[0005] In a first aspect, an interface generation method provided by an embodiment of the present application is applied to a first electronic device, and the first electronic device determines that content displayed on a first display area includes an interface of a first process and an interface of a second process, including: the first process generates a first rendering tree, and the first rendering tree is used to draw the interface of the first process; the second process generates a second rendering tree, and the second rendering tree is used to draw the interface of the second process; a third process generates a first target interface based on the first rendering tree and the second rendering tree, and the first target interface includes the interface of the first process and the interface of the second process, and the first target interface is displayed on the first display area.
[0006] In the above embodiment, a rendering tree of one or more applications on a display area is generated into an interface including one or more application program interfaces, thereby reducing the number of rendering times, reducing the power consumption of the electronic device, and improving the user experience.
[0007] In combination with some embodiments of the first aspect, in some embodiments, the third process generates a first target interface based on the first rendering tree and the second rendering tree, specifically including: the third process generates a first target rendering tree based on the first rendering tree and the second rendering tree; the third process generates the first target interface based on the first target rendering tree.
[0008] In the above embodiment, the third process can combine the rendering trees of one or more applications into a target rendering tree, and then generate an interface based on the target rendering tree, which includes the interfaces of one or more applications. Obviously, through one rendering, that is, one rendering tree to bitmap rendering process, an interface including one or more applications can be generated, which reduces the number of rendering times and thus reduces the power consumption of the electronic device.
[0009] In combination with some embodiments of the first aspect, in some embodiments, the third process generates a first target rendering tree based on the first rendering tree and the second rendering tree, specifically including: the third process creates a root rendering node as the root node of the first target rendering tree, and uses the first rendering tree and the second rendering tree as child nodes of the root rendering node.
[0010] In the above embodiment, the target rendering tree may be created by creating a new root node and mounting rendering trees of multiple applications on child nodes of the root node.
[0011] In combination with some embodiments of the first aspect, in some embodiments, the method further includes: the third process deleting a rendering node in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted rendering node corresponds to a completely obscured view.
[0012] In the above embodiment, the third process may optimize the parameters in the target rendering tree, for example, deleting the rendering nodes corresponding to the views that are completely blocked on the interface to reduce over-drawing.
[0013] In combination with some embodiments of the first aspect, in some embodiments, the method further includes: the third process deletes the drawing operation in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted drawing operation corresponds to the completely obscured graphics.
[0014] In the above embodiment, the third process may optimize the parameters in the target rendering tree, for example, deleting the rendering nodes corresponding to the graphics that are completely blocked on the interface to reduce over-drawing.
[0015] In combination with some embodiments of the first aspect, in some embodiments, the method also includes: in a process in which the third process generates a first target interface based on the first rendering tree and the second rendering tree, the third process performs a merging or batching of a first drawing operation and a second drawing operation, the first drawing operation belongs to the first rendering tree, and the second drawing operation belongs to the second rendering tree.
[0016] In the above embodiment, the third process can merge or batch the drawing operations in the target rendering tree, thereby increasing the rate of generating the interface, reducing freezes, reducing the power consumption of the electronic device, and thus improving the user experience.
[0017] In combination with some embodiments of the first aspect, in some embodiments, the method further includes: the third process determines the off-screen rendering logic of the interface of the first process, and the off-screen rendering logic includes at least one of window rounding, color change, rotation, and scaling; the third process adds off-screen rendering attributes to the rendering attributes in the first rendering tree based on the off-screen rendering logic of the interface of the first process, and the off-screen rendering attributes include: at least one of rounded corner attributes, color attributes, rotation attributes, and scaling attributes; the off-screen rendering attributes correspond one-to-one to the off-screen rendering logic, and the off-screen rendering attributes are used to modify the drawing operation to implement the off-screen rendering logic in the process of the third process generating the first target interface based on the first rendering tree and the second rendering tree.
[0018] In the above embodiment, by adding an off-screen rendering attribute in the rendering tree, the off-screen rendered graphics can be directly drawn based on the off-screen rendering attribute during the drawing operation on the surface. There is no need to perform off-screen rendering on the entire bitmap and then perform layer synthesis after the drawing is completed. Off-screen rendering can be avoided, thereby reducing the number of rendering times and the overhead of off-screen rendering, reducing the power consumption of electronic devices, and improving the user experience.
[0019] In combination with some embodiments of the first aspect, in some embodiments, when the reference coordinate system of the first rendering tree is the first coordinate system, the reference coordinate system corresponding to the first display area is the second coordinate system, and the first coordinate system and the second coordinate system are different, the method also includes: the third process determines a first parameter based on the first coordinate system and the second coordinate system, and adds the first parameter to the rendering properties of the first rendering tree; in the process of the third process generating a first target interface based on the first rendering tree and the second rendering tree, the third process modifies the reference coordinate system of a first drawing operation based on the first parameter, and the first drawing operation belongs to the first rendering tree.
[0020] In the above embodiment, when the reference coordinate system of the rendering tree generated by the application is different from the reference coordinate system of the drawing operation performed by the third process in the rendering tree, the correct drawing operation is achieved by adding a first parameter to the rendering attribute and then transforming the reference coordinate system of the drawing operation based on the first parameter.
[0021] In a second aspect, an interface generation method provided by an embodiment of the present application includes: a third process running on the second electronic device receives a first rendering tree and a second rendering tree; wherein the first rendering tree is generated by a first process running on the first electronic device, and the first rendering tree is used to draw an interface of the first process; the second rendering tree is generated by a second process running on the second electronic device, and the second rendering tree is used to draw an interface of the second process; the third process generates a target interface based on the first rendering tree and the second rendering tree, the target interface includes an interface of the first process and an interface of the second process, and the target interface is displayed on the first display area.
[0022] In the above embodiment, a rendering tree of one or more applications on a display area is generated into an interface including one or more application program interfaces, thereby reducing the number of rendering times, reducing the power consumption of the electronic device, and improving the user experience.
[0023] In combination with some embodiments of the second aspect, in some embodiments, the third process generates a first target interface based on the first rendering tree and the second rendering tree, specifically including: the third process generates a first target rendering tree based on the first rendering tree and the second rendering tree; the third process generates the first target interface based on the first target rendering tree.
[0024] In the above embodiment, the third process can combine the rendering trees of one or more applications into a target rendering tree, and then generate an interface based on the target rendering tree, which includes the interfaces of one or more applications. Obviously, through one rendering, that is, one rendering tree to bitmap rendering process, an interface including one or more applications can be generated, which reduces the number of rendering times and thus reduces the power consumption of the electronic device.
[0025] In combination with some embodiments of the second aspect, in some embodiments, the third process generates a first target rendering tree based on the first rendering tree and the second rendering tree, specifically including: the third process creates a root rendering node as the root node of the first target rendering tree, and uses the first rendering tree and the second rendering tree as child nodes of the root rendering node.
[0026] In the above embodiment, the target rendering tree may be created by creating a new root node and mounting rendering trees of multiple applications on child nodes of the root node.
[0027] In combination with some embodiments of the second aspect, in some embodiments, the method further includes: the third process deleting a rendering node in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted rendering node corresponds to a completely obscured view.
[0028] In the above embodiment, the third process may optimize the parameters in the target rendering tree, for example, deleting the rendering nodes corresponding to the views that are completely blocked on the interface to reduce over-drawing.
[0029] In combination with some embodiments of the second aspect, in some embodiments, the method further includes: the third process deletes the drawing operation in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted drawing operation corresponds to the completely obscured graphics.
[0030] In the above embodiment, the third process may optimize the parameters in the target rendering tree, for example, deleting the rendering nodes corresponding to the graphics that are completely blocked on the interface to reduce over-drawing.
[0031] In combination with some embodiments of the second aspect, in some embodiments, the method also includes: in a process in which the third process generates a first target interface based on the first rendering tree and the second rendering tree, the third process performs a merging or batching of a first drawing operation and a second drawing operation, the first drawing operation belongs to the first rendering tree, and the second drawing operation belongs to the second rendering tree.
[0032] In the above embodiment, the third process can merge or batch the drawing operations in the target rendering tree, thereby increasing the rate of generating the interface, reducing freezes, reducing the power consumption of the electronic device, and thus improving the user experience.
[0033] In combination with some embodiments of the second aspect, in some embodiments, the method also includes: the third process determines the off-screen rendering logic of the interface of the first process, and the off-screen rendering logic includes at least one of window rounding, color change, rotation, and scaling; the third process adds off-screen rendering attributes to the rendering attributes in the first rendering tree based on the off-screen rendering logic of the interface of the first process, and the off-screen rendering attributes include: at least one of rounded corner attributes, color attributes, rotation attributes, and scaling attributes; the off-screen rendering attributes correspond one-to-one to the off-screen rendering logic, and the off-screen rendering attributes are used to modify the drawing operation to implement the off-screen rendering logic in the process of the third process generating the first target interface based on the first rendering tree and the second rendering tree.
[0034] In the above embodiment, by adding an off-screen rendering attribute in the rendering tree, the off-screen rendered graphics can be directly drawn based on the off-screen rendering attribute during the drawing operation on the surface. There is no need to perform off-screen rendering on the entire bitmap and then perform layer synthesis after the drawing is completed. Off-screen rendering can be avoided, thereby reducing the number of rendering times and the overhead of off-screen rendering, reducing the power consumption of electronic devices, and improving the user experience.
[0035] In combination with some embodiments of the second aspect, in some embodiments, when the reference coordinate system of the first rendering tree is the first coordinate system, the reference coordinate system corresponding to the first display area is the second coordinate system, and the first coordinate system and the second coordinate system are different, the method also includes: the third process determines a first parameter based on the first coordinate system and the second coordinate system, and adds the first parameter to the rendering properties of the first rendering tree; in the process of the third process generating a first target interface based on the first rendering tree and the second rendering tree, the third process modifies the reference coordinate system of a first drawing operation based on the first parameter, and the first drawing operation belongs to the first rendering tree.
[0036] In the above embodiment, when the reference coordinate system of the rendering tree generated by the application is different from the reference coordinate system of the drawing operation performed by the third process in the rendering tree, the correct drawing operation is achieved by adding a first parameter to the rendering attribute and then transforming the reference coordinate system of the drawing operation based on the first parameter.
[0037] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute: the first process generates a first rendering tree, and the first rendering tree is used to draw the interface of the first process; the second process generates a second rendering tree, and the second rendering tree is used to draw the interface of the second process; the third process generates a first target interface based on the first rendering tree and the second rendering tree, the first target interface includes the interface of the first process and the interface of the second process, and the first target interface is displayed on the first display area.
[0038] In the above embodiment, in the above embodiment, the rendering tree of one or more applications on a display area is generated into an interface including one or more application interfaces, thereby reducing the number of rendering times, reducing the power consumption of the electronic device, and improving the user experience.
[0039] In combination with some embodiments of the third aspect, in some embodiments, the one or more processors are specifically used to call the computer instruction to cause the electronic device to execute: the third process generates a first target rendering tree based on the first rendering tree and the second rendering tree; the third process generates the first target interface based on the first target rendering tree.
[0040] In combination with some embodiments of the third aspect, in some embodiments, the one or more processors are specifically used to call the computer instruction to cause the electronic device to execute: the third process creates a root rendering node as the root node of the first target rendering tree, and uses the first rendering tree and the second rendering tree as child nodes of the root rendering node.
[0041] In combination with some embodiments of the third aspect, in some embodiments, the one or more processors are further used to call the computer instruction to cause the electronic device to execute: the third process deletes the rendering node in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted rendering node corresponds to a completely obscured view.
[0042] In combination with some embodiments of the third aspect, in some embodiments, the one or more processors are further used to call the computer instruction to cause the electronic device to execute: the third process deletes the drawing operation in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted drawing operation corresponds to the completely obscured graphics.
[0043] In combination with some embodiments of the third aspect, in some embodiments, the one or more processors are also used to call the computer instructions to cause the electronic device to execute: in the process of the third process generating the first target interface based on the first rendering tree and the second rendering tree, the third process performs a merge or batch operation on the first drawing operation and the second drawing operation, the first drawing operation belongs to the first rendering tree, and the second drawing operation belongs to the second rendering tree.
[0044] In combination with some embodiments of the third aspect, in some embodiments, the one or more processors are further used to call the computer instructions to cause the electronic device to execute: the third process determines the off-screen rendering logic of the interface of the first process, and the off-screen rendering logic includes at least one of window rounding, color change, rotation, and scaling; the third process adds off-screen rendering attributes to the rendering attributes in the first rendering tree based on the off-screen rendering logic of the interface of the first process, and the off-screen rendering attributes include: at least one of rounded corner attributes, color attributes, rotation attributes, and scaling attributes; the off-screen rendering attributes correspond one-to-one to the off-screen rendering logic, and the off-screen rendering attributes are used to modify the drawing operation to implement the off-screen rendering logic in the process of the third process generating the first target interface based on the first rendering tree and the second rendering tree.
[0045] In combination with some embodiments of the third aspect, in some embodiments, the one or more processors are further used to call the computer instructions to cause the electronic device to execute: the third process determines a first parameter based on the first coordinate system and the second coordinate system, and adds the first parameter to the rendering properties of the first rendering tree; in the process of the third process generating a first target interface based on the first rendering tree and the second rendering tree, the third process modifies a reference coordinate system of a first drawing operation based on the first parameter, and the first drawing operation belongs to the first rendering tree.
[0046] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store a computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute: a third process running on the second electronic device receives a first rendering tree and a second rendering tree; wherein the first rendering tree is generated by a first process running on the first electronic device, and the first rendering tree is used to draw an interface of the first process; the second rendering tree is generated by a second process running on the second electronic device, and the second rendering tree is used to draw an interface of the second process; the third process generates a target interface based on the first rendering tree and the second rendering tree, the target interface includes an interface of the first process and an interface of the second process, and the target interface is displayed on the first display area.
[0047] In the above embodiment, in the above embodiment, the rendering tree of one or more applications on a display area is generated into an interface including one or more application interfaces, thereby reducing the number of rendering times, reducing the power consumption of the electronic device, and improving the user experience.
[0048] In combination with some embodiments of the fourth aspect, in some embodiments, the one or more processors are specifically used to call the computer instruction to cause the electronic device to execute: the third process generates a first target rendering tree based on the first rendering tree and the second rendering tree; the third process generates the first target interface based on the first target rendering tree.
[0049] In combination with some embodiments of the fourth aspect, in some embodiments, the one or more processors are specifically used to call the computer instruction to cause the electronic device to execute: the third process creates a root rendering node as the root node of the first target rendering tree, and uses the first rendering tree and the second rendering tree as child nodes of the root rendering node.
[0050] In combination with some embodiments of the fourth aspect, in some embodiments, the one or more processors are further used to call the computer instruction to cause the electronic device to execute: the third process deletes the rendering node in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted rendering node corresponds to a completely obscured view.
[0051] In combination with some embodiments of the fourth aspect, in some embodiments, the one or more processors are further used to call the computer instruction to cause the electronic device to execute: the third process deletes the drawing operation in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted drawing operation corresponds to the completely obscured graphics.
[0052] In combination with some embodiments of the fourth aspect, in some embodiments, the one or more processors are also used to call the computer instructions to cause the electronic device to execute: in the process of the third process generating the first target interface based on the first rendering tree and the second rendering tree, the third process performs a merge or batch operation on the first drawing operation and the second drawing operation, the first drawing operation belongs to the first rendering tree, and the second drawing operation belongs to the second rendering tree.
[0053] In combination with some embodiments of the fourth aspect, in some embodiments, the one or more processors are further used to call the computer instructions to cause the electronic device to execute: the third process determines the off-screen rendering logic of the interface of the first process, and the off-screen rendering logic includes at least one of window rounding, color change, rotation, and scaling; the third process adds off-screen rendering attributes to the rendering attributes in the first rendering tree based on the off-screen rendering logic of the interface of the first process, and the off-screen rendering attributes include: at least one of rounded corner attributes, color attributes, rotation attributes, and scaling attributes; the off-screen rendering attributes correspond one-to-one to the off-screen rendering logic, and the off-screen rendering attributes are used to modify the drawing operation to implement the off-screen rendering logic in the process of the third process generating the first target interface based on the first rendering tree and the second rendering tree.
[0054] In combination with some embodiments of the fourth aspect, in some embodiments, the one or more processors are further used to call the computer instructions to cause the electronic device to execute: the third process determines a first parameter based on the first coordinate system and the second coordinate system, and adds the first parameter to the rendering properties of the first rendering tree; in the process of the third process generating a first target interface based on the first rendering tree and the second rendering tree, the third process modifies a reference coordinate system of a first drawing operation based on the first parameter, and the first drawing operation belongs to the first rendering tree.
[0055] In the fifth aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, which are used to call computer instructions so that the electronic device executes the method described in the first aspect and the second aspect, or any possible implementation method in the first aspect and the second aspect.
[0056] In a sixth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when the computer program product is run on an electronic device, enables the electronic device to execute the method described in the first aspect and the second aspect, or in any possible implementation manner of the first aspect and the second aspect.
[0057] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions. When the instructions are executed on an electronic device, the electronic device executes the method described in the first aspect and the second aspect, or any possible implementation method in the first aspect and the second aspect.
[0058] It is understandable that the electronic devices provided in the third and fourth aspects, the chip system provided in the fifth aspect, the computer program product provided in the sixth aspect, and the computer storage medium provided in the seventh aspect are all used to execute the methods provided in the embodiments of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1A , Figure 1B An exemplary schematic diagram of an electronic device interface provided in an embodiment of the present application.
[0060] Figure 2 An exemplary schematic diagram of generating a bitmap by an application provided in an embodiment of the present application.
[0061] Figure 3 An exemplary schematic diagram of a rendering tree provided in an embodiment of the present application.
[0062] Figure 4 An exemplary schematic diagram of a bitmap provided in an embodiment of the present application as a layer participating in layer synthesis.
[0063] Figure 5 An exemplary schematic diagram of layer synthesis provided in an embodiment of the present application.
[0064] Figure 6 Another exemplary schematic diagram of layer synthesis by SurfaceFlinge provided in an embodiment of the present application.
[0065] Fig. 7A , Figure 7BAnother exemplary schematic diagram of layer synthesis provided in an embodiment of the present application.
[0066] Figure 8 An exemplary schematic diagram of the system architecture of the interface generation method provided in an embodiment of the present application.
[0067] Fig. 9 An exemplary schematic diagram of the interface generation method provided in an embodiment of the present application.
[0068] Fig.10 An exemplary schematic diagram of the UniRender architecture provided in an embodiment of the present application.
[0069] Fig.11 An exemplary schematic diagram of a shared memory transfer rendering tree provided in an embodiment of the present application.
[0070] Fig. 12A , Fig. 12B An exemplary schematic diagram of a storage structure of a rendering tree in a shared memory provided in an embodiment of the present application.
[0071] Fig.13 An exemplary schematic diagram of the UniRender architecture provided in an embodiment of the present application.
[0072] Fig.14 An exemplary schematic diagram of an application writing a rendering tree into a shared memory provided in an embodiment of the present application.
[0073] Fig.15 Another exemplary schematic diagram of an application writing a rendering tree into a shared memory provided in an embodiment of the present application.
[0074] Figure 16A-16C An exemplary schematic diagram of a scenario for triggering drawing logic for off-screen rendering provided in an embodiment of the present application.
[0075] Fig.17A , Fig. 17B An exemplary schematic diagram of UniRender triggering an off-screen rendering instruction to move forward provided in an embodiment of the present application.
[0076] Fig.18 An exemplary schematic diagram of UniRender providing an embodiment of the present application to modify the rendering node attributes of a rendering tree.
[0077] Fig.19 An exemplary schematic diagram of combining rendering trees after forward processing of multiple off-screen rendering instructions into a target rendering tree provided in an embodiment of the present application.
[0078] Fig. 20An exemplary schematic diagram of combining rendering trees after forward processing of multiple off-screen rendering instructions into a target rendering tree provided in an embodiment of the present application.
[0079] Fig.21 An exemplary schematic diagram of setStaticMatrix() provided in an embodiment of the present application.
[0080] Figure 22A-22C An exemplary schematic diagram of a multi-display area scenario provided in an embodiment of the present application.
[0081] Figure 23A-23C Another exemplary schematic diagram of a multi-display area scenario provided in an embodiment of the present application.
[0082] Fig.24 Another exemplary schematic diagram of the interface generation method provided in an embodiment of the present application.
[0083] Fig.25 An exemplary schematic diagram of the frequency division and frequency multiplication of vertical synchronization signals of the UniRender process provided in an embodiment of the present application.
[0084] Fig.26A , Fig.26B An exemplary schematic diagram of data flow when an electronic device implements an interface generation method provided in an embodiment of the present application.
[0085] Fig. 27 Another exemplary schematic diagram of the interface generation method provided in an embodiment of the present application.
[0086] Fig.28A , Fig.28B An exemplary schematic diagram of synthesizing the rendering trees provided in the embodiment of the present application into a target rendering tree.
[0087] Fig.29 An exemplary schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
[0088] Fig.30 An exemplary schematic diagram of the software structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0089] 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 be used as limitations to the present application. As used in the specification of the present application, the singular expressions "one", "a kind of", "the", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.
[0090] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
[0091] The term "user interface (UI)" in the following embodiments of the present application refers to a medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface is a source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on an electronic device, and finally presented as content that can be recognized by the user. The commonly used form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operation displayed in a graphical manner. It can be a visual interface element such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc. displayed on the display screen of an electronic device.
[0092] For ease of understanding, the following first introduces the relevant 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 the specific embodiments of the present invention, and are not intended to limit the present invention.
[0093] The interface is a medium interface for interaction and information exchange between the application and the user. Every time a vertical synchronization signal arrives, the electronic device needs to generate the interface of the application for the foreground application. The frequency of the vertical synchronization signal is related to the refresh rate of the screen of the electronic device. For example, the frequency of the vertical synchronization signal is the same as the refresh rate of the screen of the electronic device.
[0094] That is, each time before the electronic device refreshes the content displayed on the screen, it is necessary to generate the interface of the application for the foreground application, so as to show the newly generated interface of the application to the user when the screen is refreshed.
[0095] The interface displayed by the electronic device on the electronic device may include interfaces of one or more applications, that is, the electronic device needs to generate interfaces for one or more applications and synthesize the interfaces to obtain the synthesized interface displayed on the screen.
[0096] Among them, the electronic device generates the interface of the application. The application needs to render and generate the bitmap by itself and pass its own bitmap to the surface synthesizer (SurfaceFlinger). That is, the application draws and generates the bitmap as a producer, and stores the bitmap in the buffer queue (BufferQueue) provided by SurfaceFlinger; SurfaceFlinger, as a consumer, continuously obtains the bitmap generated by the application from the BufferQueue. Among them, the bitmap is located on the surface generated by the application, and the surface will be filled in the BufferQueue.
[0097] After SurfaceFlinger obtains the bitmap of the visible application, SurfaceFlinger and the Hardware Composer (HWC) determine the way to use the bitmap as a layer. SurfaceFlinger can determine the visible application through the Window Manager Service (WMS).
[0098] After SurfaceFlinger obtains the off-screen rendering logic of the application's window from the window management service, such as rounded corners, rotation, color change, scaling, and other off-screen rendering logic, it will copy the application's bitmap to the off-screen buffer for rendering, and obtain the bitmap used to participate in layer synthesis through off-screen rendering.
[0099] After the bitmap of the application is synthesized, SurfaceFlinger / HWC fills the synthesized bitmap (bitmap can also be called layer on SurfaceFlinger) into the frame buffer and passes it to the display subsystem (DSS). After getting the synthesized bitmap, DSS can display the synthesized bitmap on the screen. The frame buffer can be an on-screen buffer.
[0100] (1) First, the following examples respectively introduce (1.1) the process of application generating bitmaps, (1.2) the process of SurfaceFlinger / HWC synthesizing bitmaps, and (1.3) off-screen rendering.
[0101] (1.1) The process of generating bitmaps by application
[0102] Figure 1A , Figure 1B An exemplary schematic diagram of an electronic device interface provided in an embodiment of the present application.
[0103] like Figure 1A As shown, the screen of the electronic device displays the interfaces of application 1 and application 2. The interface of application 1 can be called a status bar. Figure 1A In the example, application 1 may be an operating system and application 2 may be a music application.
[0104] Electronic devices display Figure 1A Before the interface shown in the figure is shown, the bitmap of the application needs to be generated separately. Among them, the interface of the status bar is maintained by the operating system, that is, it can be considered that the application that generates the bitmap of the status bar is the operating system. That is, after the operating system generates bitmap 1, it passes bitmap 1 to SurfaceFlinger; the music application generates bitmap 1. Figure 2 After that, Figure 2 Passed to SurfaceFlinger. Bitmap 1 carries the image information of the status bar; bitmap Figure 2 The image information of the music application is carried on it.
[0105] Among them, SurfaceFlinger / HWC receives bitmap 1 and bitmap Figure 2 After that, bitmap 1 and bitmap Figure 2 As a layer, layer synthesis is performed. The content of layer synthesis can refer to the text description of (1.2) SurfaceFlinger / HWC bitmap synthesis process, which will not be repeated here.
[0106] Another example Figure 1B As shown, the screen of the electronic device displays the interfaces of application 1, application 2, and application 3. Among them, the interface of application 1 can be called a status bar. Figure 1B In the example, application 1 may be an operating system, application 2 may be a browser application, and application 3 may be a text messaging application.
[0107] Electronic devices display Figure 1B Before the interface shown, it is also necessary to generate the bitmap of the application separately and independently.
[0108] That is, the operating system generates bits Figure 3 After that, Figure 3 Passed to SurfaceFlinger; SMS application generates bits Figure 4 After that, Figure 4 Passed to SurfaceFlinger; News application generates bits Figure 5 After that, Figure 5 Passed to SurfaceFlinger. Figure 3 The image information of the status bar is carried on it; Figure 4 The image information of the SMS application is carried on it; Figure 5 The image information of the news application is carried on it.
[0109] Among them, SurfaceFlinger / HWC receives the Figure 3 ,Bit Figure 4 and position Figure 5 After that, Figure 3 ,Bit Figure 4 and position Figure 5 As a layer, layer synthesis is performed. The content of layer synthesis can refer to the text description of (1.2) SurfaceFlinger / HWC bitmap synthesis process, which will not be repeated here.
[0110] The process of the application generating a bitmap is as follows Figure 2 shown.
[0111] Figure 2 An exemplary schematic diagram of generating a bitmap by an application provided in an embodiment of the present application.
[0112] like Figure 2 As shown, after receiving the vertical synchronization signal (Vsync-APP), the application starts to generate a bitmap. The specific steps include three steps, namely:
[0113] ① Invalidate the view hierarchy, and the main thread (UI thread) traverses the views of the application, determines and saves the drawing operations of each view, and records the view and the drawing operations (Draw Operation Struct, DrawOP) involved in the view into the drawing instruction list (displaylist) of the render node (RenderNode) of the render tree.
[0114] Among them, the view is the basic element that constitutes the application interface, and a control on the interface can correspond to one or more views.
[0115] The drawing operation is a data structure used to draw graphics, such as drawing lines, drawing widths, drawing rectangles, drawing text, etc. The drawing operation will be converted into API calls of the image processing library, such as OpenGL interface calls, at the rendering node. For example, DrawLineOp is a data structure that contains drawing data such as line length, width, and other information.
[0116] The drawing instruction list may be a buffer that records all drawing operations included in one frame of the application interface or identifiers of all drawing operations, such as addresses, serial numbers, etc. When the application has multiple windows or is displayed on different display areas, multiple rendering trees need to be generated independently, wherein multiple drawing instruction lists corresponding to different windows and display areas are generated independently.
[0117] In the embodiment of the present application, the display area may be a screen, or may be a virtual screen (Virtual Display), etc. The virtual screen may be an area of the electronic device used to carry the content displayed on the screen when recording the screen.
[0118] The rendering tree is a data structure generated by the UI thread and used to generate the application interface. The rendering tree may include multiple rendering nodes, each of which includes rendering attributes and a drawing instruction list. The rendering tree records all the information for generating a frame of the application interface.
[0119] ② The UI thread passes / synchronizes the rendering tree to the rendering thread, where the rendering tree is located in the stack of the process corresponding to the application and may not be continuously distributed on the physical address.
[0120] ③ The rendering thread first obtains a hardware canvas (HardwareCanvas) and performs drawing operations in the rendering tree on the hardware canvas to generate a bitmap. The hardware canvas is located in the surface held by the application, which carries bitmaps or other formats of data for storing image information.
[0121] It can be considered that ① is the construction phase, which is mainly responsible for determining the size, position, transparency and other properties of each view in the application. For example, the drawLine in the view can be encapsulated into a DrawLineOp in the construction, which contains the drawing data such as the length and width of the line, and can also contain the interface call corresponding to the drawLineOP of the underlying graphics processing library, which is used to call the underlying graphics library to generate a bitmap in the rendering phase.
[0122] Similarly, ③ can be considered as the rendering stage, which is mainly responsible for traversing the rendering nodes of the rendering tree and performing drawing operations on each rendering node, thereby generating a bitmap on the hardware canvas. In this process, the rendering thread calls the underlying graphics processing library, such as OpenGL, and then calls the GPU to complete the rendering to generate a bitmap.
[0123] Figure 3 An exemplary schematic diagram of a rendering tree provided in an embodiment of the present application.
[0124] The interface that the application needs to display is composed of multiple nested views. Different views have a parent-child relationship, so the parent-child relationship between the rendering nodes generated by traversing the view is the same as the parent-child relationship of the view. That is, the parent-child relationship between views determines the nesting relationship between different rendering nodes, and then the rendering thread can correctly render the application interface when generating a bitmap based on the rendering tree.
[0125] A view can correspond to one or more rendering nodes, and the root view (DecorView) corresponds to the root rendering node (RootRenderNode). That is, the nested relationship between rendering nodes corresponds to the parent-child relationship of views. Among them, the rendering node also includes rendering properties, which are used to determine the position, size, transparency, etc. of the view corresponding to the rendering node on the surface when rendering and generating a bitmap.
[0126] For example, the structure of the application interface is: the application's PhoneWindow carries a root view, and the subviews of the root view are view 1 and view Figure 2 ,See Figure 2 The subview is the view Figure 3 The structure of the rendering tree generated by the UI thread of the application is: the root rendering node corresponding to PhoneWindow is the root node of the rendering tree, the child node of the root rendering node is rendering node 0 corresponding to the root view, the child node of rendering node 0 is rendering node 1 corresponding to view 1 and the child node of rendering node 0 is rendering node 1 corresponding to view 1. Figure 2 The corresponding rendering node 2, the child nodes of rendering node 2 are Figure 3 The corresponding rendering node is 3.
[0127] The corresponding relationship between the view and the rendering node means that the rendering node includes all drawing operations in the corresponding view.
[0128] After receiving the rendering tree synchronized by the UI thread, the rendering thread calls the OpenGL interface to render a bitmap on the application's own surface, and sends the surface to SurfaceFlinger to wait for synthesis and display.
[0129] It is worth mentioning that the construction phase requires the use of CPU computing resources, and the rendering phase requires the use of GPU resources.
[0130] It is worth noting that if hardware acceleration is not enabled, the application completes all operations in the construction and rendering stages through the UI thread, and does not need to be encapsulated as a rendering node. After traversing the application's views and drawing the views, an anonymous shared memory is requested from SurfaceFlinger, and the underlying graphics library is directly called on the memory to generate a bitmap.
[0131] It is worth mentioning that Figure 2 The content shown is the process of generating a bitmap by an application when hardware acceleration is turned on. When hardware acceleration is not turned on in an electronic device, the application generates a bitmap by software drawing. Among them, software drawing includes:
[0132] ① Invalidate the view hierarchy, and the UI thread traverses the views of the application and records the drawing operations of each view. ② The UI thread obtains a software canvas (Canvas) for drawing through an interface, such as Surface.lockCanvas(), draws on the software canvas based on the saved drawing operation list, and generates a bitmap. And the software canvas is located on the surface generated by the application.
[0133] The surface held by the application is allocated to the application by SurfaceFlinger through binder communication. The number of surfaces held by the application can be consistent with the number of current windows (PhoneWindow) of the application.
[0134] After introducing the process of generating a bitmap by an application, the process of synthesizing a bitmap is exemplarily introduced.
[0135] (1.2) The process of SurfaceFlinger / HWC synthesizing bitmaps
[0136] SurfaceFlinger is a system service on electronic devices that is used to allocate surfaces to applications and use bitmaps on one or more surfaces as layers for layer synthesis. HWC is a functional module of the Hardware Abstraction Layer (HAL) responsible for synthesis and display in electronic devices. It provides an interface to the upper layer SurfaceFlinger and calls the capabilities of the underlying hardware (such as display drivers, excluding GPU) to synthesize layers.
[0137] Figure 4 An exemplary schematic diagram of a bitmap provided in an embodiment of the present application as a layer participating in layer synthesis.
[0138] like Figure 4As shown, the rendering thread of the application generates a bitmap on the surface allocated by SurfaceFlinger. SurfaceFlinger maintains the surface of one or more applications with the BufferQueue mechanism, that is, SurfaceFlinger can obtain bitmaps of different applications.
[0139] After SurfaceFlinger obtains the bitmaps of one or more applications, it can call the GPU to synthesize multiple bitmaps into one bitmap (the synthesis of bitmaps is called layer synthesis), which can also be called Client synthesis or GLES synthesis.
[0140] After SurfaceFlinger obtains the bitmap of the application, it can call the underlying hardware (excluding GPU) through HWC for synthesis. This synthesis method is also called Device synthesis.
[0141] Among them, Client synthesis needs to call the GPU. Client synthesis can synthesize multiple layers and complete synthesis involving pixel-by-pixel processing methods such as linear deepening on the layers.
[0142] Device can synthesize a limited number of layers and does not support many pixel-by-pixel processing methods. When synthesizing multiple layers that do not overlap on the screen, Device synthesis does not require layer synthesis. Instead, it reads data from different surfaces for display at different screen positions.
[0143] like Figure 4 As shown, SurfaceFlinger obtains bitmap 1 of application 1 and bitmap 2 of application 2. Figure 2 , ..., bitmap N of application N, you can use bitmap 1 and bitmap Figure 2 Perform client synthesis to generate bits Fig.11 . Second, SurfaceFlinger will be Fig.11 And bitmap N calls the underlying hardware through HWC for Device synthesis.
[0144] Device synthesis will temporarily save the position Fig.11 and bitmap N, and when the screen of the electronic device needs to display, Fig.11 / Bitmap N takes the corresponding pixel and displays it on the screen. For example, Figure 1B In the interface shown, Fig.11 It is a bitmap synthesized by the SMS application and the news application, and bitmap N is the bitmap of the status bar.
[0145] For the underlying hardware corresponding to SurfaceFlinger or HWC, each bitmap is equivalent to a layer.
[0146] The layer synthesis method can be determined by the underlying hardware corresponding to the HWC or by SurfaceFlinger.
[0147] For example, first, after SurfaceFlinger obtains the bitmap, it passes the layer collection to the underlying hardware through HWC, and the underlying hardware decides which layers are synthesized by the Client and which layers are synthesized by the Device. The underlying hardware will mark the synthesis method for the layers in the layer list, and return the synthesis methods of different layers to SurfaceFlinger, which will synthesize the layers marked as GPU synthesis and put the synthesis results into a buffer. SurfaceFlinger passes the buffer and other layers marked as Overlay synthesis methods to the underlying hardware through HWC, and the underlying hardware completes the synthesis of the layers.
[0148] For another example, SurfaceFlinger will directly mark the layers that trigger off-screen rendering logic such as window animation during layer synthesis as GPU synthesis. Among them, the off-screen rendering logic involved also includes logic such as rounded corners, scaling, rotation, color conversion, etc. that the underlying hardware corresponding to HWC cannot handle.
[0149] Since the surface allocated by SurfaceFlinger to the application contains not only the bitmap generated by the application rendering thread, but also window control information such as the layer Z order obtained from the window management service, SurfaceFlinger can obtain the window control information of the layer from the surface, and then determine whether the layer needs GPU synthesis. Among them, the layer Z order determines the height order of the layer on the Z axis, where the Z axis is perpendicular to the screen and is used to calculate the upper and lower relationships of different layers.
[0150] Figure 5 An exemplary schematic diagram of layer synthesis provided in an embodiment of the present application.
[0151] like Figure 5 As shown in the figure, after SurfaceFlinger obtains the bitmap of the application, it writes each bitmap as a layer into the layer list. SurfaceFlinger passes the layer list to the underlying hardware through HWC. The underlying hardware determines the synthesis method of different layers according to its own capabilities and returns the result to SurfaceFlinger through HWC.
[0152] After SurfaceFlinger obtains the result returned by HWC, it can know the synthesis method of each layer in the layer list. For the layer marked as GPU synthesis, SurfaceFlinger synthesizes the layer and passes the synthesized layer and the layer marked as overlay synthesis to the underlying hardware through HWC, and then synthesizes the layer through the underlying hardware corresponding to HWC.
[0153] Figure 6 Another exemplary schematic diagram of layer synthesis by SurfaceFlinge provided in an embodiment of the present application.
[0154] After SurfaceFlinger gets multiple surfaces, it can determine the bitmaps on each surface as the synthesis mode of the layer. After SurfaceFlinger gets multiple layers and determines that the synthesis mode of the layer is GPU, it can perform Client synthesis. The synthesis mode of the layer can include: Mode.CLEAR (display the layer at the top of the Z order), Mode.SRC_OVER (display each layer in sequence according to the Z order), Mode.DST_IN (display the part of the layer at the top of the Z order that does not intersect with the layers below it), etc.
[0155] For example, Figure 6 As shown, when the composition mode of the layer is Mode.SRC_OVER, SurfaceFlinger will synthesize the contents of the three layers, determine the upper and lower relationships of different layers according to the Z order of the layers, and superimpose them on one layer in turn.
[0156] The Z order of layer 1 is a, the Z order of layer 2 is a+1, and the Z order of layer 3 is a+2. After SurfaceFlinger synthesizes the contents of the three layers, the contents of layer 1 and layer 2 are completely obscured, and only the content of layer 3 is displayed.
[0157] Among them, complete occlusion means that the view on the layer with a lower Z order will not be displayed at all due to the occlusion of the layer with a higher Z order.
[0158] All layers that are composited by GPU will trigger off-screen rendering, and layer compositing is performed through off-screen rendering. The following introduces the relevant concepts of off-screen rendering.
[0159] (1.3) Off-screen rendering
[0160] When SurfaceFlinger determines that any number of layers need to be composited by the GPU, off-screen rendering needs to be enabled to complete the layer synthesis.
[0161] Among them, off-screen rendering is to apply for an off-screen buffer for SurfaceFlinger, and call the GPU to perform image processing in the off-screen buffer. The off-screen buffer is a piece of memory outside the current screen buffer, and multiple layers are synthesized in the off-screen buffer.
[0162] Off-screen rendering can include the following steps:
[0163] ① The bitmap in the GPU-synthesized layer determined by SurfaceFlinger needs to be converted into a texture and uploaded to the GPU memory (i.e., off-screen buffer) or mapped as an OpenGL texture through shared memory, and then OpenGL binds the texture (binding the texture includes binding the context context).
[0164] ② Render the texture according to the instructions related to the window animation corresponding to the layer. And merge the textures of multiple applications, where the layer merging performs pixel-by-pixel rendering according to the layer synthesis mode.
[0165] ③SurfaceFlinger obtains the rendered texture from the GPU memory or directly obtains the rendered texture from the shared memory.
[0166] Obviously, off-screen rendering will cause context switching, and context switching adds additional performance overhead.
[0167] Combining the contents of (1.1) the process of application generating bitmaps, (1.2) the process of SurfaceFlinger / HWC synthesizing bitmaps, and (1.3) off-screen rendering, the following is a complete introduction to the process of synthesizing bitmaps as layers.
[0168] Fig. 7A , Figure 7B Another exemplary schematic diagram of layer synthesis provided in an embodiment of the present application.
[0169] like Fig. 7A As shown, UI threads of different applications independently generate their own rendering trees, and pass the rendering trees to their own rendering threads for rendering to generate bitmaps.
[0170] The rendering thread first generates a bitmap based on the attributes and drawing instruction list in the rendering node in the rendering tree, and synthesizes the bitmap as a layer. When the layer synthesis method is GPU synthesis, SurfaceFlinger merges multiple layers into one layer through off-screen rendering.
[0171] For example, application 1 generates render tree 1, and then generates bitmap 1 based on render tree 1. Application 2 generates render tree 2, and then generates bitmap 1 based on render tree 2. Figure 2 SurfaceFlinger receives bitmap 1 and bitmap Figure 2 After that, the bitmap 1 and bitmap Figure 2 Perform off-screen rendering to generate bits Figure 5 In the off-screen rendering process, bitmap 1 is first copied to the off-screen buffer, and based on the window animation information, bitmap 1 is converted into bitmap in the off-screen buffer. Figure 3 ; Similarly, Figure 2 Convert to bit Figure 4 ; Finally, place Figure 3 and position Figure 4 Generate positions based on the layer synthesis mode Figure 5 .
[0172] like Figure 7B As shown, to achieve Figure 1B As shown in the interface, after receiving the bitmap of the application, SurfaceFlinger first performs off-screen rendering on the bitmap of the application involved in the window animation bitmap to complete the transformation, and then copies the transformed layer to the on-screen buffer for display.
[0173] For example, if the bitmap of application 3 needs to be reduced, the bitmap of application 3 cannot be directly copied to the on-screen buffer for transformation, which may affect the bitmaps of other applications. Instead, it needs to be copied to the off-screen buffer for transformation separately, and the transformed result is copied back to the on-screen buffer.
[0174] Obviously, the correct interface can only be generated by first changing the bitmap generated by each application and then superimposing them according to the layer synthesis mode.
[0175] Among them, from the generation of the rendering tree by the main thread of the application to the completion of the SurfaceFlinger layer synthesis, since the process of calling the GPU is always changing (from application 1 to application 2, ..., application N, SurfaceFlinger), the GPU needs to be started separately at least N+1 times, where N is the number of applications.
[0176] It is understandable that, since different applications independently construct and render their own bitmaps, when the layers are synthesized, the layers with lower Z order may be completely obscured by the layers with higher Z order, which inevitably leads to the overdraw of the bitmaps of different applications, for example Figure 6The overlapping parts of the three graphics are overdrawn, that is, layer 1 and layer 2 are transitionally drawn, and the synthesized interface is not affected by layer 1 and layer 2; secondly, off-screen rendering requires new allocation of off-screen buffers and context switching, which increases the memory and computing overhead of electronic devices.
[0177] (2) Next, the interface generation method provided in the embodiment of the present application is described below.
[0178] The interface generation method provided in the embodiment of the present application first obtains the rendering trees of one or more applications through the UniRender process, and recombine the one or more rendering trees to generate a target rendering tree; secondly, the UniRender process renders based on the target rendering tree to directly obtain a bitmap carrying the interface image information of the one or more application programs without performing layer synthesis.
[0179] First, the interface generation method provided by the embodiment of the present application merges the target rendering trees of one or more applications into a target rendering tree. In the process of generating the target rendering tree, the UniRender process determines the off-screen rendering logic of each layer, and adds or modifies the properties of the corresponding rendering nodes in the target rendering tree according to the off-screen rendering logic, so that the UniRender process directly generates a bitmap without off-screen rendering.
[0180] Secondly, the interface generation method provided by the embodiment of the present application merges the target rendering trees of one or more applications into a target rendering tree, without generating multiple bitmaps as layers for synthesis. In the process of rendering and generating bitmaps according to the target rendering tree, the UniRender process uses the Z order of the layer as the Z order of the rendering tree, and can delete the rendering nodes corresponding to the views that are not displayed or do not affect the display, thereby avoiding over-drawing.
[0181] Finally, the interface generation method provided in the embodiment of the present application can enable the application to not generate a rendering thread, but instead hand it over to the UniRender process for unified rendering, thereby helping to improve the speed of interface rendering.
[0182] (2.1) System architecture of the interface generation method provided in the embodiment of the present application
[0183] Figure 8 An exemplary schematic diagram of the system architecture of the interface generation method provided in an embodiment of the present application.
[0184] When the application interface is updated, the application can request a vertical synchronization signal (Vsync-APP) from the UniRender process (SurfaceFlinger is not in Figure 8) In the presence of SurfaceFlinger, the application can request a vertical synchronization signal (Vsync-APP) from SurfaceFlinger.
[0185] Among them, the vertical synchronization signal (Vsync-APP) of the UniRender process can come from SurfaceFlinger or directly from the underlying hardware corresponding to the HWC (such as the screen) or the UniRender process starts a timed wake-up thread to generate a vertical synchronization signal (Vsync-APP). In the case of SurfaceFlinger, Vsync-APP can come from SurfaceFlinger.
[0186] After the application obtains the vertical synchronization signal (Vsync-APP), the application generates a rendering tree and passes the rendering tree to the UniRender process.
[0187] Upon receiving the vertical synchronization signal (Vsync-UR), the UniRender process merges one or more rendering trees to generate a target rendering tree. Then, the UniRender process uses the rendering engine to traverse and execute the drawing operations in the drawing instruction list of each rendering node in the rendering tree to generate a bitmap carrying one or more rendering tree image information. The bitmap can be located in the screen buffer.
[0188] The difference between Vsync-UR and Vsync-APP is Vsync-Offset, which can be determined by the UniRender process. In the case of SurfaceFlinger, Vsync-Offset can be determined by SurfaceFlinger.
[0189] After the UniRender process generates the bitmap, it passes the bitmap to the display subsystem through the HWC and then sends it to the display.
[0190] After introducing the system architecture of the interface generation method of the present application, the method flow of the interface generation method provided by the embodiment of the present application is exemplarily introduced.
[0191] (2.2) Method flow of the interface generation method provided in the embodiment of the present application
[0192] Combine the following Fig. 9 The interface generation method provided in the embodiment of the present application is introduced exemplarily.
[0193] Fig. 9 An exemplary schematic diagram of the interface generation method provided in an embodiment of the present application.
[0194] like Fig. 9 As shown, the interface generation method provided in the embodiment of the present application includes:
[0195] S901: After receiving the vertical synchronization signal, build a rendering tree
[0196] When the application needs to update the interface, it can request a vertical synchronization signal (Vsync-APP) from the UniRender process. After receiving the vertical synchronization signal, the application executes the measure() method, layout() method, and draw() method in the UI thread. Among them, when executing the draw() method, the UI thread will traverse the views of the application, determine the drawing instructions required for rendering each view, and continuously record / record them in the drawing instruction list of the rendering node corresponding to the view.
[0197] The interface that the application needs to display is composed of multiple nested views. The drawing instruction list corresponding to the root view (DecorView) includes the drawing instruction list entries of the root view's subviews. That is, the nesting relationship between drawing instruction lists is the same as the nesting relationship between views, so the nesting relationship of rendering nodes is the same as the nesting relationship of views. For the definitions of the relevant concepts of rendering tree and rendering node, please refer to the above. Figure 3 The corresponding text description.
[0198] Fig.10 An exemplary schematic diagram of constructing a rendering tree provided in an embodiment of the present application.
[0199] After measuring, laying out, and drawing, the application UI thread can obtain the parent-child structure of multiple views of the interface to be updated, and in the process of traversing the views, determine the content to be displayed on each view and the interface calls required to generate the content, such as drawCircle, drawLine, etc.
[0200] The application encapsulates the drawing interface calls such as drawCircle and drawLine into corresponding DrawOp such as DrawCircleOp and DrawLineOp, and saves them in the drawing instruction list. DrawLineOp is the interface call for drawing graphics of the underlying graphics library (such as OpenGL), which will be further converted into instructions for calling the GPU to draw graphics.
[0201] like Fig.10 As shown, the view structure of the application interface is: root view, the subviews of the root view are view 1 and view Figure 2 ,See Figure 2 The subview is the view Figure 3Among them, Figure 2 If the rectangle and circle are included, Figure 2 The corresponding drawing operations in the drawing instruction list of the rendering node 2 include: an operation of drawing a rectangle, an operation of drawing a circle, and the like.
[0202] 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 operations in each view, and encapsulate the drawing operations as DrawOp. After generating the drawing instruction list, the UI thread of the application will further encapsulate the drawing instruction list as a render tree.
[0203] The rendering node in the rendering tree includes a drawing instruction list and rendering attributes. The rendering attributes are 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 content of the view to be rendered by the rendering node, such as lines, rectangles, circles, etc.
[0204] The surface is requested by the application, and the application determines the size of the surface. If SurfaceFlinger exists, the surface can be requested by the application to SurfaceFlinger, and if SurfaceFlinger does not exist, it can be requested to the UniRender process. SurfaceFlinger may not allocate a surface to the application.
[0205] Optionally, in some embodiments of the present application, the UniRender process can 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 application displayed on display area 1 generates a rendering tree at the frequency of the screen refresh rate of display area 1.
[0206] It is worth noting that the UI thread of an application can generate multiple rendering trees, for example, in multi-display area scenarios such as multi-screen, virtual screen, and multi-window scenarios. For multi-display area scenarios, please refer to the text description in (2.2) Interface generation method under multi-display area scenario.
[0207] S902: Transferring the rendering tree across processes
[0208] 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 rendering tree is on the stack of the process corresponding to the application. The corresponding UniRender process needs to receive the rendering trees passed by different applications and determine the corresponding relationship between the rendering tree and the application.
[0209] Among them, multiple applications in the foreground pass the rendering tree to UniRender. If the application meets any of the following three conditions, the application is a foreground application, the application has a visible activity, the application has a foreground service, and other foreground applications are associated with the application.
[0210] Since the memory of different processes is not shared, data exchange between processes needs to be completed through inter-process communication (IPC). Among them, the application can pass the rendering tree to the UniRender process through Binder, AIDL, shared memory, Socket, etc. to achieve IPC communication, which is not limited here.
[0211] The following uses shared memory as an example of IPC communication to illustrate how to transfer the rendering tree across processes.
[0212] (a) The application writes the render tree to shared memory
[0213] Fig.11 An exemplary schematic diagram of a shared memory transfer rendering tree provided in an embodiment of the present application.
[0214] like Fig.11 As shown, first, the application will request shared memory from the UniRender process every time it is started. After receiving the shared memory request initiated by the application, the UniRender process requests a piece of shared memory and the handle corresponding to the shared memory through the anonymous shared memory (Ashmem) subsystem.
[0215] 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.
[0216] The shared memory may be a virtual file established in a memory (RAM) through a temporary file system (tmpfs), and is mapped to user spaces of different processes respectively.
[0217] Among them, cross-process communication such as the application applies for shared memory from the UniRender process, the UniRender process applies for shared memory from the Ashmem subsystem, and the UniRender process returns the handle corresponding to the applied shared memory to the application can be achieved through Binder communication.
[0218] It is understandable that the rendering tree stored on the stack of the application process can be passed to the UniRender process through other IPC methods such as shared memory, which is not limited here.
[0219] Optionally, in some embodiments of the present application, a whitelist is configured in a local configuration file of the electronic device or on a cloud server, and the whitelist stores the package name of the application and other identifiers that can uniquely identify the application process. If the application belongs to the whitelist, the rendering tree is passed to the UniRender process; if the application does not belong to the whitelist, after the UI thread software draws or the rendering thread renders it into a bitmap, the bitmap is passed to UniRender for process synthesis or the bitmap is passed to SurfaceFlinger, which synthesizes the bitmap of the application that does not belong to the whitelist with the bitmap generated by the UniRender process.
[0220] 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 shared memories, which are used to store different layers, that is, to store data of different rendering trees.
[0221] Optionally, in some embodiments of the present application, the application may request two blocks of shared memory from the UniRender process for staggered writing of the rendering tree. For example, if the rendering tree corresponding to a certain frame interface is written to the first block of shared memory, the rendering tree corresponding to the next frame interface is written to the second block of shared memory; and the rendering tree corresponding to the next frame interface is written to the first block of shared memory. This helps to prevent read-write conflicts that result in the inability to write rendering tree data to the shared memory in a timely manner when there is only one block of shared memory.
[0222] (b) Storage data structure of the rendering tree in shared memory
[0223] 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 is an exemplary introduction to the data structure of the rendering tree stored in the shared memory:
[0224] The memory tree can be composed of multiple segments of data, and different segments of data store layer information, rendering data, etc. Fig. 12A , Fig. 12B The content shown in FIG. 1 is used as an example to introduce the structure of the memory tree. The offsets of data of different segments in the shared memory may be fixed or non-fixed and adaptive.
[0225] Fig. 12A , Fig. 12B An exemplary schematic diagram of a storage structure of a rendering tree in a shared memory provided in an embodiment of the present application.
[0226] like Fig. 12A As shown, the storage structure of the rendering tree includes three pieces of data, namely the HEAD field, the MAPPING field, and the NODES field.
[0227] 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.
[0228] 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 other than the root node of the rendering tree, and one nodeid corresponds to one address, which 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, currentproperties is the rendering properties read by the UniRender process, and currentdisplaylist is the drawing instruction list read by the UniRender process.
[0229] It is worth noting that, assuming that "stagingproperties and stagingdisplaylist" are the first set of data, and "currentproperties and currentdisplaylist" are the second set of data, the data written by the application is the first set of data, and the next time the application writes data is the second set of data, realizing 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.
[0230] Optionally, in some embodiments of the present application, the storage structure of the rendering tree in the shared memory can be as follows: Fig. 12B As shown, the NODES field may include only one set of data, namely, only rendering attributes and a drawing instruction list.
[0231] Layerkey is used for: Before the UniRender process reads the layer data in the shared memory through the handle, it can obtain the layer ID of the application that needs to be displayed and the layer ID of the application that needs to participate in the layer synthesis from the WMS. The UniRender process verifies the layer ID with the layer ID included in the layerkey in the shared memory.
[0232] Rootid is used for: Rootid is the entry point of the rendering tree and stores the entry points 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.
[0233] currentproperties, stagingproperties, stagingdisplaylist, and currentdisplaylist are used for: after the application completes writing the drawing instruction list and rendering properties, the values of currentproperties and stagingproperties are exchanged, and the values of currentdisplaylist and stagingdisplaylist are exchanged. The UniRender process reads the rendering properties and drawing instruction list from currentproperties and currentdisplaylist.
[0234] For example, application 1 is an application displayed in the foreground, and application 1 may have multiple layers, that is, after receiving the vertical synchronization signal (Vsync-APP), application 1 will generate multiple rendering trees, such as rendering tree 1 and rendering tree 2. The UniRender process determines from WMS that the rendering tree corresponding to the layer participating in layer synthesis is rendering tree 1.
[0235] Since the offsets of layerkey and rootid are fixed, the UniRender process can determine the address of the root node. The UniRender process finds the location of the root node on the NODES side in the MAPPING segment, reads the rendering instructions for rendering the node, and if there are child nodes, there will be corresponding DrawRenderNode instructions, which store the id of the child node, and find the location of the child node in the MAPPING segment through the hash value. For example, the parent-child relationship of the rendering nodes of the rendering tree is saved in the DrawOP operation. For example, the drawing instruction list of rendering node 2 includes several DrawOP operations and the "Draw RenderNode3" operation, so the UniRender process can determine that rendering node 3 is a child node of rendering node 2.
[0236] It is understandable that the rendering tree in the shared memory still retains the same nesting relationship as the application's view, so the UniRender process can read data starting from the root node and then read the data of the entire rendering tree.
[0237] 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, so that half of the data written by the application is prevented from being read by the UniRender process as the latest data to render and generate the application interface. For the security guarantee of simultaneous reading and writing of the rendering tree, please refer to the text description of reading and writing the rendering tree in shared memory in (2.3) below, which will not be repeated here.
[0238] Optionally, in some embodiments of the present application, the sizes of the three segments of data may be fixed. That is, when the UniRender process applies for shared memory from the Ashmem subsystem, the shared memory obtained is a memory of size (a+b+c). Among them, from the starting address (physical address) to the starting address+a is the position to fill the HEAD field; from the starting address+a+1 to the starting address+a+b is the position to fill the MAPPING field; from the starting address+a+b+1 to the starting address+a+b+c is the position to fill the NODES field.
[0239] It can be understood that when the sizes of the three segments of data are fixed, the UniRender process can determine the start of each segment of data according to the fixed offset, and then find the Mapping segment, which stores the offset of the rendering node of the rendering tree in the NODES field, and then find the data of each rendering node.
[0240] Optionally, in some embodiments of the present application, when the size of the three segments of data is fixed, if the rendering node written by the application exceeds the size of b, a second block of shared memory is requested from the UniRender process. The second block of shared memory may have the same format as the first block of shared memory, and the NODES field of the second block of shared memory continues to store the drawing instruction list and rendering node attributes of the rendering node. The HEAD field and / or the MAPPING field of the second block of shared memory may be empty or may not exist. That is, in some embodiments of the present application, the second block of shared memory only includes the NODES field.
[0241] (c) UniRender reads the render tree in shared memory
[0242] (c.1) UniRender Architecture
[0243] Fig.13 An exemplary schematic diagram of the UniRender architecture provided in an embodiment of the present application.
[0244] like Fig.13 As shown, the UniRender provided in this application may include four parts, namely NodeManager, LayerManager, DisplayManager, and UniRenderCore.
[0245] NodeManager is a node management module in the UniRender process, which is responsible for receiving the rendering tree sent by the application program, etc. For the synthesis of the target rendering tree, reference may be made to the text description in step S903.
[0246] Among them, LayerManager is the layer management module in the UniRender process, which is responsible for synchronizing layer information such as layer creation, destruction, property changes, etc. from the Window Manager Service (WMS). Among them, a bitmap is equivalent to a layer.
[0247] Among them, DisplayManager is the display device management module in the UniRender process, which is responsible for synchronizing the display device information, such as the screen size, from the Display Manager Service (DMS).
[0248] Among them, UniRenderCore is the rendering management module within the UniRender process, which is responsible for: establishing a corresponding rendering node for each layer; receiving rendering trees corresponding to different applications maintained in NodeManager, removing the layer information instructions of the application from LayerManager and inserting them into rendering nodes; merging the rendering trees corresponding to all visible layers of the activated display device maintained in DisplayManager; traversing the merged rendering tree for each display area, and UniRender generating a bitmap on the buffer allocated for it, etc.
[0249] (c.2) UniRender reads the render tree
[0250] The UniRender process first determines the applications displayed on each display area from the DMS and WMS. These applications are the applications participating in layer synthesis. Among them, the UniRender process can further determine the applications that perform layer synthesis in the UniRender process in combination with the whitelist. Among them, the UniRender process can determine the layer ID of each application through the WMS.
[0251] Among them, the DisplayManager 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.
[0252] Since the UniRender process stores the handle of the shared memory corresponding to the application, after UniRender determines the application participating in layer synthesis, it can determine the shared memory corresponding to the application through the handle. UniRender reads the rendering tree from the shared memory through the handle.
[0253] 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.
[0254] The process of UniRender process reading the rendering tree from shared memory includes:
[0255] First, the UniRender process reads layerkey from the start address of the shared memory and verifies the layer ID. The UniRender process compares the layer ID determined by WMS with the layer ID determined by layerkey. When the verification is consistent, the UniRender process starts reading the rendering tree from the root node rootid.
[0256] Secondly, after finding the address of the root node, the UniRender process determines the starting address of the root node in the NODES segment using the address field in the MAPPING segment, and starts reading the drawing instruction list and rendering attributes of the rendering node. If the root node has child nodes, the entry of the child node is stored in the drawing list instruction of the root node, such as the DrawRenderNode instruction. Since the DrawRenderNode instruction includes the ID of the child node, the UniRender process finds the corresponding nodeid in the MAPPING segment through a hash operation, and then determines the location of the drawing instruction list and rendering attributes of the child node in the NODES segment, and reads the drawing instruction list and rendering attributes of the child node.
[0257] (d) Reading and writing the render tree in shared memory
[0258] The render tree in shared memory can be read and written by two or more processes. In order to reduce and avoid read-write conflicts that may cause errors in the render tree data, you can configure a synchronization lock between processes to ensure the read and write security of the render tree.
[0259] Combine the following Fig.14 , Fig.15 The content shown here exemplifies the process of reading and writing the render tree.
[0260] Fig.14 An exemplary schematic diagram of an application writing a rendering tree into a shared memory provided in an embodiment of the present application.
[0261] Each application stores at least one lock variable A to prevent the application and UniRender from reading and writing the shared memory at the same time. UniRender obtains the status (holding or releasing) of the lock variables of different applications through IPC communication.
[0262] like Fig.14 As shown, ① first, when the application needs to update the interface, it requests and receives the vertical synchronization signal (Vsync-APP), then obtains the lock variable A of the shared memory corresponding to the application, and calculates and updates the attributes and drawing instruction list of the rendering node starting from the root node.
[0263] ② Secondly, the application writes the updated rendering node properties and drawing instruction list into the stagingproperties and stagingdisplaylist data segments of the NODES segment in the shared memory, and adds the changed rendering node id to the properties_dirty queue and displaylist_dirty queue, which are stored in the shared memory management class singleton on the application side.
[0264] It can be understood that the rendering nodes marked with changes in the properties_dirty queue and the displaylist_dirty queue can achieve differential update of the rendering tree.
[0265] Optionally, in some embodiments of the present application, the properties_dirty queue and the displaylist_dirty queue may not be saved to implement a full rendering tree update.
[0266] ③ Again, the application copies the stagingproperties segment of the corresponding rendering node in the properties_dirty queue to the currentproperties segment. The application exchanges the draw_pointer and record_pointer of the corresponding rendering node in the displaylist_dirty queue, that is, copies the stagingdisplaylist segment of the corresponding rendering node in the displaylist_dirty queue to the currentdisplaylist; or the application copies the stagingdisplaylist segment to the currentdisplaylist.
[0267] It can be understood that, compared with 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 exchanges the draw_pointer and record_pointer of the corresponding rendering node in the displaylist_dirty queue, thereby realizing the differential update of currentdisplaylist.
[0268] It is understandable that the application can copy the stagingdisplaylist segment to the currentdisplaylist to achieve a full update, that is, all data of the rendering tree generated by the application in response to the vertical synchronization signal (Vsync-APP) is directly written to the shared memory, which is relatively simple to implement.
[0269] Optionally, in some embodiments of the present application, without saving the properties_dirty queue and the displaylist_dirty queue, the stagingproperties segment of all rendering nodes of the application is copied to the currentproperties segment, and the stagingdisplaylist segment is copied to the currentdisplaylist segment. This copying can be achieved by changing the position of the pointer.
[0270] ④ Again, the application transmits the information that the lock variable A has been released to the UniRender process through IPC communication.
[0271] ⑤Again, the UniRender process holds the lock variable A.
[0272] ⑥Finally, corresponding to ③, the UniRender process reads the current displaylist, current properties from the shared memory, or reads the stagingdisplaylist segment of the corresponding rendering node in the displaylist_dirty queue and copies it to the currentdisplaylist.
[0273] After reading the data, the UniRender process 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 the rendering tree is written into the shared memory. At this time, the roles of the staging data segment and the current data segment are interchanged. The UniRender process finally reads the stagingdisplaylist and stagingproperties segments to implement the "double buffering" mechanism and ensure the robustness of interface generation.
[0274] Optionally, in some embodiments of the present application, when there is a lock variable between the application and the UniRender process, the NODES field may include only stagingdisplaylist and stagingproperties, or only currentdisplaylist and currentproperties. The application and the UniRender process achieve read-write security through the lock variable, so that the UniRender process reads the correct rendering tree.
[0275] Optionally, in some embodiments of the present application, each application may hold more lock variables, for example, each application holds lock variable A and lock variable B. Then, after the application releases lock A, it does not need to wait for UniRender to release lock A. After holding lock variable B, after receiving the next vertical synchronization signal (Vsync-APP), the rendering tree data is directly written into the shared memory.
[0276] The holding, releasing, and inter-process synchronization of the lock variable B are the same as the holding, releasing, and inter-process synchronization of the lock variable A. For details, please refer to Fig.14 The text description shown is not repeated here.
[0277] Fig.15 Another exemplary schematic diagram of an application writing a rendering tree into a shared memory provided in an embodiment of the present application.
[0278] like Fig.15 As shown, when an application stores a lock variable A, after receiving the vertical synchronization signal 1 (Vsync-APP), the application holds the lock variable A and writes the generated rendering tree into the shared memory during the holding stage. After the application writes the rendering tree into the shared memory, the lock variable A is released. After determining that the lock variable A is released by the application, UniRender holds the lock variable A and starts to read the rendering tree generated by the application in response to the vertical synchronization signal 1 from the shared memory.
[0279] During the time when the UniRender process holds the lock variable A, the application receives the vertical synchronization signal 2 (Vsync-APP) after the vertical synchronization signal 1. Since the lock variable A is held by the UniRender process, the application cannot write the rendering tree to the shared memory in time and needs to wait for a while until the application determines that the UniRender process releases lock A.
[0280] But, obviously, in Fig.13 In the content, the UniRender process reads the currentdisplaylist field and the currentproperties field, while the application writes to the stagingdisplaylist field and the stagingproperties field. Concurrent reading and writing of different fields in the shared memory can be achieved by increasing the number of lock variables.
[0281] like Fig.15As shown, 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 writes the generated rendering tree into the shared memory during the holding stage. After the application writes the rendering tree into the shared memory, the lock variable A is released. After determining that the lock variable A is released by the application, the UniRender process holds the lock variable and starts to read the rendering tree generated by the application in response to the vertical synchronization signal 1 from the shared memory.
[0282] During the time when the UniRender process holds lock variable A, the application receives vertical synchronization signal 2 (Vsync-APP) after vertical synchronization signal 1. At this time, the application holds lock variable B. The application can write the rendering tree to the shared memory in time without waiting for a while until the application determines that the UniRender process releases lock A.
[0283] Correspondingly, after determining that the lock variable B is released by the application, the UniRender process holds the lock variable B and starts to read the rendering tree generated by the application in response to the vertical synchronization signal 2 from the shared memory.
[0284] It is worth noting that the number of lock variables held by the application 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.
[0285] For example, if currentdisplaylist and currentproperties are the first group, and stagingdisplaylist and stagingproperties are the second group, then two synchronization lock variables can be configured in the application and UniRender process, corresponding to the two groups of data respectively. Similarly, for another example, if the NODES field includes three groups of data, then three synchronization lock variables can be configured in the application and UniRender.
[0286] Among them, a lock variable corresponds to a set of data, for example, lock variable A corresponds to currentdisplaylist and currentproperties, then the change of lock variable A from the held state to the released state indicates that the application has successfully updated the data of currentdisplaylist and currentproperties in the shared memory, and the data of currentdisplaylist and currentproperties can be read by the UniRender process; or, the change of lock variable A from the held state to the released state indicates that the UniRender process has completed the reading of the data of currentdisplaylist and currentproperties from the shared memory, and the data of currentdisplaylist and currentproperties can be updated by the application.
[0287] The number of locked variables may be related to the value of Vsync-offset.
[0288] 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). When Vsync-offset is large, the lock variable may not be configured. When the lock variable is not configured, the UniRender process reads the rendering tree from the shared memory after receiving the vertical synchronization signal (Vsync-UR). Since Vsync-offset is large, the application has completely written the rendering tree into the shared memory when the UniRender process reads the rendering tree.
[0289] S903: Transmitting the application's window control information and display area information
[0290] The LayerManager in the UniRender process obtains the window control information of one or more applications from the window management service, and then determines whether there is drawing logic that triggers off-screen rendering on the layer of any application in combination with the layers of the one or more applications obtained in step S802.
[0291] The UniRender process can also obtain the Z order between layers of different applications, where the Z order is the up-down order of the Z axis between different layers.
[0292] The DisplayManager in the UniRender process obtains the display area information from the display management service, and the display area information includes the size of the display device. The UniRender process determines the size of the allocated surface based on the display area information, and the surface is used to carry the bitmap generated by UniRender based on the target rendering tree. Among them, the UniRender process generates a bitmap based on the target rendering tree. Please refer to the text description in step S905, which will not be repeated here.
[0293] Among them, instructions related to off-screen rendering include instructions such as rounding, scaling, rotation, color conversion, etc.; the definition of off-screen rendering can refer to the text description in (1.3) off-screen rendering above, which will not be repeated here.
[0294] The following is an illustrative introduction to the drawing logic involved in triggering off-screen rendering, such as rounded corners, scaling, rotation, and color conversion.
[0295] Figure 16A-16C An exemplary schematic diagram of a scenario for triggering drawing logic for off-screen rendering provided in an embodiment of the present application.
[0296] In response to user interaction, such as a full-screen gesture (such as sliding upward from the bottom to the center of the screen) or clicking a multitasking control in the bottom navigation bar, the electronic device displays a multitasking interface such as Fig.16A shown.
[0297] The bitmap generated by the gallery application is the same size as the screen, while in Fig.16A The interface of the gallery application in the multitasking interface shown is a scaled interface with rounded corners.
[0298] like Fig. 16B As shown, in the small window mode, the interface of the electronic device displays views of multiple applications, wherein the interfaces of some applications are located in floating windows.
[0299] For example, the interface of the electronic device displays interfaces of a news application and a text message application, wherein the interface of the text message application is located in a rendered floating window.
[0300] The bitmap generated by the SMS application is the same size as the screen, while in Fig. 16B In the small window mode shown, the interface of the SMS application is scaled and has rounded corners.
[0301] like Fig. 16CAs shown, in response to the user clicking the icon of the reading application in the desktop application, the electronic device starts the reading application. During the startup process of the reading application, the main interface (interface corresponding to the Main Activity) or the starting window (starting window) of the reading application is continuously enlarged.
[0302] Among them, the bitmap corresponding to the main interface or startup window of the reading application is the screen size, and the effect of continuous enlargement is achieved by adjusting the scaling ratio. Secondly, the bitmap corresponding to the main interface or startup window of the reading application is a bitmap with rounded corners, which is then displayed on the interface of the electronic device.
[0303] It is understandable that in Figure 16A-16C In the scenes shown and many other scenes, it is necessary to use rounded corners, scaling, rotation, and color conversion to generate an interface that is more in line with the user's visual habits and improve the user experience.
[0304] It is worth noting that in Figure 16A-16C In the scenario shown and many other scenarios, the UniRender process receives window control information of each application's layer from the window management service, and then determines whether each application's layer needs to be rounded, scaled, rotated, or color converted.
[0305] Optionally, in some embodiments of the present application, the UniRender process may first obtain window control information of one or more applications from the window management service, and then obtain the rendering tree of the one or more applications, that is, the occurrence sequence of step S902 and step S903 may be interchangeable.
[0306] S904: Generate a target rendering tree based on the obtained rendering tree, window control information, and display area information
[0307] First, after the UniRender process receives the render tree generated by one or more applications, it responds to and receives the vertical synchronization signal and window control information, and determines from the window control information whether there is logic for triggering off-screen rendering in the layer of each application.
[0308] Among them, when the application is displayed on the display area of the local electronic device, the window control information can come from the local window management service; when the application is displayed on the display area of other electronic devices, the window control information can come from the window management service of the other electronic device.
[0309] If the UniRender process determines that any layer of an application has logic that triggers off-screen rendering, the UniRender process converts the logic that triggers off-screen rendering into an off-screen rendering instruction, and converts the off-screen rendering instruction to the attributes of the rendering node of the corresponding rendering tree. For the convenience of description, the process in which the UniRender process converts the logic that triggers off-screen rendering into an off-screen rendering instruction and converts the off-screen rendering instruction to the attributes of the rendering node of the corresponding rendering tree can be referred to as the forward movement of the off-screen rendering instruction.
[0310] Then, after the UniRender process moves forward the trigger off-screen rendering instructions of one or more render trees, for each display area (display), the render trees corresponding to the visible layers of each display area are merged to generate a target render tree. That is, the number of target render trees may be related to the number of display areas.
[0311] The UniRender process can start reading the rendering tree from the shared memory after receiving the vertical synchronization signal (Vsync-UR), and after obtaining multiple rendering trees, move the off-screen rendering instructions forward and synthesize the rendering trees. Alternatively, the UniRender process can start reading the rendering tree from the shared memory while holding the lock variable, and start moving the off-screen rendering instructions forward and synthesizing the rendering trees after receiving the vertical synchronization signal (Vsync-UR).
[0312] The following describes the process of triggering the off-screen rendering instruction to move forward and the process of generating the target rendering tree.
[0313] (a) The process of moving the instructions that trigger off-screen rendering forward
[0314] First, the UniRender process obtains the window control information of each application layer and determines whether the window control information of any layer contains the drawing logic that triggers off-screen rendering. When the UniRender process determines that the window control information of the layers of all applications in a display area does not contain the drawing logic that triggers off-screen rendering, one or more rendering trees can be directly synthesized into a target rendering tree; when the UniRender process determines that the window control information of the layers of any application in a display area contains the drawing logic that triggers off-screen rendering, the instruction that triggers off-screen rendering is first moved forward, and then multiple rendering trees are synthesized into a target rendering tree.
[0315] The process of triggering the off-screen rendering instruction to move forward:
[0316] The UniRender process first determines the drawing logic that triggers off-screen rendering from the window control information, and converts the drawing logic that triggers off-screen rendering into instructions that can be configured in the rendering properties of the rendering node (or called drawing logic instructionization). After determining the binding relationship between the layer and the rendering tree, the UniRender process updates the off-screen rendering instructions to the rendering properties of the corresponding rendering node.
[0317] Among them, when the rendering attributes of the rendering node have corresponding scaling attributes (scale), rounded corner attributes (roundrect), color conversion attributes (colortransform), rotation attributes (transform), etc., the parameters in the scaling instructions, rounded corner instructions, color conversion instructions, and rotation instructions in the instructions that trigger off-screen rendering are assigned to the scaling attributes, rounded corner attributes, color conversion attributes, and rotation attributes in the attributes of the rendering node; when the rendering attributes of the rendering node do not have corresponding scaling attributes, rounded corner attributes, color conversion attributes, and rotation attributes, etc., the scaling attributes, rounded corner attributes, color conversion attributes, and rotation attributes will be added to the rendering node, and the parameters in the scaling instructions, rounded corner attributes, color conversion instructions, and rotation instructions in the instructions that trigger off-screen rendering are assigned to the scaling attributes, rounded corner attributes, color conversion attributes, and rotation attributes in the attributes of the rendering node.
[0318] Fig.17A , Fig. 17B An exemplary schematic diagram of UniRender triggering an off-screen rendering instruction to move forward provided in an embodiment of the present application.
[0319] like Fig.17A As shown, after the UI threads of application 1 and application 2 independently generate rendering trees and independently pass the rendering trees to the UniRender process through IPC communication, the UniRender process determines the instructions for triggering off-screen rendering of the layers of each application from the window management service. Among them, the rendering tree generated by application 1 is rendering tree 1, and the rendering tree generated by application 2 is rendering tree 2.
[0320] UniRender independently updates the properties of the render nodes in different render trees. That is, the UniRender process updates the properties of the render nodes in render tree 1, and UniRender updates the properties of the render nodes in render tree 2.
[0321] The instruction that triggers off-screen rendering acts on the entire layer, and the UniRender process assigns the parameters in the off-screen rendering instruction to the root node of the rendering tree corresponding to the layer, or directly assigns them to all rendering nodes of the rendering tree.
[0322] Among them, when the UniRender process assigns the parameters in the off-screen rendering instruction to the root node of the rendering tree corresponding to the layer, the UniRender process will automatically configure these properties of the rendering node to the rendering properties of the child nodes of the root node when generating a bitmap based on the rendering tree.
[0323] For example, if the child node of Render Node 1 is Render Node 2, then when the rendering attribute of Render Node 1 is configured with a rotation attribute (transform), the UniRender process will configure the same rotation attribute (transform) to the rendering attribute of RenderNode2 when generating the rendering tree.
[0324] like Fig. 17B As shown, before the off-screen rendering instruction is moved forward, after SurfaceFlinger receives the bitmap corresponding to the rendering tree generated by the application, it needs to process the bitmaps of different applications differently based on the window control information to complete the layer synthesis.
[0325] After the off-screen rendering instruction is moved forward to the rendering tree of the application, the UniRender process assigns the parameters in the off-screen rendering instruction to the rendering attributes of the rendering tree, so that in the process of generating a bitmap based on the rendering tree, the transformed bitmap is directly drawn on the canvas. Since there is no need to process the bitmaps of different applications differently, the bitmaps of different applications can be drawn sequentially on an on-screen buffer.
[0326] Among them, the UniRender process assigns the parameters in the off-screen rendering instruction to the rendering properties of the rendering tree, such as Fig.18 shown.
[0327] Fig.18 An exemplary schematic diagram of UniRender providing an embodiment of the present application to modify the rendering node attributes of a rendering tree.
[0328] like Fig.18 As shown, the UniRender process modifies the properties of the root node of the rendering tree and adds instructions to add the properties of the rendering node. Among them, the instruction corresponding to the scaling attribute is setScale(), the instruction corresponding to the rounded corner attribute is outline.setRoundRect(), the instruction corresponding to the color conversion attribute is setColorFilter(), and the instruction corresponding to the rotation attribute is setLeftTopRightBottom().
[0329] In step S905 below, when the UniRender process generates a bitmap based on the rendering tree, it will modify the drawing operation in the drawing instruction list according to the rendering attributes, and then generate a bitmap after scaling, rounding, color conversion, and rotation. For details, please refer to the text description in step S905, which will not be repeated here.
[0330] Optionally, in some embodiments of the present application, the instructions in the attributes of the root node of the rendering tree may also include instructions such as setStaticMatrix(). Since the application UI thread generates a rendering tree based on the surface applied to SurfaceFlinger, in order to transform the reference system when UniRender generates a bitmap based on the rendering tree in step S905, the instruction setStaticMatrix() is configured in the root node of the rendering tree during the process of moving the instruction that triggers off-screen rendering forward. The specific content of the instruction setStaticMatrix() can refer to the text description in step S905 below, which will not be repeated here.
[0331] (b) The process of generating the target rendering tree
[0332] After the UniRender process performs off-screen rendering instruction forward processing on all rendering trees, one or more processed rendering trees are obtained.
[0333] When the number of processed rendering trees is one, the processed rendering tree is the target rendering tree; when the number of processed rendering trees is greater than one, multiple processed rendering trees are synthesized into one target rendering tree.
[0334] Fig.19 An exemplary schematic diagram of combining rendering trees after forward processing of multiple off-screen rendering instructions into a target rendering tree provided in an embodiment of the present application.
[0335] like Fig.19 As shown, the UniRender process can create a new root rendering node, such as Fig.19 The new root rendering node in the target rendering tree is created, and the processed rendering trees of multiple applications are used 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.
[0336] Fig. 20 An exemplary schematic diagram of combining rendering trees after forward processing of multiple off-screen rendering instructions into a target rendering tree provided in an embodiment of the present application.
[0337] 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 shielding relationship between the layers of the application. Then, in the process of generating the target rendering tree, the rendering node corresponding to the completely shielded view is deleted, thereby reducing the amount of calculation in the process of generating the bitmap in step S905 and improving the speed of generating the bitmap.
[0338] For example, Fig. 20 As shown, the layer corresponding to the rendering tree generated by application 1 is layer 1, and the layer corresponding to the rendering tree generated by application 2 is layer 2. The Z order of layer 1 is higher than that of layer 2. The rendering tree corresponding to layer 1 is root rendering node 1, rendering node 1, rendering node 2, and rendering node 3. Rendering node 1 and rendering node 2 are child rendering nodes of root rendering node 1, and rendering node 3 is a child rendering node of rendering node 2. The rendering tree corresponding to layer 2 is root rendering node 2, rendering node 4, rendering node 5, and rendering node 6. Rendering node 4 and rendering node 5 are child rendering nodes of the new root rendering node, and rendering node 6 is a child rendering node of rendering node 5.
[0339] The UniRender process can traverse the rendering child nodes of the rendering tree corresponding to layer 1 and the child nodes of the rendering tree corresponding to layer 2, determine the position of the view corresponding to each rendering node in the surface (surface allocated by the UniRender process), and combine the layer Z order of layer 1 and the Z order of layer 2 to determine the completely obscured view and the rendering node of the completely obscured view.
[0340] For example, UniRender may determine that the view corresponding to the rendering node 6 in the rendering tree corresponding to layer 2 is completely obscured, and then delete the rendering node 6.
[0341] After the UniRender process deletes the rendering node corresponding to the completely obscured view, it can be done as follows Fig.18 The content shown merges all rendering trees that have been processed after triggering the off-screen rendering instructions to move forward into the target rendering tree.
[0342] 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, the DrawOP drawing operation that does not affect the interface is deleted, where the graphics drawn by the DrawOP drawing operation are not displayed on the interface; for another example, for different applications, the position of the DrawOP operation in the drawing node is modified so that the same type of DrawOP drawing operations can be executed together, such as modifying the DrawOP drawing operation of the rendering node 2 of the application 1 to the drawing instruction list of the rendering node 1 of the application 2, which is not limited here.
[0343] Optionally, in some embodiments of the present application, the following Fig.18 The content shown merges multiple rendering trees that trigger the forward processing of off-screen rendering instructions into one rendering tree, then determines the completely obscured view and deletes the rendering nodes corresponding to the completely obscured view to generate a target rendering tree.
[0344] Optionally, in some embodiments of the present application, for a partially obscured view, the rendering node corresponding to the view may be clipped by a clip instruction, wherein the clipping may be performed before or after the target rendering tree is synthesized.
[0345] Optionally, in some embodiments of the present application, after step S904 and before step S905, the UniRender process generates a target rendering tree and then decapsulates the drawing instruction list of RenderNode to obtain a series of DrawOPs, and then performs DrawOP operations on the target rendering tree as a whole to batch and merge, and in step S805, a target rendering tree that can generate a bitmap with less computational effort is obtained.
[0346] It is understandable that in Fig.16A , Fig. 16B In the illustrated scenario and other scenarios, by merging multiple rendering trees and optimizing the merged rendering tree, overdrawing can be avoided or reduced, thereby increasing the speed of generating the bitmap in step S905, saving power consumption of the electronic device, and improving the user experience.
[0347] 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.
[0348] S905: Generate a bitmap based on the target rendering tree
[0349] After obtaining the target rendering tree, the UniRender process allocates a surface to the target rendering tree, and the UniRender process generates a bitmap on the surface based on the target rendering tree, and the bitmap corresponds to the composite interface of one or more applications.
[0350] When the electronic device has multiple display areas, the surface can be bound to one of the display areas, and the surface can be the same size as the display area bound to the surface.
[0351] The UniRender process generates a bitmap based on the target render tree in the surface, including:
[0352] First, the UniRender process traverses the target rendering tree starting from the root node, and it can traverse the child nodes of the root node in a variety of ways.
[0353] The UniRender process can traverse different layers under the root node according to the Z order of the layers. The UniRender process can traverse different layers in the order of Z order from high to low, or can traverse different layers in the order of Z order from low to high.
[0354] For example, in Fig. 20 In the target rendering tree shown, the Z order of layer 1 is higher than that of layer 2, so the UniRender process can first traverse the rendering tree corresponding to layer 1, that is, first traverse the rendering tree composed of root rendering node 1, rendering node 1, rendering node 2, and rendering node 3, and then traverse the rendering tree composed of root rendering node 2, rendering node 4, and rendering node 5. Similarly, the UniRender process can first traverse the rendering tree corresponding to layer 2, and then traverse the rendering tree corresponding to layer 1.
[0355] It is worth noting that when the UniRender process traverses the layers from high to low in Z order, when the UniRender process executes the drawing operations in the drawing instruction list, when the layers are synthesized into an upper and lower shielding relationship, it can only draw in places that have not been drawn, which can reduce over-drawing.
[0356] It is worth noting that when the UniRender process traverses the layers from low to high in Z order, the UniRender process sequentially executes the drawing operations in the drawing instruction list in the rendering tree corresponding to different layers to generate a bitmap.
[0357] Second, the UniRender process modifies the drawing operations in the drawing instruction list according to the rendering attributes, executes the drawing operations, and then generates a bitmap.
[0358] When the UniRender process traverses each rendering node, it first reads the rendering properties of the rendering node. If the rendering properties include scaling properties, corner fillet properties, color conversion properties, rotation properties, etc., the UniRender process modifies the parameters of the drawing operation in the drawing instruction list based on these properties, and then executes the drawing operation in the modified drawing instruction list. If the rendering properties do not include scaling properties, corner fillet properties, color conversion properties, rotation properties, etc., UniRender directly executes the drawing operation in the drawing instruction list.
[0359] The following is an exemplary description of a method in which the UniRender process modifies the parameters of a drawing operation in a drawing instruction list according to rendering attributes.
[0360] For example, the rendering properties of the rendering node include setscale(0.5), where setscale(0.5) means scaling down to 0.5 times the original value, and the drawing instruction list includes drawCircle(x0, y0, 5). When the UniRender process executes the drawing operation drawCircle(x0, y0, 5), it will transform the drawing operation into drawCircle(x0, y0, 2.5). The first parameter of drawCircle() is the coordinate of the center of the circle on the X axis, the second parameter is the coordinate of the center of the circle on the Y axis, and the third parameter is the radius of the circle.
[0361] Considering that the drawing instruction list generated by the application UI thread may be related to the surface size applied for by the application itself, in an embodiment of the present application, the UniRender process configures setStaticMatrix() in the properties of the rendering node when traversing the rendering tree node to transform the reference coordinate system for drawing and rendering.
[0362] Among them, the UniRender process can determine the size of the reference coordinate system or reference surface when each application generates a drawing instruction list through WMS, and then determine the parameters of setStaticMatrix().
[0363] Fig.21 An exemplary schematic diagram of setStaticMatrix() provided in an embodiment of the present application.
[0364] After determining the surface coordinate system that the application generates the drawing instruction list with reference to, the UniRender process determines the coordinate transformation matrix Transformation according to the coordinate system of the surface held by the UniRender process.
[0365]
[0366] Among them, scale x is the scaling and skew along the x-axis x is the distortion / tilt along the x-axis, translate x is the translation along the x-axis; scale y is the scaling and skew along the y-axis y is the distortion / tilt along the y-axis, translate y Translation along the y-axis.
[0367] After the UniRender process executes the setStaticMatrix() instruction, it will calculate the coordinate transformation matrix Transformation and apply the transformation matrix to each drawing operation in the drawing instruction list. Fig.21 As shown in the figure, when the rendering tree generated by the application UI thread is referenced by a coordinate system that is not the coordinate system on the surface held by the UniRender process, the UniRender process determines the coordinate transformation matrix Transformation through the setStaticMatrix() instruction, and transforms the reference coordinate system when drawing the interface on the surface based on the drawing instruction list to correctly draw the interface.
[0368] The above mainly introduces the specific process of implementing the interface generation method provided by the embodiment of the present application in the single display area scenario. The following mainly introduces the specific process of implementing the interface generation method provided by the embodiment of the present application in the multi-display area scenario.
[0369] (2.3) Interface generation method in multi-display area scenario
[0370] First, a scenario of multiple display areas is introduced as an example.
[0371] (a) Multiple display area scenario
[0372] In the embodiment of the present application, the display area (display) may be a screen, or may be a virtual screen (VirtualDisplay), etc. The virtual screen may be an area of the electronic device used to carry the content displayed on the screen when recording the screen.
[0373] Figure 22A-22C An exemplary schematic diagram of a multi-display area scenario provided in an embodiment of the present application.
[0374] When multiple screens are configured on an electronic device, each screen is a display area. Fig.22AAs shown, the main screen of the electronic device serves as display area 1 to display desktop applications, and the secondary screen of the electronic device serves as display area 2 to display music applications.
[0375] In the case where the screen of an electronic device can have multiple states, the screen in each state can be one or more display areas. Fig. 22B As shown, when the screen of the electronic device is in a folded state, each part of the screen can be a display area; when the screen of the electronic device is in an unfolded state, the left half of the screen and the right half of the screen can each be a display area.
[0376] like Fig. 22C As shown, when the screen recording function is turned on, the screen of the electronic device is a display area, and the virtual screen carrying the screen recording content is a display area. The content displayed on the two display areas can be the same.
[0377] Figure 23A-23C Another exemplary schematic diagram of a multi-display area scenario provided in an embodiment of the present application.
[0378] like Fig.23A As shown, electronic device 1 shares the content displayed on the screen to the screen of electronic device 2. In this case, for electronic device 1, the screen of electronic device 1 is display area 1, and the screen of electronic device 2 is display area 2. The content displayed on the screen of electronic device 2 includes the content on the screen of electronic device 1.
[0379] like Fig. 23B As shown, electronic device 1 projects the content displayed on the screen onto the screen of electronic device 2. In this case, for electronic device 1, the screen of electronic device 1 is display area 1, and the screen of electronic device 2 is display area 2. Fig.23A The difference between the displayed contents is that the contents displayed on the screen of electronic device 2 are only the contents on the screen of electronic device 1.
[0380] like Fig.23C As shown, electronic device 1 projects the content displayed on the screen onto the screen of electronic device 2. In this case, for electronic device 1, the screen of electronic device 1 is display area 1, and the screen of electronic device 2 is display area 2. Fig.23A , Fig. 23B The difference between the displayed contents is that the contents displayed on the screen of electronic device 2 are part of the contents on the screen of electronic device 1 .
[0381] It is worth noting that in a multi-display area scenario and in the case of multiple electronic devices, such as if there is display area 1 on electronic device 1 and display area 2 on electronic device 2, display area 2 may only display the content displayed on the screen of electronic device 1; or, display area 2 may display a superposition of part or all of the content displayed on the screen of electronic device 1 and the content originally displayed on the screen of electronic device 2, etc.
[0382] (b) Interface generation method in a single device with multiple display areas
[0383] Fig.24 Another exemplary schematic diagram of the interface generation method provided in an embodiment of the present application.
[0384] like Fig.24 As shown, the interface generation method in a single device multi-display area scenario includes:
[0385] S2401: After receiving the vertical signal, build a rendering tree
[0386] For specific content, please refer to Fig. 9 The corresponding text description in step S901 will not be repeated here.
[0387] S2402: Passing rendering tree across processes
[0388] For specific content, please refer to Fig. 9 The corresponding text description in step S902 will not be repeated here.
[0389] Optionally, in some embodiments of the present application, the DisplayRender subprocess may directly communicate with the corresponding application to obtain the rendering tree through IPC, wherein the UniRender process determines the corresponding relationship between the DisplayRender subprocess and the application.
[0390] Optionally, in some embodiments of the present application, there may be a shared memory set consisting of multiple shared memories between all DisplayRender sub-processes and all applications, and each DisplayRender sub-process holds handles to the multiple shared memories.
[0391] The concept of the DisplayRender subprocess may refer to the corresponding text description in step S2404, which will not be repeated here.
[0392] S2403: Transmitting the application's window control information and display area information
[0393] For specific content, please refer to Fig. 9 The corresponding text description in step S903 will not be repeated here.
[0394] S2404: Allocate rendering tree
[0395] The UniRender process can create a number of child processes DisplayRender (equal to the number of display areas) Fig.24 DisplayRender1 to DisplayRenderN), and passes the rendering tree of the application displayed on the display area to DisplayRender.
[0396] For example, application 1 and application 2 are displayed on display area 1, which corresponds to the child process DisplayRender1; application 3 and application 4 are displayed on display area 2, which corresponds to the child process DisplayRender2. Then, the UniRender process passes the rendering tree of application 1 and the rendering tree of application 2 to the child process DisplayRender1, and passes the rendering tree of application 3 and the rendering tree of application 4 to the child process DisplayRender2.
[0397] Among them, DisplayRender1 and DisplayRender2 can obtain the handle of the shared memory of the corresponding application from the UniRender process, and then obtain the rendering tree of the corresponding application. Alternatively, the rendering tree of the application can be obtained from the UniRender process through other IPC communication methods such as Binder, which is not limited here.
[0398] Optionally, in some embodiments of the present application, the UniRender process may first synthesize the rendering trees of multiple applications into a target rendering tree, and then pass the target rendering tree to the corresponding DisplayRender subprocess. The transfer of the target rendering tree may be implemented through a variety of IPC communication methods such as shared memory and Binder, which are not limited here.
[0399] Optionally, in some embodiments of the present application, the UniRender process may perform forward processing of off-screen rendering instructions on the rendering tree and then pass it to the corresponding DisplayRender sub-process, or may pass the window control information and rendering tree of the application on the corresponding display area to the corresponding DisplayRender sub-process, and the DisplayRender sub-process may perform forward processing of off-screen rendering instructions on the rendering tree and synthesize multiple rendering trees into a target rendering tree.
[0400] Optionally, in some embodiments of the present application, the DisplayRender subprocess can be configured with two threads, such as an I / O thread and a rendering thread, the I / O thread is responsible for receiving the rendering tree, the rendering thread is responsible for generating a target rendering tree, and generating a bitmap based on the target rendering tree.
[0401] It can be understood that the UniRender process can divide and multiply the vertical synchronization signal (Vsync-UR) by creating multiple DisplayRender sub-processes, and pass the divided and multiplied vertical synchronization signal (Vsync-UR) to different DisplayRender sub-processes, so that different DisplayRender sub-processes generate bitmaps at different frequencies to match the refresh rates of different display areas.
[0402] Fig.25 An exemplary schematic diagram of the frequency division and frequency multiplication of vertical synchronization signals of the UniRender process provided in an embodiment of the present application.
[0403] like Fig.25 As shown, when the refresh rates of the display areas corresponding to different DisplayRender sub-processes are different, UniRender can divide or multiply the vertical synchronization signal (Vsync-UR) and then forward it to different DisplayRender sub-processes.
[0404] For example, the refresh rate of display area 1 is 60Hz, the refresh rate of display area 2 is 30Hz, and the DisplayRender sub-process corresponding to display area 1 is DisplayRender1, and the DisplayRender sub-process corresponding to display area 2 is DisplayRender2. Then, after receiving the 60Hz vertical synchronization signal (Vsync), or after the UniRender process generates the 60Hz vertical synchronization signal (Vsync), it divides the frequency to generate a 30Hz vertical synchronization signal (Vsync-UR) and a 60Hz vertical synchronization signal (Vsync-UR), passes the 60Hz vertical synchronization signal (Vsync-UR) to the DisplayRender1 sub-process, and passes the 30Hz vertical synchronization signal (Vsync-UR) to the DisplayRender2 sub-process.
[0405] It is understandable that by dividing or doubling the vertical synchronization signal (Vsync-UR), the frequency at which the DisplayUniRender process receives the rendering tree or the target rendering tree and generates the bitmap can be made consistent with the refresh frequency of the display area.
[0406] Among them, after receiving the vertical synchronization signal (Vsync-UR), the DisplayRender sub-process can start reading the rendering tree, generating the target rendering tree, and generating the bitmap.
[0407] It is worth noting that the UniRender process receives the display area information sent by the display management service, determines the connection status of each display area, and then creates and destroys the DisplayRender process corresponding to each display area according to the connection status of the display area.
[0408] The contents of UniRender's architecture, shared memory and other concepts can be found in the text description in step S904 and will not be repeated here.
[0409] S2405: Generate a target rendering tree based on the obtained rendering tree, window control information, and display area information
[0410] The DisplayRender subprocess synthesizes one or more target rendering trees into a target rendering tree, and moves the off-screen rendering instructions forward for the rendering tree of the application if the layer of the application involves off-screen rendering logic.
[0411] It is worth noting that the DisplayRender subprocess can obtain the window control information and display area information on the display area from the UniRender process.
[0412] Optionally, in some embodiments of the present application, the UniRender process may synthesize one or more rendering trees into a target rendering tree and then pass it to the DisplayRender sub-process.
[0413] The process of generating the target rendering tree, the forward movement of the off-screen rendering instruction and other concepts may refer to the text description in step S904, which will not be repeated here.
[0414] S2406: Generate a bitmap based on the target rendering tree
[0415] After generating the target rendering tree, the DisplayRender subprocess generates a bitmap based on the target rendering tree. After generating the bitmap, the DisplayRender subprocess passes the surface carrying the bitmap to the UniRender process, and the UniRender process sends the content of the surface to each display area through DSS.
[0416] The process of generating a bitmap based on the target rendering tree may refer to the text description in step S905, which will not be described in detail here.
[0417] Since the call of the underlying graphics library depends on the context, different DisplayRender subprocesses correspond to different contexts, and thus bitmaps can be generated for different display areas in parallel.
[0418] It can be understood that the UniRender process can generate bitmaps for each display area in parallel by creating DisplayRender sub-processes that correspond to the display areas one by one. In a multi-display area scenario, it can increase the interface generation speed, reduce lag, and improve the user experience.
[0419] Combine the following Fig.26A , Fig.26B The content shown exemplarily introduces the data flow process when the electronic device implements the interface generation method.
[0420] Fig.26A , Fig.26B An exemplary schematic diagram of data flow when an electronic device implements an interface generation method provided in an embodiment of the present application.
[0421] like Fig.26A As shown, there are two display areas on the electronic device, namely display area 1 and display area 2. Display area 1 displays the contents of application 1 and application 3; display area 2 displays the contents of application 2, application 3, and application 4.
[0422] The UniRender process creates a DisplayRender1 child process corresponding to display area 1 and a DisplayRender2 child process corresponding to display area 2. After receiving the rendering tree 1 of application 1, the rendering tree 2 of application 2, the rendering tree 3 of application 3, and the rendering tree 4 of application 4, the UniRender process passes the rendering tree 1 and the rendering tree 3 to the DisplayRender1 child process, and passes the rendering tree 2, the rendering tree 3, and the rendering tree 4 to the DisplayRender2 child process. The UniRender process passes the relevant window control information and display area information to the DisplayRender child process.
[0423] The DisplayRender1 subprocess and the DisplayRender2 subprocess generate bitmaps based on the target rendering tree independently. The DisplayRender1 subprocess generates surface1 based on the display area information of display area 1, and the DisplayRender1 subprocess generates surface2 based on the display area information of display area 2. Among them, surface1 is used to carry bitmap 1 generated by the DisplayRender1 subprocess; surface2 is used to carry bitmap 2 generated by the DisplayRender1 subprocess. Figure 2 The size of surface 1 may be related to the size of display area 1 , and the size of surface 2 may be related to the size of display area 2 .
[0424] In the embodiment of the present application, the content displayed by the application in different display areas can be the same or different. When the content displayed by the application in different display areas is the same, a rendering tree generated by the application will be assigned to multiple DisplayRender sub-processes; when the content displayed by the application in different display areas is different, the application will generate multiple different rendering trees, which will be assigned to multiple DisplayRender sub-processes accordingly.
[0425] For example, in Fig.26B In the content shown, since the sizes (such as resolution) of display area 1 and display area 2 are different, application 3 will display different interfaces on display area 1 and display area 2 (for example, different layout structures, but the same content), so the application will generate rendering trees corresponding to different display areas, namely rendering tree 31 and rendering tree 32. Among them, rendering tree 31 will be passed to the DisplayRender1 child process, and rendering tree 32 will be passed to the DisplayRender2 child process.
[0426] Among them, any DisplayRender subprocess can be configured with two threads, such as an I / O thread and a rendering thread. The I / O thread is responsible for receiving the rendering tree, and the rendering thread is responsible for generating a target rendering tree and generating a bitmap based on the target rendering tree.
[0427] (c) Interface generation method in multi-device multi-display area scenario
[0428] like Figure 23A-23C As shown in the scenario, the electronic device can display part or all of the content on the screen on the screen of the other electronic device through screen projection, multi-screen collaboration, etc.
[0429] In a multi-device multi-display area scenario, after the local electronic device establishes a connection with the peer electronic device, the screen of the peer electronic device can be used as display area 2, and the rendering tree of the application to be displayed on display area 2 is transmitted to the peer electronic device. After receiving the rendering tree of the local electronic device, the peer electronic device synthesizes the rendering trees of all applications displayed on display area 2 into a target rendering tree, and then generates a bitmap and sends it for display.
[0430] Alternatively, the local electronic device may also send the interface of the application displayed on the display area 2 to the peer electronic device.
[0431] Fig. 27 Another exemplary schematic diagram of the interface generation method provided in an embodiment of the present application.
[0432] like Fig. 27 As shown, the interface generation method provided in the embodiment of the present application includes:
[0433] S2701: Establishing a connection
[0434] Electronic device 1 and electronic device 2 establish communication connection through various methods such as Bluetooth, Wi-Fi, HiLink, etc. Electronic device 1 uses the screen of electronic device 2 as display area 2, wherein the screen of electronic device 1 itself is used as display area 1.
[0435] After determining that electronic device 1 and electronic device 2 are connected, or after receiving requests for screen projection, multi-screen collaboration, etc. from the display management service and window management service, the UniRender process on electronic device 2 can apply to open a heap memory to store data sent by electronic device 1 for rendering and generating bitmaps, such as a rendering tree.
[0436] S2702: Determine the application displayed in display area 2
[0437] The window management service and display management service on electronic device 1 determine the application to be displayed on display area 2, and pass the result to UniRender1 process on electronic device 1. Then, UniRender1 process of electronic device 1 obtains the rendering tree of the application displayed on display area 2 through IPC communication.
[0438] The UniRender1 process obtains the rendering tree of the application through IPC communication, which can be referred to the text description in step S902 above and will not be repeated here.
[0439] S2703: Sending the rendering tree of the application displayed in display area 2
[0440] The UniRender1 process of electronic device 1 sends the rendering tree of the application displayed on display area 2 to electronic device 2 .
[0441] UniRender1 may determine the starting address and size of the shared memory, and pass the rendering tree to the already opened heap memory of the UniRender2 process of the electronic device 2 through the communication connection of step S2701.
[0442] The storage structure of the data on the heap memory may be consistent with the storage structure of the data in the shared memory on UniRender1. The storage structure of the data on the heap memory and the read and write security of the heap memory can refer to the text description in step S902, which will not be repeated here.
[0443] It is understandable that when electronic device 1 sends the rendering tree to electronic device 2, the data transmission volume between electronic device 1 and electronic device 2 can be reduced, thereby reducing latency and increasing the speed of generating the interface.
[0444] S2704: Synthesize the rendering tree of the application displayed in display area 2 into a target rendering tree
[0445] After receiving the vertical synchronization signal (Vsync-UR2), the UniRender2 process of the electronic device 2 synthesizes the rendering tree of the application displayed on the display area 2 into the target rendering tree, and can complete the forward movement of the off-screen rendering instruction in the process.
[0446] The electronic device 2 may synthesize the rendering tree sent by the electronic device 1 and the local rendering tree of the electronic device 2 into a target rendering tree.
[0447] Fig.28A , Fig.28B An exemplary schematic diagram of synthesizing the rendering trees provided in the embodiment of the present application into a target rendering tree.
[0448] like Fig.28A As shown, electronic device 1 runs application 1 and application 2, the rendering tree generated by application 1 is rendering tree 1, and the rendering tree generated by application 2 is rendering tree 2. Electronic device 2 runs application 3, and the rendering tree generated by application 3 is rendering tree 3.
[0449] The UniRender1 process on the electronic device 1 determines that the interface of the application 2 is to be displayed on the display area 2 , and then sends the rendering tree 2 to the UniRender2 process of the electronic device 2 .
[0450] The UniRender1 process moves the off-screen rendering instructions forward for the rendering tree 1 and the rendering tree 2, and synthesizes them into the target rendering tree 1 to generate bitmap 1. The UniRender2 process moves the off-screen rendering instructions forward for the rendering tree 2 and the rendering tree 3, and synthesizes them into the target rendering tree 2 to generate bitmap 1. Figure 2 .
[0451] It is worth noting that when UniRender1 process sends data of render tree 2 to UniRender2 process, it can send all data of render tree 2 or differential data of render tree 2. All data of render tree 2 can be current properties, current displaylist or staging displaylist, staging properties in shared memory; differential data of render tree 2 can be drawing instruction list and rendering properties of rendering nodes of render tree 2 in properties_dirty queue and displaylist_dirty queue.
[0452] like Fig.28B As shown, electronic device 1 runs application 1, application 2, and application 3. The rendering tree generated by application 1 is rendering tree 1, the rendering tree generated by application 2 is rendering tree 2, and the rendering tree generated by application 2 is rendering tree 3. Electronic device 2 runs application 4, and the rendering tree generated by application 4 is rendering tree 4.
[0453] The UniRender1 process on electronic device 1 determines that the interfaces of application 2 and application 3 are to be displayed on display area 2, then sends rendering tree 2 and rendering tree 3 to the UniRender2 process of electronic device 2, or after synthesizing rendering tree 2 and rendering tree 3 into target rendering tree 2, sends target rendering tree 2 to the UniRender2 process of electronic device 2.
[0454] The UniRender1 process moves the off-screen rendering instructions forward for rendering tree 1, rendering tree 2, and rendering tree 3 respectively, and synthesizes them into target rendering tree 1 to generate bitmap 1; the UniRender1 process moves the off-screen rendering instructions forward for rendering tree 2 and rendering tree 3 respectively, and synthesizes them into target rendering tree 2.
[0455] Optionally, in some embodiments of the present application, the UniRender1 process may create multiple child processes DisplayRender to receive and process rendering trees from different applications respectively. Fig.28BIn the content shown, the UniRender1 process can create two child processes DisplayRender, namely DisplayRender1 and DisplayRender2. The DisplayRender1 child process receives rendering tree 1, rendering tree 2, and rendering tree 3, and synthesizes them into target rendering tree 1; the DisplayRender2 child process receives rendering tree 2 and rendering tree 3, synthesizes them into target rendering tree 2, and sends the target rendering tree 2 to the UniRender2 process.
[0456] The UniRender2 process moves the off-screen rendering instructions to the rendering tree 2 and the rendering tree 3 respectively, and synthesizes them into the target rendering tree 2 to generate the bitmap. Figure 2 .
[0457] It is worth noting that the UniRender1 process responds to the vertical synchronization signal (Vsync-UR1) on electronic device 1, obtains the rendering tree of one or more applications from the shared memory, and starts to generate the target rendering tree. UniRender2 responds to the vertical synchronization signal (Vsync-UR2) on electronic device 2, obtains the rendering tree of one or more applications from the heap memory and / or shared memory, and starts to generate the target rendering tree.
[0458] Optionally, in some embodiments of the present application, when the frequencies of the vertical synchronization signal (Vsync-UR1) on electronic device 1 and the vertical synchronization signal (Vsync-UR2) on electronic device 2 are inconsistent, the UniRender on electronic device 1 can adjust the frequency of the vertical synchronization signal (Vsync-UR1) to be the same as Vsync-UR2 by dividing or doubling the frequency; or the UniRender2 on electronic device 2 can adjust the frequency of the vertical synchronization signal (Vsync-UR2) to be the same as the vertical synchronization signal (Vsync-UR1) by dividing or doubling the frequency.
[0459] Optionally, in some embodiments of the present application, the electronic device 1 may be configured with a vertical synchronization signal (Vsync-UR1) of multiple frequencies. Fig.28A , Fig.28BIn the scenario shown, the original vertical synchronization signal (Vsync-UR) frequency on electronic device 1 is 60Hz, and the original vertical synchronization signal (Vsync-UR2) frequency on electronic device 2 is 90Hz. After electronic device 1 determines to display the interface of application 2 on electronic device 2, the UniRender process of electronic device 1 can generate vertical synchronization signal (Vsync-UR1) frequencies of 60Hz and 90Hz respectively, so that application 2 generates a rendering tree at a frequency of 90Hz. Then the UniRender1 process can pass the rendering tree to the UniRender2 process at a frequency of 90Hz. Among them, application 1 can still generate a rendering tree at a frequency of 60Hz.
[0460] Among them, on any electronic device, the vertical synchronization signal (Vsync-UR) received or generated by UniRender can be the same as the vertical synchronization signal (Vsync-APP) received by the application.
[0461] S2705: Generate a bitmap based on the target rendering tree.
[0462] For the specific content, please refer to the text description in step S905, which will not be repeated here.
[0463] Optionally, in some embodiments of the present application, the UniRender1 process of electronic device 1 may first synthesize one or more rendering trees on display area 2 into a target rendering tree, generate a bitmap based on the target rendering tree, and pass the bitmap to the UniRender2 process of electronic device 2.
[0464] It is worth noting that, when electronic device 2 displays the interface of application 1 on electronic device 1, the user clicks on the interface of application 1 on electronic device 2 by clicking or other interactive methods, and electronic device 2 can send the position of the user's click operation in the interface of application 1 to application 1 on electronic device 1, so that application 1 can correctly respond to the user's interaction. Alternatively, since the interface of application 1 on electronic device 2 is generated by the UniRender2 process on electronic device 2 based on the rendering tree, and the rendering tree contains the location information of the view, electronic device 2 can determine the view clicked by the user and directly send the view click event to application 1 on electronic device 1, so that application 1 can correctly respond to the user's interaction.
[0465] (3) Finally, the hardware architecture and software architecture of the electronic device provided in the embodiments of the present application are introduced.
[0466] Fig.29 An exemplary schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
[0467] The following is a specific description of the embodiment using an electronic device as an example. It should be understood that the electronic device may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure 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.
[0468] The electronic device may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194 and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0469] It is to be understood that the structure illustrated 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 figure, or combine certain components, or split certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0470] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0471] The controller can be the nerve center and command center of the electronic device. The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of fetching and executing instructions.
[0472] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0473] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0474] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface to realize the touch function of the electronic device.
[0475] The I2S interface can be used for audio communication. The PCM interface can also be used for audio communication to sample, quantize and encode analog signals. The UART interface is a universal serial data bus used for asynchronous communication.
[0476] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate through the CSI interface to realize the shooting function of the electronic device. The processor 110 and the display screen 194 communicate through the DSI interface to realize the display function of the electronic device. The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc. The SIM interface can be used to communicate with the SIM card interface 195 to realize the function of transmitting data to the SIM card or reading data in the SIM card. The USB interface 130 is an interface that complies with USB standard specifications, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc.
[0477] It is understandable that the interface connection relationship between the modules illustrated 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.
[0478] The charging management module 140 is used to receive charging input from a charger. The power management module 141 is used to connect the battery 142 , the charging management module 140 and the processor 110 .
[0479] The wireless communication function of the electronic device can be implemented by antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modulation and demodulation processor and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antenna. The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to electronic devices. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from antenna 1, and filter, amplify and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be arranged in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be provided in the same device.
[0480] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0481] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to electronic devices. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0482] In some embodiments, the antenna 1 of the electronic device is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS) and / or satellite based augmentation system (SBAS).
[0483] The electronic device implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0484] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can 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 (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (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.
[0485] 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.
[0486] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise and brightness of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0487] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0488] Digital signal processors are used to process digital signals. In addition to processing 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.
[0489] Video codecs are used to compress or decompress digital videos. Electronic devices can support one or more video codecs. In this way, electronic devices can play or record videos in multiple coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0490] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and continuously self-learn. NPU can realize applications such as intelligent cognition of electronic devices, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0491] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
[0492] Random access memory may include 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, for example, the fifth generation DDR SDRAM is generally referred to as DDR5 SDRAM), etc.
[0493] Non-volatile memory may include disk storage devices and flash memory.
[0494] In the embodiment of the present application, the non-real-time video may be located in a non-volatile memory.
[0495] Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle; single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc. according to the storage unit potential level; universal flash storage (UFS), embedded multi media card (eMMC), etc. according to the storage specification.
[0496] The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data.
[0497] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 110 .
[0498] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external non-volatile memory.
[0499] The electronic device can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0500] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The speaker 170A, also called a "speaker", is used to convert audio electrical signals into sound signals. The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. The microphone 170C, also called a "microphone" or "microphone", is used to convert sound signals into electrical signals.
[0501] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0502] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. The gyroscope sensor 180B can be used to determine the motion posture of the electronic device. The air pressure sensor 180C is used to measure the air pressure. The magnetic sensor 180D includes a Hall sensor. The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device in all directions (generally three axes). The distance sensor 180F is used to measure the distance. The proximity light sensor 180G can include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The ambient light sensor 180L is used to sense the brightness of the ambient light. The fingerprint sensor 180H is used to collect fingerprints. The electronic device can use the collected fingerprint characteristics to realize fingerprint unlocking, access application locks, fingerprint photography, fingerprint answering calls, etc. The temperature sensor 180J is used to detect the temperature.
[0503] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set 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 touch operations acting 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 other embodiments, the touch sensor 180K can also be set on the surface of the electronic device, which is different from the position of the display screen 194.
[0504] The button 190 includes a power button, a volume button, etc. The button 190 may be a mechanical button. It may also be a touch button. The electronic device may receive the button input and generate a key signal input related to the user settings and function control of the electronic device. The motor 191 may generate a vibration prompt. The indicator 192 may be an indicator light, which may be used to indicate the charging status, the change of the power, or may be used to indicate messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect the SIM card. The electronic device interacts with the network through the SIM card to realize functions such as calls and data communications.
[0505] Fig.30An exemplary schematic diagram of the software structure of an electronic device provided in an embodiment of the present application.
[0506] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the system is divided into four layers, from top to bottom: application layer, application framework layer, system library, and kernel layer.
[0507] The application layer can include a series of application packages. Fig. 20 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications (also referred to as applications).
[0508] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0509] like Fig.30 As shown, the application framework layer may include window management services, display management services, content providers, view systems, phone managers, resource managers, notification managers, local profile management assistants (LPA), and the like.
[0510] The window management service is responsible for starting, adding, and deleting windows. It can determine the application displayed on the window and the creation, destruction, and property changes of the application's layer, determine whether there is a status bar, lock the screen, take screenshots, etc.
[0511] The display management service can obtain the number and size of display areas, and is responsible for starting, adding, and deleting display areas.
[0512] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0513] The phone manager is used to provide communication functions for electronic devices, such as the management of call status (including answering, hanging up, etc.).
[0514] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0515] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications from applications running in the background, or a notification that appears on the screen in the form of a dialogue interface. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0516] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0517] The view system also includes UniRender, which can receive the render tree of one or more applications. UniRender can synchronize layer information such as layer creation, destruction, property changes, etc. through the window management service. UniRender can synchronize display area information such as screen size from the display management service.
[0518] Optionally, in some embodiments of the present application, the view system further includes SurfaceFlinger. On an electronic device configured with a whitelist, when an application does not belong to the whitelist, after the UI thread of the application generates a rendering tree, the rendering thread of the application generates a bitmap, which is then handed over to SurfaceFlinger for layer synthesis.
[0519] 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, UniRender is responsible for generating the bitmap of the applications in the whitelist. After UniRender generates the bitmap, it passes the bitmap to SurfaceFlinger. SurfaceFlinger then performs layer synthesis on the bitmap and other applications not in the whitelist to generate a bitmap for display.
[0520] The runtime includes the core library and the virtual machine. The runtime is responsible for the scheduling and management of the operating system.
[0521] The core library consists of two parts: one part is the function that the Java language needs to call, and the other part is the core library.
[0522] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application 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.
[0523] The system library may include multiple functional modules, such as a surface manager, a media library, and a graphics processing library, wherein the graphics processing library includes a 3D graphics processing library (such as OpenGLES), a 2D graphics engine (such as SGL), and the like.
[0524] The surface manager is used to manage the display subsystem and provides the fusion of two-dimensional (2D) and three-dimensional (3D) layers for multiple applications.
[0525] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static 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.
[0526] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, layer synthesis, and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.
[0527] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, sensor driver, and virtual card driver.
[0528] In an embodiment of the present application, one or more applications in the application layer pass the rendering tree generated 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 the display management service, and then synthesizes the rendering trees of the applications on a display area into a target rendering tree. After generating the target rendering tree, the UniRender process 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.
[0529] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.
[0530] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0531] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.
Claims
1. An interface generation method, applied to a first electronic device, wherein the first electronic device determines that the content displayed on a first display area includes an interface of a first process and an interface of a second process, characterized in that: include: The first process generates a first rendering tree, where the first rendering tree is used to draw an interface of the first process; The second process generates a second rendering tree, where the second rendering tree is used to draw an interface of the second process; The third process determines the off-screen rendering logic of the interface of the first process, where the off-screen rendering logic includes at least one of window rounding, color change, rotation, and scaling; The third process adds an off-screen rendering attribute to the rendering attributes in the first rendering tree based on the off-screen rendering logic of the interface of the first process, where the off-screen rendering attribute includes at least one of a rounded corner attribute, a color attribute, a rotation attribute, and a scaling attribute; The off-screen rendering attributes correspond to the off-screen rendering logic one by one, and the off-screen rendering attributes are used to modify the drawing operation to implement the off-screen rendering logic during the process in which the third process generates the first target interface based on the first rendering tree and the second rendering tree; The third process generates a first target interface based on the first rendering tree and the second rendering tree, where the first target interface includes an interface of the first process and an interface of the second process, and the first target interface is displayed in the first display area.
2. The method according to claim 1, characterized in that The third process generates a first target interface based on the first rendering tree and the second rendering tree, specifically comprising: The third process generates a first target rendering tree based on the first rendering tree and the second rendering tree; The third process generates the first target interface based on the first target rendering tree.
3. The method according to claim 2, characterized in that The third process generates a first target rendering tree based on the first rendering tree and the second rendering tree, specifically comprising: The third process creates a root rendering node as the root node of the first target rendering tree, and uses the first rendering tree and the second rendering tree as child nodes of the root rendering node.
4. The method according to claim 3, characterized in that The method further comprises: The third process deletes rendering nodes in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted rendering nodes correspond to views that are completely blocked.
5. The method according to claim 3, characterized in that: The method further comprises: The third process deletes the drawing operations in the first target rendering tree based on the Z order of the first rendering tree and the second rendering tree, and the deleted drawing operations correspond to the completely obscured graphics.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: In a process in which the third process generates a first target interface based on the first rendering tree and the second rendering tree, the third process merges or batches a first drawing operation and a second drawing operation, the first drawing operation belongs to the first rendering tree, and the second drawing operation belongs to the second rendering tree.
7. The method according to any one of claims 1 to 5, characterized in that When the reference coordinate system of the first rendering tree is a first coordinate system, the reference coordinate system corresponding to the first display area is a second coordinate system, and the first coordinate system and the second coordinate system are different, the method further includes: The third process determines a first parameter based on the first coordinate system and the second coordinate system, and adds the first parameter to the rendering attribute of the first rendering tree; In a process in which a third process generates a first target interface based on the first rendering tree and the second rendering tree, the third process modifies a reference coordinate system of a first drawing operation based on the first parameter, and the first drawing operation belongs to the first rendering tree.
8. An interface generation method, applied to a second electronic device, wherein the second electronic device determines that the content displayed on the first display area includes an interface of a first process and an interface of a second process, characterized in that: include: A third process running on the second electronic device receives a first rendering tree and a second rendering tree; wherein the first rendering tree is generated by a first process running on the first electronic device, and the first rendering tree is used to draw an interface of the first process; the second rendering tree is generated by a second process running on the second electronic device, and the second rendering tree is used to draw an interface of the second process; The third process determines the off-screen rendering logic of the interface of the first process, where the off-screen rendering logic includes at least one of window rounding, color change, rotation, and scaling; The third process adds an off-screen rendering attribute to the rendering attributes in the first rendering tree based on the off-screen rendering logic of the interface of the first process, where the off-screen rendering attribute includes at least one of a rounded corner attribute, a color attribute, a rotation attribute, and a scaling attribute; The off-screen rendering attributes correspond to the off-screen rendering logic one by one, and the off-screen rendering attributes are used to modify the drawing operation to implement the off-screen rendering logic during the process in which the third process generates the first target interface based on the first rendering tree and the second rendering tree; The third process generates a target interface based on the first rendering tree and the second rendering tree, the target interface includes an interface of the first process and an interface of the second process, and the target interface is displayed on the first display area.
9. An electronic device, characterized in that: The electronic device comprises: 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, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 1 to 8.
10. A chip system, which is applied to electronic equipment, characterized in that: The chip system includes one or more processors, and the processor is used to call computer instructions so that the electronic device executes the method as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that: The method comprises instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 8.
12. A computer program product, characterized in that The method comprises computer readable instructions which, when executed by one or more processors, implement the method of any one of claims 1 to 8.
Citation Information
Cited By
Interface generation method and electronic device
EP4421619A1
Interface generation method and electronic device
WO2023093779A1
Interface generation method and electronic device
WO2024083014A1
