Rendering method and related equipment

By grouping and multi-threading the drawing tasks of the application interface, the problem of low efficiency of electronic devices when rendering tasks are heavy is solved, and efficient rendering performance and correct rendering results are achieved.

CN118625979APending Publication Date: 2024-09-10HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310267611.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-08
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

In the existing technology, when electronic devices have heavy rendering tasks, especially when the screen size increases and there are many interface elements, the processing efficiency of the serial process is low, resulting in unsatisfactory rendering efficiency.

Method used

By determining the grouping results of frames to be displayed, the drawing tasks of the application interface are divided into drawing task groups, and multi-threading is used to process these task groups to improve rendering efficiency and ensure the correctness and efficiency of the rendering results. Specific methods include splitting the rendering tree of the user interface, generating non-overlapping spatial trees, and processing drawing task groups in parallel through multi-threads to improve rendering performance.

Benefits of technology

It effectively improves the rendering efficiency of frames to be displayed, ensuring the accuracy of the rendering results and processing efficiency of the user interface, especially when the rendering task is heavy, it can maximize the use of multi-core processor capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118625979A
    Figure CN118625979A
Patent Text Reader

Abstract

The embodiment of the invention provides a rendering method and related equipment, and relates to the field of electronic equipment. In the method, a grouping result of a to-be-displayed frame is determined firstly, and the grouping result can enable the drawing duration of the to-be-displayed frame to be smaller than or equal to the sum of the drawing durations of at least one application interface, namely the drawing duration required by the to-be-displayed frame when grouping is not performed. The method comprises the steps of obtaining a grouping result of a to-be-displayed frame, dividing drawing tasks of the to-be-displayed frame according to the grouping result to obtain at least one drawing task group, processing the drawing tasks of the at least one drawing task group by at least one drawing thread to obtain at least one drawing result, and synthesizing the at least one drawing result to obtain a total drawing result of the to-be-displayed frame. And rendering the to-be-displayed frame. Therefore, by using the rendering method of the scheme, the grouping result of the to-be-displayed frame is determined in advance so as to realize optimal rendering of the to-be-displayed frame, and the rendering efficiency of the to-be-displayed frame can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of electronic devices, and in particular to a rendering method and related devices. Background Art

[0002] Electronic devices can provide a user interface (UI) for interacting with users. The UI includes interface elements such as icons, windows, and controls, where controls can include visual interface elements such as pictures, buttons, menus, tabs, text boxes, dialog boxes, status bars, and navigation bars.

[0003] The rendering task of the user interface is generally processed in a serial process. When the rendering task becomes more and more arduous, for example, as the terminal screen size increases, more and more interface elements can be presented on the screen, and the rendering content increases, the processing efficiency of the serial process is low. Therefore, how to improve the rendering efficiency is imminent. Summary of the invention

[0004] The present application provides a rendering method and related devices, which can improve the rendering efficiency of picture frames to be displayed.

[0005] In a first aspect, a rendering method is provided.

[0006] The method comprises the following steps: determining the grouping result of the frames to be displayed. The frames to be displayed are used to display at least one application interface. The grouping result is used to group the drawing tasks of the at least one application interface into at least one drawing task group, so that the drawing time of the frame to be displayed is less than or equal to the sum of the drawing time of the at least one application interface. The drawing tasks of the at least one application interface are divided into at least one drawing task group according to the grouping result. At least one drawing thread is used to process the drawing tasks of the at least one drawing task group to obtain at least one drawing result, and the at least one drawing result is used to synthesize and obtain the total drawing result of the frame to be displayed.

[0007] In this solution, the grouping result of the frames to be displayed is first determined, and the grouping result can make the drawing time of the frames to be displayed less than or equal to the sum of the drawing time of at least one application interface, that is, the drawing time required for the frames to be displayed when no grouping is performed. Then, the drawing tasks of the frames to be displayed are divided according to the grouping result to obtain at least one drawing task group. Finally, at least one drawing thread processes the drawing tasks of the at least one drawing task group to obtain at least one drawing result. The at least one drawing result is used to synthesize the total drawing result of the frames to be displayed to render the frames to be displayed. It can be seen that by using the rendering method of this solution, the grouping results of the frames to be displayed are determined in advance to achieve the optimal rendering of the frames to be displayed, which can effectively improve the rendering efficiency of the frames to be displayed.

[0008] In combination with a possible implementation of the first aspect, the rendering method further includes: sending at least one drawing result.

[0009] It can be seen that in this case, at least one drawing result corresponding to at least one drawing task group is sent to other devices or modules, so that other devices or modules can synthesize the total drawing result of the frame to be displayed, and finally complete the rendering of the frame to be displayed.

[0010] In a possible implementation of the first aspect, the rendering method further includes: splitting the rendering tree corresponding to the user interface to obtain at least two spatial trees. The state operation of the drawing nodes in each spatial tree remains unchanged before and after the splitting, and the state operation is an operation of modifying the properties of the canvas.

[0011] The at least two space trees are used to render a user interface, and the user interface is at least one of the at least one application interface.

[0012] It can be seen that in the present application, the rendering tree corresponding to the user interface is split into at least two spatial trees, and the state operation of the drawing nodes in each spatial tree before and after the split is guaranteed to remain unchanged. In this way, when the above-mentioned user interface is rendered using at least two spatial trees, correct rendering can be achieved, ensuring the correctness of the rendering result of the user interface.

[0013] In a possible implementation of the first aspect, the rendering areas corresponding to the at least two space trees do not overlap, wherein the rendering areas do not overlap at all, so that the correctness of the rendering result of the user interface can be further ensured.

[0014] In combination with a possible implementation manner of the first aspect, the rendering tree corresponding to the user interface is split to obtain at least two space trees, including:

[0015] Determine the circumscribed graph of the rendering area corresponding to each rendering node in the rendering tree. Divide the circumscribed graph corresponding to each rendering node in the rendering tree into at least two sets. The difference between the number of circumscribed graphs in any two of the at least two sets is less than a first threshold, and / or the difference between the sum of the areas of the circumscribed graphs in any two of the at least two sets is less than a second threshold. Split the rendering tree according to the at least two sets to obtain at least two spatial trees.

[0016] The space tree corresponding to the set includes the drawing nodes corresponding to the external graphics in the set, and the state operation nodes passed when tracing back from the drawing nodes to the root node of the rendering tree.

[0017] An external graphic refers to a regular graphic and / or a graphic whose area can be calculated, such as a rectangle, circle, square, trapezoid, etc. Since the shapes of the rendering areas corresponding to the drawing nodes are different, it is impossible to accurately divide the drawing nodes. Therefore, the drawing nodes can be accurately divided using the external graphics corresponding to the drawing nodes. In addition, when dividing the nodes in the rendering tree, the drawing nodes are divided first, and then the drawing nodes are traced back to the root node of the rendering tree. The state operation nodes passed during the tracing process are classified into the same set as the above-mentioned drawing nodes. In this way, it can be ensured that the state operation of the drawing nodes before and after the division remains unchanged, ensuring that the spatial tree obtained after the split can be rendered correctly.

[0018] In a possible implementation manner of the first aspect, the rendering areas corresponding to the at least two sets do not overlap, so that the correctness of the rendering result of the user interface can be further ensured.

[0019] In a possible implementation of the first aspect, the external graphic of the rendering area corresponding to the drawing node is a bounding box of the rendering area corresponding to the drawing node. There is no need to re-establish the external graphic, and the existing bounding box of the drawing node is directly used as the external graphic, which saves processing flow and improves rendering efficiency.

[0020] In a possible implementation manner of the first aspect, at the same time, one core of a central processing unit (CPU) in the electronic device executes one drawing thread. One core is responsible for one drawing thread, so that the rendering efficiency can be guaranteed to be the highest.

[0021] In combination with a possible implementation of the first aspect, the grouping result is a grouping scheme of at least one application interface whose first value satisfies a preset condition, the first value of the grouping scheme is the sum of the drawing time and the synthesis time of the longest drawing task group corresponding to the grouping scheme, and the synthesis time is the product of the number of drawing task groups in the grouping scheme and the synthesis overhead.

[0022] It can be seen that in the present application, by determining a grouping scheme of at least one application interface, when the first value of the grouping scheme meets the preset condition, the grouping scheme is determined to be the above-mentioned grouping result.

[0023] In a possible implementation of the first aspect, when the number of drawing task groups in the grouping scheme is two, the grouping scheme of the at least one application interface includes a first grouping scheme, wherein the first grouping scheme is to divide the application interface sequence into two parts of equal drawing time, and the application interface sequence is a sequence obtained by arranging the at least one application interface in a preset order. It can be seen that the bisection scheme can be used as a possible grouping scheme for the at least one application interface.

[0024] Optionally, the grouping scheme of the at least one application interface further includes a second grouping scheme and / or a third grouping scheme, wherein the second grouping scheme is to move the bisection point to the starting point of the drawing task of the first application interface when the bisection point is within the drawing task range of the first application interface. The bisection point is a position corresponding to dividing the application interface sequence into two parts of equal drawing time, and the first application interface is one of the at least one application interface.

[0025] The third grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the end point of the drawing task of the first application interface.

[0026] It can be seen that it is also possible to obtain a possible grouping scheme for at least one of the above-mentioned application interfaces by moving the bisection point to the starting point and / or end point of the drawing task of the application interface, thereby avoiding the segmentation overhead generated when segmenting the application interface and reducing the drawing time of the drawing task group.

[0027] In combination with a possible implementation of the first aspect, when the number of drawing task groups in the grouping scheme is M, M is greater than or equal to three, and the grouping scheme of the above-mentioned at least one application interface includes a fourth grouping scheme, and the fourth grouping scheme is to divide the application interface sequence into M parts with equal drawing time.

[0028] Optionally, the grouping scheme of at least one application interface further includes a fifth grouping scheme, wherein when the first M sub-point is within the drawing task range of the first application interface, the positions of M-2 of the M-1 M sub-points of the application interface sequence are fixed, and the first M sub-point is moved to the starting point of the drawing task of the first application interface. The M-1 M sub-points are positions corresponding to dividing the application interface sequence into M parts of equal drawing duration, and the first M sub-point is any one of the M-1 M sub-points.

[0029] Optionally, the grouping scheme of the above-mentioned at least one application interface also includes a sixth grouping scheme, and the above-mentioned sixth grouping scheme is that when the first M sub-points are located within the drawing task range of the first application interface, M-2 of the M-1 M sub-points of the above-mentioned application interface sequence are fixed, and the above-mentioned first M sub-points are moved to the end point of the drawing task of the first application interface.

[0030] It can be seen that when the number of drawing task groups in the grouping scheme is M, a method similar to that when the number of drawing task groups in the grouping scheme is two is adopted, and the M-equal division scheme is used as a possible grouping scheme for the at least one application interface. When the first M-divided point is within the drawing task range of the first application interface, by fixing the positions of M-2 of the M-1 M-divided points in the application interface sequence, and moving the first M-divided point to the starting point and / or end point of the drawing task of the first application interface, a possible grouping scheme for the at least one application interface can be obtained.

[0031] In a possible implementation manner of the first aspect, the drawing duration of the drawing task group is at least one of the following:

[0032] When the drawing task group includes the drawing task of a complete application interface, "include" here means only including, and the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group.

[0033] When the drawing task group includes the drawing task of an incomplete application interface, "include" here means only including, the drawing duration of the drawing task group is the first drawing duration, the first drawing duration is the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the sum of the split durations, and the split duration is the product of the number of incomplete application interfaces and the splitting overhead.

[0034] When the drawing task group includes drawing tasks of a complete application interface and drawing tasks of an incomplete application interface, "include" here means only including, the drawing time of the drawing task group is the second drawing time, the second drawing time is the sum of the first drawing time and the third drawing time, and the third drawing time is the sum of the drawing times of the complete application interface included in the drawing task group.

[0035] In a possible implementation manner of the first aspect, the drawing time of the complete application interface is any one of the following:

[0036] The weighted average drawing time of the application interface, where the weighted average drawing time is a weighted calculation value of the fourth drawing time, the fifth drawing time, and their respective weights, the fourth drawing time is the actually measured drawing time of the application interface in the second frame before the frame to be displayed, and the fifth drawing time is the actually measured drawing time of the application interface in the frame before the frame to be displayed.

[0037] The total number of rendering instructions of the application interface, where the total number of rendering instructions is a weighted calculation value of the number of different types of rendering instructions and their corresponding weights.

[0038] In the present application, the weighted average drawing time of the application interface or the total number of rendering instructions is used as the drawing time of the application interface, so as to accurately estimate the drawing load size of the application interface.

[0039] In a second aspect, the present application also provides a rendering method, the method comprising the following steps:

[0040] The rendering tree corresponding to the user interface is split to obtain at least two spatial trees. The state operation of the drawing nodes in each spatial tree remains unchanged before and after the split, and the state operation is an operation of modifying the properties of the canvas. The at least two spatial trees are used to render the user interface.

[0041] In this application, the user interface is at least one application interface presented to the user on the screen. The rendering tree corresponding to the user interface is split into at least two spatial trees, and the state operation of the drawing nodes in each spatial tree before and after the split is guaranteed to remain unchanged. In this way, when the above user interface is rendered using at least two spatial trees, the correctness of the rendering result of the user interface can be ensured.

[0042] In a possible implementation of the second aspect, the rendering areas corresponding to the at least two space trees do not overlap, wherein the rendering areas do not overlap at all, so that the correctness of the rendering result of the user interface can be further ensured.

[0043] In combination with a possible implementation manner of the second aspect, the rendering tree corresponding to the user interface is split to obtain at least two space trees, including:

[0044] Determine the external graphics of the rendering area corresponding to each drawing node in the rendering tree. Divide the external graphics corresponding to the drawing nodes in the rendering tree into at least two sets. The difference between the number of external graphics in any two of the at least two sets is less than a first threshold, and / or the difference between the sum of the areas of the external graphics in any two of the at least two sets is less than a second threshold. Split the rendering tree according to the at least two sets to obtain at least two spatial trees. The spatial tree corresponding to the set includes the drawing node corresponding to the external graphics in the set, and the state operation node passed when tracing back from the drawing node to the root node of the rendering tree.

[0045] Since the shapes of the rendering areas corresponding to the drawing nodes are different, it is impossible to accurately divide the drawing nodes. Therefore, in this application, the drawing nodes can be accurately divided using the external graphics corresponding to the drawing nodes. In addition, when dividing the nodes in the rendering tree, the drawing nodes are divided first, and then the state operation nodes passed through during the backtracking process are classified into the same set as the above-mentioned drawing nodes. In this way, it can be ensured that the state operation of the drawing nodes before and after the division remains unchanged, and the spatial tree obtained after the split can be rendered correctly.

[0046] In a possible implementation manner of the second aspect, the rendering areas corresponding to the at least two sets do not overlap, so that the correctness of the rendering result of the user interface can be further ensured.

[0047] In a possible implementation of the second aspect, the external graphic of the rendering area corresponding to the drawing node is a bounding box of the rendering area corresponding to the drawing node. There is no need to re-establish the external graphic, and the existing bounding box of the drawing node is directly used as the external graphic, which saves processing flow and improves rendering efficiency.

[0048] In a possible implementation of the second aspect, before splitting the rendering tree corresponding to the user interface, the rendering method further includes: determining a grouping result of frames to be displayed. The frames to be displayed are used to display the at least one application interface. The grouping result is used to group the drawing tasks of the at least one application interface into at least one drawing task group, so that the drawing time of the frames to be displayed is less than or equal to the sum of the drawing time of the at least one application interface.

[0049] In this solution, the grouping result of the frames to be displayed is first determined, and the grouping result can make the drawing time of the frames to be displayed less than or equal to the sum of the drawing time of at least one application interface, that is, the drawing time required for the frames to be displayed when no grouping is performed. When the grouping result indicates that the user interface needs to be split, the splitting method provided in the second aspect is used for splitting.

[0050] In a possible implementation of the second aspect, the rendering method further includes: dividing the drawing tasks of the at least one application interface into at least one drawing task group according to the grouping result. Using at least one drawing thread to process the drawing tasks of the at least one drawing task group to obtain at least one drawing result, and the at least one drawing result is used to synthesize the total drawing result of the frame to be displayed.

[0051] It can be seen that by using the rendering method of this solution, the grouping results of the frames to be displayed are determined in advance to achieve the optimal rendering of the frames to be displayed, which can effectively improve the rendering efficiency of the frames to be displayed. Furthermore, when the grouping result indicates that the user interface needs to be split, after the rendering tree corresponding to the user interface is split, the drawing tasks of at least one application interface are divided into at least one drawing task group according to the grouping result, and then the drawing tasks of the drawing task group are processed by the drawing thread.

[0052] In combination with a possible implementation of the second aspect, the rendering method further includes: sending at least one drawing result.

[0053] In a possible implementation manner of the second aspect, at the same time, one core of a central processing unit (CPU) in the electronic device executes one drawing thread. One core is responsible for one drawing thread, so that the rendering efficiency can be guaranteed to be the highest.

[0054] In combination with a possible implementation of the second aspect, the grouping result is a grouping scheme of at least one application interface whose first value satisfies a preset condition, the first value of the grouping scheme is the sum of the drawing time and the synthesis time of the longest drawing task group corresponding to the grouping scheme, and the synthesis time is the product of the number of drawing task groups in the grouping scheme and the synthesis overhead.

[0055] In combination with a possible implementation of the second aspect, when the number of drawing task groups in the grouping scheme is two, the grouping scheme of the above-mentioned at least one application interface includes a first grouping scheme, and the first grouping scheme is to divide the application interface sequence into two parts with equal drawing time, and the above-mentioned application interface sequence is a sequence obtained by arranging the above-mentioned at least one application interface in a preset order.

[0056] Optionally, the grouping scheme of the at least one application interface further includes a second grouping scheme and / or a third grouping scheme, wherein the second grouping scheme is to move the bisection point to the starting point of the drawing task of the first application interface when the bisection point is within the drawing task range of the first application interface. The bisection point is a position corresponding to dividing the application interface sequence into two parts of equal drawing time, and the first application interface is one of the at least one application interface.

[0057] The third grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the end point of the drawing task of the first application interface.

[0058] In combination with a possible implementation of the second aspect, when the number of drawing task groups in the grouping scheme is M, M is greater than or equal to three, and the grouping scheme of the above-mentioned at least one application interface includes a fourth grouping scheme, and the fourth grouping scheme is to divide the application interface sequence into M parts with equal drawing time.

[0059] Optionally, the grouping scheme of at least one application interface further includes a fifth grouping scheme, wherein when the first M sub-point is within the drawing task range of the first application interface, the positions of M-2 of the M-1 M sub-points of the application interface sequence are fixed, and the first M sub-point is moved to the starting point of the drawing task of the first application interface. The M-1 M sub-points are positions corresponding to dividing the application interface sequence into M parts of equal drawing duration, and the first M sub-point is any one of the M-1 M sub-points.

[0060] Optionally, the grouping scheme of the above-mentioned at least one application interface also includes a sixth grouping scheme, and the above-mentioned sixth grouping scheme is that when the first M sub-points are located within the drawing task range of the first application interface, M-2 of the M-1 M sub-points of the above-mentioned application interface sequence are fixed, and the above-mentioned first M sub-points are moved to the end point of the drawing task of the first application interface.

[0061] In a possible implementation manner of the second aspect, the drawing duration of the drawing task group is at least one of the following:

[0062] When the drawing task group includes the drawing task of a complete application interface, "include" here means only including, and the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group.

[0063] When the drawing task group includes the drawing task of an incomplete application interface, "include" here means only including, the drawing duration of the drawing task group is the first drawing duration, the first drawing duration is the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the sum of the split durations, and the split duration is the product of the number of incomplete application interfaces and the splitting overhead.

[0064] When the drawing task group includes drawing tasks of a complete application interface and drawing tasks of an incomplete application interface, "include" here means only including, the drawing time of the drawing task group is the second drawing time, the second drawing time is the sum of the first drawing time and the third drawing time, and the third drawing time is the sum of the drawing times of the complete application interface included in the drawing task group.

[0065] In a possible implementation of the second aspect, the drawing time of the complete application interface is any one of the following:

[0066] The weighted average drawing time of the application interface, where the weighted average drawing time is a weighted calculation value of the fourth drawing time, the fifth drawing time, and their respective weights, the fourth drawing time is the actually measured drawing time of the application interface in the second frame before the frame to be displayed, and the fifth drawing time is the actually measured drawing time of the application interface in the frame before the frame to be displayed.

[0067] The total number of rendering instructions of the application interface, where the total number of rendering instructions is a weighted calculation value of the number of different types of rendering instructions and their corresponding weights.

[0068] In a third aspect, the present application further provides a rendering device, the device comprising a determination module, a division module and a processing module, wherein:

[0069] The determination module is used to determine the grouping result corresponding to the frame to be displayed. The frame to be displayed is used to display at least one application interface, and the grouping result is used to group the drawing tasks of the at least one application interface into at least one drawing task group so that the drawing time of the frame to be displayed is less than or equal to the sum of the drawing time of the at least one application interface.

[0070] The division module is used to divide the drawing tasks of at least one application interface into at least one drawing task group according to the grouping result.

[0071] The processing module is used to process at least one drawing task group using at least one drawing thread to obtain at least one drawing result.

[0072] In combination with a possible implementation of the third aspect, the rendering device further includes a sending module, wherein:

[0073] The sending module is used to send at least one drawing result.

[0074] In combination with a possible implementation manner of the third aspect, the rendering device further includes a splitting module, wherein:

[0075] A splitting module is used to split the rendering tree corresponding to the user interface to obtain at least two spatial trees. The state operation of the drawing node in each spatial tree remains unchanged before and after the split, and the state operation is an operation of modifying the properties of the canvas. Among them, at least two spatial trees are used to render to obtain a user interface. The user interface is at least one of at least one application interface.

[0076] In a possible implementation manner in conjunction with the third aspect, rendering areas corresponding to the at least two spatial trees do not overlap.

[0077] In combination with a possible implementation manner of the third aspect, the splitting module is specifically used to:

[0078] Determine the circumscribed graphics of the rendering area corresponding to each drawing node in the rendering tree. Divide the circumscribed graphics corresponding to each drawing node in the rendering tree into at least two sets. The difference between the number of circumscribed graphics in any two of the at least two sets is less than a first threshold, and / or the difference between the sum of the areas of the circumscribed graphics in any two of the at least two sets is less than a second threshold. Split the rendering tree according to the at least two sets to obtain at least two spatial trees. The spatial tree corresponding to the set includes the drawing node corresponding to the circumscribed graphics in the set, and the state operation node passed when tracing back from the drawing node to the root node of the rendering tree.

[0079] In combination with a possible implementation of the third aspect, rendering areas corresponding to the at least two sets do not overlap.

[0080] The external graphic of the rendering area corresponding to the drawing node is a bounding box of the rendering area corresponding to the drawing node.

[0081] In a possible implementation manner in conjunction with the third aspect, at the same time, one core of a central processing unit (CPU) in the electronic device executes one of the drawing threads.

[0082] In combination with a possible implementation of the third aspect, the above grouping result is a grouping scheme of at least one application interface whose first value satisfies a preset condition, and the first value of the grouping scheme is the sum of the drawing time and the synthesis time of the longest drawing task group corresponding to the grouping scheme.

[0083] In combination with a possible implementation of the third aspect, when the number of drawing task groups in the grouping scheme is two, the grouping scheme of the above-mentioned at least one application interface includes a first grouping scheme, and the first grouping scheme is to divide the application interface sequence into two parts with equal drawing time, and the above-mentioned application interface sequence is a sequence obtained by arranging the above-mentioned at least one application interface in a preset order.

[0084] Optionally, the grouping scheme of the at least one application interface further includes a second grouping scheme and / or a third grouping scheme, wherein the second grouping scheme is to move the bisection point to the starting point of the drawing task of the first application interface when the bisection point is within the drawing task range of the first application interface. The bisection point is a position corresponding to dividing the application interface sequence into two parts of equal drawing time, and the first application interface is one of the at least one application interface.

[0085] The third grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the end point of the drawing task of the first application interface.

[0086] In combination with a possible implementation of the third aspect, when the number of drawing task groups in the grouping scheme is M, M is greater than or equal to three, and the grouping scheme of the above-mentioned at least one application interface includes a fourth grouping scheme, and the fourth grouping scheme is to divide the application interface sequence into M parts with equal drawing time.

[0087] Optionally, the grouping scheme of at least one application interface further includes a fifth grouping scheme, wherein when the first M sub-point is within the drawing task range of the first application interface, the positions of M-2 of the M-1 M sub-points of the application interface sequence are fixed, and the first M sub-point is moved to the starting point of the drawing task of the first application interface. The M-1 M sub-points are positions corresponding to dividing the application interface sequence into M parts of equal drawing duration, and the first M sub-point is any one of the M-1 M sub-points.

[0088] Optionally, the grouping scheme of the above-mentioned at least one application interface also includes a sixth grouping scheme, and the above-mentioned sixth grouping scheme is that when the first M sub-points are located within the drawing task range of the first application interface, M-2 of the M-1 M sub-points of the above-mentioned application interface sequence are fixed, and the above-mentioned first M sub-points are moved to the end point of the drawing task of the first application interface.

[0089] In a possible implementation manner of the third aspect, the drawing duration of the drawing task group is at least one of the following:

[0090] When the drawing task group includes a drawing task of a complete application interface, the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group;

[0091] When the drawing task group includes a drawing task of an incomplete application interface, the drawing duration of the drawing task group is a first drawing duration, the first drawing duration is the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the segmentation duration, and the segmentation duration is the product of the number of incomplete application interfaces and the segmentation overhead;

[0092] When the drawing task group includes a drawing task of a complete application interface and a drawing task of an incomplete application interface, the drawing duration of the drawing task group is the second drawing duration, the second drawing duration is the sum of the first drawing duration and the third drawing duration, and the third drawing duration is the sum of the drawing durations of the complete application interface included in the drawing task group.

[0093] In a possible implementation of the third aspect, the drawing time of the complete application interface is any one of the following:

[0094] the weighted average drawing time of the application interface, where the weighted average drawing time is a weighted calculation value of the fourth drawing time, the fifth drawing time, and their respective weights, the fourth drawing time is the actually measured drawing time of the application interface in the second frame before the frame to be displayed, and the fifth drawing time is the actually measured drawing time of the application interface in the frame before the frame to be displayed;

[0095] The total number of rendering instructions of the application interface, where the total number of rendering instructions is a weighted calculation value of the number of different types of rendering instructions and their corresponding weights.

[0096] In a fourth aspect, the present application further provides a rendering device, the device comprising a splitting module, wherein:

[0097] A splitting module is used to split the rendering tree corresponding to the user interface to obtain at least two spatial trees. The state operation of the drawing nodes in each spatial tree remains unchanged before and after the splitting, and the state operation is an operation to modify the properties of the canvas; the at least two spatial trees are used to render the user interface. In a possible implementation of the fourth aspect, the rendering areas corresponding to the at least two spatial trees do not overlap.

[0098] In combination with a possible implementation manner of the fourth aspect, the splitting module is specifically used to:

[0099] Determine the external graphics of the rendering area corresponding to each drawing node in the rendering tree. Divide the external graphics corresponding to the drawing nodes in the rendering tree into at least two sets. The difference between the number of external graphics in any two of the at least two sets is less than a first threshold, and / or the difference between the sum of the areas of the external graphics in any two of the at least two sets is less than a second threshold. Split the rendering tree according to the at least two sets to obtain at least two spatial trees. The spatial tree corresponding to the set includes the drawing node corresponding to the external graphics in the set, and the state operation node passed when tracing back from the drawing node to the root node of the rendering tree.

[0100] In combination with a possible implementation of the fourth aspect, rendering areas corresponding to the at least two sets do not overlap.

[0101] In a possible implementation manner in conjunction with the fourth aspect, the circumscribed graphic of the rendering area corresponding to the drawing node is a bounding box of the rendering area corresponding to the drawing node.

[0102] In combination with a possible implementation of the fourth aspect, the rendering device further includes a determination module, wherein:

[0103] The determination module is used to determine the grouping result of the frames to be displayed. The frames to be displayed are used to display the at least one application interface. The grouping result is used to group the drawing tasks of the at least one application interface into at least one drawing task group so that the drawing time of the frames to be displayed is less than or equal to the sum of the drawing time of the at least one application interface.

[0104] In combination with a possible implementation of the fourth aspect, the rendering device further includes a division module and a processing module, wherein:

[0105] The division module is used to divide the drawing tasks of at least one application interface into at least one drawing task group according to the grouping result.

[0106] The processing module is used to process the drawing tasks of at least one drawing task group using at least one drawing thread to obtain at least one drawing result, and the at least one drawing result is used to synthesize the total drawing result of the frame to be displayed.

[0107] Obviously, when the grouping result indicates that the user interface does not need to be split, the division module divides the drawing tasks of at least one application interface into at least one drawing task group according to the grouping result, and the processing module then uses the drawing thread to process the drawing tasks of the drawing task group.

[0108] Furthermore, when the grouping result indicates that the user interface needs to be split, after the splitting module splits the rendering tree corresponding to the user interface, the division module divides the drawing tasks of at least one application interface into at least one drawing task group according to the grouping result, and the processing module then uses the drawing thread to process the drawing tasks of the drawing task group.

[0109] In combination with a possible implementation of the fourth aspect, the rendering device further includes a sending module, wherein:

[0110] The sending module is used to send at least one drawing result.

[0111] In a possible implementation manner of the fourth aspect, at the same time, a core of a central processing unit (CPU) in the electronic device executes a drawing thread.

[0112] In combination with a possible implementation of the fourth aspect, the grouping result is a grouping scheme of at least one application interface whose first value satisfies a preset condition, the first value of the grouping scheme is the sum of the drawing time and the synthesis time of the longest drawing task group corresponding to the grouping scheme, and the synthesis time is the product of the number of drawing task groups in the grouping scheme and the synthesis overhead.

[0113] In combination with a possible implementation of the fourth aspect, when the number of drawing task groups in the grouping scheme is two, the grouping scheme of the above-mentioned at least one application interface includes a first grouping scheme, and the first grouping scheme is to divide the application interface sequence into two parts with equal drawing time, and the above-mentioned application interface sequence is a sequence obtained by arranging the above-mentioned at least one application interface in a preset order.

[0114] Optionally, the grouping scheme of the at least one application interface further includes a second grouping scheme and / or a third grouping scheme, and the second grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the starting point of the drawing task of the first application interface. The bisection point is the position corresponding to dividing the application interface sequence into two parts of equal drawing time, and the first application interface is one of the at least one application interface.

[0115] The third grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the end point of the drawing task of the first application interface.

[0116] In combination with a possible implementation of the fourth aspect, when the number of drawing task groups in the grouping scheme is M, M is greater than or equal to three, and the grouping scheme of the above-mentioned at least one application interface includes a fourth grouping scheme, and the fourth grouping scheme is to divide the application interface sequence into M parts with equal drawing time.

[0117] Optionally, the grouping scheme of at least one application interface further includes a fifth grouping scheme, wherein when the first M sub-point is within the drawing task range of the first application interface, the positions of M-2 of the M-1 M sub-points of the application interface sequence are fixed, and the first M sub-point is moved to the starting point of the drawing task of the first application interface. The M-1 M sub-points are positions corresponding to dividing the application interface sequence into M parts of equal drawing duration, and the first M sub-point is any one of the M-1 M sub-points.

[0118] Optionally, the grouping scheme of the above-mentioned at least one application interface also includes a sixth grouping scheme, and the above-mentioned sixth grouping scheme is that when the first M sub-points are located within the drawing task range of the first application interface, M-2 of the M-1 M sub-points of the above-mentioned application interface sequence are fixed, and the above-mentioned first M sub-points are moved to the end point of the drawing task of the first application interface.

[0119] In a possible implementation manner of the fourth aspect, the drawing duration of the drawing task group is at least one of the following:

[0120] When the drawing task group includes the drawing task of a complete application interface, "include" here means only including, and the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group.

[0121] When the drawing task group includes the drawing task of an incomplete application interface, "include" here means only including, the drawing duration of the drawing task group is the first drawing duration, the first drawing duration is the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the sum of the split durations, and the split duration is the product of the number of incomplete application interfaces and the splitting overhead.

[0122] When the drawing task group includes drawing tasks of a complete application interface and drawing tasks of an incomplete application interface, "include" here means only including, the drawing time of the drawing task group is the second drawing time, the second drawing time is the sum of the first drawing time and the third drawing time, and the third drawing time is the sum of the drawing times of the complete application interface included in the drawing task group.

[0123] In a possible implementation of the fourth aspect, the drawing time of the complete application interface is any one of the following:

[0124] The weighted average drawing time of the application interface, where the weighted average drawing time is a weighted calculation value of the fourth drawing time, the fifth drawing time, and their respective weights, the fourth drawing time is the actually measured drawing time of the application interface in the second frame before the frame to be displayed, and the fifth drawing time is the actually measured drawing time of the application interface in the frame before the frame to be displayed.

[0125] The total number of rendering instructions of the application interface, where the total number of rendering instructions is a weighted calculation value of the number of different types of rendering instructions and their corresponding weights.

[0126] In a fifth aspect, the present application also provides an electronic device, comprising a processor and a memory, wherein the processor and the memory are connected, wherein the memory is used to store program code, and the processor is used to call the program code to execute the rendering method as described in any one of the first aspect or the second aspect.

[0127] In a sixth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the rendering method as described in any one of the first aspect or the second aspect.

[0128] In a seventh aspect, the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute the rendering method described in any one of the first aspect or the second aspect.

[0129] In an eighth aspect, the present application further provides a chip, comprising a processor and a data interface, wherein the processor reads instructions stored in a memory through the data interface to execute the method described in the first aspect or the second aspect.

[0130] Optionally, as an implementation method, the chip may also include a memory, in which instructions are stored, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to execute the method described in the first aspect or the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0131] The following is an introduction to the drawings used in the embodiments of the present application.

[0132] Figure 1 It is a schematic diagram of an application architecture of a rendering method provided in an embodiment of the present application;

[0133] Figure 2 It is a flowchart of a rendering method provided in an embodiment of the present application;

[0134] Figure 3A This is a schematic diagram of a process for determining a segmentation scheme provided in an embodiment of the present application;

[0135] Figure 3B is a schematic diagram of another process for determining a segmentation scheme provided in an embodiment of the present application;

[0136] Figure 3C This is a schematic diagram of calculating the duration of a drawing task group provided in an embodiment of the present application;

[0137] Figure 4A It is a flowchart of a rendering method provided in an embodiment of the present application;

[0138] Figure 4B This is a single-threaded single-frame drawing schematic diagram provided in an embodiment of the present application;

[0139] Figure 4C It is a multi-threaded drawing schematic diagram provided by an embodiment of the present application;

[0140] Figure 5 is a flowchart of another rendering method provided in an embodiment of the present application;

[0141] Fig. 6A is a schematic diagram of a rendering tree provided in an embodiment of the present application;

[0142] Figure 6B is a schematic diagram of a bounding box of a drawing node provided in an embodiment of the present application;

[0143] Figure 6C is a schematic diagram of dividing a rectangle provided in an embodiment of the present application;

[0144] Fig.6D is a marking schematic diagram of a rendering tree provided in an embodiment of the present application;

[0145] Fig. 6E is a schematic diagram of a space tree and its drawing result provided in an embodiment of the present application;

[0146] Fig. 6F It is a thread allocation diagram of an application interface provided in an embodiment of the present application;

[0147] Figure 6G It is a thread allocation diagram of another application interface provided in an embodiment of the present application;

[0148] Figure 7 It is a flowchart of a rendering device provided in an embodiment of the present application;

[0149] Figure 8 is a schematic structural diagram of another rendering device provided by an embodiment of the present invention;

[0150] Fig. 9 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0151] The technical solution in this application will be described below in conjunction with the accompanying drawings.

[0152] In the embodiments of the present application, the words "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0153] The "at least one" mentioned in the embodiments of the present application refers to one or more, and "multiple" refers to two or more. "At least one of the following" or its similar expression refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, (a and b), (a and c), (b and c), or (a and b and c), where a, b, c can be single or multiple. "And / or" describes the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can be represented by: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are an "or" relationship. The serial numbers of the steps of the embodiments of the present application (such as step S1, step S21, etc.) are only for distinguishing different steps, and do not limit the order of execution between the steps.

[0154] Furthermore, unless otherwise specified, the ordinal numbers such as "first" and "second" used in the embodiments of the present application are used to distinguish multiple objects, and are not used to limit the order, timing, priority or importance of multiple objects. For example, the first device and the second device are only for the convenience of description, and do not represent the difference in structure, importance, etc. between the first device and the second device. In some embodiments, the first device and the second device can also be the same device.

[0155] In the embodiments of the present application, the term "when..." can be interpreted as meaning "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the concept and principle of the present application shall be included in the protection scope of the present application.

[0156] Due to the applications involved in the embodiments of the present application, in order to facilitate understanding, the relevant terms and other related concepts involved in the embodiments of the present application are first introduced below.

[0157] (1) Rendering pipeline

[0158] The rendering pipeline, also known as the rendering production line, is the various operation processes that the graphic image must go through step by step from data to the final output image. It generally includes: vertex data input, vertex shader, surface subdivision process, geometry shader, primitive assembly, clipping and culling, rasterization, fragment shader and mixed test and other processes.

[0159] (2) Rendering frame rate

[0160] The rendering frame rate refers to the frame rate per second (Frame Pre Second, FPS), that is, the number of times (or rate) that a bitmap image in frames appears continuously on the display per second. In simple terms, it is how many pictures are displayed on the screen in one second.

[0161] (3) Canvas

[0162] Canvas is the core class provided by the rendering engine. It encapsulates all drawing operations on the device and records the drawing status of the management device. By calling the rendering canvas interface, the rendering texture can be drawn or the status can be changed.

[0163] (4) Rendering tree

[0164] User Interface (UI) refers to at least one application interface presented to the user on the screen. The rendering tree is used for the layout and drawing of the user interface, is responsible for the actual rendering, and saves information such as the size and layout of the elements. Among them, the rendering tree includes multiple rendering nodes, each rendering node contains the layout information of the node and the recorded drawing operation information (DrawOp), the layout information includes the position, size (such as width, height) and bounding box of the rendering node, and the bounding box refers to the circumscribed rectangle of the drawing area (or rendering area) corresponding to the rendering node. The drawing operation information refers to the content that the rendering node needs to draw, including but not limited to at least one of the following: drawing graphics, drawing text characters, drawing pictures, canvas clipping (Clip), canvas rotation (Transform), canvas movement (Move), and canvas transparency modification.

[0165] The rendering node is used to perform drawing operations and / or state operations, wherein the drawing operation can be understood as an operation of rendering, including but not limited to at least one of the following: drawing graphics, drawing text characters, and drawing pictures.

[0166] State operations can be understood as operations that modify properties of the canvas (such as the size, position, transparency, etc. of the canvas), including but not limited to at least one of the following: canvas cropping, canvas rotation, canvas movement, and canvas transparency modification.

[0167] In the embodiment of the present application, a drawing node refers to a rendering node in a rendering tree for performing a drawing operation, and a state operation node refers to a rendering node in a rendering tree for performing a state operation. Exemplarily, the drawing node and the state operation node may be the same rendering node, that is, the rendering node is used to perform a drawing operation and a state operation.

[0168] (5) Buffer Queue

[0169] Buffer queues are used to connect a party that generates graphics data buffers (producers) to a party that receives data for display or further processing (consumers).

[0170] (6) UI controls

[0171] UI controls refer to components that users can interact with or operate, such as buttons, input boxes, etc.

[0172] (7) Rendering space tree (referred to as space tree)

[0173] The spatial tree is a tree structure composed of rendering nodes (i.e., drawing nodes and / or state operation nodes) corresponding to UI controls in a certain rendering area, and mainly represents the relationship between UI controls in space. Optionally, different spatial trees do not intersect in spatial relationship, that is, the rendering areas corresponding to different spatial trees do not overlap at all.

[0174] (8) Window

[0175] A window is a graphical interface element that displays the contents of an application for the user to view and interact with. A window is typically a rectangular area that can be resized and usually edited according to the capabilities and restrictions imposed on it by the application providing the window.

[0176] (9) Z order

[0177] The Z order refers to the Z-axis order of windows. The Z order of a window indicates the position of the window in the list of stacked windows, which can also be understood as the Z-axis order of the application interface. The direction of the window stacking is along an imaginary axis, namely the Z axis, extending from the screen outward.

[0178] The rendering task of the user interface is generally processed in a serial process. When the rendering task becomes more and more arduous, the processing efficiency of the serial process is low. For example, when the number of application interfaces included in the user interface increases, the rendering task becomes heavier, and the efficiency of the serial processing process is not ideal. Therefore, how to improve the rendering efficiency is imminent.

[0179] The present application proposes a rendering method for this purpose, by first determining the grouping result of the picture frame to be displayed (i.e., the frame to be displayed), then processing the drawing task of the frame to be displayed according to the grouping result to obtain at least one drawing task group, and finally using at least one drawing thread to process the drawing task of the at least one drawing task group to obtain at least one drawing result, and synthesizing at least one drawing result to obtain the total drawing result of the frame to be displayed. Among them, the frame to be displayed is used to display at least one application interface. Since the above grouping result can make the drawing time of the frame to be displayed less than the sum of the drawing time of at least one application interface, that is, the drawing time required for the frame to be displayed when no grouping is performed, therefore, using the rendering method of the present application, the rendering efficiency of the frame to be displayed can be effectively improved.

[0180] In addition, when the grouping result indicates that the user interface needs to be split, another rendering method provided by the present application can be used to split the user interface, and the above-mentioned user interface is at least one of at least one application interface. Of course, the above-mentioned user interface can also be understood as at least one application interface presented to the user on the screen, and the rendering method of the present application can also be applied. Among them, in the embodiment of the present application, when the user interface is split, the rendering tree corresponding to the user interface is split into at least two spatial trees, and the state operation of the drawing nodes in each spatial tree before and after the split is guaranteed to remain unchanged. In this way, when the above-mentioned user interface is rendered using at least two spatial trees, the correctness of the rendering result of the user interface can be ensured.

[0181] The application architecture of the rendering method of this application is introduced below.

[0182] refer to Figure 1 , Figure 1 : is a schematic diagram of an application architecture of a rendering method provided in an embodiment of the present application. Figure 1 The numbers in the table represent the following information:

[0183] ① Update the message for drawing content;

[0184] ② is the display list;

[0185] ③ Drawing task group;

[0186] ④ Drawing instructions for the Graphics Processing Unit (GPU);

[0187] ⑤ Buffer for the total drawing results.

[0188] The rendering method in the embodiment of the present application can be applied to electronic devices, wherein reference Figure 1The electronic device includes a central processing unit (CPU) and a GPU, wherein the rendering method of the present application is mainly executed on the CPU side, the CPU is responsible for preparing data, and the GPU performs rendering.

[0189] The following uses Figure 1 The rendering process of the application architecture in the example is described in detail:

[0190] 1. When the content drawn on the screen of the electronic device needs to be updated, a drawing content update message is sent to the CPU to trigger the UI thread.

[0191] 2. The UI thread completes the measurement and layout of the controls, and constructs a rendering tree based on the control information. The rendering tree contains several rendering nodes, each of which contains a display list, which is used to store several drawing operation information that needs to be processed. Then the UI thread sends a synchronization (Sync) signal to the main rendering thread to trigger the main rendering thread to synchronize the status with the UI thread, including synchronizing the display list. In addition, the UI thread will also synchronize node attribute information (such as node size, position, etc.) with the main rendering thread.

[0192] 3. The main rendering thread applies for a drawing cache for the current frame to be displayed, and then determines the grouping result of the drawing task of the frame to be displayed (for details, refer to Figures 2 to 4C ), and then process the drawing task of the frame to be displayed according to the grouping result. When the grouping result of the frame to be displayed indicates that the user interface needs to be split, the user interface is split (for details, refer to Figures 5 to 6G Then, the drawing tasks of the frames to be displayed are combined according to the grouping results to obtain at least one drawing task group, and finally, the at least one drawing task group is sent to the working thread.

[0193] 4. After receiving at least one drawing task group, the worker thread will create the required resources for each drawing thread in at least one drawing thread, including applying for drawing cache. Each drawing thread has an independent GPU rendering pipeline (e.g. Figure 1 The working thread assigns the drawing tasks of at least one drawing task group to at least one drawing thread for processing to obtain at least one drawing result, i.e., a GPU instruction. One drawing thread processes the drawing tasks of one drawing task group, and each drawing thread converts the CPU instruction into a GPU instruction, and then submits the GPU instruction to the GPU for processing.

[0194] 5. After receiving the GPU instruction, the GPU starts to perform rendering work, that is, calculating and filling the correct color for the corresponding pixel points. Since each drawing thread is submitted to a separate drawing buffer, the GPU finally needs to synthesize the drawing results of each drawing buffer to obtain the total drawing result, and finally submit the cache of the total drawing result to the hardware synthesizer.

[0195] 6. After the hardware synthesizer waits for the GPU rendering to complete, it sends the total drawing result to the screen for display.

[0196] The rendering method provided in the embodiment of the present application is described in detail below.

[0197] refer to Figure 2 , Figure 2 : is a flowchart of a rendering method provided in an embodiment of the present application; the rendering method comprises the following steps:

[0198] 201. Determine a grouping result of frames to be displayed.

[0199] Specifically, the frame to be displayed is a frame waiting to be displayed. The frame to be displayed is used to display at least one application interface. The above grouping result is used to group the drawing tasks of at least one application interface into at least one drawing task group, so that the drawing time of the frame to be displayed is less than or equal to the sum of the drawing time of at least one application interface.

[0200] 202. Divide the drawing task of at least one application interface into at least one drawing task group according to the grouping result.

[0201] Specifically, when the grouping result indicates that the user interface needs to be split, the user interface is an interface composed of at least one application interface among the at least one application interface, and the following method can be used: Figure 5 The method shown performs splitting processing on the user interface, which will not be described in detail here, and then the drawing tasks corresponding to the spatial tree obtained after the splitting are divided into corresponding drawing task groups according to the grouping results. In addition, when the grouping result indicates that the application interface does not need to be split, the drawing tasks of at least one application interface can be combined according to the grouping result. When the grouping result indicates that the drawing tasks of at least one application interface do not need to be split, the drawing tasks of at least one application interface are taken as a drawing task group.

[0202] 203. Use at least one drawing thread to process the drawing tasks of at least one drawing task group to obtain at least one drawing result, where the at least one drawing result is used to synthesize a total drawing result of a frame to be displayed.

[0203] In an embodiment of the present application, the grouping result of the frames to be displayed is first determined, and the grouping result can make the drawing time of the frames to be displayed less than the sum of the drawing time of at least one application interface, that is, the drawing time required for the frames to be displayed when no grouping is performed. Then, the drawing tasks of the frames to be displayed are divided according to the grouping result to obtain at least one drawing task group. Finally, at least one drawing thread processes the drawing tasks of the at least one drawing task group to obtain at least one drawing result. The at least one drawing result is used to synthesize the total drawing result of the frames to be displayed to render the frames to be displayed. It can be seen that by using the rendering method of the embodiment of the present application, the grouping result of the frames to be displayed is determined in advance to achieve the optimal rendering of the frames to be displayed, which can effectively improve the rendering efficiency of the frames to be displayed.

[0204] Exemplarily, the embodiments of the present application determine the corresponding grouping results by judging the rendering tasks of the frames to be displayed in different situations, so as to optimize the rendering efficiency of the frames to be displayed. For example, when the rendering tasks are heavy, the grouping results can divide the rendering tasks into two or more groups; and when the rendering tasks are light, the rendering tasks may not be grouped. The actual grouping results are determined according to the actual situation of the rendering tasks of the frames to be displayed.

[0205] In one possible implementation, reference Figure 2 , the above rendering method also includes:

[0206] 204. Send at least one drawing result.

[0207] In the embodiment of the present application, at least one drawing result corresponding to at least one drawing task group is sent to other devices or modules, so that other devices or modules can synthesize the total drawing result of the frame to be displayed, and finally complete the rendering of the frame to be displayed. Exemplarily, the CPU executes step 204, and the CPU sends at least one drawing result to the GPU, so that the GPU synthesizes the total drawing result of the frame to be displayed according to the at least one drawing result.

[0208] In a possible implementation, in the embodiment of the present application, at the same time, the at least one drawing thread is executed by a core of a CPU of the electronic device.

[0209] In a possible implementation, in the embodiment of the present application, at the same time, one core of the CPU in the electronic device executes one drawing thread. One core is responsible for one drawing thread, so that the rendering efficiency of the frame to be displayed can be guaranteed to be the highest. In addition, when the electronic device has two or more cores, by using the method of the embodiment of the present application, by reasonably grouping the drawing content of the frame to be displayed, the multi-core capability of the electronic device can be fully utilized, so that the hardware can exert its maximum energy efficiency and avoid the problem of uneven rendering load.

[0210] Exemplarily, when the electronic device has two or more cores, in an embodiment of the present application, at the same time, the number of drawing threads executing tasks is less than or equal to the number of cores of the CPU of the electronic device, and can be set according to actual conditions.

[0211] In a possible implementation, the grouping result is a grouping scheme of at least one application interface whose first value satisfies a preset condition, the first value of the grouping scheme is the sum of the drawing time and the synthesis time of the longest drawing task group corresponding to the grouping scheme, and the synthesis time is the product of the number of drawing task groups in the grouping scheme and the synthesis overhead.

[0212] The grouping scheme is a scheme for grouping the drawing tasks of at least one application interface into at least one drawing task group. In the embodiment of the present application, by determining the grouping scheme of at least one application interface, when the first value of the grouping scheme meets the preset condition, the grouping scheme is determined to be the above-mentioned grouping result.

[0213] For example, at least one grouping scheme of at least one application interface may be determined first, and then the grouping scheme whose first value satisfies the preset condition in the at least one grouping scheme may be determined as the grouping result of the at least one application interface. In the embodiment of the present application, the corresponding preset condition may be set according to the actual situation, and this is not particularly limited. For example, the preset condition is that the first value is the smallest so that the drawing time of a single frame is minimized.

[0214] Specifically, the drawing time of each frame is mainly affected by the window load, that is, the drawing time of each application interface. The more application interfaces that need to be drawn, the greater the total load of all windows, and the longer the single-frame drawing time will be. In addition, the drawing time of each frame is also mainly affected by the number of GPU synthesis times (that is, the number M of drawing task groups to be displayed). Each synthesis causes a certain synthesis overhead α, α is an empirical value, which is generally related to the size of the synthesis buffer and the computing power of the device and can be obtained through actual testing. Therefore, this implementation example needs to calculate the appropriate number of GPU synthesis times. Multiple drawing task groups are drawn in parallel, so the drawing time of each frame is mainly affected by the drawing task group with the longest (drawing time). Further, when the drawing time of the longest drawing task group is the shortest, the drawing time of a single frame is also the shortest. That is, the embodiment of the present application determines the grouping of drawing tasks through time budget, synthesis number constraints, and the maximum number of threads of the device.

[0215] As an optimization, we want to maximize the number of drawing task groups that can be executed simultaneously. Because each CPU core can independently execute the drawing operation of a drawing task group at the same time in a drawing cycle, the maximum number of GPU synthesis times is set to be equal to the number of CPU cores m of the electronic device to maximize the parallel execution of drawing operations. When the longest drawing task group has the shortest duration, the drawing duration of a single frame is the shortest and the drawing frame rate is the highest.j Indicates the drawing duration of the jth drawing task group.

[0216] In the embodiment of the present application, the first value D is set to:

[0217] D=T max +M*α (1)

[0218] Among them, T max =max(T),T j ∈T,1≤j≤m,T max Indicates the drawing duration of the longest drawing task group in the grouping scheme.

[0219] In an embodiment of the present application, at least one possible grouping scheme for at least one application interface can be obtained first, and then the first value of each grouping scheme can be calculated according to formula (1), and the grouping scheme with the smallest first value can be used as the grouping result of at least one application interface, so that the drawing time of the frame to be displayed is less than the sum of the drawing times of at least one application interface.

[0220] In a possible implementation, when the number of drawing task groups in the grouping scheme is two, the grouping scheme of the at least one application interface includes a first grouping scheme, the first grouping scheme is to divide the application interface sequence into two parts of equal drawing time, and the application interface sequence is a sequence obtained by arranging the at least one application interface in a preset order. In the embodiment of the present application, the bisection scheme can be used as a possible grouping scheme for the at least one application interface.

[0221] The preset order can be determined according to the actual situation. For example, the application interface sequence can be obtained by arranging them in ascending order according to the Z order. The preset order can also be the order from large to small in the Z order, and the order of the application interface sequence is not particularly limited. In addition, since the drawing order of the application interface must be in the order from small to large in the Z order, therefore, in the GPU synthesis stage, it is necessary to synthesize in the order from small to large in the Z order of the application interface, so as to ensure the correctness of the drawing result.

[0222] Optionally, the grouping scheme of the at least one application interface further includes a second grouping scheme and / or a third grouping scheme, and the second grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the starting point of the drawing task of the first application interface. The bisection point is the position corresponding to dividing the application interface sequence into two parts of equal drawing time, and the first application interface is one of the at least one application interface.

[0223] The third grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the end point of the drawing task of the first application interface.

[0224] In an embodiment of the present application, it is also possible to obtain a possible grouping scheme for at least one of the above-mentioned application interfaces by moving the bisection point to the starting point and / or end point of the drawing task of the application interface, thereby avoiding the segmentation overhead generated when segmenting the application interface and reducing the drawing time of the drawing task group.

[0225] In a possible implementation, when the number of drawing task groups in the grouping scheme is M, M is greater than or equal to three, and the grouping scheme of the above-mentioned at least one application interface includes a fourth grouping scheme, and the fourth grouping scheme is to divide the application interface sequence into M parts with equal drawing time.

[0226] Optionally, the grouping scheme of at least one application interface further includes a fifth grouping scheme, wherein when the first M sub-point is within the drawing task range of the first application interface, the positions of M-2 of the M-1 M sub-points of the application interface sequence are fixed, and the first M sub-point is moved to the starting point of the drawing task of the first application interface. The M-1 M sub-points are positions corresponding to dividing the application interface sequence into M parts of equal drawing duration, and the first M sub-point is any one of the M-1 M sub-points.

[0227] Optionally, the grouping scheme of the above-mentioned at least one application interface also includes a sixth grouping scheme, and the above-mentioned sixth grouping scheme is that when the first M sub-points are located within the drawing task range of the first application interface, M-2 of the M-1 M sub-points of the above-mentioned application interface sequence are fixed, and the above-mentioned first M sub-points are moved to the end point of the drawing task of the first application interface.

[0228] In the embodiment of the present application, when the number of drawing task groups in the grouping scheme is M, a method similar to that when the number of drawing task groups in the grouping scheme is two is adopted, and the M-equal division scheme is used as a possible grouping scheme for the above-mentioned at least one application interface. When the first M-divided point is located within the drawing task range of the first application interface, by fixing the positions of M-2 of the M-1 M-divided points in the above-mentioned application interface sequence, and moving the above-mentioned first M-divided point to the starting point and / or end point of the drawing task of the first application interface, a possible grouping scheme for the above-mentioned at least one application interface can be obtained.

[0229] Exemplarily, a possible grouping scheme of the at least one application interface may also be determined by methods such as manual grouping, and the grouping method of the at least one application interface is not limited.

[0230] The following is a detailed description of a method for obtaining at least one possible grouping scheme for the at least one application interface:

[0231] First, the number M of the drawing task groups of the frames to be displayed is determined. The selection range of the number M is 1 to m, where m is the number of cores of the central processing unit CPU of the electronic device, that is, the maximum number of GPU synthesis times supported by the electronic device.

[0232] Determine at least one segmentation scheme corresponding to the application interface sequence under each number M, then you can get m types of Y segmentation schemes corresponding to the number M, where Y is greater than or equal to m. Each segmentation scheme divides the application interface sequence into at least one portion, and each portion corresponds to a drawing task group. A segmentation scheme under the number M is a possible grouping scheme of the at least one application interface.

[0233] According to formula (1), the first value corresponding to each segmentation scheme is determined, and the segmentation scheme with the smallest first value among the Y segmentation schemes and the corresponding number M are determined as the grouping result. The first value of the segmentation scheme is the sum of the drawing time and the synthesis time of the longest drawing task group corresponding to the segmentation scheme. The synthesis time is the product of the number M and the synthesis overhead.

[0234] In an embodiment of the present application, by determining at least one segmentation scheme corresponding to each number M, and then determining a segmentation scheme with the smallest first value from the Y segmentation schemes, the segmentation scheme with the smallest first value and the corresponding number M are used as the grouping results, thereby ensuring the accuracy of the grouping results.

[0235] For example, assuming that at least one segmentation scheme corresponding to each number M is determined, a possible solution for determining the above three segmentation schemes is provided below. First, take the determination of the corresponding three segmentation schemes when the number M is 2 as an example. Figure 3A , Figure 3A This is a schematic diagram of a process for determining a segmentation scheme provided by an embodiment of the present application. Taking the application interface sequence 304 in the order of background application, vibrato application, Taobao application, status bar application and navigation bar application as an example, the bisection point 302 of the application interface sequence 304 is first determined. The bisection point 302 is located within the drawing task range of the Taobao application, and the segmentation scheme corresponding to the bisection point 302 is used as a segmentation scheme of the application interface sequence 304. Then move the bisection point 302 to the left to the starting point 301 of the drawing task of the Taobao application, and use the segmentation scheme corresponding to the starting point 301 as a segmentation scheme of the application interface sequence 304. Similarly, move the bisection point 302 to the right to the end point 303 of the drawing task of the Taobao application, and use the segmentation scheme corresponding to the end point 303 as a segmentation scheme of the application interface sequence 304. At this point, it can be determined that when the number M is 2, the three segmentation schemes corresponding to the application interface sequence 304 can be determined. In addition, when the bisection point 302 overlaps with the starting point 301 or the end point 303, when the number M is 2, there are two corresponding segmentation schemes.

[0236] refer to Figure 3B , Figure 3B306, respectively, and the segmentation schemes corresponding to the three-point points 305 and 306 are used as a segmentation scheme for the application interface sequence 304. Then, the position of the three-point point 306 is fixed, and the portion from the starting point of the application interface sequence 304 to the three-point point 306 is divided into two segments according to the same process. Figure 3A The method is used to move the third point 305 to the left and right to reach the starting point and the end point of the drawing task of the Douyin application, and the segmentation scheme corresponding to the third point 306 and the starting point of the drawing task of the Douyin application is used as a segmentation scheme of the application interface sequence 304, and the segmentation scheme corresponding to the third point 306 and the end point of the drawing task of the Douyin application is used as a segmentation scheme of the application interface sequence 304. Similarly, the position of the third point 305 is fixed, and the part from the third point 305 to the end point of the application interface sequence 304 is segmented according to Figure 3A The method is used to move the third point 306 to the left and right to reach the starting point and the end point of the drawing task of the status bar application, and the segmentation scheme corresponding to the third point 305 and the starting point of the drawing task of the status bar application is used as a segmentation scheme of the application interface sequence 304, and the segmentation scheme corresponding to the third point 305 and the end point of the drawing task of the status bar application is used as a segmentation scheme of the application interface sequence 304.

[0237] When the number M is greater than 3, the method for determining the segmentation scheme is the same as the method for determining the number M is 3, and will not be repeated here. The difference is that what needs to be determined is the M-points, and then the positions of M-2 M-points are fixed, and the remaining M-points are moved left and right in sequence to the boundary points of the application interface (i.e., the starting point and end point of the drawing task of the application interface).

[0238] In a possible implementation, when the above-mentioned drawing task group includes a drawing task of a complete application interface, "include" here means only including, and the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group.

[0239] Specifically, when the positions of the front and back cutting points of a drawing task group are both located on the boundary of the application interface, refer to Figure 3C , Figure 3C This is a schematic diagram of the duration calculation of a drawing task group provided by an embodiment of the present application, wherein the application interface sequence 304 is based on the order of background application, Douyin application, Taobao application, status bar application and navigation bar application as an example, and the drawing task group H1 includes the drawing tasks of two complete application interfaces, the background application and the Douyin application. In this case, the drawing duration of the drawing task group is determined by formula (2):

[0240]

[0241] Among them, t p to q Indicates the drawing time required for the complete application interface included in the drawing task group.

[0242] For example, reference Figure 3C , the drawing time of the drawing task group H1 is the sum of the drawing time required by the background application and the drawing time required by the TikTok application.

[0243] In a possible implementation, when the above-mentioned drawing task group includes the drawing task of an incomplete application interface, "include" here means only including, the drawing duration of the drawing task group is the first drawing duration, the first drawing duration is the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the sum of the segmentation durations, and the segmentation duration is the product of the number of incomplete application interfaces and the segmentation overhead.

[0244] Specifically, when the positions of the front and rear cutting points of a drawing task group are both located inside the application interface and the drawing task group does not include a complete application interface, a possible situation is that the drawing task group only includes a drawing task of an incomplete application interface. Figure 3C , where the drawing task group H2 includes a part of the drawing tasks of the Taobao application. In this case, the drawing time of the drawing task group is the drawing time of the incomplete application interface plus a segmentation cost β. The segmentation cost β is usually related to the number of nodes in the rendering tree of the cut application interface. Since this value is generally small, it can be simplified to a fixed cutting cost obtained by actual measurement of a system, or a segmentation cost β can be measured for each application interface. The drawing time of the incomplete application interface is the product of the segmentation ratio and the drawing time of the complete application interface. The segmentation ratio is the proportion of the drawing tasks of the drawing task group to the drawing tasks of the entire application interface. Figure 3C For example, at this time, the drawing duration of the drawing task group H2 is the product of the drawing duration t5 of the Taobao application and k, where k is the proportion of the drawing task group H2 in the drawing task group of the Taobao application.

[0245] Another possible situation is that the drawing task group includes two incomplete application interface drawing tasks, refer to Figure 3C , the drawing task group H3 includes a part of the drawing tasks of the Taobao application and a part of the drawing tasks of the status bar application. In this case, the drawing time of the drawing task group is the drawing time of two incomplete application interfaces plus two segmentation overheads β. The proportion of the drawing tasks of the Taobao application in the drawing task group H3 is u, where the sum of k and u is one. The proportion of the drawing tasks of the status bar application in the drawing task group H3 is e.

[0246] In a possible implementation, when the above-mentioned drawing task group includes a drawing task of a complete application interface and a drawing task of an incomplete application interface, "include" here means only including, the drawing time of the drawing task group is the second drawing time, the second drawing time is the sum of the first drawing time and the third drawing time, and the third drawing time is the sum of the drawing time of the complete application interface included in the drawing task group.

[0247] refer to Figure 3C , the drawing task group H4 includes a part of the drawing tasks of the status bar application and the drawing tasks of the navigation bar application, wherein the proportion of the drawing tasks of the status bar application in the drawing task group H4 is n, and the sum of e and n is one. It can be seen that, Figure 3C The drawing task group includes only one incomplete application interface, so the first drawing duration at this time includes one segmentation cost β. When the drawing task group includes two drawing tasks of incomplete application interfaces, the first drawing duration includes two segmentation costs β.

[0248] In a possible implementation, the drawing time of the above-mentioned complete application interface may be a weighted average drawing time of the application interface. The weighted average drawing time is a weighted calculation value of the fourth drawing time, the fifth drawing time, and their respective weights. The fourth drawing time is the drawing time actually measured in the second frame before the frame to be displayed, and the fifth drawing time is the drawing time actually measured in the frame before the frame to be displayed.

[0249] In an embodiment of the present application, the historical running time of each application interface is used to fit the load of each application interface, and the weighted average drawing time of the application interface is used as the drawing time of the application interface, so as to accurately estimate the drawing load size of the application interface.

[0250] In an embodiment of the present application, the load of a window is defined as the duration of the CPU processing the drawing operation of the window. Due to the operating system scheduling, the CPU core frequency changes, that is, the number of instructions executed by the CPU per unit time changes. Therefore, the difference in the drawing duration of multiple frames in the same application under the same drawing operation is also obvious. The embodiment of the present application uses the weighted average drawing duration of multiple frames to estimate the window drawing load relatively accurately. The calculation method of the estimated weighted average drawing duration used in the embodiment of the present application can minimize the impact of severe load jitter caused by system scheduling.

[0251] In the embodiment of the present application, the weighted average drawing time The calculation method of is shown in equations (3) and (4).

[0252]

[0253] a n-1=max(0.1,0.9×a n-2 ), where n≥2, a1=1 (4)

[0254] in, It is the estimated weighted average drawing time of the nth frame, that is, the drawing load of the nth frame. is the weighted average load of the previous n-2 frames. n-1 is the measured load of the n-1th frame. n-1 is the weighted average factor, and its value is calculated by formula (4). In order to ensure the accuracy of the weighted average drawing time of the current frame, the weighted average factor of the weighted average drawing time of the historical frames has a greater impact on the weighted average drawing time of the current frame. Therefore, in the embodiment of the present application, the weight of the measured load of the n-1th frame is finally determined at an empirical value, as shown in formula (4), and the empirical value can be 0.1 or 0.2, etc. When the window is drawn for the first time, that is, n is equal to 1, the definition of formula (3) is = 0, and define the average load factor a1 of the first frame in equation (4) to be 1, then the weighted average load of the first frame is The actual load is equal to t1. When the second frame to the nth frame are subsequently drawn, the weighted average factor is first calculated using formula (4), and then the weighted average drawing time of the current frame is calculated using formula (3).

[0255] In a possible implementation, the drawing time of the complete application interface may be the total number of rendering instructions of the application interface, where the total number of rendering instructions is a weighted calculation value of different types of rendering instructions, the number of rendering instructions and their corresponding weights.

[0256] In the embodiment of the present application, the total number of rendering instructions of the application interface is used as the drawing duration of the application interface, so as to accurately estimate the drawing load size of the application interface.

[0257] Specifically, first, determine the weight corresponding to each rendering instruction, and the specific value of the weight can be set according to the actual situation. For example, actually measure the execution time required for a rendering instruction on different devices, and then calculate an average time as the final execution time of the rendering instruction. The longer the execution time, the greater the weight of the rendering instruction. Next, count the number of each rendering instruction required to draw the application interface, calculate the product of the weight of different rendering instructions and the corresponding number of instructions, and then sum the different products to get the total number of rendering instructions for the application interface.

[0258] The rendering method of the embodiment of the present application is specifically described below with an example:

[0259] refer to Figure 4A , Figure 4AThis is a flowchart of a rendering method provided by an embodiment of the present application. The specific process package is:

[0260] When the graphics rendering module of the electronic device is started, the drawing thread pool for executing the graphics rendering task is initialized first, including creating drawing resources for each drawing thread, and the drawing resources include two-dimensional (2D) engine instance resources and drawing backend resources. For example, using OpenGL as the rendering backend, in order to share drawing resources among multiple threads, the drawing thread creates a shared context resource based on the context of the main thread.

[0261] The number of threads in the thread pool can be determined according to the hardware capability of the CPU. Furthermore, for a multi-core CPU, the number of drawing threads is the same as the number of CPU cores, so that each drawing thread runs on a separate CPU core at the same time to fully utilize the multi-core capability of the CPU. The number of drawing threads can also be less than the number of CPU cores, and there is no special limitation on this.

[0262] After completing the initialization of the thread pool, the drawing process of each frame is entered. Each frame first determines whether the drawing signal is received. If not, the thread pool is suspended. When a frame drawing signal is received, the rendering tree information is first updated, including the drawing operation information and the attribute information of the rendering node. After the information update is completed, the grouping result is determined.

[0263] Based on formula (1), the first value satisfies the preset condition to determine the grouping result of the frame to be displayed, wherein the grouping result includes how many parts each application interface is divided into, the ratio of each part, and how at least one application interface is grouped. According to the grouping result, the drawing task of at least one application interface is processed to obtain at least one drawing task group, and at least one drawing task group is added to the task queue. If there is no application interface to be split, all drawing operation information contained in the frame to be displayed is packaged into one task. If there is an application interface to be split, the following is performed. Figure 5 The method shown handles the application interface.

[0264] Next, determine whether the task group to be drawn in the task queue is empty. If so, synthesize all the drawing results and send them to the display. Otherwise, find an idle thread in the thread pool to process the drawing tasks of the drawing task group, determine whether there are idle threads in the thread pool, and wait if there are no idle threads. If there are idle threads, assign the drawing task group to be drawn to the idle thread, and let the thread execute the drawing task. After each task of the drawing task group is completed, save the drawing result of the drawing task group, mark the thread that executes the drawing task of the drawing task group as idle, and delete the drawing task group from the task queue. Repeat the above process until all tasks in the task queue are completed, and synthesize the results of all task drawing and send them to the display.

[0265] The following is a specific example to introduce the advantages of the rendering method of the embodiment of the present application. Figure 4B , Figure 4B It is a single-threaded single-frame drawing schematic diagram provided by an embodiment of the present application; taking the frame to be displayed as an example for displaying five application interfaces, namely, background application, Douyin application, Taobao application, status bar application and navigation bar application, wherein, in split-screen mode, one application (such as Taobao and Douyin) is displayed in the left and right areas of the screen, that is, two applications are displayed side by side. The status bar application is used to display time, battery power, network signal, etc. The navigation bar application is used to switch windows, etc. Both the Taobao application and the Douyin application are free windows, and the z-order of their windows can be changed. Assume that the z-order of the Taobao application is large and the z-order of the Douyin application is small. Then according to the z-order of each application interface from small to large, the drawing order is background, Douyin, Taobao, status bar and navigation bar. When a single thread is used to process the drawing task of the frame to be displayed, the rendering is performed according to the Z order of the application interface. It can be determined that the drawing time of a single frame is the sum of the drawing times of the five applications, that is, t1+t2+t3+t4+t5, a total of 21ms, where t1 is the drawing time of the background application, t2 is the drawing time of the Douyin application, t3 is the drawing time of the Taobao application, t4 is the drawing time of the status bar application, and t5 is the drawing time of the navigation bar application. t1=3ms, t2=10ms, t3=6ms, t4=1ms, t5=1ms.

[0266] refer to Figure 4C , Figure 4C is a multi-threaded drawing schematic diagram provided by an embodiment of the present application; when the rendering method of the embodiment of the present application is used to process the drawing task of the above-mentioned frame to be displayed, assuming that the CPU of the electronic device has three cores, it can be divided into at most three drawing task groups, and the maximum value of M is 3. Figure 2The grouping result finally determined by the method shown is: the first drawing task group includes background applications and TikTok applications at a ratio of 0.4. The second group of drawing tasks includes TikTok applications at a ratio of 0.6 and Taobao applications at a ratio of 0.4. The third group of drawing tasks includes Taobao applications at a ratio of 0.6, a status bar and a navigation bar. Since the grouping results determined by the rendering method of the present application can make the drawing time of each drawing task group equal or close, the single-frame drawing time is the drawing time of any drawing task group. Taking the first group of drawing tasks as an example, the single-frame drawing time is t1+t2-1+β+M*α=3+4+0.5+3*0.5=9ms. Compared with the single-threaded case, the rendering efficiency can be improved by 57.1%. In addition, in an embodiment of the present application, the rendering of five application interfaces can be completed in one process, so cross-window animation can be supported.

[0267] The following is a detailed description of the method for splitting the user interface provided in an embodiment of the present application.

[0268] refer to Figure 5 , Figure 5 : is a flowchart of another rendering method provided by an embodiment of the present application. The rendering method includes the following steps:

[0269] 501. Split the rendering tree corresponding to the user interface to obtain at least two spatial trees.

[0270] The user interface is at least one application interface. The state operation of the drawing nodes in each space tree remains unchanged before and after the splitting, and the state operation is an operation of modifying the properties of the canvas. The at least two space trees are used to render the user interface.

[0271] Specifically, since the design composition logic of the controls of the application interface is a parent-child relationship, for example, a button control, its parent node is the background of the button, and the child node is the text on the button, etc. This type of parent-child relationship constitutes a complete rendering tree. Each node on the rendering tree includes layout information and recorded drawing operation information. Since the organizational relationship of the controls may have a mezzanine structure, that is, the rendering nodes may be coupled in space, the drawing of two-dimensional controls is a series of stateful and sequential operations. If you want to split the drawing tasks of the application interface, you must ensure that the state and order of each drawing task after the split are consistent with the original serial drawing. Therefore, when splitting the rendering tree, the embodiment of the present application splits the drawing nodes corresponding to the user interface, and ensures that the state operation of the drawing nodes before and after the split remains unchanged, so as to split and obtain at least two spatial trees. Among them, the specific number of spatial trees can be determined according to actual conditions.

[0272] In an embodiment of the present application, the rendering tree corresponding to the user interface is split into at least two spatial trees, and the state operation of the drawing nodes in each spatial tree is ensured to remain unchanged before and after the split. In this way, when the above-mentioned user interface is rendered using at least two spatial trees, the correctness of the rendering result of the user interface can be ensured. In addition, the rendering task of the user interface is split into at least two spatial trees, and when rendering is performed using at least two spatial trees, correct parallel rendering can be supported.

[0273] In a possible implementation, the rendering areas corresponding to the at least two spatial trees overlap, which can reduce the time required for splitting the rendering tree and improve the efficiency of splitting the rendering tree.

[0274] In a possible implementation, when the rendering areas overlap, the rendering result of the overlapping parts may be wrong. Therefore, in the embodiment of the present application, the rendering areas corresponding to the at least two spatial trees do not overlap. The non-overlapping rendering areas refer to the complete non-overlapping rendering areas, which can further ensure the correctness of the rendering result of the user interface.

[0275] In a possible implementation, the above step 501 includes:

[0276] 511. Determine an external graphic of a rendering area corresponding to each drawing node in the rendering tree.

[0277] In the embodiment of the present application, a drawing node refers to a rendering node in a rendering tree for performing a drawing operation, and a state operation node refers to a rendering node in a rendering tree for performing a state operation. Exemplarily, the drawing node and the state operation node may be the same rendering node, that is, the rendering node is used to perform a drawing operation and a state operation.

[0278] The circumscribed figure refers to a regular figure and / or a figure whose area can be calculated, such as a rectangle, a circle, a square, a trapezoid, etc. Exemplarily, the circumscribed figure in the embodiment of the present application can be an circumscribed figure in the usual sense, that is, the circumscribed figure intersects with each vertex of the rendering area. Also exemplarily, the circumscribed figure in the embodiment of the present application can be a figure containing the rendering area, that is, each vertex of the rendering area does not intersect with the circumscribed figure, but has a certain distance, and the specific value of the distance can be set according to actual needs, and is not particularly limited here.

[0279] Further exemplary, in the embodiment of the present application, the external graphics of the drawing node can be determined according to the layout information of the drawing node (including the position and shape of the rendering area, etc.). Another exemplary method is to directly use the bounding box of the drawing node as the external graphics of the drawing node without re-establishing the external graphics, thus saving processing flow and improving rendering efficiency.

[0280] In the embodiment of the present application, an external graphic corresponding to a rendering area of ​​a drawing node is determined, so as to approximately estimate the drawing load size of the drawing node according to the external graphic.

[0281] 512. Divide the external graphics corresponding to the drawing nodes in the rendering tree into at least two sets.

[0282] Specifically, the difference in the number of circumscribed graphics in any two of the at least two sets is less than a first threshold, and / or the difference in the sum of the areas of the circumscribed graphics in any two of the at least two sets is less than a second threshold. The specific values ​​of the first threshold and the second threshold can be set according to actual conditions without special restrictions, so that the number of circumscribed graphics in any two of the at least two sets is not much different, and / or the sum of the areas of the circumscribed graphics in any two of the at least two sets is not much different. Such division can ensure that the drawing loads between any two of the at least two spatial trees obtained after the splitting are similar, that is, the drawing load can be split in a balanced manner.

[0283] Exemplarily, if the difference in the number of external graphics in any two sets of at least two sets is less than a first threshold, the user interface can be abstracted into a two-dimensional array, and obtaining the external graphics of the drawing node is equivalent to marking in the two-dimensional array. At this time, it can be abstracted into a general problem: how to divide the areas of the two groups of arrays so that the number of external graphics in each area is as equal as possible. The layer-by-layer scanning line algorithm or the segment tree algorithm can be used to solve the above general problem.

[0284] Exemplarily, the rendering areas corresponding to the at least two sets overlap, so that the time required for external graphics division can be reduced. Also exemplarily, the rendering areas corresponding to the at least two sets do not overlap, so that the correctness of the rendering result of the user interface can be further ensured.

[0285] As another example, in order to improve the accuracy of the division of the external graphics, the external graphics may be roughly divided into several small sets, and then the several small sets may be combined according to the first threshold and / or the second threshold to obtain the above-mentioned at least two sets. Each small set may be composed of a preset number of external graphics, or each small set may be composed of a preset number of adjacent external graphics. The specific value of the above-mentioned preset number can be set according to the actual situation without special limitation. For example, the preset number is 2, 3, 4 or 5. Optionally, any two small sets also meet the conditions corresponding to the above-mentioned first threshold and / or second threshold. Similarly, a layer-by-layer scanning line algorithm or a segment tree algorithm may be used to divide and obtain several small sets.

[0286] 513. Split the rendering tree according to at least two sets to obtain at least two spatial trees.

[0287] The space tree corresponding to the set includes the drawing nodes corresponding to the external graphics in the set, and the state operation nodes passed when tracing back from the drawing nodes to the root node of the rendering tree.

[0288] Specifically, since the shapes of the rendering areas corresponding to the drawing nodes are different, it is impossible to accurately divide the drawing nodes. Therefore, in the embodiment of the present application, the drawing nodes can be accurately divided using the external graphics corresponding to the drawing nodes. In addition, when dividing the nodes in the rendering tree, the drawing nodes are divided first, and then the drawing nodes are traced back to the root node of the rendering tree. The state operation nodes passed during the tracing process are classified into the same set as the above-mentioned drawing nodes. In this way, it can be ensured that the state operation of the drawing nodes before and after the division remains unchanged, and the spatial tree obtained after the split can be rendered correctly.

[0289] In addition, when an external graphic is divided, when an external graphic is divided into at least two sets (taking two sets as an example, in this case, a part of the external graphic belongs to a set A, and another part of the external graphic belongs to another set B), when calculating the number of external graphics included in the set, the above at least two sets need to include the external graphic. And the position of the rendering area of ​​the drawing node corresponding to the external graphic covers the rendering area corresponding to at least two spatial trees. Therefore, when rendering, it is assumed that at least two drawing threads process the drawing tasks corresponding to at least two spatial trees corresponding to the above at least two sets. Each drawing thread is responsible for processing the drawing tasks of the external graphic in the set corresponding to the drawing thread. For example, partial area a of the external graphic of the drawing node is located in set A, and the remaining partial area b of the external graphic except partial area a is located in set B. Drawing thread 1 corresponding to the spatial tree corresponding to set A processes the drawing tasks corresponding to partial area a, and drawing thread 2 corresponding to the spatial tree corresponding to set B processes the drawing tasks corresponding to partial area b.

[0290] The following takes the user interface as an application interface as an example to illustrate the specific process of splitting the user interface:

[0291] refer to Fig. 6A , Fig. 6A It is a schematic diagram of a rendering tree provided in an embodiment of the present application. Fig. 6A It is a rendering tree of an application interface, where root is the root node of the rendering tree, node A, node B and node C are state operation nodes, and node D, node E, node F, node G, node H, node I, node J and node K are drawing nodes.

[0292] First, if Figure 6B As shown, Figure 6BIt is a schematic diagram of a bounding box of a drawing node provided in an embodiment of the present application. The layout information of the rendering node is obtained from the rendering tree corresponding to the application interface 601, and then the layout information of the rendering node is used to abstract the drawing node (such as node D, node E, etc.) into a rectangle, that is, a bounding box.

[0293] Next, mark each node (i.e., drawing node) in the area that needs to be rendered, such as Figure 6B The rectangle is divided into two sets. For example, taking the example of dividing the rectangle into two sets, the rectangles corresponding to nodes D, E, J and K are one set, and the rectangles corresponding to nodes H, I, F and G are another set.

[0294] For example, in this embodiment, reference Figure 6C , Figure 6C is a schematic diagram of a rectangle partition provided by an embodiment of the present application; using a layer-by-layer scanning line algorithm (such as Figure 6C The scanning line 602 in the image is used to divide the entire area to be rendered into multiple balanced small areas (i.e., the above-mentioned small sets), that is, the number of rectangles contained in each of the multiple divided small areas is approximately equal (the difference in the number of rectangles in each small area is less than the first threshold), and the small areas include a small area composed of a rectangle corresponding to node D and a rectangle corresponding to node E, a small area composed of a rectangle corresponding to node J and a rectangle corresponding to node K, a small area composed of a rectangle corresponding to node H and a rectangle corresponding to node I, and a small area composed of a rectangle corresponding to node F and a rectangle corresponding to node G. Then, the small areas are combined according to actual needs to obtain at least two sets. For example, taking the example of dividing rectangles to obtain two sets, the small area composed of the rectangle corresponding to node D and the rectangle corresponding to node E, the small area composed of the rectangle corresponding to node J and the rectangle corresponding to node K form one set, and the small area composed of the rectangle corresponding to node H and the rectangle corresponding to node I, and the small area composed of the rectangle corresponding to node F and the rectangle corresponding to node G form another set.

[0295] Furthermore, the rendering tree is traversed according to the at least two sets, thereby constructing at least two spatial trees, wherein the drawing nodes corresponding to the rectangles in the set are classified into the same spatial tree, and for each rectangle in the set, the state operation nodes passed through during the process are traced back from the node corresponding to the rectangle to the root node and classified into the spatial tree where the rectangle is located.

[0296] For example, reference Fig.6D , Fig.6DThis is a marking schematic diagram of a rendering tree provided by an embodiment of the present application. When at least two spatial trees are obtained according to at least two sets, a binary number marking method can be used for division. For example, the rectangles corresponding to nodes D, E, J and K are a set A, and the rectangles corresponding to nodes H, I, F and G are another set B. Since there are two sets, two-digit binary numbers can be used to mark the nodes on the rendering tree. When the node belongs to set B, the first binary number is 1, otherwise it is 0. When the node belongs to set A, the second binary number is 1, otherwise it is 0. Among them, after marking the nodes corresponding to the rectangles and the state operation nodes passed by the nodes corresponding to the rectangles in the set when tracing back to the root node using the above method, at least two spatial trees can be obtained. For example, node D is marked as "01", indicating that node D belongs to set A, and node F is marked as "10", indicating that node F belongs to set B. The root node is marked as "11", indicating that the root node belongs to both set A and set B. Fig.6D The rendering tree is split into Fig. 6E As shown, the space tree 603 corresponding to the set A and the space tree 604 corresponding to the set B show that when the rendering load is measured by the number of rectangles, since the number of rectangles corresponding to the space tree 603 and the space tree 604 is equal, their rendering load accounts for 1 / 2.

[0297] Then, according to the division of the spatial tree, the drawing operation information contained in each spatial tree is packaged into a single task. Since the spatial tree is constructed based on the spatial position of the UI control, each spatial tree represents the drawing task of an area. For example, after the rendering tree is split, the rendering areas corresponding to each spatial tree do not overlap, and the spatial tree can ensure that its drawing operation information is executed in the order of the guaranteed state from bottom to top, so the tasks corresponding to the spatial tree can also be executed in parallel. For example, Fig. 6E As shown, the rendering tree is split into a space tree 603 corresponding to set A and a space tree 604 corresponding to set B. The left half of the application interface 601 can be obtained by rendering according to the space tree 603, and the right half of the application interface 601 can be obtained by rendering according to the space tree 604.

[0298] When the electronic device system has only one foreground application and the application has a heavy load, such as TikTok, the system performance depends on the slowest application, and the execution time of TikTok affects the overall performance. Fig. 6F , Fig. 6FThis is a thread allocation diagram of an application interface provided by an embodiment of the present application; wherein, thread 1 is responsible for processing the rendering tasks of the background application, and the drawing time required for rendering one frame is t1. Thread 2 is responsible for processing the rendering tasks of the Douyin application, and the drawing time required for rendering one frame is t2. Thread 3 is responsible for processing the rendering tasks of the status bar application and the navigation bar application, and the drawing times required for rendering one frame are t3 and t4 respectively. At this time, the time required to complete the rendering of a single frame depends on the thread with the longest drawing time, that is, the drawing time t2 corresponding to thread 2. According to the scheme of the embodiment of the present application, the drawing task of the Douyin application can be split to obtain at least two sub-drawing tasks. At this time, the at least two sub-drawing tasks can be assigned to at least two threads for processing, thereby reducing the drawing time required for a single frame. For example, Douyin is split into a sub-drawing task corresponding to Douyin-1 (the required drawing time is t2-1) and a sub-drawing task corresponding to Douyin-2 (the required drawing time is t2-2). Reference Figure 6G , Figure 6G It is a thread allocation diagram of another application interface provided by an embodiment of the present application. Assume that the sub-drawing task corresponding to Douyin-1 is assigned to thread 1 for processing, and the sub-drawing task corresponding to Douyin-2 continues to be assigned to thread 2 for processing. At this time, the drawing time of a single frame is t2-2. It can be seen that t2-2 is less than the drawing time t2 of Douyin. It can be seen that using the method of the present application, correct parallel rendering can be achieved to improve the rendering efficiency of the application interface.

[0299] The device provided by this application is described below.

[0300] Figure 7 and Figure 8 A schematic diagram of the structure of a possible rendering device provided in an embodiment of the present application. These rendering devices can be used to implement the functions of the above method embodiments, and thus can also achieve the beneficial effects possessed by the above method embodiments. In an embodiment of the present application, the rendering device can be an electronic device, or a module (such as a chip) applied to an electronic device.

[0301] like Figure 7 As shown, the rendering device 700 includes a determination module 701, a division module 702 and a processing module 703. The rendering device 700 is used to implement the above Figure 2 Alternatively, the rendering device 700 may include a method for implementing the above Figure 2 Any function or operation module in the method embodiment shown in the figure may be implemented in whole or in part by software, hardware, firmware or any combination thereof.

[0302] When the rendering device 700 is used to implement Figure 2When the functions in the method embodiment shown are performed, a determination module 701 is used to determine the grouping result corresponding to the frame to be displayed. The frame to be displayed is used to display at least one application interface, and the grouping result is used to group the drawing tasks of the at least one application interface into at least one drawing task group, so that the drawing time of the frame to be displayed is less than or equal to the sum of the drawing time of the at least one application interface. A division module 702 is used to divide the drawing tasks of the at least one application interface into at least one drawing task group according to the grouping result. A processing module 703 is used to process at least one drawing task group using at least one drawing thread to obtain at least one drawing result.

[0303] In a possible implementation, the rendering device 700 further includes a sending module, wherein:

[0304] The sending module is used to send at least one drawing result.

[0305] In a possible implementation, the rendering device 700 further includes a splitting module, wherein:

[0306] A splitting module is used to split the rendering tree corresponding to the user interface to obtain at least two spatial trees. The state operation of the drawing node in each spatial tree remains unchanged before and after the split, and the state operation is an operation of modifying the properties of the canvas. Among them, at least two spatial trees are used to render to obtain a user interface. The user interface is at least one of at least one application interface.

[0307] In a possible implementation, the rendering areas corresponding to the at least two spatial trees do not overlap.

[0308] In a possible implementation, the splitting module is specifically used to: determine the external graphics of the rendering area corresponding to each drawing node in the rendering tree. Divide the external graphics corresponding to each drawing node in the rendering tree into at least two sets. The difference between the number of external graphics in any two of the at least two sets is less than a first threshold, and / or the difference between the sum of the areas of the external graphics in any two of the at least two sets is less than a second threshold. The rendering tree is split according to the at least two sets to obtain at least two spatial trees. The spatial tree corresponding to the set includes the drawing node corresponding to the external graphics in the set, and the state operation node passed when tracing back from the drawing node to the root node of the rendering tree.

[0309] In a possible implementation, the rendering areas corresponding to the at least two sets do not overlap.

[0310] The external graphic of the rendering area corresponding to the drawing node is a bounding box of the rendering area corresponding to the drawing node.

[0311] In a possible implementation, at the same time, one core of a central processing unit (CPU) in the electronic device executes one drawing thread.

[0312] In a possible implementation, the grouping result is a grouping scheme of at least one application interface whose first value satisfies a preset condition, and the first value of the grouping scheme is the sum of the drawing time and the synthesis time of the longest drawing task group corresponding to the grouping scheme.

[0313] In a possible implementation, when the number of drawing task groups in the grouping scheme is two, the grouping scheme of the at least one application interface includes a first grouping scheme, wherein the first grouping scheme is to divide the application interface sequence into two parts of equal drawing time, and the application interface sequence is a sequence obtained by arranging the at least one application interface in a preset order.

[0314] Optionally, the grouping scheme of the at least one application interface further includes a second grouping scheme and / or a third grouping scheme, wherein the second grouping scheme is to move the bisection point to the starting point of the drawing task of the first application interface when the bisection point is within the drawing task range of the first application interface. The bisection point is a position corresponding to dividing the application interface sequence into two parts of equal drawing time, and the first application interface is one of the at least one application interface.

[0315] The third grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the end point of the drawing task of the first application interface.

[0316] In a possible implementation, when the number of drawing task groups in the grouping scheme is M, M is greater than or equal to three, and the grouping scheme of the above-mentioned at least one application interface includes a fourth grouping scheme, and the fourth grouping scheme is to divide the application interface sequence into M parts with equal drawing time.

[0317] Optionally, the grouping scheme of at least one application interface further includes a fifth grouping scheme, wherein when the first M sub-point is within the drawing task range of the first application interface, the positions of M-2 of the M-1 M sub-points of the application interface sequence are fixed, and the first M sub-point is moved to the starting point of the drawing task of the first application interface. The M-1 M sub-points are positions corresponding to dividing the application interface sequence into M parts of equal drawing duration, and the first M sub-point is any one of the M-1 M sub-points.

[0318] Optionally, the grouping scheme of the above-mentioned at least one application interface also includes a sixth grouping scheme, and the above-mentioned sixth grouping scheme is that when the first M sub-points are located within the drawing task range of the first application interface, M-2 of the M-1 M sub-points of the above-mentioned application interface sequence are fixed, and the above-mentioned first M sub-points are moved to the end point of the drawing task of the first application interface.

[0319] In a possible implementation manner, the drawing duration of the drawing task group is at least one of the following:

[0320] When the drawing task group includes a drawing task of a complete application interface, the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group;

[0321] When the drawing task group includes a drawing task of an incomplete application interface, the drawing duration of the drawing task group is a first drawing duration, the first drawing duration is the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the segmentation duration, and the segmentation duration is the product of the number of incomplete application interfaces and the segmentation overhead;

[0322] When the drawing task group includes a drawing task of a complete application interface and a drawing task of an incomplete application interface, the drawing duration of the drawing task group is the second drawing duration, the second drawing duration is the sum of the first drawing duration and the third drawing duration, and the third drawing duration is the sum of the drawing durations of the complete application interface included in the drawing task group.

[0323] In a possible implementation, the drawing time of the complete application interface is any one of the following:

[0324] the weighted average drawing time of the application interface, where the weighted average drawing time is a weighted calculation value of the fourth drawing time, the fifth drawing time, and their respective weights, the fourth drawing time is the actually measured drawing time of the application interface in the second frame before the frame to be displayed, and the fifth drawing time is the actually measured drawing time of the application interface in the frame before the frame to be displayed;

[0325] The total number of rendering instructions of the application interface, where the total number of rendering instructions is a weighted calculation value of the number of different types of rendering instructions and their corresponding weights.

[0326] like Figure 8 As shown, the rendering device 800 includes a splitting module 801. The rendering device 800 is used to implement the above Figure 5 Alternatively, the rendering device 800 may include a method for implementing the above Figure 5 Any function or operation module in the method embodiment shown in the figure may be implemented in whole or in part by software, hardware, firmware or any combination thereof.

[0327] When the rendering device 800 is used to implement Figure 5 In the function of the method embodiment shown, the splitting module 801 is used to split the rendering tree corresponding to the user interface to obtain at least two spatial trees. The state operation of the drawing node in each spatial tree remains unchanged before and after the split, and the state operation is an operation to modify the properties of the canvas. The above-mentioned at least two spatial trees are used to render the user interface.

[0328] In a possible implementation, the rendering areas corresponding to the at least two spatial trees do not overlap.

[0329] In a possible implementation manner, the splitting module 801 is specifically used to:

[0330] Determine the external graphics of the rendering area corresponding to each drawing node in the rendering tree. Divide the external graphics corresponding to the drawing nodes in the rendering tree into at least two sets. The difference between the number of external graphics in any two of the at least two sets is less than a first threshold, and / or the difference between the sum of the areas of the external graphics in any two of the at least two sets is less than a second threshold. Split the rendering tree according to the at least two sets to obtain at least two spatial trees. The spatial tree corresponding to the set includes the drawing nodes corresponding to the external graphics in the set, and the state operation nodes passed when tracing back from the drawing node to the root node of the rendering tree. In a possible implementation, the rendering areas corresponding to the at least two sets do not overlap.

[0331] In a possible implementation manner, the external graphic of the rendering area corresponding to the rendering node is a bounding box of the rendering area corresponding to the rendering node.

[0332] In a possible implementation, the rendering device further includes a determination module, wherein:

[0333] The determination module is used to determine the grouping result of the frames to be displayed. The frames to be displayed are used to display the at least one application interface. The grouping result is used to group the drawing tasks of the at least one application interface into at least one drawing task group so that the drawing time of the frames to be displayed is less than or equal to the sum of the drawing time of the at least one application interface.

[0334] In a possible implementation, the rendering device further includes a division module and a processing module, wherein:

[0335] The division module is used to divide the drawing tasks of at least one application interface into at least one drawing task group according to the grouping result.

[0336] The processing module is used to process the drawing tasks of at least one drawing task group using at least one drawing thread to obtain at least one drawing result, and the at least one drawing result is used to synthesize the total drawing result of the frame to be displayed.

[0337] In a possible implementation, the rendering device further includes a sending module, wherein:

[0338] The sending module is used to send at least one drawing result.

[0339] In a possible implementation, at the same time, a core of a central processing unit (CPU) in the electronic device executes a drawing thread.

[0340] In a possible implementation, the grouping result is a grouping scheme of at least one application interface whose first value satisfies a preset condition, the first value of the grouping scheme is the sum of the drawing time and the synthesis time of the longest drawing task group corresponding to the grouping scheme, and the synthesis time is the product of the number of drawing task groups in the grouping scheme and the synthesis overhead.

[0341] In a possible implementation, when the number of drawing task groups in the grouping scheme is two, the grouping scheme of the above-mentioned at least one application interface includes a first grouping scheme, and the first grouping scheme is to divide the application interface sequence into two parts with equal drawing time, and the above-mentioned application interface sequence is a sequence obtained by arranging the above-mentioned at least one application interface in a preset order.

[0342] Optionally, the grouping scheme of the at least one application interface further includes a second grouping scheme and / or a third grouping scheme, and the second grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the starting point of the drawing task of the first application interface. The bisection point is the position corresponding to dividing the application interface sequence into two parts of equal drawing time, and the first application interface is one of the at least one application interface.

[0343] The third grouping scheme is that when the bisection point is within the drawing task range of the first application interface, the bisection point is moved to the end point of the drawing task of the first application interface.

[0344] In a possible implementation, when the number of drawing task groups in the grouping scheme is M, M is greater than or equal to three, and the grouping scheme of the above-mentioned at least one application interface includes a fourth grouping scheme, and the fourth grouping scheme is to divide the application interface sequence into M parts with equal drawing time.

[0345] Optionally, the grouping scheme of at least one application interface further includes a fifth grouping scheme, wherein when the first M sub-point is within the drawing task range of the first application interface, the positions of M-2 of the M-1 M sub-points of the application interface sequence are fixed, and the first M sub-point is moved to the starting point of the drawing task of the first application interface. The M-1 M sub-points are positions corresponding to dividing the application interface sequence into M parts of equal drawing duration, and the first M sub-point is any one of the M-1 M sub-points.

[0346] Optionally, the grouping scheme of the above-mentioned at least one application interface also includes a sixth grouping scheme, and the above-mentioned sixth grouping scheme is that when the first M sub-points are located within the drawing task range of the first application interface, M-2 of the M-1 M sub-points of the above-mentioned application interface sequence are fixed, and the above-mentioned first M sub-points are moved to the end point of the drawing task of the first application interface.

[0347] In a possible implementation, the drawing duration of the drawing task group is at least one of the following:

[0348] When the drawing task group includes the drawing task of a complete application interface, "include" here means only including, and the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group.

[0349] When the drawing task group includes the drawing task of an incomplete application interface, "include" here means only including, the drawing duration of the drawing task group is the first drawing duration, the first drawing duration is the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the sum of the split durations, and the split duration is the product of the number of incomplete application interfaces and the splitting overhead.

[0350] When the drawing task group includes drawing tasks of a complete application interface and drawing tasks of an incomplete application interface, "include" here means only including, the drawing time of the drawing task group is the second drawing time, the second drawing time is the sum of the first drawing time and the third drawing time, and the third drawing time is the sum of the drawing times of the complete application interface included in the drawing task group.

[0351] In a possible implementation, the drawing time of a complete application interface is any of the following:

[0352] The weighted average drawing time of the application interface, where the weighted average drawing time is a weighted calculation value of the fourth drawing time, the fifth drawing time, and their respective weights, the fourth drawing time is the actually measured drawing time of the application interface in the second frame before the frame to be displayed, and the fifth drawing time is the actually measured drawing time of the application interface in the frame before the frame to be displayed.

[0353] The total number of rendering instructions of the application interface, where the total number of rendering instructions is a weighted calculation value of the number of different types of rendering instructions and their corresponding weights.

[0354] The present application also provides an electronic device, Fig. 9 The electronic device 900 shown includes a memory 901, a processor 902, a communication interface 904 and a bus 903. The memory 901, the processor 902 and the communication interface 904 are connected to each other through the bus 903.

[0355] The memory 901 may be a read-only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM). The memory 901 may store a program. When the program stored in the memory 901 is executed by the processor 902, the processor 902 and the communication interface 904 are used to execute the various steps of the rendering method of the embodiment of the present application.

[0356] The processor 902 can adopt a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the functions required to be performed by the units in the rendering device of the embodiment of the present application, or to execute the rendering method of the embodiment of the present application.

[0357] The processor 902 may also be an integrated circuit chip having signal processing capabilities. In the implementation process, each step of the rendering method of the embodiment of the present application may be completed by an integrated logic circuit of hardware or software instructions in the processor 902. The above-mentioned processor 902 may also be a general-purpose processor, a digital signal processor (DigitalSignal Processing, DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (Field ProgrammableGate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the rendering method in conjunction with the embodiment of the present application may be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in a decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 901, and the processor 902 reads the information in the memory 901, and combines its hardware to complete the functions required to be performed by the units included in the rendering device of the embodiment of the present application, or executes the rendering method of the embodiment of the present application.

[0358] The communication interface 904 uses a transceiver such as, but not limited to, a transceiver to implement communication between the electronic device 900 and other devices or a communication network. For example, data can be acquired through the communication interface 904 .

[0359] The bus 903 may include a path for transmitting information between various components of the electronic device 900 (eg, the memory 901 , the processor 902 , and the communication interface 904 ).

[0360] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0361] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0362] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0363] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.

[0364] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A rendering method, characterized in that: The method comprises: Determine a grouping result of frames to be displayed, wherein the frames to be displayed are used to display at least one application interface, and the grouping result is used to group the drawing tasks of the at least one application interface into at least one drawing task group, so that the drawing time of the frames to be displayed is less than or equal to the sum of the drawing time of the at least one application interface; Dividing the drawing task of the at least one application interface into the at least one drawing task group according to the grouping result; At least one drawing thread is used to process the drawing tasks of the at least one drawing task group to obtain at least one drawing result, and the at least one drawing result is used to synthesize and obtain the total drawing result of the frame to be displayed.

2. The method according to claim 1, characterized in that: The method further comprises: The at least one drawing result is sent.

3. The method according to claim 1 or 2, characterized in that: The method further comprises: The rendering tree corresponding to the user interface is split to obtain at least two spatial trees, and the state operation of the drawing nodes in each of the spatial trees remains unchanged before and after the splitting, and the state operation is an operation of modifying the properties of the canvas; the at least two spatial trees are used to render the user interface, and the user interface is at least one of the at least one application interface.

4. The method according to claim 3, characterized in that The rendering areas corresponding to the at least two spatial trees do not overlap.

5. The method according to claim 3 or 4, characterized in that: The rendering tree corresponding to the user interface is split to obtain at least two space trees, including: Determine an external graphic of a rendering area corresponding to each rendering node in the rendering tree; Dividing the circumscribed graphics corresponding to each rendering node in the rendering tree into at least two sets, wherein a difference between the numbers of the circumscribed graphics in any two of the at least two sets is less than a first threshold, and / or a difference between the sums of the areas of the circumscribed graphics in any two of the at least two sets is less than a second threshold; The rendering tree is split according to the at least two sets to obtain the at least two spatial trees.

6. The method according to claim 5, characterized in that The rendering areas corresponding to the at least two sets do not overlap.

7. The method according to claim 5 or 6, characterized in that: The external graphic of the rendering area corresponding to the rendering node is a bounding box of the rendering area corresponding to the rendering node.

8. The method according to any one of claims 1 to 7, characterized in that: At the same time, one core of the central processing unit (CPU) in the electronic device executes one of the drawing threads.

9. The method according to any one of claims 1 to 8, characterized in that: The grouping result is a grouping scheme of the at least one application interface whose first value satisfies a preset condition, and the first value of the grouping scheme is the sum of the drawing duration and the synthesis duration of the longest drawing task group corresponding to the grouping scheme.

10. The method according to claim 9, characterized in that The drawing duration of the drawing task group is at least one of the following: When the drawing task group includes a drawing task of a complete application interface, the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group; When the drawing task group includes a drawing task of an incomplete application interface, the drawing duration of the drawing task group is a first drawing duration, which is the sum of the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the segmentation duration, and the segmentation duration is the product of the number of the incomplete application interfaces and the segmentation overhead; When the drawing task group includes a drawing task of a complete application interface and a drawing task of an incomplete application interface, the drawing duration of the drawing task group is a second drawing duration, the second drawing duration is the sum of the first drawing duration and a third drawing duration, and the third drawing duration is the sum of the drawing durations of the complete application interfaces included in the drawing task group.

11. The method according to claim 10, characterized in that The drawing time of the complete application interface is any one of the following: a weighted average drawing time of the application interface, wherein the weighted average drawing time is a weighted calculation value of a fourth drawing time, a fifth drawing time and their respective weights, the fourth drawing time is an actually measured drawing time of the application interface in a second frame before the frame to be displayed, and the fifth drawing time is an actually measured drawing time of the application interface in a frame before the frame to be displayed; The total number of rendering instructions of the application interface, wherein the total number of rendering instructions is a weighted calculation value of the number of different types of rendering instructions and their corresponding weights.

12. A rendering method, characterized in that: The method comprises: The rendering tree corresponding to the user interface is split to obtain at least two spatial trees, wherein the state operation of the drawing nodes in each of the spatial trees remains unchanged before and after the splitting, and the state operation is an operation of modifying the properties of the canvas; and the at least two spatial trees are used to render the user interface.

13. The method according to claim 12, characterized in that The rendering areas corresponding to the at least two spatial trees do not overlap.

14. The method according to claim 12 or 13, characterized in that The rendering tree corresponding to the user interface is split to obtain at least two space trees, including: Determine an external graphic of a rendering area corresponding to each rendering node in the rendering tree; Dividing the external graphics corresponding to the drawing nodes in the rendering tree into at least two sets, wherein the difference between the numbers of the external graphics in any two of the at least two sets is less than a first threshold, and / or the difference between the sums of the areas of the external graphics in any two of the at least two sets is less than a second threshold; The rendering tree is split according to the at least two sets to obtain the at least two spatial trees, wherein the spatial tree corresponding to the set includes a drawing node corresponding to the external graphics in the set and a state operation node passed when tracing back from the drawing node to the root node of the rendering tree.

15. The method according to claim 14, characterized in that The rendering areas corresponding to the at least two sets do not overlap.

16. The method according to claim 14 or 15, characterized in that The external graphic of the rendering area corresponding to the rendering node is a bounding box of the rendering area corresponding to the rendering node.

17. A rendering device, characterized in that: include: a determination module, configured to determine a grouping result of frames to be displayed, wherein the frames to be displayed are used to display at least one application interface, and the grouping result is used to group the drawing tasks of the at least one application interface into at least one drawing task group, so that the drawing time of the frames to be displayed is less than or equal to the sum of the drawing time of the at least one application interface; A division module, used for dividing the drawing task of the at least one application interface into the at least one drawing task group according to the grouping result; The processing module is used to use at least one drawing thread to process the drawing tasks of the at least one drawing task group to obtain at least one drawing result, and the at least one drawing result is used to synthesize and obtain the total drawing result of the frame to be displayed.

18. The device according to claim 17, characterized in that The device also includes: A sending module is used to send the at least one drawing result.

19. The device according to claim 17 or 18, characterized in that The device also includes: A splitting module is used to split the rendering tree corresponding to the user interface to obtain at least two spatial trees, and the state operation of the drawing nodes in each of the spatial trees remains unchanged before and after the splitting, and the state operation is an operation to modify the properties of the canvas; the at least two spatial trees are used to render the user interface, and the user interface is at least one of the at least one application interface.

20. The device according to claim 19, characterized in that The rendering areas corresponding to the at least two spatial trees do not overlap.

21. The device according to claim 19 or 20, characterized in that The splitting module is specifically used for: Determine an external graphic of a rendering area corresponding to each rendering node in the rendering tree; Dividing the circumscribed graphics corresponding to each rendering node in the rendering tree into at least two sets, wherein a difference between the numbers of the circumscribed graphics in any two of the at least two sets is less than a first threshold, and / or a difference between the sums of the areas of the circumscribed graphics in any two of the at least two sets is less than a second threshold; The rendering tree is split according to the at least two sets to obtain the at least two spatial trees.

22. The device according to claim 21, characterized in that The rendering areas corresponding to the at least two sets do not overlap.

23. The device according to claim 21 or 22, characterized in that The external graphic of the rendering area corresponding to the rendering node is a bounding box of the rendering area corresponding to the rendering node.

24. The device according to any one of claims 17 to 23, characterized in that At the same time, one core of the central processing unit (CPU) in the electronic device executes one of the drawing threads.

25. The device according to any one of claims 17 to 24, characterized in that The grouping result is a grouping scheme of the at least one application interface whose first value satisfies a preset condition, and the first value of the grouping scheme is the sum of the drawing duration and the synthesis duration of the longest drawing task group corresponding to the grouping scheme.

26. The device according to claim 25, characterized in that The drawing duration of the drawing task group is at least one of the following: When the drawing task group includes a drawing task of a complete application interface, the drawing duration of the drawing task group is the sum of the drawing durations of the complete application interfaces included in the drawing task group; When the drawing task group includes a drawing task of an incomplete application interface, the drawing duration of the drawing task group is a first drawing duration, which is the sum of the sum of the drawing durations of the incomplete application interfaces included in the drawing task group and the segmentation duration, and the segmentation duration is the product of the number of the incomplete application interfaces and the segmentation overhead; When the drawing task group includes a drawing task of a complete application interface and a drawing task of an incomplete application interface, the drawing duration of the drawing task group is a second drawing duration, the second drawing duration is the sum of the first drawing duration and a third drawing duration, and the third drawing duration is the sum of the drawing durations of the complete application interfaces included in the drawing task group.

27. The device according to claim 26, characterized in that The drawing time of the complete application interface is any one of the following: a weighted average drawing time of the application interface, wherein the weighted average drawing time is a weighted calculation value of a fourth drawing time, a fifth drawing time and their respective weights, the fourth drawing time is an actually measured drawing time of the application interface in a second frame before the frame to be displayed, and the fifth drawing time is an actually measured drawing time of the application interface in a frame before the frame to be displayed; The total number of rendering instructions of the application interface, wherein the total number of rendering instructions is a weighted calculation value of the number of different types of rendering instructions and their corresponding weights.

28. A rendering device, characterized in that: include: A splitting module is used to split the rendering tree corresponding to the user interface to obtain at least two spatial trees, wherein the state operation of the drawing nodes in each of the spatial trees remains unchanged before and after the splitting, and the state operation is an operation for modifying the properties of the canvas; the at least two spatial trees are used to render the user interface.

29. The device according to claim 28, characterized in that The rendering areas corresponding to the at least two spatial trees do not overlap.

30. The device according to claim 28 or 29, characterized in that The splitting module is specifically used for: Determine an external graphic of a rendering area corresponding to each rendering node in the rendering tree; Dividing the external graphics corresponding to the drawing nodes in the rendering tree into at least two sets, wherein the difference between the numbers of the external graphics in any two of the at least two sets is less than a first threshold, and / or the difference between the sums of the areas of the external graphics in any two of the at least two sets is less than a second threshold; The rendering tree is split according to the at least two sets to obtain the at least two spatial trees, wherein the spatial tree corresponding to the set includes a drawing node corresponding to the external graphics in the set and a state operation node passed when tracing back from the drawing node to the root node of the rendering tree.

31. The device according to claim 30, characterized in that The rendering areas corresponding to the at least two sets do not overlap.

32. The device according to claim 30 or 31, characterized in that The external graphic of the rendering area corresponding to the rendering node is a bounding box of the rendering area corresponding to the rendering node.

33. An electronic device, characterized in that: It comprises a processor and a memory, wherein the processor and the memory are connected, wherein the memory is used to store program code, and the processor is used to call the program code to execute the rendering method according to any one of claims 1 to 16.

34. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the rendering method according to any one of claims 1 to 16.

Citation Information

Cited By

  • Rendering method and related device

    EP4478187A1

  • Rendering method and related device

    WO2024183771A1