WO2019042329A1 - Method and apparatus for rendering user interface - Google Patents

Method and apparatus for rendering user interface Download PDF

Info

Publication number
WO2019042329A1
WO2019042329A1 PCT/CN2018/103020 CN2018103020W WO2019042329A1 WO 2019042329 A1 WO2019042329 A1 WO 2019042329A1 CN 2018103020 W CN2018103020 W CN 2018103020W WO 2019042329 A1 WO2019042329 A1 WO 2019042329A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
rasterized
rendering
user interface
nodes
Prior art date
Application number
PCT/CN2018/103020
Other languages
French (fr)
Chinese (zh)
Inventor
李沛
杨朝楷
Original Assignee
口碑(上海)信息技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 口碑(上海)信息技术有限公司 filed Critical 口碑(上海)信息技术有限公司
Publication of WO2019042329A1 publication Critical patent/WO2019042329A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Definitions

  • the present application relates to the field of UI rendering technologies, and in particular, to a method for user interface rendering.
  • the application also relates to a device for rendering a user interface, and an electronic device.
  • the CPU Central Processing Unit
  • the GPU Graphics Processing Unit
  • the display performs the user interface (UI, User Interface) rendering, and work together in the following manner: when the frame synchronization signal arrives After that, the application is notified to perform user interface rendering, and the main thread of the application starts to calculate the display content in the CPU, such as view creation, layout calculation, image decoding, text drawing, etc., after the calculation is completed, the CPU submits the display content to the GPU.
  • the GPU converts, merges, and renders according to the displayed content.
  • the GPU puts the rendering result into the frame buffer area, and waits for the next frame synchronization signal to arrive, and then transfers the data of the frame buffer area to the display for display.
  • the application uses the UIKit and CoreAnimation frameworks provided by the system to render the user interface.
  • these frameworks must be operated on the main thread.
  • the internal implementation is also performed by the main thread on the CPU, such as preparation. View hierarchy, set layer properties, draw bitmaps, and decode images.
  • the main thread is performing other heavy tasks, such as responding to user touches and clicks in the main thread, the main thread may not be able to process the rendering task in time, which may also cause the user interface to be stuck.
  • the present application provides a method for user interface rendering to solve the problem of user interface jams existing in the prior art.
  • the application also relates to a device for rendering a user interface, and an electronic device.
  • the application provides a method for rendering a user interface, including:
  • the bitmap corresponding to the object to be rendered is drawn according to a rasterization result of nodes in the view hierarchy tree.
  • the method for rendering the user interface includes:
  • the node attributes include: a rasterized attribute and a non-rasterized attribute;
  • the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
  • the rasterized root node is configured with a state identifier, where the state identifier includes: a first state identifier that allows rasterization with the rasterized child node, and a second state that does not allow rasterization with the rasterized child node Status identifier.
  • the rasterizing the nodes in the view hierarchy tree is implemented as follows:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • determining whether the candidate node is a rasterized root node and determining whether the status identifier of the candidate node is the first state identifier substep is no, perform the following operations:
  • the candidate node is set as the parent node of the node.
  • the method for rendering the user interface includes:
  • the rasterizing the nodes in the view hierarchy tree is implemented as follows:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • the rasterizing the nodes in the view hierarchy tree is implemented as follows:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • the rasterizing the nodes in the view hierarchy tree is implemented as follows:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • mapping of the bitmap corresponding to the object to be rendered is implemented as follows:
  • the node view corresponding to the node and the node view corresponding to the candidate node are drawn on a bitmap.
  • the method is implemented based on a terminal device, where the terminal device is configured with a central processing unit, a graphics processor, and a display screen;
  • the step of triggering a user interface for the object to be rendered based on the main thread the step of switching from the main thread to the child thread, drawing a bitmap step corresponding to the object to be rendered by the child thread, and the step Calling back the main thread, applying the drawn bitmap to the display content of the object to be rendered, based on the central processor;
  • the step of rendering a user interface according to the display content of the object to be rendered is implemented based on the graphics processor
  • the central processor submits the display content to the graphics processor
  • the graphics processor After rendering the user interface according to the display content of the object to be rendered, the graphics processor passes the rendering result to the display screen.
  • the application also provides a device for rendering a user interface, including:
  • a rendering trigger unit for triggering a user interface rendering for the object to be rendered based on the main thread
  • bitmap drawing unit configured to switch from the main thread to a child thread, by using the child thread to draw a bitmap corresponding to the object to be rendered
  • bitmap application unit configured to call back the main thread, and apply the drawn bitmap to the display content of the object to be rendered
  • a user interface rendering unit configured to render the user interface according to the display content of the object to be rendered.
  • the device for rendering the user interface includes:
  • a view level tree determining unit configured to determine a view level tree of the object to be rendered
  • a rasterizing unit configured to rasterize nodes in the view hierarchy tree
  • the bitmap drawing unit performs rendering according to the rasterization result of the rasterization unit.
  • the device for rendering the user interface includes:
  • a node attribute determining unit configured to determine a node attribute of a node in the view level tree according to the attribute information of the object to be rendered
  • the node attributes include: a rasterized attribute and a non-rasterized attribute;
  • the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
  • the rasterized root node is configured with a state identifier, where the state identifier includes: a first state identifier that allows rasterization with the rasterized child node, and a second state that does not allow rasterization with the rasterized child node Status identifier.
  • the rasterizing unit includes:
  • the first node traverses the subunit, and is configured to traverse the nodes in the view hierarchy tree by using a depth-first rule, each traversing one node, and running the first ancestor node search subunit and the first ancestor node judgment subunit for the traversed node;
  • the first ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree
  • the first ancestor node determining subunit is configured to determine whether a rasterized root node or a non-rasterized node exists in the found ancestor node, and if present, run the first candidate node determining subunit and the first rasterized attribute determiner unit;
  • the first candidate node determining subunit is configured to select, in a rasterized root node or a non-rasterized node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node or non-rasterization
  • the node acts as a candidate node
  • the first rasterization attribute determining subunit is configured to determine whether a node attribute of the node is a rasterization attribute, and if yes, running a first candidate node to determine a subunit;
  • the first candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if yes, running the first node merging subunit;
  • the first node merges subunits for merging the nodes onto the candidate nodes.
  • the application also provides an electronic device, including:
  • the memory is for storing computer executable instructions
  • the central processor is configured to execute computer executable instructions as follows:
  • the graphics processor is configured to execute computer executable instructions to render a user interface according to display content of the object to be rendered.
  • the method for rendering the user interface includes: triggering a user interface rendering for an object to be rendered based on a main thread; switching from the main thread to a child thread, and drawing, by the child thread, a corresponding object to be rendered a bitmap; the callback is applied to the main thread, and the drawn bitmap is applied to the display content of the object to be rendered; and the user interface is rendered according to the display content of the object to be rendered.
  • the method for rendering the user interface in the process of rendering the user interface, when the user interface rendering of the object to be rendered is triggered based on the main thread, switching from the main thread to the child thread, and performing the sub-thread
  • the bitmap is drawn, and is switched back to the main thread after the drawing is completed, where the main thread applies bitmap rendering to the corresponding display content to be rendered, and finally performs a user interface according to the corresponding display content to be rendered.
  • Rendering thereby transferring the bitmap drawing operation originally performed by the main thread to the sub-thread, reducing the load of the main thread, and reducing the user interface card caused by the main thread failing to process the rendering task in time when the task is heavy pause.
  • FIG. 1 is a process flow diagram of an embodiment of a method for user interface rendering provided by the present application
  • FIG. 2 is a timing diagram of a user interface rendering provided by the present application
  • Figure 3 is a schematic diagram of a view hierarchy tree provided by the present application.
  • FIG. 4 is a schematic diagram of a rasterization process provided by the present application.
  • FIG. 5 is a schematic diagram of an apparatus embodiment for user interface rendering provided by the present application.
  • FIG. 6 is a schematic diagram of an embodiment of an electronic device provided by the present application.
  • the present application provides a method for user interface rendering, and the present application also provides a device for rendering a user interface, and an electronic device.
  • the following is a detailed description of the embodiments of the embodiments provided herein, and the various steps of the method are explained.
  • a method for implementing user interface rendering provided by the present application is as follows:
  • FIG. 1 is a process flow diagram of a method for rendering a user interface provided by the present application.
  • FIG. 2 a timing diagram of user interface rendering provided by the present application is shown.
  • FIG. 3 is a schematic diagram showing a view hierarchy tree provided by the present application.
  • FIG. 4 a schematic diagram of a rasterization process provided by the present application is shown.
  • Step S101 triggering a user interface rendering for the object to be rendered based on the main thread.
  • the user interface rendering (UI rendering) is performed by the main thread of the application, but subject to the processing power of the main thread and the performance of the CPU, the task processing in the main thread is heavy or CPU performance. At lower levels, UI rendering on iOS devices may cause page jams.
  • the method for rendering the user interface provided by the present application as shown in FIG. 2, is used for the rendering of the UI included in the rendering task 1 or the rendering task 2, and the main thread of the application performs the operation in the CPU.
  • Asynchronous processing the part of the operation originally executed by the main thread of the application is transferred to the sub-thread of the application, and after the execution of the sub-thread is completed, the execution result is synchronized to the main thread, and the execution is continued in the main thread.
  • the main thread In order to alleviate the load of the main thread, and at the same time reduce the user interface jam caused by the main thread unable to process the rendering task in time when the task is heavy.
  • the main thread performs UI rendering according to the frame synchronization signal.
  • the period of the frame synchronization signal in the UI rendering process is fixed.
  • the period of the frame synchronization signal in the iOS system is 1/60 s. That is: the user interface displayed on the screen needs to be refreshed 60 times per second.
  • the application-based main thread triggers UI rendering for the object to be rendered, which is triggered after receiving the rendering command, and is triggered after the frame synchronization signal arrives at the application after receiving the rendering command.
  • the object to be rendered in the embodiment of the present application may be any element on the user interface, or may be the user interface as a whole; correspondingly, the UI rendering of the object to be rendered may be any for the user interface.
  • a rendering task in which an element performs UI rendering may also be a rendering task that is updated overall for the user interface.
  • the rendering mechanism in the UI rendering may be UI rendering only for the changed element, or the UI of the user interface where the changed element is located.
  • the rendering mechanism of the rendering of the object to be rendered can be configured according to the actual situation, which is not limited herein.
  • Step S102 Switch from the main thread to the sub-thread, and draw a bitmap corresponding to the object to be rendered by the sub-thread.
  • frame1 to frame5 represent the period of the frame synchronization signal, that is, the rendering period of the UI rendering, specifically, after the frame synchronization signal reaches the application, the UI for the object to be rendered is triggered in the main thread. Rendering, and switching from the main thread to the child thread, by which the bitmap corresponding to the object to be rendered is drawn.
  • the main thread and the sub-thread may also adopt an asynchronous processing manner, and do not affect each other, but the main thread and the sub-thread can implement data sharing, and the triggering is performed based on the main thread.
  • the view hierarchy tree of the object to be rendered may be determined, and the view is The nodes in the hierarchical tree are rasterized.
  • the rasterization in the embodiment of the present application refers to merging a plurality of nodes into one node in the view hierarchy tree, and respectively displaying the display characteristics of each node on the view of the merged node.
  • the nodes in the view hierarchy tree have respective node attributes, and the node attributes include a rasterization attribute and a non-rasterized attribute. If a node attribute of a node is a rasterization attribute, the node may be related to the view level. Other nodes in the tree are rasterized; conversely, if a node's node property is a non-rasterized property, the node cannot be rasterized with other nodes. It should be noted that performing rasterization processing on the nodes in the view hierarchy tree is implemented based on the node attributes corresponding to the nodes, and therefore, before performing rasterization on the nodes in the view hierarchy tree.
  • nodes in the view hierarchy tree can be divided into a root node and a child node, wherein the child node can be either a child node of the root node or an ancestor node of its child node.
  • the nodes in the view hierarchy tree have corresponding node attributes: rasterized attributes and non-rasterized attributes.
  • the nodes in the view hierarchy tree are divided into: a rasterized root node, a rasterized child node, and a non-rasterized node.
  • a corresponding state identifier may be set for the rasterized root node in the view level tree, and the state identifier is used to determine whether the rasterized root node can receive the rasterized child node and rasterize it.
  • the state identifier of the rasterized root node includes a first state identifier and a second state identifier, and if the state identifier of the rasterized root node is the first state identifier, allowing the rasterized root node and the rasterizer The node performs rasterization; conversely, if the state of the rasterized root node is identified as the second state identifier, the rasterized root node and the rasterized child node are not allowed to be rasterized.
  • the status of the rasterized root node identifies that the initial default state identifier is the first state identifier, but when the rasterized root node encounters a descendant node that cannot be rasterized during the traversal process, The state identifier of the rasterized root node is changed to the second state identifier.
  • the state identifiers of node 1, node 7, and node 8 are set to the first state at initialization. logo.
  • the nodes in the view hierarchy tree are traversed by depth-first rules, and each node is traversed, and the following operations are performed for the traversed nodes:
  • the view hierarchy tree shown in FIG. 3 is traversed from the root node in the view hierarchy tree in the process of traversing the nodes in the view hierarchy tree by using a depth-first rule.
  • the specific traversal order is: node 1-> Node 2 -> Node 3 -> Node 4 -> Node 5 -> Node 6 -> Node 7 -> Node 8 -> Node 9.
  • searching for the ancestor node of the node in the view hierarchy tree specifically searching for the ancestor node of the node, starting from the parent node closest to the hierarchical relationship of the node, and sequentially looking up the node in the All ancestor nodes in the view hierarchy tree.
  • the ancestor node of the node is not found in the view hierarchy tree, it indicates that the node is a root node in the view hierarchy tree, such as node 1 in the view hierarchy tree shown in FIG. 3, because there is no ancestor node Therefore, it is impossible to rasterize with the ancestor node, and without processing, continue to traverse the next node (node 2) in the view hierarchy tree.
  • the found ancestor nodes are rasterized child nodes.
  • the rasterized root node can receive the rasterization with the rasterized child nodes. It can be seen that if the found ancestors are rasterized A child node indicates that the node cannot be rasterized with the found ancestor node. In this case, it is further determined whether the node attribute of the node is a rasterization attribute, and if so, the node is used as a rasterization root node, and the state identifier of the node is set as the first state identifier.
  • node 2 in the view hierarchy tree shown in Figure 3 there is only one ancestor node of node 2: rasterize root node 1, so rasterized root node 1 is used as a candidate node for node 2.
  • node 3 in the view hierarchy tree there are two ancestor nodes: node 2 and node 1, the level of node 2 is adjacent to the level of node 3, and the level of node 1 is different from the level of node 3, which is visible.
  • the level at which node 2 is located is the closest to the level at which node 3 is located, so node 2 is the candidate node for node 3.
  • step 5 determining whether the node attribute of the node is a rasterization attribute, and if so, performing the following step 5); as shown in Figure 3, node 2 in the view hierarchy tree is a rasterized child node, and the node attribute is rasterized. Attribute, then perform the next step for node 2.
  • the candidate node is set as a parent node of the node, and it is determined whether the candidate node is a rasterized root node, and if so, the state identifier of the candidate node is marked as the second state identifier.
  • the ancestor nodes of node 6 include: node 1, node 4, and node 5, and the node attribute of node 6 is a non-rasterized attribute.
  • node 1 satisfies the condition, so node 1 is set to a candidate node of the node 6; furthermore, since the node 1 is a rasterized root node, the state of the node 1 is identified as the second state identifier, that is, after the node 1 does not allow the rasterized child node to be rasterized thereafter .
  • step 5 determining whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if yes, performing the following step 6), rasterizing the node to the candidate node Up, ie, merging the nodes onto the candidate nodes. If the candidate node (node 1) of the node 2 in the view hierarchy tree shown in FIG. 3 is a rasterized root node, and the state identifier of the node 1 is the first state identifier, the rasterized root node and the rasterizer are allowed. The node is rasterized and node 2 is rasterized onto node 1.
  • the candidate node is set as the parent of the node.
  • the parent node of node 2 is node 1, where the candidate node of node 2 (node 1) is set as the parent node of node 2, and the view of node 2 and node 1 is not changed.
  • Hierarchy and connection relationships in the hierarchy tree are not changed.
  • the above rasterization process is mainly described by taking node 2 as an example, and provides a specific process of rasterizing node 2 to node 1, such as the view hierarchy tree shown in FIG. 3, combined with the above rasterization process, node 3, node 4 and The processing steps of node 5 during the traversal process are similar to those of node 2, and are eventually rasterized onto node 1.
  • the ancestor nodes of node 6 include: node 1, node 4, and node 5, and the node attribute of node 6 is a non-rasterized attribute. It can be seen that only node 1 satisfies the condition, so node 1 is set to a candidate node of the node 6; furthermore, since the node 1 is a rasterized root node, the state of the node 1 is identified as the second state identifier, that is, after the node 1 does not allow the rasterized child node to be rasterized thereafter .
  • the ancestor node of node 7 When traversing to node 7, the ancestor node of node 7 includes: node 1 and node 4, while the node attribute of node 7 is a rasterization attribute, node 4 does not satisfy the condition set as a candidate node, and node 1 is set to node 7.
  • Candidate node although node 1 is a rasterized root node, since the state identifier of node 1 is set to the second state identifier during the traversal of node 6, it can be seen that node 7 is not allowed to be rasterized onto node 1, then Node 1 is set as the parent node of node 7, that is, the parent node of node 7 is changed from node 4 to node 1.
  • node 8 in the traversal process is similar to that of node 7, and finally, the parent node of node 8 is set to node 1, but since the initial parent node of node 8 is also node 1, the level of node 8 in the view hierarchy tree is No change has taken place.
  • the ancestor node of node 9 has node 1 and node 8. Since the level of node 8 is adjacent to the level of node 9, node 8 is the candidate node of device node 9, and node 8 is rasterized.
  • the root node and the status identifier are the first status identifier, so node 9 is merged onto node 8.
  • the nodes in the view hierarchy tree are prevented from being missed, and each node in the view hierarchy tree may be traversed.
  • the rasterization process can also be implemented in a similar implementation, such as the three implementations provided below:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • step b) determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node, if yes, performing step c) and step d) described below; if not, determining whether the node attribute of the node is a rasterization attribute, if it is a rasterization attribute, the node is used as a rasterization root node, and the state identifier of the node is set as the first state identifier;
  • step e) determining whether the node attribute of the node is a rasterization attribute, and if so, performing the following step e); if not, setting the candidate node as a parent node of the node, and determining whether the candidate node is a raster a root node, if it is a rasterized root node, marking the state identifier of the candidate node as the second state identifier;
  • step f determining whether the candidate node is a rasterized root node, and if so, performing the following step f); if not, setting the candidate node as a parent node of the node;
  • step f determining whether the state identifier of the candidate node is the first state identifier, and if so, performing the following step g); if not, setting the candidate node as the parent node of the node;
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree. Each time a node is traversed, the following operations are performed on the traversed nodes:
  • the bitmap of the object to be rendered is drawn according to the result of the rasterization, and the bitmap of the object to be rendered is specifically drawn, according to the node and the As a result of the combination of the candidate nodes, the node view corresponding to the node and the node view corresponding to the candidate node are drawn on a bitmap. As shown in the view hierarchy tree shown in FIG. 3, the node view corresponding to the rasterized and merged nodes is drawn on a bitmap, for example, node 2, node 3, node 4, and node 5 are rasterized onto node 1.
  • the corresponding node views of the nodes 1 to 5 are drawn on a bitmap, that is, the display characteristics of the node views corresponding to the nodes 2 to 5 are represented on the node view corresponding to the node 1.
  • the node view corresponding to node 8 and node 9 is drawn on a bitmap. It should be emphasized that for node 6 and node 7, since node 6 and node 7 are not merged into other nodes in the view hierarchy tree, ie, node 6 and node 7 are not associated with the view hierarchy tree. The other nodes are rasterized. Therefore, for node 6 and node 7, the corresponding node views may be respectively drawn on a bitmap according to actual needs, or may not be processed.
  • the process of drawing the bitmap corresponding to the object to be rendered and the rasterization process are transferred to the application by switching the main thread of the application to the sub-thread of the application.
  • the child thread executes, which relieves the load on the application's main thread.
  • the main thread and the sub-thread of the application are both executed on the CPU, when the CPU has a plurality of processing cores, the main thread and the sub-threads can be processed based on different processing cores of the CPU, respectively, thereby being able to Take advantage of multiple processing cores of the CPU.
  • Step S103 the main thread is called back, and the drawn bitmap is applied to the display content of the object to be rendered.
  • step S102 the bitmap corresponding to the object to be rendered is drawn in the sub-thread.
  • the main thread is called back, that is, the sub-thread is switched back to the main thread, and the main thread is drawn.
  • a good bitmap is applied to the display content of the object to be rendered. Specifically, as shown in FIG. 3, the bitmap tree corresponding to the node 1 to the node 5 is applied to the data structure of the object to be rendered, and similarly, the bitmap corresponding to the node 8 and the node 9 is applied.
  • the display features of the node 6 and the node 7 saved in the data structure of the object to be rendered are No change has occurred, so node 6 and node 7 are not processed.
  • Step S104 Render a user interface according to the display content of the object to be rendered.
  • the method for the user interface rendering provided by the present application is implemented based on an iOS device configured by a CPU (Central Processing Unit), a GPU (Graphics Processor), and a display screen.
  • the above steps S101 to S103 are based on the In the CPU implementation of the iOS device configuration
  • the UI rendering performed according to the display content of the object to be rendered in this step is implemented based on the GPU.
  • the CPU submits the display content of the object to be rendered to the GPU
  • the GPU performs UI rendering according to the submitted display content of the object to be rendered.
  • the rendered user interface is passed to the display.
  • the nodes 1 to 9 in the view hierarchy tree are respectively rendered, but After the nodes in the view hierarchy tree are rasterized, nodes 2 to 5 are rasterized onto node 1, and node 9 is rasterized onto node 8.
  • the hierarchy of the view hierarchy tree is greatly reduced.
  • the UI rendering is shorter according to the display content of the object to be rendered, which reduces the processing time of the CPU during the UI rendering process, and further reduces the time consuming time for the GPU to perform UI rendering.
  • the user interface rendering method when performing the user interface rendering process, when the main thread is triggered to render the user interface for the object to be rendered, switching from the main thread to the child thread,
  • the sub-thread performs bitmap rendering, and switches back to the main thread after the drawing, and applies the bitmap drawing to the corresponding display content to be rendered in the main thread, and finally according to the corresponding to be rendered.
  • the resulting user interface is stuck.
  • a method for rendering a user interface is provided.
  • the present application further provides a device for rendering a user interface, which will be described below with reference to the accompanying drawings.
  • FIG. 5 a schematic diagram of an apparatus embodiment of a user interface rendering provided by the present application is shown.
  • the application provides a device for rendering a user interface, including:
  • a rendering trigger unit 501 configured to trigger a user interface rendering for the object to be rendered based on the main thread
  • bitmap drawing unit 502 configured to switch from the main thread to a sub-thread, by using the sub-thread to draw a bitmap corresponding to the object to be rendered;
  • bitmap application unit 503 configured to call back the main thread, and apply the drawn bitmap to the display content of the object to be rendered;
  • the user interface rendering unit 504 is configured to render a user interface according to the display content of the object to be rendered.
  • the device for rendering the user interface includes:
  • a view level tree determining unit configured to determine a view level tree of the object to be rendered
  • a rasterizing unit configured to rasterize nodes in the view hierarchy tree
  • the bitmap drawing unit 502 performs rendering according to the rasterization result of the rasterization unit.
  • the device for rendering the user interface includes:
  • a node attribute determining unit configured to determine a node attribute of a node in the view level tree according to the attribute information of the object to be rendered
  • the node attributes include: a rasterized attribute and a non-rasterized attribute;
  • the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
  • the rasterized root node is configured with a state identifier, where the state identifier includes: a first state identifier that allows rasterization with the rasterized child node, and a second state that does not allow rasterization with the rasterized child node Status identifier.
  • the rasterizing unit includes:
  • the first node traverses the subunit, and is configured to traverse the nodes in the view hierarchy tree by using a depth-first rule, each traversing one node, and running the first ancestor node search subunit and the first ancestor node judgment subunit for the traversed node;
  • the first ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree
  • the first ancestor node determining subunit is configured to determine whether a rasterized root node or a non-rasterized node exists in the found ancestor node, and if present, run the first candidate node determining subunit and the first rasterized attribute determiner unit;
  • the first candidate node determining subunit is configured to select, in a rasterized root node or a non-rasterized node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node or non-rasterization
  • the node acts as a candidate node
  • the first rasterization attribute determining subunit is configured to determine whether a node attribute of the node is a rasterization attribute, and if yes, running a first candidate node to determine a subunit;
  • the first candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if yes, running the first node merging subunit;
  • the first node merges subunits for merging the nodes onto the candidate nodes.
  • the first ancestor node determines that the output of the subunit is a result that the found ancestor node does not have a rasterized root node or a non-rasterized node, running the second rasterization attribute determining subunit;
  • the second rasterization attribute determining subunit is configured to determine whether the node attribute of the node is a rasterization attribute, and if so, the node is used as a rasterization root node, and the state identifier of the node is set to The first status identifier.
  • the determination result output by the first rasterization attribute determining subunit is that the node attribute of the node is not a rasterization attribute, running the first parent node update subunit and the second candidate node judgment subunit;
  • the first parent node update subunit configured to set the candidate node as a parent node of the node
  • the second candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node, and if yes, mark the state identifier of the candidate node as the second state identifier.
  • the first candidate node determines that the output of the subunit is a result that the candidate node is not a rasterized root node or the state identifier of the candidate node is not the first state identifier, running the second parent node is updated.
  • the second parent node updates the subunit, and is configured to set the candidate node as a parent node of the node.
  • the rasterizing unit includes:
  • the traversing determination subunit is configured to determine whether the node in the view hierarchy tree is traversed, and if not, running the first node to traverse the subunit.
  • the rasterizing unit includes:
  • the second node traverses the sub-units for traversing the nodes in the view hierarchy tree by using depth-first rules, each traversing one node, and running a second ancestor node search sub-unit and a second ancestor node judgment sub-unit for the traversed nodes;
  • the second ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree
  • the second ancestor node determining subunit is configured to determine whether a rasterized root node or a non-rasterized node exists in the found ancestor node, and if so, running the second candidate node determining subunit and the third rasterization attribute determiner unit;
  • the second candidate node determining subunit is configured to select, in the rasterized root node or the non-rasterized node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node or non-rasterization
  • the node acts as a candidate node
  • the third rasterization attribute determining subunit is configured to determine whether a node attribute of the node is a rasterization attribute, and if so, running a third candidate node to determine a subunit;
  • the third candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node, and if yes, determining whether the state identifier of the candidate node is a first state identifier, and if so, running the second node merging subunit ;
  • the second node merging subunit is configured to merge the node onto the candidate node.
  • the rasterizing unit includes:
  • the third node traverses the sub-units for traversing the nodes in the view hierarchy tree by using a depth-first rule, each traversing one node, and running a third ancestor node search sub-unit and a third ancestor node judgment sub-unit for the traversed node;
  • the third ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree
  • the third ancestor node determining subunit is configured to determine whether a rasterized root node exists in the found ancestor node, and if so, running a third candidate node determining subunit and a second state identifier determining subunit;
  • the third candidate node determining subunit is configured to select, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node as a candidate node;
  • the second state identifier determining subunit is configured to determine whether the state identifier of the candidate node is the first state identifier, and if yes, running a fourth rasterization attribute determining subunit;
  • the fourth rasterization attribute determining subunit is configured to determine whether the node attribute of the node is a rasterization attribute, and if so, running the third node to merge the subunit;
  • the third node merging subunit is configured to merge the node onto the candidate node.
  • the rasterizing unit includes:
  • the fourth node traverses the sub-units for traversing the nodes in the view hierarchy tree by using a depth-first rule, each traversing one node, and running a fourth ancestor node search sub-unit and a fourth ancestor node judgment sub-unit for the traversed nodes;
  • the fourth ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree
  • the fourth ancestor node determining subunit is configured to determine whether a rasterized root node exists in the found ancestor node, and if yes, running a fourth candidate node determining subunit and a fifth rasterizing attribute determining subunit;
  • the fourth candidate node determining subunit is configured to select, as a candidate node, a rasterized root node whose stratum is located closest to the stratum of the node in the rasterized root node existing in the ancestor node;
  • the fifth rasterization attribute determining subunit is configured to determine whether the node attribute of the node is a rasterization attribute, and if so, running the fourth node to merge the subunit;
  • the fourth node merging subunit is configured to merge the node onto the candidate node.
  • bitmap drawing unit 502 is configured to: in accordance with a combination result of the node and the candidate node, draw a node view corresponding to the node and a node view corresponding to the candidate node in a single bit On the map.
  • the device for rendering the user interface is implemented based on a terminal device, where the terminal device is provided with a central processing unit, a graphics processor, and a display screen;
  • the rendering trigger unit 501, the bitmap rendering unit 502, and the bitmap application unit 503 are executed based on the central processing unit;
  • the user interface rendering unit 504 operates based on the graphics processor
  • the display content output by the bitmap application unit 503 is submitted to the graphics processor by the central processing unit;
  • the graphics processor After rendering the user interface according to the display content of the object to be rendered, the graphics processor passes the rendering result to the display screen.
  • An electronic device implementation provided by the present application is as follows:
  • a method for rendering a user interface is provided.
  • the present application further provides an electronic device for implementing the method for rendering the user interface, which will be described below with reference to the accompanying drawings.
  • FIG. 6 a schematic diagram of an electronic device provided by the embodiment is shown.
  • the application provides an electronic device, including:
  • the memory 601 is configured to store computer executable instructions
  • the central processor 602 is configured to execute computer executable instructions as follows:
  • the graphics processor 603 is configured to execute computer executable instructions to render a user interface according to display content of the object to be rendered.
  • the central processor 602 is further configured to execute the following computer-executable instruction :
  • the bitmap corresponding to the object to be rendered is drawn according to a rasterization result of nodes in the view hierarchy tree.
  • the central processing unit 602 is further configured to execute the following computer executable instructions:
  • the node attributes include: a rasterized attribute and a non-rasterized attribute;
  • the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
  • the rasterized root node is configured with a state identifier, where the state identifier includes: a first state identifier that allows rasterization with the rasterized child node, and a second state that does not allow rasterization with the rasterized child node Status identifier.
  • the rasterizing the nodes in the view hierarchy tree is implemented as follows:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • determining whether the candidate node is a rasterized root node and determining whether the status identifier of the candidate node is the first state identifier substep is no, perform the following operations:
  • the candidate node is set as the parent node of the node.
  • the central processing unit 602 is further configured to execute the following computer executable instructions:
  • the rasterizing the nodes in the view hierarchy tree is implemented as follows:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • the rasterizing the nodes in the view hierarchy tree is implemented as follows:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • the rasterizing the nodes in the view hierarchy tree is implemented as follows:
  • the depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
  • mapping of the bitmap corresponding to the object to be rendered is implemented as follows:
  • the node view corresponding to the node and the node view corresponding to the candidate node are drawn on a bitmap.
  • the electronic device is provided with a display screen
  • the central processing unit 602 submits the display content to the graphics processor 603;
  • the graphics processor 603 after rendering the user interface according to the display content of the object to be rendered, delivers the rendering result to the display screen.
  • a computing device includes one or more processors, input/output interfaces, network interfaces, and memory.
  • the memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory.
  • RAM random access memory
  • ROM read only memory
  • Memory is an example of a computer readable medium.
  • Computer readable media includes both permanent and non-persistent, removable and non-removable media.
  • Information storage can be implemented by any method or technology.
  • the information can be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device.
  • computer readable media does not include non-transitory computer readable media, such as modulated data signals and carrier waves.
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Image Generation (AREA)

Abstract

Disclosed in the present application is a method for rendering a user interface. The method comprises: triggering rendering of a user interface of a to-be-rendered object according to a main thread; switching the main thread to a sub-thread, and drawing a bitmap corresponding to the to-be-tendered object by means of the sub-thread; calling back to the main thread, and applying the drawn bitmap to displayed content of the to-be-tendered object; and rendering the user interface according to the displayed content of the to-be-tendered object. By means of the method for rendering a user interface, a bitmap drawing operation originally executed in the main thread is transferred to the sub-thread to perform execution, thereby reducing the load of the main thread, an avoiding the freeze of the user interface when the main thread in heavy tasks timely handles a rendering task.

Description

一种用户界面渲染的方法及装置Method and device for rendering user interface
本申请要求于2017年08月29日提交中国专利局、申请号为201710755049.1、发明名称为“一种用户界面渲染的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 200910755049.1, entitled "A Method and Apparatus for User Interface Rendering", filed on August 29, 2017, the entire contents of which are incorporated herein by reference. In the application.
技术领域Technical field
本申请涉及UI渲染技术领域,具体涉及一种用户界面渲染的方法。本申请同时涉及一种用户界面渲染的装置,以及一种电子设备。The present application relates to the field of UI rendering technologies, and in particular, to a method for user interface rendering. The application also relates to a device for rendering a user interface, and an electronic device.
背景技术Background technique
在终端设备中,CPU(中央处理器)、GPU(Graphics Processing Unit,图形处理器)和显示器在进行用户界面(UI,User Interface)渲染时,是通过下述方式协同工作:在帧同步信号到达后,会通知应用程序进行用户界面渲染,应用程序的主线程开始在CPU当中计算显示内容,比如视图的创建、布局计算、图片解码、文本绘制等,计算完成后CPU会将显示内容提交到GPU,由GPU根据显示内容进行变换、和成和渲染,渲染完成后GPU会将渲染结果放入帧缓存区,等待下一次帧同步信号到达后将帧缓存区的数据传递给显示器进行显示。In the terminal device, the CPU (Central Processing Unit), the GPU (Graphics Processing Unit), and the display perform the user interface (UI, User Interface) rendering, and work together in the following manner: when the frame synchronization signal arrives After that, the application is notified to perform user interface rendering, and the main thread of the application starts to calculate the display content in the CPU, such as view creation, layout calculation, image decoding, text drawing, etc., after the calculation is completed, the CPU submits the display content to the GPU. The GPU converts, merges, and renders according to the displayed content. After the rendering is completed, the GPU puts the rendering result into the frame buffer area, and waits for the next frame synchronization signal to arrive, and then transfers the data of the frame buffer area to the display for display.
以iOS系统为例,应用程序通过系统提供的UIKit和CoreAnimation等框架进行用户界面渲染,但这些框架都要求必须在主线程进行操作,内部的实现也都是主线程在CPU上进行的,比如准备视图的层级关系、设置图层属性、绘制位图以及图片解码等。当用户界面层级较为复杂或者绘制的内容较为繁杂时,一个刷新周期内无法完成任务,导致用户界面内容不能及时更新到屏幕上,会引起用户界面卡顿。此外,如果主线程在进行其他繁重任务,比如在主线程中响应用户的触摸、点击等操作,可能会导致主线程无法及时处理渲染任务,同样会导致用户界面卡顿。Take the iOS system as an example. The application uses the UIKit and CoreAnimation frameworks provided by the system to render the user interface. However, these frameworks must be operated on the main thread. The internal implementation is also performed by the main thread on the CPU, such as preparation. View hierarchy, set layer properties, draw bitmaps, and decode images. When the user interface level is complicated or the content is complicated, the task cannot be completed within one refresh cycle, and the user interface content cannot be updated to the screen in time, which may cause the user interface to be stuck. In addition, if the main thread is performing other heavy tasks, such as responding to user touches and clicks in the main thread, the main thread may not be able to process the rendering task in time, which may also cause the user interface to be stuck.
发明内容Summary of the invention
本申请提供一种用户界面渲染的方法,以解决现有技术存在的用户界面卡 顿的问题。The present application provides a method for user interface rendering to solve the problem of user interface jams existing in the prior art.
本申请同时涉及一种用户界面渲染的装置,以及一种电子设备。The application also relates to a device for rendering a user interface, and an electronic device.
本申请提供一种用户界面渲染的方法,包括:The application provides a method for rendering a user interface, including:
基于主线程触发针对待渲染对象的用户界面渲染;Triggering user interface rendering for the object to be rendered based on the main thread;
从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;Switching from the main thread to the child thread, and drawing, by the child thread, a bitmap corresponding to the object to be rendered;
回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;Calling back the main thread, and applying the drawn bitmap to the display content of the object to be rendered;
根据所述待渲染对象的显示内容渲染用户界面。And rendering a user interface according to the display content of the object to be rendered.
可选的,所述从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图步骤执行前,执行下述步骤:Optionally, the step of switching from the main thread to the child thread, and drawing the bitmap corresponding to the object to be rendered by the child thread, before performing the step of performing the following steps:
确定所述待渲染对象的视图层级树;Determining a view hierarchy tree of the object to be rendered;
对所述视图层级树中的节点进行光栅化;Rectifying nodes in the view hierarchy tree;
其中,所述待渲染对象对应的位图根据所述视图层级树中节点的光栅化结果进行绘制。The bitmap corresponding to the object to be rendered is drawn according to a rasterization result of nodes in the view hierarchy tree.
可选的,所述用户界面渲染的方法,包括:Optionally, the method for rendering the user interface includes:
根据所述待渲染对象的属性信息确定所述视图层级树中节点的节点属性;Determining, according to the attribute information of the object to be rendered, a node attribute of a node in the view hierarchy tree;
其中,所述节点属性包括:光栅化属性和非光栅化属性;The node attributes include: a rasterized attribute and a non-rasterized attribute;
相应的,所述视图层级树中的节点包括:光栅化根节点、光栅化子节点和非光栅化节点。Correspondingly, the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
可选的,所述光栅化根节点设置有状态标识,所述状态标识包括:允许与光栅化子节点进行光栅化的第一状态标识,以及不允许与光栅化子节点进行光栅化的第二状态标识。Optionally, the rasterized root node is configured with a state identifier, where the state identifier includes: a first state identifier that allows rasterization with the rasterized child node, and a second state that does not allow rasterization with the rasterized child node Status identifier.
可选的,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:Optionally, the rasterizing the nodes in the view hierarchy tree is implemented as follows:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;Determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node, and if so, selecting a level of the rasterized root node or the non-rasterized node existing in the ancestor node and a level of the node The nearest rasterized root node or non-rasterized node is used as the candidate node;
判断所述节点的节点属性是否为光栅化属性,若是,判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识,若是, 将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, determining whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if so, merging the nodes Go to the candidate node.
可选的,若所述判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点子步骤的判断结果为否,执行如下操作:Optionally, if the judgment result of the step of determining whether the rasterized root node or the non-rasterized node is present in the ancestor node found is no, perform the following operations:
判断所述节点的节点属性是否为光栅化属性,若是,将所述节点作为光栅化根节点,并将所述节点的状态标识设为所述第一状态标识。Determining whether the node attribute of the node is a rasterization attribute, and if so, using the node as a rasterization root node, and setting a status identifier of the node as the first status identifier.
可选的,若所述判断所述节点的节点属性是否为光栅化属性子步骤的判断结果为否,执行如下操作:Optionally, if the determining whether the node attribute of the node is a rasterization attribute sub-step is negative, perform the following operations:
将所述候选节点设为所述节点的父节点;Setting the candidate node as a parent node of the node;
判断所述候选节点是否为光栅化根节点,若是,则将所述候选节点的状态标识标记为所述第二状态标识。Determining whether the candidate node is a rasterized root node, and if so, marking the status identifier of the candidate node as the second status identifier.
可选的,若所述判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识子步骤的判断结果为否,执行如下操作:Optionally, if the determining whether the candidate node is a rasterized root node and determining whether the status identifier of the candidate node is the first state identifier substep is no, perform the following operations:
将所述候选节点设为所述节点的父节点。The candidate node is set as the parent node of the node.
可选的,所述用户界面渲染的方法,包括:Optionally, the method for rendering the user interface includes:
判断所述视图层级树中的节点是否遍历完毕,若否,执行所述采用深度优先的规则遍历所述视图层级树中的节点子步骤。Determining whether the nodes in the view hierarchy tree are traversed, and if not, performing the depth-first rule to traverse the node sub-steps in the view hierarchy tree.
可选的,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:Optionally, the rasterizing the nodes in the view hierarchy tree is implemented as follows:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;Determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node, and if so, selecting a level of the rasterized root node or the non-rasterized node existing in the ancestor node and a level of the node The nearest rasterized root node or non-rasterized node is used as the candidate node;
判断所述节点的节点属性是否为光栅化属性,若是,判断所述候选节点是否为光栅化根节点,若是,判断所述候选节点的状态标识是否为第一状态标识,若是,将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, determining whether the candidate node is a rasterized root node, and if so, determining whether the state identifier of the candidate node is a first state identifier, and if so, the node Merged onto the candidate node.
可选的,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:Optionally, the rasterizing the nodes in the view hierarchy tree is implemented as follows:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点,若存在,在所述祖先节 点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;Determining whether there is a rasterized root node in the found ancestor node, and if so, selecting, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the layer where the node is located as a candidate node;
判断所述候选节点的状态标识是否为所述第一状态标识,若是,判断所述节点的节点属性是否为光栅化属性,若是,将所述节点合并到所述候选节点上。Determining whether the state identifier of the candidate node is the first state identifier, and if so, determining whether the node attribute of the node is a rasterization attribute, and if so, merging the node onto the candidate node.
可选的,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:Optionally, the rasterizing the nodes in the view hierarchy tree is implemented as follows:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点,若存在,在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;Determining whether there is a rasterized root node in the found ancestor node, and if so, selecting, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the layer where the node is located as a candidate node;
判断所述节点的节点属性是否为光栅化属性,若是,将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, merging the node onto the candidate node.
可选的,所述绘制所述待渲染对象对应的位图,采用如下方式实现:Optionally, the mapping of the bitmap corresponding to the object to be rendered is implemented as follows:
根据所述节点和所述候选节点的合并结果,将所述节点对应的节点视图和所述候选节点对应的节点视图绘制在一张位图上。And according to the result of the combination of the node and the candidate node, the node view corresponding to the node and the node view corresponding to the candidate node are drawn on a bitmap.
可选的,所述方法基于终端设备实现,所述终端设备设置有中央处理器、图形处理器和显示屏;Optionally, the method is implemented based on a terminal device, where the terminal device is configured with a central processing unit, a graphics processor, and a display screen;
其中,所述基于主线程触发针对待渲染对象的用户界面渲染步骤,所述从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图步骤,以及所述回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中步骤,基于所述中央处理器实现;The step of triggering a user interface for the object to be rendered based on the main thread, the step of switching from the main thread to the child thread, drawing a bitmap step corresponding to the object to be rendered by the child thread, and the step Calling back the main thread, applying the drawn bitmap to the display content of the object to be rendered, based on the central processor;
所述根据所述待渲染对象的显示内容渲染用户界面步骤,基于所述图形处理器实现;The step of rendering a user interface according to the display content of the object to be rendered is implemented based on the graphics processor;
所述回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中步骤执行后,且所述根据所述待渲染对象的显示内容渲染用户界面步骤执行前,所述中央处理器将所述显示内容提交给所述图形处理器;After the step of executing the step of executing the step of performing the rendering of the bitmap to the display content of the object to be rendered, and the step of performing the rendering of the user interface according to the display content of the object to be rendered, The central processor submits the display content to the graphics processor;
所述图形处理器在根据所述待渲染对象的显示内容渲染所述用户界面后,将渲染结果传递给所述显示屏显示。After rendering the user interface according to the display content of the object to be rendered, the graphics processor passes the rendering result to the display screen.
本申请还提供一种用户界面渲染的装置,包括:The application also provides a device for rendering a user interface, including:
渲染触发单元,用于基于主线程触发针对待渲染对象的用户界面渲染;a rendering trigger unit for triggering a user interface rendering for the object to be rendered based on the main thread;
位图绘制单元,用于从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;a bitmap drawing unit, configured to switch from the main thread to a child thread, by using the child thread to draw a bitmap corresponding to the object to be rendered;
位图应用单元,用于回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;a bitmap application unit, configured to call back the main thread, and apply the drawn bitmap to the display content of the object to be rendered;
用户界面渲染单元,用于根据所述待渲染对象的显示内容渲染用户界面。And a user interface rendering unit, configured to render the user interface according to the display content of the object to be rendered.
可选的,所述用户界面渲染的装置,包括:Optionally, the device for rendering the user interface includes:
视图层级树确定单元,用于确定所述待渲染对象的视图层级树;a view level tree determining unit, configured to determine a view level tree of the object to be rendered;
光栅化单元,用于对所述视图层级树中的节点进行光栅化;a rasterizing unit, configured to rasterize nodes in the view hierarchy tree;
其中,所述位图绘制单元根据所述光栅化单元的光栅化结果进行绘制。The bitmap drawing unit performs rendering according to the rasterization result of the rasterization unit.
可选的,所述用户界面渲染的装置,包括:Optionally, the device for rendering the user interface includes:
节点属性确定单元,用于根据所述待渲染对象的属性信息确定所述视图层级树中节点的节点属性;a node attribute determining unit, configured to determine a node attribute of a node in the view level tree according to the attribute information of the object to be rendered;
其中,所述节点属性包括:光栅化属性和非光栅化属性;The node attributes include: a rasterized attribute and a non-rasterized attribute;
相应的,所述视图层级树中的节点包括:光栅化根节点、光栅化子节点和非光栅化节点。Correspondingly, the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
可选的,所述光栅化根节点设置有状态标识,所述状态标识包括:允许与光栅化子节点进行光栅化的第一状态标识,以及不允许与光栅化子节点进行光栅化的第二状态标识。Optionally, the rasterized root node is configured with a state identifier, where the state identifier includes: a first state identifier that allows rasterization with the rasterized child node, and a second state that does not allow rasterization with the rasterized child node Status identifier.
可选的,所述光栅化单元,包括:Optionally, the rasterizing unit includes:
第一节点遍历子单元,用于采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点运行第一祖先节点查找子单元以及第一祖先节点判断子单元;The first node traverses the subunit, and is configured to traverse the nodes in the view hierarchy tree by using a depth-first rule, each traversing one node, and running the first ancestor node search subunit and the first ancestor node judgment subunit for the traversed node;
其中,所述第一祖先节点查找子单元,用于在所述视图层级树中查找所述节点的祖先节点;The first ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree;
所述第一祖先节点判断子单元,用于判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,运行第一候选节点确定子单元以及第一光栅化属性判断子单元;The first ancestor node determining subunit is configured to determine whether a rasterized root node or a non-rasterized node exists in the found ancestor node, and if present, run the first candidate node determining subunit and the first rasterized attribute determiner unit;
所述第一候选节点确定子单元,用于在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;The first candidate node determining subunit is configured to select, in a rasterized root node or a non-rasterized node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node or non-rasterization The node acts as a candidate node;
所述第一光栅化属性判断子单元,用于判断所述节点的节点属性是否为光 栅化属性,若是,运行第一候选节点判断子单元;The first rasterization attribute determining subunit is configured to determine whether a node attribute of the node is a rasterization attribute, and if yes, running a first candidate node to determine a subunit;
所述第一候选节点判断子单元,用于判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识,若是,运行第一节点合并子单元;The first candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if yes, running the first node merging subunit;
所述第一节点合并子单元,用于将所述节点合并到所述候选节点上。The first node merges subunits for merging the nodes onto the candidate nodes.
本申请还提供一种电子设备,包括:The application also provides an electronic device, including:
存储器、中央处理器和图形处理器;Memory, central processing unit and graphics processor;
所述存储器用于存储计算机可执行指令,所述中央处理器用于执行如下计算机可执行指令:The memory is for storing computer executable instructions, and the central processor is configured to execute computer executable instructions as follows:
基于主线程触发针对待渲染对象的用户界面渲染;Triggering user interface rendering for the object to be rendered based on the main thread;
从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;Switching from the main thread to the child thread, and drawing, by the child thread, a bitmap corresponding to the object to be rendered;
回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;Calling back the main thread, and applying the drawn bitmap to the display content of the object to be rendered;
所述图形处理器用于执行如下计算机可执行指令:根据所述待渲染对象的显示内容渲染用户界面。The graphics processor is configured to execute computer executable instructions to render a user interface according to display content of the object to be rendered.
本申请提供的所述用户界面渲染的方法,包括:基于主线程触发针对待渲染对象的用户界面渲染;从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;根据所述待渲染对象的显示内容渲染用户界面。The method for rendering the user interface provided by the present application includes: triggering a user interface rendering for an object to be rendered based on a main thread; switching from the main thread to a child thread, and drawing, by the child thread, a corresponding object to be rendered a bitmap; the callback is applied to the main thread, and the drawn bitmap is applied to the display content of the object to be rendered; and the user interface is rendered according to the display content of the object to be rendered.
所述用户界面渲染的方法,在进行用户界面渲染过程中,当基于主线程触发了针对所述待渲染对象的用户界面渲染时,从所述主线程切换到子线程,在所述子线程进行位图绘制,并在绘制完后切换回所述主线程,在所述主线程将位图绘制应用到所述待渲染对应的显示内容当中,最终根据所述待渲染对应的显示内容进行用户界面渲染,从而将原本在所述主线程执行的位图绘制操作转移到所述子线程进行,减轻了主线程的负荷,同时降低了主线程在任务繁重时无法及时处理渲染任务造成的用户界面卡顿。The method for rendering the user interface, in the process of rendering the user interface, when the user interface rendering of the object to be rendered is triggered based on the main thread, switching from the main thread to the child thread, and performing the sub-thread The bitmap is drawn, and is switched back to the main thread after the drawing is completed, where the main thread applies bitmap rendering to the corresponding display content to be rendered, and finally performs a user interface according to the corresponding display content to be rendered. Rendering, thereby transferring the bitmap drawing operation originally performed by the main thread to the sub-thread, reducing the load of the main thread, and reducing the user interface card caused by the main thread failing to process the rendering task in time when the task is heavy pause.
附图说明DRAWINGS
附图1是本申请提供的一种用户界面渲染的方法实施例的处理流程图;1 is a process flow diagram of an embodiment of a method for user interface rendering provided by the present application;
附图2是本申请提供的一种用户界面渲染的时序图;2 is a timing diagram of a user interface rendering provided by the present application;
附图3是本申请提供的一种视图层级树的示意图;Figure 3 is a schematic diagram of a view hierarchy tree provided by the present application;
附图4是本申请提供的一种光栅化过程的示意图;4 is a schematic diagram of a rasterization process provided by the present application;
附图5是本申请提供的一种用户界面渲染的装置实施例的示意图;FIG. 5 is a schematic diagram of an apparatus embodiment for user interface rendering provided by the present application; FIG.
附图6是本申请提供的一种电子设备实施例的示意图。6 is a schematic diagram of an embodiment of an electronic device provided by the present application.
具体实施方式Detailed ways
在下面的描述中阐述了很多具体细节以便于充分理解本申请。但是本申请能够以很多不同于在此描述的其他方式来实施,本领域技术人员可以在不违背本申请内涵的情况下做类似推广,因此本申请不受下面公开的具体实施的限制。Numerous specific details are set forth in the description below in order to provide a thorough understanding of the application. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art can make similar promotion without departing from the scope of the present application, and thus the present application is not limited by the specific embodiments disclosed below.
本申请提供一种用户界面渲染的方法,本申请还提供一种用户界面渲染的装置,以及一种电子设备。以下分别结合本申请提供的实施例的附图逐一进行详细说明,并且对方法的各个步骤进行说明。The present application provides a method for user interface rendering, and the present application also provides a device for rendering a user interface, and an electronic device. The following is a detailed description of the embodiments of the embodiments provided herein, and the various steps of the method are explained.
本申请提供的一种用户界面渲染的方法实施例如下:A method for implementing user interface rendering provided by the present application is as follows:
参照附图1,其示出了本申请提供的一种用户界面渲染的方法实施例的处理流程图,参照附图2,其示出了本申请提供的一种用户界面渲染的时序图,参照附图3,其示出了本申请提供的一种视图层级树的示意图,参照附图4,其示出了本申请提供的一种光栅化过程的示意图。1 is a process flow diagram of a method for rendering a user interface provided by the present application. Referring to FIG. 2, a timing diagram of user interface rendering provided by the present application is shown. FIG. 3 is a schematic diagram showing a view hierarchy tree provided by the present application. Referring to FIG. 4, a schematic diagram of a rasterization process provided by the present application is shown.
步骤S101,基于主线程触发针对待渲染对象的用户界面渲染。Step S101, triggering a user interface rendering for the object to be rendered based on the main thread.
以iOS系统为例,在进行用户界面渲染(UI渲染)时都是由应用程序的主线程进行的,但受到主线程处理能力和CPU性能的约束,在主线程的任务处理较为繁重或者CPU性能较低时,在iOS设备上进行UI渲染可能会出现页面卡顿的情形。针对这种情况,本申请提供的所述用户界面渲染的方法,如图2所示,针对渲染任务1或者渲染任务2中包含的UI渲染,应用程序的主线程在CPU中执行操作时,采用异步处理的方式,将原本在应用程序的主线程执行的一部分操作转移到应用程序的子线程执行,待所述子线程执行完毕后,将执行结果同步到主线程,继续在所述主线程执行,从而来减轻所述主线程的负荷,同时降低了主线程在任务繁重时无法及时处理渲染任务造成的用户界面卡顿。Taking the iOS system as an example, the user interface rendering (UI rendering) is performed by the main thread of the application, but subject to the processing power of the main thread and the performance of the CPU, the task processing in the main thread is heavy or CPU performance. At lower levels, UI rendering on iOS devices may cause page jams. For this situation, the method for rendering the user interface provided by the present application, as shown in FIG. 2, is used for the rendering of the UI included in the rendering task 1 or the rendering task 2, and the main thread of the application performs the operation in the CPU. Asynchronous processing, the part of the operation originally executed by the main thread of the application is transferred to the sub-thread of the application, and after the execution of the sub-thread is completed, the execution result is synchronized to the main thread, and the execution is continued in the main thread. In order to alleviate the load of the main thread, and at the same time reduce the user interface jam caused by the main thread unable to process the rendering task in time when the task is heavy.
在UI渲染过程中,所述主线程是根据帧同步信号进行UI渲染,一般而言,UI渲染过程中帧同步信号的周期是固定的,比如iOS系统中帧同步信号的周期为1/60s,即:屏幕上显示的用户界面每秒需刷新60次。本步骤中,基于应用程 序的主线程触发针对所述待渲染对象的UI渲染,是在收到渲染命令之后触发的,并且是在收到渲染命令后帧同步信号到达应用程序之后触发的。In the UI rendering process, the main thread performs UI rendering according to the frame synchronization signal. Generally, the period of the frame synchronization signal in the UI rendering process is fixed. For example, the period of the frame synchronization signal in the iOS system is 1/60 s. That is: the user interface displayed on the screen needs to be refreshed 60 times per second. In this step, the application-based main thread triggers UI rendering for the object to be rendered, which is triggered after receiving the rendering command, and is triggered after the frame synchronization signal arrives at the application after receiving the rendering command.
本申请实施例所述待渲染对象,可以是用户界面上任意一个元素,也可以是所述用户界面整体;相应的,针对所述待渲染对象的UI渲染,可以是针对所述用户界面上任意一个元素进行UI渲染的渲染任务,也可以是针对所述用户界面整体进行更新的渲染任务。进一步,如果用户界面上的任意一个元素发生变化,具体在进行UI渲染时的渲染机制,可以是只针对所述发生变化的元素进行UI渲染,也可是对发生变化的元素所在用户界面整体进行UI渲染,可见,针对所述待渲染对象进行UI渲染的渲染机制可以根据实际情况进行配置,在此不做限定。The object to be rendered in the embodiment of the present application may be any element on the user interface, or may be the user interface as a whole; correspondingly, the UI rendering of the object to be rendered may be any for the user interface. A rendering task in which an element performs UI rendering may also be a rendering task that is updated overall for the user interface. Further, if any one of the elements on the user interface changes, the rendering mechanism in the UI rendering may be UI rendering only for the changed element, or the UI of the user interface where the changed element is located. The rendering mechanism of the rendering of the object to be rendered can be configured according to the actual situation, which is not limited herein.
步骤S102,从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图。Step S102: Switch from the main thread to the sub-thread, and draw a bitmap corresponding to the object to be rendered by the sub-thread.
如附图2所示,其中的frame1至frame5表示帧同步信号的周期,即UI渲染的渲染周期,具体在帧同步信号到达应用程序后,在所述主线程触发针对所述待渲染对象的UI渲染,并从所述主线程切换到所述子线程,通过所述子线程绘制所述待渲染对象对应的位图。As shown in FIG. 2, frame1 to frame5 represent the period of the frame synchronization signal, that is, the rendering period of the UI rendering, specifically, after the frame synchronization signal reaches the application, the UI for the object to be rendered is triggered in the main thread. Rendering, and switching from the main thread to the child thread, by which the bitmap corresponding to the object to be rendered is drawn.
在具体实施时,所述主线程和所述子线程还可以采用异步处理的方式,互不影响,但所述主线程和所述子线程二者可以实现数据共享,基于所述主线程触发针对所述待渲染对象的UI渲染的过程中,在进行线程切换之前,即:从所述主线程切换到所述子线程前,可确定所述待渲染对象的视图层级树,并对所述视图层级树中的节点进行光栅化处理。本申请实施例所述光栅化,是指在所述视图层级树当中,将多个节点合并成一个节点,并分别将各个节点的显示特性在合并后节点的视图上展示出来。In a specific implementation, the main thread and the sub-thread may also adopt an asynchronous processing manner, and do not affect each other, but the main thread and the sub-thread can implement data sharing, and the triggering is performed based on the main thread. In the process of UI rendering of the object to be rendered, before the thread switching, that is, before switching from the main thread to the child thread, the view hierarchy tree of the object to be rendered may be determined, and the view is The nodes in the hierarchical tree are rasterized. The rasterization in the embodiment of the present application refers to merging a plurality of nodes into one node in the view hierarchy tree, and respectively displaying the display characteristics of each node on the view of the merged node.
具体的,所述视图层级树中节点具有各自的节点属性,所述节点属性包括光栅化属性和非光栅化属性,如果某节点的节点属性为光栅化属性,则该节点可以与所述视图层级树中的其他节点进行光栅化;反之,如果某节点的节点属性为非光栅化属性,则该节点不可以与其他节点进行光栅化。需要说明的是,此处针对所述视图层级树中的节点进行光栅化处理是基于所述节点各自对应的节点属性实现的,因此,在对所述视图层级树中的节点进行光栅化处理之前,还需根据所述待渲染对象的属性信息确定所述视图层级树中节点的节点属性。一般而言,所述视图层级树中的节点可分为根节点和子节点,其中的子节点既 可以是根节点的子节点,也可以是其子节点的祖先节点。此外,所述视图层级树中的节点具有相应节点属性:光栅化属性和非光栅化属性。具体在本实施例中,所述视图层级树中的节点分为:光栅化根节点、光栅化子节点以及非光栅化节点。Specifically, the nodes in the view hierarchy tree have respective node attributes, and the node attributes include a rasterization attribute and a non-rasterized attribute. If a node attribute of a node is a rasterization attribute, the node may be related to the view level. Other nodes in the tree are rasterized; conversely, if a node's node property is a non-rasterized property, the node cannot be rasterized with other nodes. It should be noted that performing rasterization processing on the nodes in the view hierarchy tree is implemented based on the node attributes corresponding to the nodes, and therefore, before performing rasterization on the nodes in the view hierarchy tree. And determining, according to the attribute information of the object to be rendered, a node attribute of a node in the view level tree. In general, nodes in the view hierarchy tree can be divided into a root node and a child node, wherein the child node can be either a child node of the root node or an ancestor node of its child node. In addition, the nodes in the view hierarchy tree have corresponding node attributes: rasterized attributes and non-rasterized attributes. Specifically, in this embodiment, the nodes in the view hierarchy tree are divided into: a rasterized root node, a rasterized child node, and a non-rasterized node.
在此基础上,还可针对所述视图层级树中的光栅化根节点设置相应的状态标识,通过状态标识来确定所述光栅化根节点是否能够接收光栅化子节点与其进行光栅化。其中,所述光栅化根节点的状态标识包括第一状态标识和第二状态标识,如果所述光栅化根节点的状态标识为第一状态标识,则允许所述光栅化根节点与光栅化子节点进行光栅化;相反的,如果所述光栅化根节点的状态标识为第二状态标识,则不允许所述光栅化根节点与光栅化子节点进行光栅化。本实施例中,所述光栅化根节点的状态标识初始默认的状态标识为第一状态标识,但是,当所述光栅化根节点在遍历过程中遇到不能被光栅化的子孙节点后,所述光栅化根节点的状态标识变更为第二状态标识。如附图3所示的视图层级树,其中节点1、节点7和节点8为光栅化根节点,节点2、节点3、节点4、节点5和节点9为光栅化子节点,节点6为非光栅化节点;另外,节点1、节点7和节点8作为光栅化根节点还设置有状态标识,本实施例中,节点1、节点7和节点8的状态标识在初始化时被设置为第一状态标识。On this basis, a corresponding state identifier may be set for the rasterized root node in the view level tree, and the state identifier is used to determine whether the rasterized root node can receive the rasterized child node and rasterize it. The state identifier of the rasterized root node includes a first state identifier and a second state identifier, and if the state identifier of the rasterized root node is the first state identifier, allowing the rasterized root node and the rasterizer The node performs rasterization; conversely, if the state of the rasterized root node is identified as the second state identifier, the rasterized root node and the rasterized child node are not allowed to be rasterized. In this embodiment, the status of the rasterized root node identifies that the initial default state identifier is the first state identifier, but when the rasterized root node encounters a descendant node that cannot be rasterized during the traversal process, The state identifier of the rasterized root node is changed to the second state identifier. A view hierarchy tree as shown in FIG. 3, wherein node 1, node 7, and node 8 are rasterized root nodes, node 2, node 3, node 4, node 5, and node 9 are rasterized child nodes, and node 6 is non- Rasterization node; in addition, node 1, node 7, and node 8 are also provided with a state identifier as a rasterized root node. In this embodiment, the state identifiers of node 1, node 7, and node 8 are set to the first state at initialization. Logo.
参见附图4所示的光栅化过程的示意图,所述视图层级树中的节点进行光栅化的过程,具体实现如下:Referring to the schematic diagram of the rasterization process shown in FIG. 4, the process of rasterizing the nodes in the view hierarchy tree is as follows:
从所述视图层级树中的根节点开始,采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:Starting from the root node in the view hierarchy tree, the nodes in the view hierarchy tree are traversed by depth-first rules, and each node is traversed, and the following operations are performed for the traversed nodes:
1)在所述视图层级树中查找所述节点的祖先节点;1) searching for an ancestor node of the node in the view hierarchy tree;
如附图3所示的视图层级树,采用深度优先的规则遍历所述视图层级树中节点的过程中,从所述视图层级树中的根节点开始遍历,具体遍历顺序为:节点1->节点2->节点3->节点4->节点5->节点6->节点7->节点8->节点9。当遍历到某一个节点,在所述视图层级树中查找该节点的祖先节点,具体在查找该节点的祖先节点时,从与该节点层级关系最近的父节点开始,依次向上查找该节点在所述视图层级树中的所有祖先节点。如果在所述视图层级树中查找不到该节点的祖先节点,则表明该节点为视图层级树中的根节点,如附图3所示视图层级树中的节点1,由于其不存在祖先节点,因此无法与祖先节点进行光栅化,不作处理即可,继续遍历视图层级树中的下一个节点(节点2)。The view hierarchy tree shown in FIG. 3 is traversed from the root node in the view hierarchy tree in the process of traversing the nodes in the view hierarchy tree by using a depth-first rule. The specific traversal order is: node 1-> Node 2 -> Node 3 -> Node 4 -> Node 5 -> Node 6 -> Node 7 -> Node 8 -> Node 9. When traversing to a certain node, searching for the ancestor node of the node in the view hierarchy tree, specifically searching for the ancestor node of the node, starting from the parent node closest to the hierarchical relationship of the node, and sequentially looking up the node in the All ancestor nodes in the view hierarchy tree. If the ancestor node of the node is not found in the view hierarchy tree, it indicates that the node is a root node in the view hierarchy tree, such as node 1 in the view hierarchy tree shown in FIG. 3, because there is no ancestor node Therefore, it is impossible to rasterize with the ancestor node, and without processing, continue to traverse the next node (node 2) in the view hierarchy tree.
2)判断查找到的祖先节点(针对该节点查找到的祖先节点)中是否存在光栅化根节点或者非光栅化节点,若存在,执行下述步骤3)和步骤4);如附图3所示视图层级树中的节点2,其祖先节点为节点1,并且节点1为光栅化根节点,则针对节点2进行下一步处理。2) determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node (for the ancestor node found by the node), if present, performing the following steps 3) and 4); Node 2 in the view hierarchy tree, whose ancestor node is node 1, and node 1 is the rasterized root node, performs the next processing for node 2.
若不存在,表明查找到的祖先节点均为光栅化子节点,如上所述,只有光栅化根节点才能接收与光栅化子节点进行的光栅化,可见,如果查找到的祖先节点均为光栅化子节点,则表明该节点无法与查找到的祖先节点进行光栅化。在这种情况下,进一步判断该节点的节点属性是否为光栅化属性,若是,将该节点作为光栅化根节点,并将该节点的状态标识设为所述第一状态标识。If it does not exist, it indicates that the found ancestor nodes are rasterized child nodes. As mentioned above, only the rasterized root node can receive the rasterization with the rasterized child nodes. It can be seen that if the found ancestors are rasterized A child node indicates that the node cannot be rasterized with the found ancestor node. In this case, it is further determined whether the node attribute of the node is a rasterization attribute, and if so, the node is used as a rasterization root node, and the state identifier of the node is set as the first state identifier.
3)在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;3) selecting, in the rasterized root node or the non-rasterized node existing in the ancestor node, a rasterized root node or a non-rasterized node whose level is closest to the level of the node as a candidate node;
如附图3所示视图层级树中的节点2,节点2的祖先节点只有一个:光栅化根节点1,因此将光栅化根节点1作为节点2的候选节点。另,对于视图层级树中的节点3,祖先节点有两个:节点2和节点1,节点2所在层级与节点3所在层级相邻,节点1所在层级与节点3所在层级相差两层,可见,节点2所在层级与节点3所在层级最近,因此将节点2作为节点3的候选节点。As node 2 in the view hierarchy tree shown in Figure 3, there is only one ancestor node of node 2: rasterize root node 1, so rasterized root node 1 is used as a candidate node for node 2. In addition, for node 3 in the view hierarchy tree, there are two ancestor nodes: node 2 and node 1, the level of node 2 is adjacent to the level of node 3, and the level of node 1 is different from the level of node 3, which is visible. The level at which node 2 is located is the closest to the level at which node 3 is located, so node 2 is the candidate node for node 3.
4)判断所述节点的节点属性是否为光栅化属性,若是,执行下述步骤5);如附图3所示视图层级树中的节点2,其为光栅化子节点,节点属性为光栅化属性,则针对节点2执行下一步操作。4) determining whether the node attribute of the node is a rasterization attribute, and if so, performing the following step 5); as shown in Figure 3, node 2 in the view hierarchy tree is a rasterized child node, and the node attribute is rasterized. Attribute, then perform the next step for node 2.
若否,将所述候选节点设为所述节点的父节点,并判断所述候选节点是否为光栅化根节点,若是,则将所述候选节点的状态标识标记为所述第二状态标识。当遍历至节点6时,节点6的祖先节点包括:节点1、节点4和节点5,并且节点6的节点属性为非光栅化属性,可见,只有节点1满足条件,因此节点1会被设为节点6的候选节点;此外,由于节点1为光栅化根节点,则将节点1的状态标识为所述第二状态标识,即:节点1在此之后不允许有光栅化子节点与其进行光栅化。If not, the candidate node is set as a parent node of the node, and it is determined whether the candidate node is a rasterized root node, and if so, the state identifier of the candidate node is marked as the second state identifier. When traversing to node 6, the ancestor nodes of node 6 include: node 1, node 4, and node 5, and the node attribute of node 6 is a non-rasterized attribute. It can be seen that only node 1 satisfies the condition, so node 1 is set to a candidate node of the node 6; furthermore, since the node 1 is a rasterized root node, the state of the node 1 is identified as the second state identifier, that is, after the node 1 does not allow the rasterized child node to be rasterized thereafter .
5)判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识,若是,执行下述步骤6),将所述节点光栅化到所述候选节点上,即:将所述节点合并到所述候选节点上。如附图3所示视图层级树中的节点2的候选节点(节点1)为光栅化根节点,且节点1的状态标识为第一状态标识,则允许所述光栅化根节点与光栅化子节点进行光栅化,将节点2光栅 化到节点1上。5) determining whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if yes, performing the following step 6), rasterizing the node to the candidate node Up, ie, merging the nodes onto the candidate nodes. If the candidate node (node 1) of the node 2 in the view hierarchy tree shown in FIG. 3 is a rasterized root node, and the state identifier of the node 1 is the first state identifier, the rasterized root node and the rasterizer are allowed. The node is rasterized and node 2 is rasterized onto node 1.
若否,将所述候选节点设为所述节点的父节点。如附图3所示视图层级树中,节点2的父节点为节点1,此处将节点2的候选节点(节点1)设为节点2的父节点,并不改变节点2与节点1在视图层级树中的层级以及连接关系。If not, the candidate node is set as the parent of the node. As shown in the view hierarchy tree shown in FIG. 3, the parent node of node 2 is node 1, where the candidate node of node 2 (node 1) is set as the parent node of node 2, and the view of node 2 and node 1 is not changed. Hierarchy and connection relationships in the hierarchy tree.
6)将所述节点合并到所述候选节点上。6) Merging the node onto the candidate node.
上述光栅化过程主要以节点2为例进行说明,并提供了将节点2光栅化到节点1的具体过程,如附图3所示视图层级树,结合上述光栅化过程,节点3、节点4和节点5在遍历过程中的处理步骤与节点2类似,最终均会被光栅化到节点1上。The above rasterization process is mainly described by taking node 2 as an example, and provides a specific process of rasterizing node 2 to node 1, such as the view hierarchy tree shown in FIG. 3, combined with the above rasterization process, node 3, node 4 and The processing steps of node 5 during the traversal process are similar to those of node 2, and are eventually rasterized onto node 1.
当遍历至节点6时,节点6的祖先节点包括:节点1、节点4和节点5,并且节点6的节点属性为非光栅化属性,可见,只有节点1满足条件,因此节点1会被设为节点6的候选节点;此外,由于节点1为光栅化根节点,则将节点1的状态标识为所述第二状态标识,即:节点1在此之后不允许有光栅化子节点与其进行光栅化。When traversing to node 6, the ancestor nodes of node 6 include: node 1, node 4, and node 5, and the node attribute of node 6 is a non-rasterized attribute. It can be seen that only node 1 satisfies the condition, so node 1 is set to a candidate node of the node 6; furthermore, since the node 1 is a rasterized root node, the state of the node 1 is identified as the second state identifier, that is, after the node 1 does not allow the rasterized child node to be rasterized thereafter .
当遍历至节点7时,节点7的祖先节点包括:节点1和节点4,同时节点7的节点属性为光栅化属性,节点4不满足被设为候选节点的条件,节点1被设为节点7的候选节点,虽然节点1为光栅化根节点,但由于节点1的状态标识在节点6的遍历过程中被设为第二状态标识,可见,节点7不允许被光栅化到节点1上,则将节点1设为节点7的父节点,即:将节点7的父节点从节点4变更为节点1。节点8在遍历过程中的处理与节点7类似,最终,节点8的父节点被设为节点1,但由于节点8最初的父节点同样是节点1,因此,节点8在视图层级树中的层级没有发生变化。当遍历至节点9时,节点9的祖先节点有节点1和节点8,由于节点8所在层级与节点9所在层级相邻,因此节点8被设备节点9的候选节点,同时,节点8为光栅化根节点且状态标识为第一状态标识,因此节点9被合并到节点8上。When traversing to node 7, the ancestor node of node 7 includes: node 1 and node 4, while the node attribute of node 7 is a rasterization attribute, node 4 does not satisfy the condition set as a candidate node, and node 1 is set to node 7. Candidate node, although node 1 is a rasterized root node, since the state identifier of node 1 is set to the second state identifier during the traversal of node 6, it can be seen that node 7 is not allowed to be rasterized onto node 1, then Node 1 is set as the parent node of node 7, that is, the parent node of node 7 is changed from node 4 to node 1. The processing of node 8 in the traversal process is similar to that of node 7, and finally, the parent node of node 8 is set to node 1, but since the initial parent node of node 8 is also node 1, the level of node 8 in the view hierarchy tree is No change has taken place. When traversing to node 9, the ancestor node of node 9 has node 1 and node 8. Since the level of node 8 is adjacent to the level of node 9, node 8 is the candidate node of device node 9, and node 8 is rasterized. The root node and the status identifier are the first status identifier, so node 9 is merged onto node 8.
在具体实施时,上述遍历过程中为了确保所述视图层级树中的节点全部被遍历,避免所述视图层级树中的节点被漏掉,可在每遍历所述视图层级树中的一个节点后,执行如下遍历判断操作:判断所述视图层级树中的节点是否遍历完毕,若是,则结束针对所述视图层级树中节点的遍历过程;若否,则继续进行遍历,按照深度优先规则对所述视图层级树中尚未遍历的节点进行遍历。In a specific implementation, in order to ensure that all the nodes in the view hierarchy tree are traversed during the traversal process, the nodes in the view hierarchy tree are prevented from being missed, and each node in the view hierarchy tree may be traversed. Performing a traversal determination operation of: determining whether the nodes in the view hierarchy tree are traversed, and if so, ending the traversal process for the nodes in the view hierarchy tree; if not, continuing the traversal, according to the depth priority rule Nodes that have not been traversed in the view hierarchy tree are traversed.
除上述提供的光栅化过程的实现方式之外,所述光栅化过程还可以采用类 似实现方式实现,例如下述提供的三种实现方式:In addition to the implementation of the rasterization process provided above, the rasterization process can also be implemented in a similar implementation, such as the three implementations provided below:
实现方式一:Implementation one:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
a)在所述视图层级树中查找所述节点的祖先节点;a) looking up the ancestor node of the node in the view hierarchy tree;
b)判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,执行下述步骤c)和下述步骤d);若不存在,判断所述节点的节点属性是否为光栅化属性,如果是光栅化属性,将所述节点作为光栅化根节点,并将所述节点的状态标识设为所述第一状态标识;b) determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node, if yes, performing step c) and step d) described below; if not, determining whether the node attribute of the node is a rasterization attribute, if it is a rasterization attribute, the node is used as a rasterization root node, and the state identifier of the node is set as the first state identifier;
c)在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;c) selecting, in the rasterized root node or the non-rasterized node existing in the ancestor node, a rasterized root node or a non-rasterized node whose level is closest to the level of the node as a candidate node;
d)判断所述节点的节点属性是否为光栅化属性,若是,执行下述步骤e);若否,将所述候选节点设为所述节点的父节点,并判断所述候选节点是否为光栅化根节点,如果是光栅化根节点,则将所述候选节点的状态标识标记为所述第二状态标识;d) determining whether the node attribute of the node is a rasterization attribute, and if so, performing the following step e); if not, setting the candidate node as a parent node of the node, and determining whether the candidate node is a raster a root node, if it is a rasterized root node, marking the state identifier of the candidate node as the second state identifier;
e)判断所述候选节点是否为光栅化根节点,若是,执行下述步骤f);若否,将所述候选节点设为所述节点的父节点;e) determining whether the candidate node is a rasterized root node, and if so, performing the following step f); if not, setting the candidate node as a parent node of the node;
f)判断所述候选节点的状态标识是否为第一状态标识,若是,执行下述步骤g);若否,将所述候选节点设为所述节点的父节点;f) determining whether the state identifier of the candidate node is the first state identifier, and if so, performing the following step g); if not, setting the candidate node as the parent node of the node;
g)将所述节点合并到所述候选节点上。g) merging the nodes onto the candidate nodes.
实现方式二:Implementation 2:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点,若存在,在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;判断所述候选节点的状态标识是否为所述第一状态标识,若是,判断所述节点的节点属性是否为光栅化属性,若是,将所述节点合并到所述候选节点上。Determining whether there is a rasterized root node in the found ancestor node, and if so, selecting, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the layer where the node is located as a candidate node; Determining whether the state identifier of the candidate node is the first state identifier, and if so, determining whether the node attribute of the node is a rasterization attribute, and if so, merging the node onto the candidate node.
实现方式三:Implementation three:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针 对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree. Each time a node is traversed, the following operations are performed on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点,若存在,在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;判断所述节点的节点属性是否为光栅化属性,若是,将所述节点合并到所述候选节点上。Determining whether there is a rasterized root node in the found ancestor node, and if so, selecting, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the layer where the node is located as a candidate node; Determining whether the node attribute of the node is a rasterization attribute, and if so, merging the node onto the candidate node.
本步骤从所述主线程切换到所述子线程之后,根据上述光栅化的结果绘制所述待渲染对象的位图,具体绘制所述待渲染对象的位图,是指根据所述节点和所述候选节点的合并结果,将所述节点对应的节点视图和所述候选节点对应的节点视图绘制在一张位图上。如附图3所示的视图层级树,将经光栅化后合并的节点对应的节点视图绘制在一张位图上,例如节点2、节点3、节点4和节点5被光栅化到节点1上,则将节点1至节点5各自对应的节点视图绘制在一张位图上,即:将节点2至节点5各自对应的节点视图的显示特性在节点1对应的节点视图上表现出来。类似的,将节点8和节点9对应的节点视图绘制在一张位图上。需要强调的是,对于节点6和节点7,由于节点6和节点7并未合并到所述视图层级树中的其他节点上,即:节点6和节点7并未与所述视图层级树中的其他节点进行光栅化,因此,对于节点6和节点7,可根据实际需要将其各自对应的节点视图分别绘制在一张位图上,也可以不做处理。After the step is switched from the main thread to the sub-thread, the bitmap of the object to be rendered is drawn according to the result of the rasterization, and the bitmap of the object to be rendered is specifically drawn, according to the node and the As a result of the combination of the candidate nodes, the node view corresponding to the node and the node view corresponding to the candidate node are drawn on a bitmap. As shown in the view hierarchy tree shown in FIG. 3, the node view corresponding to the rasterized and merged nodes is drawn on a bitmap, for example, node 2, node 3, node 4, and node 5 are rasterized onto node 1. Then, the corresponding node views of the nodes 1 to 5 are drawn on a bitmap, that is, the display characteristics of the node views corresponding to the nodes 2 to 5 are represented on the node view corresponding to the node 1. Similarly, the node view corresponding to node 8 and node 9 is drawn on a bitmap. It should be emphasized that for node 6 and node 7, since node 6 and node 7 are not merged into other nodes in the view hierarchy tree, ie, node 6 and node 7 are not associated with the view hierarchy tree. The other nodes are rasterized. Therefore, for node 6 and node 7, the corresponding node views may be respectively drawn on a bitmap according to actual needs, or may not be processed.
需要说明的是,在实际应用中,通过将应用程序的主线程切换到应用程序的子线程进行处理,从而将绘制所述待渲染对象对应的位图的过程以及光栅化处理过程转移到应用程序的子线程执行,从而减轻了应用程序的主线程的负荷。同时,由于应用程序的主线程和子线程都是在CPU上执行,因此,当CPU具有多个处理核心时,所述主线程和所述子线程可分别基于CPU不同的处理核心进行处理,从而能够充分利用CPU的多个处理核心。It should be noted that, in an actual application, the process of drawing the bitmap corresponding to the object to be rendered and the rasterization process are transferred to the application by switching the main thread of the application to the sub-thread of the application. The child thread executes, which relieves the load on the application's main thread. Meanwhile, since the main thread and the sub-thread of the application are both executed on the CPU, when the CPU has a plurality of processing cores, the main thread and the sub-threads can be processed based on different processing cores of the CPU, respectively, thereby being able to Take advantage of multiple processing cores of the CPU.
步骤S103,回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中。Step S103, the main thread is called back, and the drawn bitmap is applied to the display content of the object to be rendered.
上述步骤S102在所述子线程绘制好所述待渲染对象对应的位图,本步骤中,回调所述主线程,即从所述子线程切换回所述主线程,在所述主线程将绘制好的位图应用到所述待渲染对象的显示内容当中。具体的,如附图3所示的视图层级树,将节点1至节点5对应的位图应用到所述待渲染对象的数据结构当中,类似的,将节点8和节点9对应的位图应用到所述数据结构中,由于节点6和 节点7并未与所述视图层级树中的其他节点进行光栅化,因此,所述待渲染对象的数据结构中保存的节点6和节点7的显示特征并未发生变化,因此,对于节点6和节点7不作处理即可。In the above step S102, the bitmap corresponding to the object to be rendered is drawn in the sub-thread. In this step, the main thread is called back, that is, the sub-thread is switched back to the main thread, and the main thread is drawn. A good bitmap is applied to the display content of the object to be rendered. Specifically, as shown in FIG. 3, the bitmap tree corresponding to the node 1 to the node 5 is applied to the data structure of the object to be rendered, and similarly, the bitmap corresponding to the node 8 and the node 9 is applied. In the data structure, since the node 6 and the node 7 are not rasterized with other nodes in the view hierarchy tree, the display features of the node 6 and the node 7 saved in the data structure of the object to be rendered are No change has occurred, so node 6 and node 7 are not processed.
步骤S104,根据所述待渲染对象的显示内容渲染用户界面。Step S104: Render a user interface according to the display content of the object to be rendered.
本申请提供的所述用户界面渲染的方法基于iOS设备实现,所述iOS设备配置由CPU(中央处理器)、GPU(图形处理器)和显示屏,相应的,上述步骤S101至步骤S103基于所述iOS设备配置的CPU实现,本步骤根据所述待渲染对象的显示内容进行的UI渲染基于所述GPU实现。如附图2所示,在上述步骤S103执行之后,所述CPU将所述待渲染对象的显示内容提交给所述GPU,所述GPU根据提交的所述待渲染对象的显示内容进行UI渲染,并将渲染获得的用户界面传递给所述显示屏显示。The method for the user interface rendering provided by the present application is implemented based on an iOS device configured by a CPU (Central Processing Unit), a GPU (Graphics Processor), and a display screen. Correspondingly, the above steps S101 to S103 are based on the In the CPU implementation of the iOS device configuration, the UI rendering performed according to the display content of the object to be rendered in this step is implemented based on the GPU. As shown in FIG. 2, after the step S103 is performed, the CPU submits the display content of the object to be rendered to the GPU, and the GPU performs UI rendering according to the submitted display content of the object to be rendered. The rendered user interface is passed to the display.
具体在所述GPU根据所述待渲染对象的显示内容进行UI渲染的过程中,如果没有进行光栅化处理,则需针对所述视图层级树中的节点1至节点9分别进行渲染,但在针对所述视图层级树中的节点进行光栅化之后,节点2至节点5被光栅化到节点1上,节点9被光栅化到节点8上,可见,所述视图层级树的层级大大缩减,在此基础上根据所述待渲染对象的显示内容进行UI渲染的耗时更短,从而降低了CPU在进行UI渲染过程中的处理耗时,进一步降低了GPU在进行UI渲染时的耗时。Specifically, in the process of performing UI rendering by the GPU according to the display content of the object to be rendered, if the rasterization process is not performed, respectively, the nodes 1 to 9 in the view hierarchy tree are respectively rendered, but After the nodes in the view hierarchy tree are rasterized, nodes 2 to 5 are rasterized onto node 1, and node 9 is rasterized onto node 8. As can be seen, the hierarchy of the view hierarchy tree is greatly reduced. The UI rendering is shorter according to the display content of the object to be rendered, which reduces the processing time of the CPU during the UI rendering process, and further reduces the time consuming time for the GPU to perform UI rendering.
综上所述,所述用户界面渲染的方法,在进行用户界面渲染过程中,当基于主线程触发了针对所述待渲染对象的用户界面渲染时,从所述主线程切换到子线程,在所述子线程进行位图绘制,并在绘制完后切换回所述主线程,在所述主线程将位图绘制应用到所述待渲染对应的显示内容当中,最终根据所述待渲染对应的显示内容进行用户界面渲染,从而将原本在所述主线程执行的位图绘制操作转移到所述子线程进行,减轻了主线程的负荷,同时降低了主线程在任务繁重时无法及时处理渲染任务造成的用户界面卡顿。In summary, the user interface rendering method, when performing the user interface rendering process, when the main thread is triggered to render the user interface for the object to be rendered, switching from the main thread to the child thread, The sub-thread performs bitmap rendering, and switches back to the main thread after the drawing, and applies the bitmap drawing to the corresponding display content to be rendered in the main thread, and finally according to the corresponding to be rendered. Displaying content for user interface rendering, thereby transferring the bitmap drawing operation originally performed by the main thread to the sub-thread, reducing the load of the main thread, and reducing the main thread cannot process the rendering task in time when the task is heavy The resulting user interface is stuck.
本申请提供的一种用户界面渲染的装置实施例如下:An apparatus implementation for user interface rendering provided by the present application is as follows:
在上述的实施例中,提供了一种用户界面渲染的方法,与之相对应的,本申请还提供了一种用户界面渲染的装置,下面结合附图进行说明。In the above embodiment, a method for rendering a user interface is provided. Correspondingly, the present application further provides a device for rendering a user interface, which will be described below with reference to the accompanying drawings.
参照附图5,其示出了本申请提供的一种用户界面渲染的装置实施例的示意图。Referring to FIG. 5, a schematic diagram of an apparatus embodiment of a user interface rendering provided by the present application is shown.
由于装置实施例基本相似于方法实施例,所以描述得比较简单,相关的部 分请参见上述提供的方法实施例的对应说明即可。下述描述的装置实施例仅仅是示意性的。Since the device embodiment is basically similar to the method embodiment, the description is relatively simple. For related parts, refer to the corresponding description of the method embodiment provided above. The device embodiments described below are merely illustrative.
本申请提供一种用户界面渲染的装置,包括:The application provides a device for rendering a user interface, including:
渲染触发单元501,用于基于主线程触发针对待渲染对象的用户界面渲染;a rendering trigger unit 501, configured to trigger a user interface rendering for the object to be rendered based on the main thread;
位图绘制单元502,用于从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;a bitmap drawing unit 502, configured to switch from the main thread to a sub-thread, by using the sub-thread to draw a bitmap corresponding to the object to be rendered;
位图应用单元503,用于回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;a bitmap application unit 503, configured to call back the main thread, and apply the drawn bitmap to the display content of the object to be rendered;
用户界面渲染单元504,用于根据所述待渲染对象的显示内容渲染用户界面。The user interface rendering unit 504 is configured to render a user interface according to the display content of the object to be rendered.
可选的,所述用户界面渲染的装置,包括:Optionally, the device for rendering the user interface includes:
视图层级树确定单元,用于确定所述待渲染对象的视图层级树;a view level tree determining unit, configured to determine a view level tree of the object to be rendered;
光栅化单元,用于对所述视图层级树中的节点进行光栅化;a rasterizing unit, configured to rasterize nodes in the view hierarchy tree;
其中,所述位图绘制单元502根据所述光栅化单元的光栅化结果进行绘制。The bitmap drawing unit 502 performs rendering according to the rasterization result of the rasterization unit.
可选的,所述用户界面渲染的装置,包括:Optionally, the device for rendering the user interface includes:
节点属性确定单元,用于根据所述待渲染对象的属性信息确定所述视图层级树中节点的节点属性;a node attribute determining unit, configured to determine a node attribute of a node in the view level tree according to the attribute information of the object to be rendered;
其中,所述节点属性包括:光栅化属性和非光栅化属性;The node attributes include: a rasterized attribute and a non-rasterized attribute;
相应的,所述视图层级树中的节点包括:光栅化根节点、光栅化子节点和非光栅化节点。Correspondingly, the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
可选的,所述光栅化根节点设置有状态标识,所述状态标识包括:允许与光栅化子节点进行光栅化的第一状态标识,以及不允许与光栅化子节点进行光栅化的第二状态标识。Optionally, the rasterized root node is configured with a state identifier, where the state identifier includes: a first state identifier that allows rasterization with the rasterized child node, and a second state that does not allow rasterization with the rasterized child node Status identifier.
可选的,所述光栅化单元,包括:Optionally, the rasterizing unit includes:
第一节点遍历子单元,用于采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点运行第一祖先节点查找子单元以及第一祖先节点判断子单元;The first node traverses the subunit, and is configured to traverse the nodes in the view hierarchy tree by using a depth-first rule, each traversing one node, and running the first ancestor node search subunit and the first ancestor node judgment subunit for the traversed node;
其中,所述第一祖先节点查找子单元,用于在所述视图层级树中查找所述节点的祖先节点;The first ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree;
所述第一祖先节点判断子单元,用于判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,运行第一候选节点确定子单元以及第一光栅化属性判断子单元;The first ancestor node determining subunit is configured to determine whether a rasterized root node or a non-rasterized node exists in the found ancestor node, and if present, run the first candidate node determining subunit and the first rasterized attribute determiner unit;
所述第一候选节点确定子单元,用于在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;The first candidate node determining subunit is configured to select, in a rasterized root node or a non-rasterized node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node or non-rasterization The node acts as a candidate node;
所述第一光栅化属性判断子单元,用于判断所述节点的节点属性是否为光栅化属性,若是,运行第一候选节点判断子单元;The first rasterization attribute determining subunit is configured to determine whether a node attribute of the node is a rasterization attribute, and if yes, running a first candidate node to determine a subunit;
所述第一候选节点判断子单元,用于判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识,若是,运行第一节点合并子单元;The first candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if yes, running the first node merging subunit;
所述第一节点合并子单元,用于将所述节点合并到所述候选节点上。The first node merges subunits for merging the nodes onto the candidate nodes.
可选的,若所述第一祖先节点判断子单元输出的判断结果为查找到的祖先节点中不存在光栅化根节点或者非光栅化节点,运行第二光栅化属性判断子单元;Optionally, if the first ancestor node determines that the output of the subunit is a result that the found ancestor node does not have a rasterized root node or a non-rasterized node, running the second rasterization attribute determining subunit;
其中,所述第二光栅化属性判断子单元,用于判断所述节点的节点属性是否为光栅化属性,若是,将所述节点作为光栅化根节点,并将所述节点的状态标识设为所述第一状态标识。The second rasterization attribute determining subunit is configured to determine whether the node attribute of the node is a rasterization attribute, and if so, the node is used as a rasterization root node, and the state identifier of the node is set to The first status identifier.
可选的,若所述第一光栅化属性判断子单元输出的判断结果为所述节点的节点属性不是光栅化属性,运行第一父节点更新子单元和第二候选节点判断子单元;Optionally, if the determination result output by the first rasterization attribute determining subunit is that the node attribute of the node is not a rasterization attribute, running the first parent node update subunit and the second candidate node judgment subunit;
其中,所述第一父节点更新子单元,用于将所述候选节点设为所述节点的父节点;The first parent node update subunit, configured to set the candidate node as a parent node of the node;
所述第二候选节点判断子单元,用于判断所述候选节点是否为光栅化根节点,若是,则将所述候选节点的状态标识标记为所述第二状态标识。The second candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node, and if yes, mark the state identifier of the candidate node as the second state identifier.
可选的,若所述第一候选节点判断子单元输出的判断结果为所述候选节点不是光栅化根节点或者所述候选节点的状态标识不是所述第一状态标识,运行第二父节点更新子单元;Optionally, if the first candidate node determines that the output of the subunit is a result that the candidate node is not a rasterized root node or the state identifier of the candidate node is not the first state identifier, running the second parent node is updated. Subunit
其中,所述第二父节点更新子单元,用于将所述候选节点设为所述节点的父节点。The second parent node updates the subunit, and is configured to set the candidate node as a parent node of the node.
可选的,所述光栅化单元,包括:Optionally, the rasterizing unit includes:
遍历判断子单元,用于判断所述视图层级树中的节点是否遍历完毕,若否,运行所述第一节点遍历子单元。The traversing determination subunit is configured to determine whether the node in the view hierarchy tree is traversed, and if not, running the first node to traverse the subunit.
可选的,所述光栅化单元,包括:Optionally, the rasterizing unit includes:
第二节点遍历子单元,用于采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点运行第二祖先节点查找子单元以及第二祖先节点判断子单元;The second node traverses the sub-units for traversing the nodes in the view hierarchy tree by using depth-first rules, each traversing one node, and running a second ancestor node search sub-unit and a second ancestor node judgment sub-unit for the traversed nodes;
其中,所述第二祖先节点查找子单元,用于在所述视图层级树中查找所述节点的祖先节点;The second ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree;
所述第二祖先节点判断子单元,用于判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,运行第二候选节点确定子单元以及第三光栅化属性判断子单元;The second ancestor node determining subunit is configured to determine whether a rasterized root node or a non-rasterized node exists in the found ancestor node, and if so, running the second candidate node determining subunit and the third rasterization attribute determiner unit;
所述第二候选节点确定子单元,用于在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;The second candidate node determining subunit is configured to select, in the rasterized root node or the non-rasterized node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node or non-rasterization The node acts as a candidate node;
所述第三光栅化属性判断子单元,用于判断所述节点的节点属性是否为光栅化属性,若是,运行第三候选节点判断子单元;The third rasterization attribute determining subunit is configured to determine whether a node attribute of the node is a rasterization attribute, and if so, running a third candidate node to determine a subunit;
所述第三候选节点判断子单元,用于判断所述候选节点是否为光栅化根节点,若是,判断所述候选节点的状态标识是否为第一状态标识,若是,运行第二节点合并子单元;The third candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node, and if yes, determining whether the state identifier of the candidate node is a first state identifier, and if so, running the second node merging subunit ;
所述第二节点合并子单元,用于将所述节点合并到所述候选节点上。The second node merging subunit is configured to merge the node onto the candidate node.
可选的,所述光栅化单元,包括:Optionally, the rasterizing unit includes:
第三节点遍历子单元,用于采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点运行第三祖先节点查找子单元以及第三祖先节点判断子单元;The third node traverses the sub-units for traversing the nodes in the view hierarchy tree by using a depth-first rule, each traversing one node, and running a third ancestor node search sub-unit and a third ancestor node judgment sub-unit for the traversed node;
所述第三祖先节点查找子单元,用于在所述视图层级树中查找所述节点的祖先节点;The third ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree;
所述第三祖先节点判断子单元,用于判断查找到的祖先节点中是否存在光栅化根节点,若存在,运行第三候选节点确定子单元以及第二状态标识判断子单元;The third ancestor node determining subunit is configured to determine whether a rasterized root node exists in the found ancestor node, and if so, running a third candidate node determining subunit and a second state identifier determining subunit;
所述第三候选节点确定子单元,用于在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;The third candidate node determining subunit is configured to select, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node as a candidate node;
所述第二状态标识判断子单元,用于判断所述候选节点的状态标识是否为所述第一状态标识,若是,运行第四光栅化属性判断子单元;The second state identifier determining subunit is configured to determine whether the state identifier of the candidate node is the first state identifier, and if yes, running a fourth rasterization attribute determining subunit;
所述第四光栅化属性判断子单元,用于判断所述节点的节点属性是否为光 栅化属性,若是,运行第三节点合并子单元;The fourth rasterization attribute determining subunit is configured to determine whether the node attribute of the node is a rasterization attribute, and if so, running the third node to merge the subunit;
所述第三节点合并子单元,用于将所述节点合并到所述候选节点上。The third node merging subunit is configured to merge the node onto the candidate node.
可选的,所述光栅化单元,包括:Optionally, the rasterizing unit includes:
第四节点遍历子单元,用于采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点运行第四祖先节点查找子单元以及第四祖先节点判断子单元;The fourth node traverses the sub-units for traversing the nodes in the view hierarchy tree by using a depth-first rule, each traversing one node, and running a fourth ancestor node search sub-unit and a fourth ancestor node judgment sub-unit for the traversed nodes;
所述第四祖先节点查找子单元,用于在所述视图层级树中查找所述节点的祖先节点;The fourth ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree;
所述第四祖先节点判断子单元,用于判断查找到的祖先节点中是否存在光栅化根节点,若存在,运行第四候选节点确定子单元以及第五光栅化属性判断子单元;The fourth ancestor node determining subunit is configured to determine whether a rasterized root node exists in the found ancestor node, and if yes, running a fourth candidate node determining subunit and a fifth rasterizing attribute determining subunit;
所述第四候选节点确定子单元,用于在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;The fourth candidate node determining subunit is configured to select, as a candidate node, a rasterized root node whose stratum is located closest to the stratum of the node in the rasterized root node existing in the ancestor node;
所述第五光栅化属性判断子单元,用于判断所述节点的节点属性是否为光栅化属性,若是,运行第四节点合并子单元;The fifth rasterization attribute determining subunit is configured to determine whether the node attribute of the node is a rasterization attribute, and if so, running the fourth node to merge the subunit;
所述第四节点合并子单元,用于将所述节点合并到所述候选节点上。The fourth node merging subunit is configured to merge the node onto the candidate node.
可选的,所述位图绘制单元502,具体用于根据所述节点和所述候选节点的合并结果,将所述节点对应的节点视图和所述候选节点对应的节点视图绘制在一张位图上。Optionally, the bitmap drawing unit 502 is configured to: in accordance with a combination result of the node and the candidate node, draw a node view corresponding to the node and a node view corresponding to the candidate node in a single bit On the map.
可选的,所述用户界面渲染的装置基于终端设备实现,所述终端设备设置有中央处理器、图形处理器和显示屏;Optionally, the device for rendering the user interface is implemented based on a terminal device, where the terminal device is provided with a central processing unit, a graphics processor, and a display screen;
其中,所述渲染触发单元501、所述位图绘制单元502以及所述位图应用单元503基于所述中央处理器运行;The rendering trigger unit 501, the bitmap rendering unit 502, and the bitmap application unit 503 are executed based on the central processing unit;
所述用户界面渲染单元504基于所述图形处理器运行;The user interface rendering unit 504 operates based on the graphics processor;
所述位图应用单元503输出的所述显示内容通过所述中央处理器提交给所述图形处理器;The display content output by the bitmap application unit 503 is submitted to the graphics processor by the central processing unit;
所述图形处理器在根据所述待渲染对象的显示内容渲染所述用户界面后,将渲染结果传递给所述显示屏显示。After rendering the user interface according to the display content of the object to be rendered, the graphics processor passes the rendering result to the display screen.
本申请提供的一种电子设备实施例如下:An electronic device implementation provided by the present application is as follows:
在上述的实施例中,提供了一种用户界面渲染的方法,此外,本申请还提供了一种用于实现所述用户界面渲染的方法的电子设备,下面结合附图进行说 明。In the above embodiment, a method for rendering a user interface is provided. In addition, the present application further provides an electronic device for implementing the method for rendering the user interface, which will be described below with reference to the accompanying drawings.
参照附图6,其示出了本实施例提供的一种电子设备的示意图。Referring to FIG. 6, a schematic diagram of an electronic device provided by the embodiment is shown.
本申请提供的所述电子设备实施例描述得比较简单,相关的部分请参见上述提供的所述用户界面渲染的方法实施例的对应说明即可。下述描述的实施例仅仅是示意性的。The embodiment of the electronic device provided by the present application is described in a relatively simple manner. For related parts, refer to the corresponding description of the method embodiment of the user interface rendering provided above. The embodiments described below are merely illustrative.
本申请提供一种电子设备,包括:The application provides an electronic device, including:
存储器601、中央处理器602和图形处理器603;a memory 601, a central processing unit 602 and a graphics processor 603;
所述存储器601用于存储计算机可执行指令,所述中央处理器602用于执行如下计算机可执行指令:The memory 601 is configured to store computer executable instructions, and the central processor 602 is configured to execute computer executable instructions as follows:
基于主线程触发针对待渲染对象的用户界面渲染;Triggering user interface rendering for the object to be rendered based on the main thread;
从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;Switching from the main thread to the child thread, and drawing, by the child thread, a bitmap corresponding to the object to be rendered;
回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;Calling back the main thread, and applying the drawn bitmap to the display content of the object to be rendered;
所述图形处理器603用于执行如下计算机可执行指令:根据所述待渲染对象的显示内容渲染用户界面。The graphics processor 603 is configured to execute computer executable instructions to render a user interface according to display content of the object to be rendered.
可选的,所述从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图指令执行前,所述中央处理器602还用于执行如下计算机可执行指令:Optionally, the switching from the main thread to the sub-thread, before the execution of the bitmap instruction corresponding to the object to be rendered by the sub-thread, the central processor 602 is further configured to execute the following computer-executable instruction :
确定所述待渲染对象的视图层级树;Determining a view hierarchy tree of the object to be rendered;
对所述视图层级树中的节点进行光栅化;Rectifying nodes in the view hierarchy tree;
其中,所述待渲染对象对应的位图根据所述视图层级树中节点的光栅化结果进行绘制。The bitmap corresponding to the object to be rendered is drawn according to a rasterization result of nodes in the view hierarchy tree.
可选的,所述中央处理器602还用于执行如下计算机可执行指令:Optionally, the central processing unit 602 is further configured to execute the following computer executable instructions:
根据所述待渲染对象的属性信息确定所述视图层级树中节点的节点属性;Determining, according to the attribute information of the object to be rendered, a node attribute of a node in the view hierarchy tree;
其中,所述节点属性包括:光栅化属性和非光栅化属性;The node attributes include: a rasterized attribute and a non-rasterized attribute;
相应的,所述视图层级树中的节点包括:光栅化根节点、光栅化子节点和非光栅化节点。Correspondingly, the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
可选的,所述光栅化根节点设置有状态标识,所述状态标识包括:允许与光栅化子节点进行光栅化的第一状态标识,以及不允许与光栅化子节点进行光栅化的第二状态标识。Optionally, the rasterized root node is configured with a state identifier, where the state identifier includes: a first state identifier that allows rasterization with the rasterized child node, and a second state that does not allow rasterization with the rasterized child node Status identifier.
可选的,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:Optionally, the rasterizing the nodes in the view hierarchy tree is implemented as follows:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;Determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node, and if so, selecting a level of the rasterized root node or the non-rasterized node existing in the ancestor node and a level of the node The nearest rasterized root node or non-rasterized node is used as the candidate node;
判断所述节点的节点属性是否为光栅化属性,若是,判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识,若是,将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, determining whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if so, merging the nodes Go to the candidate node.
可选的,若所述判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点子步骤的判断结果为否,执行如下操作:Optionally, if the judgment result of the step of determining whether the rasterized root node or the non-rasterized node is present in the ancestor node found is no, perform the following operations:
判断所述节点的节点属性是否为光栅化属性,若是,将所述节点作为光栅化根节点,并将所述节点的状态标识设为所述第一状态标识。Determining whether the node attribute of the node is a rasterization attribute, and if so, using the node as a rasterization root node, and setting a status identifier of the node as the first status identifier.
可选的,若所述判断所述节点的节点属性是否为光栅化属性子步骤的判断结果为否,执行如下操作:Optionally, if the determining whether the node attribute of the node is a rasterization attribute sub-step is negative, perform the following operations:
将所述候选节点设为所述节点的父节点;Setting the candidate node as a parent node of the node;
判断所述候选节点是否为光栅化根节点,若是,则将所述候选节点的状态标识标记为所述第二状态标识。Determining whether the candidate node is a rasterized root node, and if so, marking the status identifier of the candidate node as the second status identifier.
可选的,若所述判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识子步骤的判断结果为否,执行如下操作:Optionally, if the determining whether the candidate node is a rasterized root node and determining whether the status identifier of the candidate node is the first state identifier substep is no, perform the following operations:
将所述候选节点设为所述节点的父节点。The candidate node is set as the parent node of the node.
可选的,所述中央处理器602还用于执行如下计算机可执行指令:Optionally, the central processing unit 602 is further configured to execute the following computer executable instructions:
判断所述视图层级树中的节点是否遍历完毕,若否,执行所述采用深度优先的规则遍历所述视图层级树中的节点子步骤。Determining whether the nodes in the view hierarchy tree are traversed, and if not, performing the depth-first rule to traverse the node sub-steps in the view hierarchy tree.
可选的,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:Optionally, the rasterizing the nodes in the view hierarchy tree is implemented as follows:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;Determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node, and if so, selecting a level of the rasterized root node or the non-rasterized node existing in the ancestor node and a level of the node The nearest rasterized root node or non-rasterized node is used as the candidate node;
判断所述节点的节点属性是否为光栅化属性,若是,判断所述候选节点是否为光栅化根节点,若是,判断所述候选节点的状态标识是否为第一状态标识,若是,将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, determining whether the candidate node is a rasterized root node, and if so, determining whether the state identifier of the candidate node is a first state identifier, and if so, the node Merged onto the candidate node.
可选的,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:Optionally, the rasterizing the nodes in the view hierarchy tree is implemented as follows:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点,若存在,在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;Determining whether there is a rasterized root node in the found ancestor node, and if so, selecting, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the layer where the node is located as a candidate node;
判断所述候选节点的状态标识是否为所述第一状态标识,若是,判断所述节点的节点属性是否为光栅化属性,若是,将所述节点合并到所述候选节点上。Determining whether the state identifier of the candidate node is the first state identifier, and if so, determining whether the node attribute of the node is a rasterization attribute, and if so, merging the node onto the candidate node.
可选的,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:Optionally, the rasterizing the nodes in the view hierarchy tree is implemented as follows:
采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
判断查找到的祖先节点中是否存在光栅化根节点,若存在,在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;Determining whether there is a rasterized root node in the found ancestor node, and if so, selecting, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the layer where the node is located as a candidate node;
判断所述节点的节点属性是否为光栅化属性,若是,将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, merging the node onto the candidate node.
可选的,所述绘制所述待渲染对象对应的位图,采用如下方式实现:Optionally, the mapping of the bitmap corresponding to the object to be rendered is implemented as follows:
根据所述节点和所述候选节点的合并结果,将所述节点对应的节点视图和所述候选节点对应的节点视图绘制在一张位图上。And according to the result of the combination of the node and the candidate node, the node view corresponding to the node and the node view corresponding to the candidate node are drawn on a bitmap.
可选的,所述电子设备设置有显示屏;Optionally, the electronic device is provided with a display screen;
其中,所述回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中指令的执行后,且所述根据所述待渲染对象的显示内容渲染用户界面指令执行前,所述中央处理器602将所述显示内容提交给所述图形处理器603;The calling back the main thread, applying the drawn bitmap to the execution of the instruction in the display content of the object to be rendered, and executing the user interface instruction according to the display content of the object to be rendered The central processing unit 602 submits the display content to the graphics processor 603;
所述图形处理器603在根据所述待渲染对象的显示内容渲染所述用户界面后,将渲染结果传递给所述显示屏显示。The graphics processor 603, after rendering the user interface according to the display content of the object to be rendered, delivers the rendering result to the display screen.
本申请虽然以较佳实施例公开如上,但其并不是用来限定本申请,任何本 领域技术人员在不脱离本申请的精神和范围内,都可以做出可能的变动和修改,因此本申请的保护范围应当以本申请权利要求所界定的范围为准。The present application is disclosed in the above preferred embodiments, but it is not intended to limit the present application, and any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. The scope of protection should be based on the scope defined by the claims of the present application.
在一个典型的配置中,计算设备包括一个或多个处理器、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors, input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。The memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory. Memory is an example of a computer readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括非暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer readable media includes both permanent and non-persistent, removable and non-removable media. Information storage can be implemented by any method or technology. The information can be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media, such as modulated data signals and carrier waves.
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, system, or computer program product. Thus, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment in combination of software and hardware. Moreover, the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.

Claims (20)

  1. 一种用户界面渲染的方法,其特征在于,包括:A method for rendering a user interface, comprising:
    基于主线程触发针对待渲染对象的用户界面渲染;Triggering user interface rendering for the object to be rendered based on the main thread;
    从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;Switching from the main thread to the child thread, and drawing, by the child thread, a bitmap corresponding to the object to be rendered;
    回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;Calling back the main thread, and applying the drawn bitmap to the display content of the object to be rendered;
    根据所述待渲染对象的显示内容渲染用户界面。And rendering a user interface according to the display content of the object to be rendered.
  2. 根据权利要求1所述的用户界面渲染的方法,其特征在于,所述从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图步骤执行前,执行下述步骤:The method for rendering user interface according to claim 1, wherein the step of switching from the main thread to the child thread, and drawing the bitmap corresponding to the object to be rendered by the child thread is performed before the execution is performed Steps:
    确定所述待渲染对象的视图层级树;Determining a view hierarchy tree of the object to be rendered;
    对所述视图层级树中的节点进行光栅化;Rectifying nodes in the view hierarchy tree;
    其中,所述待渲染对象对应的位图根据所述视图层级树中节点的光栅化结果进行绘制。The bitmap corresponding to the object to be rendered is drawn according to a rasterization result of nodes in the view hierarchy tree.
  3. 根据权利要求2所述的用户界面渲染的方法,其特征在于,包括:The method for rendering a user interface according to claim 2, comprising:
    根据所述待渲染对象的属性信息确定所述视图层级树中节点的节点属性;Determining, according to the attribute information of the object to be rendered, a node attribute of a node in the view hierarchy tree;
    其中,所述节点属性包括:光栅化属性和非光栅化属性;The node attributes include: a rasterized attribute and a non-rasterized attribute;
    相应的,所述视图层级树中的节点包括:光栅化根节点、光栅化子节点和非光栅化节点。Correspondingly, the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
  4. 根据权利要求3所述的用户界面渲染的方法,其特征在于,所述光栅化根节点设置有状态标识,所述状态标识包括:The method for rendering a user interface according to claim 3, wherein the rasterized root node is provided with a state identifier, and the state identifier comprises:
    允许与光栅化子节点进行光栅化的第一状态标识,以及不允许与光栅化子节点进行光栅化的第二状态标识。A first state identification that allows rasterization with the rasterized child nodes, and a second state identification that does not allow rasterization with the rasterized child nodes.
  5. 根据权利要求4所述的用户界面渲染的方法,其特征在于,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:The method for rendering a user interface according to claim 4, wherein the rasterizing the nodes in the view hierarchy tree is implemented as follows:
    采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
    在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
    判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;Determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node, and if so, selecting a level of the rasterized root node or the non-rasterized node existing in the ancestor node and a level of the node The nearest rasterized root node or non-rasterized node is used as the candidate node;
    判断所述节点的节点属性是否为光栅化属性,若是,判断所述候选节点是 否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识,若是,将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, determining whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if so, merging the nodes Go to the candidate node.
  6. 根据权利要求5所述的用户界面渲染的方法,其特征在于,若所述判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点子步骤的判断结果为否,执行如下操作:The method for rendering a user interface according to claim 5, wherein if the determination result of the step of determining whether the rasterized root node or the non-rasterized node is present in the found ancestor node is no, the following operations are performed:
    判断所述节点的节点属性是否为光栅化属性,若是,将所述节点作为光栅化根节点,并将所述节点的状态标识设为所述第一状态标识。Determining whether the node attribute of the node is a rasterization attribute, and if so, using the node as a rasterization root node, and setting a status identifier of the node as the first status identifier.
  7. 根据权利要求5所述的用户界面渲染的方法,其特征在于,若所述判断所述节点的节点属性是否为光栅化属性子步骤的判断结果为否,执行如下操作:The method for rendering a user interface according to claim 5, wherein if the determining whether the node attribute of the node is a rasterization attribute sub-step is negative, performing the following operations:
    将所述候选节点设为所述节点的父节点;Setting the candidate node as a parent node of the node;
    判断所述候选节点是否为光栅化根节点,若是,则将所述候选节点的状态标识标记为所述第二状态标识。Determining whether the candidate node is a rasterized root node, and if so, marking the status identifier of the candidate node as the second status identifier.
  8. 根据权利要求5所述的用户界面渲染的方法,其特征在于,若所述判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识子步骤的判断结果为否,执行如下操作:The method for rendering user interface according to claim 5, wherein if the determining whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier substep If the judgment result is no, perform the following operations:
    将所述候选节点设为所述节点的父节点。The candidate node is set as the parent node of the node.
  9. 根据权利要求5所述的用户界面渲染的方法,其特征在于,包括:The method for rendering a user interface according to claim 5, comprising:
    判断所述视图层级树中的节点是否遍历完毕,若否,执行所述采用深度优先的规则遍历所述视图层级树中的节点子步骤。Determining whether the nodes in the view hierarchy tree are traversed, and if not, performing the depth-first rule to traverse the node sub-steps in the view hierarchy tree.
  10. 根据权利要求4所述的用户界面渲染的方法,其特征在于,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:The method for rendering a user interface according to claim 4, wherein the rasterizing the nodes in the view hierarchy tree is implemented as follows:
    采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
    在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
    判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;Determining whether there is a rasterized root node or a non-rasterized node in the found ancestor node, and if so, selecting a level of the rasterized root node or the non-rasterized node existing in the ancestor node and a level of the node The nearest rasterized root node or non-rasterized node is used as the candidate node;
    判断所述节点的节点属性是否为光栅化属性,若是,判断所述候选节点是否为光栅化根节点,若是,判断所述候选节点的状态标识是否为第一状态标识,若是,将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, determining whether the candidate node is a rasterized root node, and if so, determining whether the state identifier of the candidate node is a first state identifier, and if so, the node Merged onto the candidate node.
  11. 根据权利要求4所述的用户界面渲染的方法,其特征在于,所述对所 述视图层级树中的节点进行光栅化,采用如下方式实现:The method for rendering a user interface according to claim 4, wherein the rasterizing the nodes in the view hierarchy tree is implemented as follows:
    采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
    在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
    判断查找到的祖先节点中是否存在光栅化根节点,若存在,在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;Determining whether there is a rasterized root node in the found ancestor node, and if so, selecting, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the layer where the node is located as a candidate node;
    判断所述候选节点的状态标识是否为所述第一状态标识,若是,判断所述节点的节点属性是否为光栅化属性,若是,将所述节点合并到所述候选节点上。Determining whether the state identifier of the candidate node is the first state identifier, and if so, determining whether the node attribute of the node is a rasterization attribute, and if so, merging the node onto the candidate node.
  12. 根据权利要求3所述的用户界面渲染的方法,其特征在于,所述对所述视图层级树中的节点进行光栅化,采用如下方式实现:The method for rendering a user interface according to claim 3, wherein the rasterizing the nodes in the view hierarchy tree is implemented as follows:
    采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点执行如下操作:The depth-first rule is used to traverse the nodes in the view hierarchy tree, each time traversing one node, and performing the following operations on the traversed nodes:
    在所述视图层级树中查找所述节点的祖先节点;Finding an ancestor node of the node in the view hierarchy tree;
    判断查找到的祖先节点中是否存在光栅化根节点,若存在,在所述祖先节点中存在的光栅化根节点中选择其所在层级与所述节点所在层级最近的光栅化根节点作为候选节点;Determining whether there is a rasterized root node in the found ancestor node, and if so, selecting, in the rasterized root node existing in the ancestor node, a rasterized root node whose level is closest to the layer where the node is located as a candidate node;
    判断所述节点的节点属性是否为光栅化属性,若是,将所述节点合并到所述候选节点上。Determining whether the node attribute of the node is a rasterization attribute, and if so, merging the node onto the candidate node.
  13. 根据权利要求5至12任意一项所述的用户界面渲染的方法,其特征在于,所述绘制所述待渲染对象对应的位图,采用如下方式实现:The method for rendering a user interface according to any one of claims 5 to 12, wherein the drawing a bitmap corresponding to the object to be rendered is implemented as follows:
    根据所述节点和所述候选节点的合并结果,将所述节点对应的节点视图和所述候选节点对应的节点视图绘制在一张位图上。And according to the result of the combination of the node and the candidate node, the node view corresponding to the node and the node view corresponding to the candidate node are drawn on a bitmap.
  14. 根据权利要求1至12任意一项所述的用户界面渲染的方法,其特征在于,所述方法基于终端设备实现,所述终端设备设置有中央处理器、图形处理器和显示屏;The method for rendering user interface according to any one of claims 1 to 12, wherein the method is implemented based on a terminal device, where the terminal device is provided with a central processing unit, a graphics processor and a display screen;
    其中,所述基于主线程触发针对待渲染对象的用户界面渲染步骤,所述从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图步骤,以及所述回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中步骤,基于所述中央处理器实现;The step of triggering a user interface for the object to be rendered based on the main thread, the step of switching from the main thread to the child thread, drawing a bitmap step corresponding to the object to be rendered by the child thread, and the step Calling back the main thread, applying the drawn bitmap to the display content of the object to be rendered, based on the central processor;
    所述根据所述待渲染对象的显示内容渲染用户界面步骤,基于所述图形处 理器实现;The step of rendering a user interface according to the display content of the object to be rendered is implemented based on the graphics processor;
    所述回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中步骤执行后,且所述根据所述待渲染对象的显示内容渲染用户界面步骤执行前,所述中央处理器将所述显示内容提交给所述图形处理器;After the step of executing the step of executing the step of performing the rendering of the bitmap to the display content of the object to be rendered, and the step of performing the rendering of the user interface according to the display content of the object to be rendered, The central processor submits the display content to the graphics processor;
    所述图形处理器在根据所述待渲染对象的显示内容渲染所述用户界面后,将渲染结果传递给所述显示屏显示。After rendering the user interface according to the display content of the object to be rendered, the graphics processor passes the rendering result to the display screen.
  15. 一种用户界面渲染的装置,其特征在于,包括:A device for rendering a user interface, comprising:
    渲染触发单元,用于基于主线程触发针对待渲染对象的用户界面渲染;a rendering trigger unit for triggering a user interface rendering for the object to be rendered based on the main thread;
    位图绘制单元,用于从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;a bitmap drawing unit, configured to switch from the main thread to a child thread, by using the child thread to draw a bitmap corresponding to the object to be rendered;
    位图应用单元,用于回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;a bitmap application unit, configured to call back the main thread, and apply the drawn bitmap to the display content of the object to be rendered;
    用户界面渲染单元,用于根据所述待渲染对象的显示内容渲染用户界面。And a user interface rendering unit, configured to render the user interface according to the display content of the object to be rendered.
  16. 根据权利要求15所述的用户界面渲染的装置,其特征在于,包括:The apparatus for rendering a user interface according to claim 15, comprising:
    视图层级树确定单元,用于确定所述待渲染对象的视图层级树;a view level tree determining unit, configured to determine a view level tree of the object to be rendered;
    光栅化单元,用于对所述视图层级树中的节点进行光栅化;a rasterizing unit, configured to rasterize nodes in the view hierarchy tree;
    其中,所述位图绘制单元根据所述光栅化单元的光栅化结果进行绘制。The bitmap drawing unit performs rendering according to the rasterization result of the rasterization unit.
  17. 根据权利要求16所述的用户界面渲染的装置,其特征在于,包括:The apparatus for rendering a user interface according to claim 16, comprising:
    节点属性确定单元,用于根据所述待渲染对象的属性信息确定所述视图层级树中节点的节点属性;a node attribute determining unit, configured to determine a node attribute of a node in the view level tree according to the attribute information of the object to be rendered;
    其中,所述节点属性包括:光栅化属性和非光栅化属性;The node attributes include: a rasterized attribute and a non-rasterized attribute;
    相应的,所述视图层级树中的节点包括:光栅化根节点、光栅化子节点和非光栅化节点。Correspondingly, the nodes in the view hierarchy tree include: a rasterized root node, a rasterized child node, and a non-rasterized node.
  18. 根据权利要求17所述的用户界面渲染的装置,其特征在于,所述光栅化根节点设置有状态标识,所述状态标识包括:The apparatus for rendering user interface according to claim 17, wherein the rasterized root node is provided with a status identifier, and the status identifier comprises:
    允许与光栅化子节点进行光栅化的第一状态标识,以及不允许与光栅化子节点进行光栅化的第二状态标识。A first state identification that allows rasterization with the rasterized child nodes, and a second state identification that does not allow rasterization with the rasterized child nodes.
  19. 根据权利要求18所述的用户界面渲染的装置,其特征在于,所述光栅化单元,包括:The apparatus for rendering a user interface according to claim 18, wherein the rasterizing unit comprises:
    第一节点遍历子单元,用于采用深度优先的规则遍历所述视图层级树中的节点,每遍历一个节点,针对遍历的节点运行第一祖先节点查找子单元以及第 一祖先节点判断子单元;The first node traverses the subunits for traversing the nodes in the view hierarchy tree by using depth-first rules, each traversing one node, and running the first ancestor node lookup subunit and the first ancestor node judgment subunit for the traversed node;
    其中,所述第一祖先节点查找子单元,用于在所述视图层级树中查找所述节点的祖先节点;The first ancestor node search subunit is configured to search for an ancestor node of the node in the view hierarchy tree;
    所述第一祖先节点判断子单元,用于判断查找到的祖先节点中是否存在光栅化根节点或者非光栅化节点,若存在,运行第一候选节点确定子单元以及第一光栅化属性判断子单元;The first ancestor node determining subunit is configured to determine whether a rasterized root node or a non-rasterized node exists in the found ancestor node, and if present, run the first candidate node determining subunit and the first rasterized attribute determiner unit;
    所述第一候选节点确定子单元,用于在所述祖先节点中存在的光栅化根节点或者非光栅化节点中选择其所在层级与所述节点所在层级最近的光栅化根节点或者非光栅化节点作为候选节点;The first candidate node determining subunit is configured to select, in a rasterized root node or a non-rasterized node existing in the ancestor node, a rasterized root node whose level is closest to the level of the node or non-rasterization The node acts as a candidate node;
    所述第一光栅化属性判断子单元,用于判断所述节点的节点属性是否为光栅化属性,若是,运行第一候选节点判断子单元;The first rasterization attribute determining subunit is configured to determine whether a node attribute of the node is a rasterization attribute, and if yes, running a first candidate node to determine a subunit;
    所述第一候选节点判断子单元,用于判断所述候选节点是否为光栅化根节点且所述候选节点的状态标识是否为所述第一状态标识,若是,运行第一节点合并子单元;The first candidate node determining subunit is configured to determine whether the candidate node is a rasterized root node and whether the state identifier of the candidate node is the first state identifier, and if yes, running the first node merging subunit;
    所述第一节点合并子单元,用于将所述节点合并到所述候选节点上。The first node merges subunits for merging the nodes onto the candidate nodes.
  20. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    存储器、中央处理器和图形处理器;Memory, central processing unit and graphics processor;
    所述存储器用于存储计算机可执行指令,所述中央处理器用于执行如下计算机可执行指令:The memory is for storing computer executable instructions, and the central processor is configured to execute computer executable instructions as follows:
    基于主线程触发针对待渲染对象的用户界面渲染;Triggering user interface rendering for the object to be rendered based on the main thread;
    从所述主线程切换至子线程,通过所述子线程绘制所述待渲染对象对应的位图;Switching from the main thread to the child thread, and drawing, by the child thread, a bitmap corresponding to the object to be rendered;
    回调所述主线程,将绘制好的位图应用到所述待渲染对象的显示内容当中;Calling back the main thread, and applying the drawn bitmap to the display content of the object to be rendered;
    所述图形处理器用于执行如下计算机可执行指令:根据所述待渲染对象的显示内容渲染用户界面。The graphics processor is configured to execute computer executable instructions to render a user interface according to display content of the object to be rendered.
PCT/CN2018/103020 2017-08-29 2018-08-29 Method and apparatus for rendering user interface WO2019042329A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710755049.1 2017-08-29
CN201710755049.1A CN107729094B (en) 2017-08-29 2017-08-29 User interface rendering method and device

Publications (1)

Publication Number Publication Date
WO2019042329A1 true WO2019042329A1 (en) 2019-03-07

Family

ID=61204831

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/103020 WO2019042329A1 (en) 2017-08-29 2018-08-29 Method and apparatus for rendering user interface

Country Status (2)

Country Link
CN (1) CN107729094B (en)
WO (1) WO2019042329A1 (en)

Families Citing this family (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107729094B (en) * 2017-08-29 2020-12-29 口碑(上海)信息技术有限公司 User interface rendering method and device
CN108595236A (en) * 2018-03-27 2018-09-28 五八有限公司 A kind of method and device for preventing sub-line journey from carrying out operating user interface
CN108733445A (en) * 2018-05-17 2018-11-02 北京五八信息技术有限公司 A kind of view management method, device, equipment and computer readable storage medium
CN109669752A (en) * 2018-12-19 2019-04-23 北京达佳互联信息技术有限公司 A kind of interface method for drafting, device and mobile terminal
CN109739505B (en) 2019-01-08 2019-11-29 网易(杭州)网络有限公司 A kind for the treatment of method and apparatus of user interface
CN109788334A (en) * 2019-01-31 2019-05-21 北京字节跳动网络技术有限公司 Barrage processing method, device, electronic equipment and computer readable storage medium
CN109801210A (en) * 2019-01-31 2019-05-24 北京字节跳动网络技术有限公司 Image processing method, device, electronic equipment and computer readable storage medium
WO2020156035A1 (en) * 2019-01-31 2020-08-06 北京字节跳动网络技术有限公司 View processing method and apparatus, and electronic device and computer-readable storage medium, and image processing method and apparatus, and electronic device and computer-readable storage medium
CN109935312A (en) * 2019-02-28 2019-06-25 深圳市理邦精密仪器股份有限公司 Progress control method, device, patient monitor and the medium of patient monitor
CN110096277B (en) * 2019-03-19 2020-06-12 北京三快在线科技有限公司 Dynamic page display method and device, electronic equipment and storage medium
CN110109667A (en) * 2019-04-30 2019-08-09 广东趣炫网络股份有限公司 A kind of interface UI draw method of calibration, device, terminal and computer storage medium
CN110502294B (en) * 2019-07-20 2021-08-20 华为技术有限公司 Data processing method and device and electronic equipment
CN110597512B (en) * 2019-08-23 2022-04-08 荣耀终端有限公司 Method for displaying user interface and electronic equipment
CN110930496B (en) * 2019-11-19 2021-01-26 北京达佳互联信息技术有限公司 View drawing method and device, electronic equipment and storage medium
CN111080766B (en) * 2019-12-30 2023-09-01 中科星图股份有限公司 GPU (graphics processing unit) acceleration mass target efficient rendering method based on WebGL
CN111459591B (en) * 2020-03-31 2023-03-28 杭州海康威视数字技术股份有限公司 To-be-rendered object processing method and device and terminal
CN111506372B (en) * 2020-04-07 2023-09-26 口碑(上海)信息技术有限公司 Object visualization processing method and device
CN112035768A (en) * 2020-08-27 2020-12-04 深圳市欢太科技有限公司 Page rendering method and device for fast application, storage medium and electronic equipment
CN112581559A (en) * 2020-12-01 2021-03-30 贝壳技术有限公司 Chart generation method and device in application and storage medium
CN112925601B (en) * 2021-03-23 2022-07-19 厦门亿联网络技术股份有限公司 Screen display method, device, equipment and storage medium
CN113326115A (en) * 2021-06-21 2021-08-31 上海华客信息科技有限公司 Rendering method and system of multi-chart page, electronic device and storage medium
CN113254492B (en) * 2021-07-07 2021-11-23 北京优锘科技有限公司 Method, device and equipment for inquiring background synchronous management level visual object
CN115994007A (en) * 2021-10-18 2023-04-21 华为技术有限公司 Animation effect display method and electronic equipment
CN116821040B (en) * 2023-08-30 2023-11-21 西安芯云半导体技术有限公司 Display acceleration method, device and medium based on GPU direct memory access

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140250393A1 (en) * 2013-03-04 2014-09-04 Scott Goodson Techniques For Asynchronous Rendering
CN105549820A (en) * 2015-12-11 2016-05-04 魅族科技(中国)有限公司 Graphic user interface display method and terminal
CN106354512A (en) * 2016-09-08 2017-01-25 广州华多网络科技有限公司 User interface rendering method and device thereof
CN107729094A (en) * 2017-08-29 2018-02-23 口碑(上海)信息技术有限公司 The method and device that a kind of user interface renders

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110193871A1 (en) * 2010-02-07 2011-08-11 Microsoft Corporation Rendering multi-layered image
CN104424661B (en) * 2013-08-23 2018-01-23 联想(北京)有限公司 Three dimensional object display methods and device
GB2524287B (en) * 2014-03-19 2020-07-01 Advanced Risc Mach Ltd Graphics processing systems
CN105279253B (en) * 2015-10-13 2018-12-14 上海联彤网络通讯技术有限公司 Promote the system and method for webpage painting canvas rendering speed
EP3214599B1 (en) * 2015-10-21 2018-12-19 MediaTek Inc. A graphics accelerator with direct memoryless interface to the display
CN106340055A (en) * 2016-08-19 2017-01-18 江苏电力信息技术有限公司 Multithreading-based OpenGL quick drawing method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140250393A1 (en) * 2013-03-04 2014-09-04 Scott Goodson Techniques For Asynchronous Rendering
CN105549820A (en) * 2015-12-11 2016-05-04 魅族科技(中国)有限公司 Graphic user interface display method and terminal
CN106354512A (en) * 2016-09-08 2017-01-25 广州华多网络科技有限公司 User interface rendering method and device thereof
CN107729094A (en) * 2017-08-29 2018-02-23 口碑(上海)信息技术有限公司 The method and device that a kind of user interface renders

Also Published As

Publication number Publication date
CN107729094B (en) 2020-12-29
CN107729094A (en) 2018-02-23

Similar Documents

Publication Publication Date Title
WO2019042329A1 (en) Method and apparatus for rendering user interface
JP6185843B2 (en) Adjust animation across multiple applications or processes
TWI697790B (en) Method and equipment for reuse of mixed model list items
CN110096277A (en) A kind of dynamic page methods of exhibiting, device, electronic equipment and storage medium
US9547466B2 (en) Systems and methods for using screen sampling to detect display changes
US20150243257A1 (en) Cross-Platform Rendering Engine
US11467717B2 (en) Optimizing window resize actions for remoted applications
WO2016034089A1 (en) Image rendering method and apparatus, mobile terminal and machine-readable storage medium
WO2016095728A1 (en) Multi-window display method and device
US20150331836A9 (en) Graceful degradation of level-of-detail in document rendering
US9766860B2 (en) Dynamic source code formatting
WO2016206559A1 (en) Method and device for full size adaptation of object to be displayed
CN107179920B (en) Network engine starting method and device
US10282887B2 (en) Information processing apparatus, moving image reproduction method, and computer readable medium for generating display object information using difference information between image frames
WO2016015527A1 (en) Webpage update method and apparatus based on synthetic rendering acceleration
US20170315982A1 (en) Method, device and mobile terminal for webpage text parsing
CN111596919B (en) Display method and device of graphic drawing result, computer equipment and storage medium
US20220121307A1 (en) Method and device of drawing handwriting track, electronic apparatus, medium, and program product
CN107621951B (en) View level optimization method and device
CN106488298B (en) Method and device for drawing image in UI (user interface) and television
US20180275833A1 (en) System and method for managing and displaying graphical elements
CN109284101B (en) Method and device for changing association of object attributes
US9633408B2 (en) Coalescing graphics operations
WO2017215516A1 (en) Method and apparatus for determining decoding task
US10559105B2 (en) Implementing interactive hierarachical chart legend data display

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18850814

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 27.07.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18850814

Country of ref document: EP

Kind code of ref document: A1