Window drawing method and device, electronic equipment, chip and storage medium
By directly manipulating the outline parameters of the root layout at the application layer and using a hardware compositing module to draw window rounded corners, the high energy consumption and poor performance of GPU compositing for window rounded corners in existing technologies are solved, achieving a more efficient drawing effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING XIAOMI MOBILE SOFTWARE CO LTD
- Filing Date
- 2024-10-28
- Publication Date
- 2026-04-28
AI Technical Summary
In existing mobile operating systems, GPU compositing of rounded corners for windows consumes a lot of energy and performs poorly, especially in multi-layered scenes, which leads to GPU resource shortages and performance degradation.
By directly manipulating the outline parameters of the root layout in the application layer module, the window rounded corners are drawn using the hardware compositing module, avoiding GPU compositing. The drawing parameter information is transmitted using the binder communication mechanism, and the drawing process is optimized by combining buffer management.
It reduces GPU load, avoids GPU resource shortages and contention, improves the rendering efficiency and performance of rounded corners in windows, and reduces frame drops.
Smart Images

Figure CN121934799A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing, and more particularly to a window drawing method, apparatus, electronic device, chip, and storage medium. Background Technology
[0002] In existing mobile operating systems, window rendering typically relies on two methods: hardware compositing (HWC) or graphics processing unit (GPU) compositing. Due to their complexity, rounded corners are generally rendered using GPU compositing. However, rendering rounded corners via GPU is energy-intensive and suffers from poor performance due to the complexity of the process. Summary of the Invention
[0003] This disclosure provides a window drawing method, apparatus, electronic device, chip, and storage medium to solve problems in the related art.
[0004] The first aspect of this disclosure provides a window drawing method, which includes: a first frame layer module obtaining drawing parameter information of a first window and passing the drawing parameter information of the first window to a second frame layer module; an application layer module receiving the drawing parameter information of the first window passed by the second frame layer module and updating the outline parameters of the first window in the root layout according to the drawing parameter information of the first window; and the application layer module drawing the first window according to the outline parameters to obtain the drawing result of the first window.
[0005] In some embodiments of this disclosure, the method further includes: the application layer module storing the drawing result of the first window into a first buffer; the first local layer module obtaining the drawing result of the first window from the first buffer, and the drawing result being used by the hardware synthesis module to synthesize the layers of the first window.
[0006] In some embodiments of this disclosure, the method further includes: a first frame layer module transmitting the drawing parameter information of the first window to a second frame layer module via a first binder communication; and the second frame layer module transmitting the drawing parameter information of the first window to an application layer module via a second binder communication.
[0007] In some embodiments of this disclosure, the method further includes: a second frame layer module detecting whether the information transmitted by the first frame layer module contains drawing parameter information of the first window; if the drawing parameter information of the first window is included, the second frame layer module determining whether the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time; if the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time, the second frame layer module transmitting the drawing parameter information transmitted this time to the application layer module.
[0008] In some embodiments of this disclosure, the application layer module draws a first window based on contour parameters, and the drawing result of the first window includes: the application layer module scheduling a second local layer module to determine the display parameters of the first window based on the contour parameters, wherein the display parameters include at least one of RGB values and transparency; and the second local layer module generating the drawing result of the first window based on the display parameters of the first window.
[0009] In some embodiments of this disclosure, the application layer module stores the drawing result of the first window into the first buffer, which includes: determining whether the display parameters of the second window stored in the first buffer are different from the display parameters of the first window; and when the display parameters of the second window are different from the display parameters of the first window, replacing the display parameters of the second window with the display parameters of the first window.
[0010] A second aspect of this disclosure provides a window drawing apparatus, comprising: an acquisition module for a first frame layer module to acquire drawing parameter information of a first window and transmit the drawing parameter information of the first window to a second frame layer module; a processing module for an application layer module to receive the drawing parameter information of the first window transmitted by the second frame layer module and update the outline parameters of the first window in the root layout according to the drawing parameter information of the first window; and a drawing module for the application layer module to draw the first window according to the outline parameters and obtain the drawing result of the first window.
[0011] A third aspect of this disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods described in the first aspect of this disclosure.
[0012] A fourth aspect of this disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the methods described in the first aspect of this disclosure.
[0013] A fifth aspect of this disclosure provides a chip characterized by including at least one processor and a communication interface; the communication interface is used to receive signals input to the chip or signals output from the chip, and the processor communicates with the communication interface and implements the method described in the first aspect of this disclosure through logic circuits or executing code instructions.
[0014] In summary, the window drawing method proposed in this disclosure can pass the drawing parameters of rounded corners to the application layer module, and directly operate on the root layout of the application layer module. It can synthesize rounded corners through hardware, avoiding the problems of poor performance and high power consumption caused by GPU synthesis of rounded corners.
[0015] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0017] Figure 1 A flowchart illustrating a window drawing method provided in this embodiment of the disclosure. Figure 1 ;
[0018] Figure 2 A flowchart illustrating a window drawing method provided in this embodiment of the disclosure. Figure 2 ;
[0019] Figure 3 A flowchart illustrating a window drawing method provided in this embodiment of the disclosure. Figure 3 ;
[0020] Figure 4 A flowchart illustrating an application-side method for drawing rounded corners of a window, as provided in this embodiment of the disclosure. Figure 1 ;
[0021] Figure 5 A flowchart illustrating an application-side method for drawing rounded corners of a window, as provided in this embodiment of the disclosure. Figure 2 ;
[0022] Figure 6 This is a schematic diagram of the structure of a window drawing device provided in an embodiment of the present disclosure;
[0023] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure;
[0024] Figure 8 This is a schematic diagram of the chip structure provided in an embodiment of this disclosure. Detailed Implementation
[0025] Embodiments of this disclosure are described in detail below. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting this disclosure.
[0026] In existing Android systems, window rendering typically relies on two methods: hardware compositing and GPU compositing. Due to their complexity, rounded corners are generally rendered using GPU compositing. However, its high power consumption and performance bottlenecks for complex operations are major issues, especially in multi-layered scenarios where the GPU may exhaust resources, leading to performance degradation. HWC compositing relies on the hardware display controller to handle simple layer operations, offering low power consumption and high efficiency, but its functionality is limited and it cannot handle complex rounded corner effects. Therefore, it needs to be handled by the GPU, increasing system overhead.
[0027] In addition, because the display system service (SurfaceFlinger) has a high priority in GPU resource allocation, excessively long GPU compositing times can preempt business GPU resources, leading to long application rendering thread times and causing stuttering. To solve the problem of high GPU overhead caused by the SurfaceFlinger process when drawing rounded corners on the window side, we need to adopt a new approach to draw the same effect of rounded corners on the window without using SurfaceFlinger's GPU compositing.
[0028] Therefore, to address the aforementioned issues, this disclosure proposes a window rendering method, primarily applicable to scenarios requiring rounded corners, such as application entry / exit animations and freeform windows. These scenarios involve a large number of layers, and rendering rounded corners on the application side can effectively reduce the high GPU load caused by Surface Flinger GPU compositing.
[0029] The specific details of this method are as follows.
[0030] Figure 1 A flowchart illustrating a window drawing method provided in this embodiment of the disclosure. Figure 1 .like Figure 1 As shown, the method may include the following steps.
[0031] Step 101: The first frame layer module obtains the drawing parameter information of the first window and passes the drawing parameter information of the first window to the second frame layer module.
[0032] In some embodiments, the first frame layer module may optionally be WM Shell, which can be used to obtain drawing parameter information of the first window. For example, WM Shell can read the default initial value of rounded corners stored in the system. Alternatively, the second frame layer module may be WM Core, which can pass the received window drawing parameter information to the application layer module.
[0033] In some embodiments, the method further includes: a first frame layer module transmitting drawing parameter information of a first window to a second frame layer module via a first binder communication; and a second frame layer module transmitting drawing parameter information of a first window to an application layer module via a second binder communication.
[0034] For example, binder communication refers to an inter-process communication (IPC) mechanism in the Android operating system that allows data exchange and communication between different processes.
[0035] In other words, the first frame layer module and the second frame layer module can exchange window drawing parameter information, such as window rounded corner drawing parameters, through the binder communication mechanism; the second frame layer module and the application layer module can also exchange window drawing parameter information, such as window rounded corner drawing parameters, through the binder communication mechanism. Optionally, the first frame layer module and the second frame layer module, and the second frame layer module and the application layer module, can also exchange other parameter information through the binder communication mechanism. In this case, the window drawing parameter information can be transmitted along with other parameter information, that is, the window drawing parameter information can be transmitted alone or along with other information, and this disclosure does not limit this.
[0036] In the above embodiments, for example, when the first frame layer module is WM Shell, the second frame layer module is WMCore, and the application layer module is APP, and the window drawing parameter information is the window rounded corner drawing parameter, since WM Shell cannot communicate directly with APP, in order to pass the rounded corner drawing parameter to the APP side, it is necessary to pass the rounded corner parameter information through WM Core. At this time, there are their own data synchronization and update mechanisms between WM Shell and WM Core, and between WM Core and APP, such as the binder communication mechanism. We add the transmission of rounded corner parameter information to both of these update mechanisms, which can enable WM Shell to pass the obtained rounded corner parameter information to APP.
[0037] In some embodiments, the rounded corner parameter information can be passed to the APP side, which can be done by passing the rounded corner parameter information to the outline parameter of the root layout (DecorView) on the APP side. In other words, the APP side can update the outline parameter of the root layout according to the received rounded corner parameter information.
[0038] In some embodiments, optionally, after obtaining the rounded corner parameter information, WM Shell, WM Core, and APP can store the obtained rounded corner parameter information. WM Shell can update the rounded corner parameter information and pass the updated rounded corner parameter information to WM Core. WM Core can determine whether the rounded corner parameter information has been updated based on the stored rounded corner parameter information and the newly received rounded corner parameter information.
[0039] In other words, WM Core can monitor whether the corner radius parameter information passed by WM Shell has been updated based on the stored corner radius parameter information.
[0040] Step 102: The application layer module receives the drawing parameter information of the first window from the second frame layer module, and updates the outline parameters of the first window in the root layout according to the drawing parameter information of the first window.
[0041] In some embodiments, the application layer module can receive the drawing parameter information of the first window transmitted by the second frame layer module through the binder communication mechanism. The application layer module updates the outline parameter of the first window in the root layout according to the drawing parameter information of the first window, which can realize direct operation on the root layout of the application layer module. The outline parameter is the outline parameter when the window is drawn. When the outline parameter is determined, the drawing of other content of the window will not exceed the position limited by the outline parameter. Therefore, the effect of rounded corners of the window can be achieved by determining the outline parameter.
[0042] In other words, contour parameters can limit the boundaries when the window is drawn. Contour parameters can include the style and size of the contour. For example, the contour style can be rectangular or rounded, etc.
[0043] Step 103: The application layer module draws the first window based on the contour parameters and obtains the drawing result of the first window.
[0044] In some embodiments, the application layer module can draw the first window based on contour parameters, for example, draw the boundary of the first window based on contour parameters.
[0045] In some embodiments, the application layer module draws a first window based on contour parameters, and the drawing result of the first window includes: the application layer module scheduling a second local layer module to determine the display parameters of the first window based on the contour parameters, wherein the display parameters include at least one of RGB values and transparency; and the second local layer module generating the drawing result of the first window based on the display parameters of the first window.
[0046] In some embodiments, the second local layer module may optionally be a hardware accelerated rendering engine for user interface (HWUI), that is, HWUI can determine the display parameters of the first window according to the outline parameters, and draw the window according to the display parameters to generate the drawing result of the first window.
[0047] In some embodiments, the method further includes: the application layer module storing the drawing result of the first window into a first buffer; the first local layer module obtaining the drawing result of the first window from the first buffer, and the drawing result being used by the hardware synthesis module to synthesize the layers of the first window.
[0048] In some embodiments, the first buffer may be a buffer, and the drawing result of the first window may include the display parameters corresponding to each position of the first window or each pixel in the first window, such as the RGB value, transparency value, etc. of each pixel.
[0049] In other words, HWUI can determine the display parameters corresponding to each pixel in the first window based on the outline parameters. After determining the display parameters corresponding to all pixels, the drawing result of the first window can be obtained. Optionally, the drawing result of the first window can include all pixels contained in the first window, their respective RGB values and transparency values, etc. HWUI can store the drawing result of the first window into a buffer, or in other words, HWUI can draw the first window in the buffer.
[0050] In some embodiments, when drawing the rounded corners of a window according to the contour parameters, the position of the rounded corners can be determined according to the rounded corner parameter information. Optionally, the RGB values and transparency values of the pixels outside the rounded corners can be set to 0, indicating that the positions of these pixels cannot be filled or drawn, that is, they cannot be drawn outside the contour. This can prevent other sub-layouts from exceeding the contour when drawing, and can achieve window clipping. Alternatively, the RGB values and transparency values of the pixels outside the rounded corners can be set to other values, which are not limited in this disclosure.
[0051] In some embodiments, after the drawing result of the first window is stored in the first buffer, the first local module can obtain the drawing result of the first window from the first buffer. The first local module can be Surface Flinger. In other words, Surface Flinger can obtain the buffer and use the hardware compositing module to compose the layers of the first window. The hardware module can be HWC. In other words, the first window can be composited using HWC based on the drawing result of the first window in the first buffer, which can avoid using GPU compositing.
[0052] In some embodiments, by passing the rounded corner parameter information to the APP side, the outline parameters of the root layout on the APP side can be manipulated. This avoids using the GPU to composite the first window layer during compositing, and the first window layer can be composited solely through hardware. When the outline parameter is set to the rounded corner parameter, the rounded corners of the first window can be generated through hardware compositing. That is, the above-described method of this disclosure can achieve hardware compositing of the rounded corners of the first window, which can improve the drawing efficiency of the window rounded corners, reduce the complexity of implementing the window rounded corners, and avoid problems such as GPU resource shortage, GPU resource contention, and frame dropping caused by the high GPU pressure and high load resulting from GPU compositing.
[0053] In summary, the above embodiments of this disclosure can directly manipulate the root layout of the application layer by passing the drawing parameter information of the first window to the outline parameters of the root layout of the application layer. The first window can be drawn according to the outline parameters, and hardware compositing can be used directly during compositing, avoiding problems such as high pressure, high load, GPU resource shortage, GPU resource contention, and frame dropping caused by GPU compositing.
[0054] Figure 2 A flowchart illustrating a window drawing method provided in this embodiment of the disclosure. Figure 2 .like Figure 2 As shown, based on Figure 1 The illustrated embodiment shows that the method includes the following steps.
[0055] Step 201: The second frame layer module detects whether the information passed by the first frame layer module contains the drawing parameter information of the first window.
[0056] In some embodiments, the second frame layer module can detect whether the information transmitted by the first frame layer module includes the drawing parameter information of the first window. That is, the second frame layer module can listen for the transmission of the drawing parameter information of the first window. Optionally, the drawing parameter information of the first window may be, for example, the rounded corner drawing parameter information.
[0057] In some embodiments, the first frame layer module can update the drawing parameter information of the first window. For example, the first frame layer module can update the stored drawing parameter information of the first window when the system default rounded corner parameter value changes. Or, when the first frame layer module is WM Shell, WM Shell can enlarge and shrink the rounded corners during animation generation, causing the rounded corner parameter value to be updated. When the drawing information of the first window is updated, the first frame layer module can pass the updated drawing parameter information of the first window to the second frame layer module through the binder communication mechanism.
[0058] Step 202: In the case of the drawing parameter information of the first window, the second frame layer module determines whether the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time.
[0059] In some embodiments, when the second frame layer module determines that the drawing parameter information of the first window is included, it can determine whether the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time based on the received drawing parameter information of the first window and the stored drawing parameter information of the first window. That is, it can determine whether the drawing parameters have been updated based on the stored drawing parameters and the newly received drawing parameters.
[0060] Optionally, when the drawing parameters of the first window are the rounded corner drawing information of the first window, such as the rounded corner parameter value of the first window, the stored rounded corner parameter value can be compared with the newly received rounded corner parameter value. If they are different, it can be determined that the drawing parameter information of the first window has been updated.
[0061] Step 203: When the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time, the second frame layer module transmits the drawing parameter information transmitted this time to the application layer module.
[0062] In some embodiments, when the second frame layer module determines that the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time, it indicates that the transmitted drawing parameter information has been updated. At this time, the second frame layer module can transmit the updated drawing parameter information to the application layer module through the binder communication mechanism and update the stored drawing parameter information.
[0063] In some embodiments, when the second frame layer module determines that the drawing parameter information transmitted this time is the same as the drawing parameter information transmitted last time, it indicates that the transmitted drawing parameter information has not been updated. At this time, there is no need to perform the next round of binder communication. That is, the second frame layer module does not need to transmit the newly received drawing parameter information to the application layer module through the binder communication mechanism, and there is no need to update the stored drawing parameter information.
[0064] In summary, according to the above embodiments of this application, when the drawing parameter information of the first window is determined to be updated, the second frame layer module can pass the updated drawing parameter information to the application layer, thereby realizing the synchronous update of the drawing parameter information stored in the application layer, reducing the frequent transmission of drawing parameter information, and ensuring the synchronization of drawing parameter information on the application layer module side.
[0065] Figure 3 A flowchart illustrating a window drawing method provided in this embodiment of the disclosure. Figure 3 .like Figure 3As shown, based on Figure 1 The illustrated embodiment shows that the method includes the following steps.
[0066] Step 301: Determine whether the display parameters of the second window stored in the first buffer are different from the display parameters of the first window.
[0067] In some embodiments, the display parameters of the second window can be the drawing result of the second window currently stored in the first buffer. That is, the second window is the window that was drawn in the first buffer before the first window. In other words, the first buffer can be reused between the second local layer module storing the drawing result of the first window into the first buffer. The first buffer may contain the drawing result of the last drawing.
[0068] In some embodiments, when the second local layer module is HWUI, HWUI can reuse the buffers, for example, three or four buffers can be used in a loop.
[0069] In some embodiments, optionally, when the drawing parameter information of the first window is a rounded corner parameter value, when there are 3 buffers, a buffer reuse scenario is as follows: the first frame buffer is not drawn with rounded corners, that is, the outline of the first frame buffer is in a rectangular filled state. Starting from the second frame, rounded corner drawing is performed, and the outline of the second and third frame buffers is rounded corner filled. At this time, the four corners of the buffer will not have color filling (e.g., RGB value and transparency are both 0). Since the contents of these three buffers are empty before drawing and there is no dirty data, no drawing abnormality will occur during the first drawing, whether it is rectangular filling or rounded corner filling.
[0070] Optionally, when drawing the fourth frame, according to the buffer reuse requirement, the buffer used when drawing the first frame can be used for rounded corners. However, the first buffer is now filled with a rectangle, and the four corners have color fill. When drawing the rounded corners, it is impossible to cover the original rectangle's four corners, resulting in the visual appearance that the rounded corners were not successfully drawn. Therefore, buffer reuse causes the rounded corner drawing to fail.
[0071] In some embodiments, when drawing the first window, it can be determined whether the display parameters of the second window stored in the first buffer differ from the display parameters of the first window. This determines whether the previously drawn content exists in the first buffer and whether there are differences between the previously drawn content and the content being drawn in the current draw. Specifically, when the first buffer does not contain previously drawn content (i.e., the first buffer is empty), the drawing result of the first window can be directly stored in the first buffer without any errors. When the first buffer contains previously drawn content, if there are differences between the previously drawn content and the content being drawn in the current draw, the previously drawn result stored in the first buffer needs to be processed.
[0072] Step 302: When the display parameters of the second window are different from those of the first window, replace the display parameters of the second window with the display parameters of the first window.
[0073] In some embodiments, when the display parameters of the second window are different from those of the first window, the display parameters of the first window can be used to replace the display parameters of the second window. That is, the drawing results of the second window stored in the first buffer can be cleared. For example, the display parameters of the second window stored in the first buffer can be cleared, and the display parameters of the second window can be replaced with the display parameters of the first window, that is, the drawing results of the first window can be stored in the first buffer.
[0074] Optionally, when the drawing parameters of the first window are rounded corner drawing parameters, the display parameters may include the RGB values and transparency of the pixels at the four corners. In this case, if the display parameters of the second window are different from those of the first window, the second window may be filled, while the first window is filled with rounded corners. In this case, the display parameters of the second window stored in the first buffer can be updated according to the display parameters of the first window. For example, the areas at the four corners can be cleared, that is, the RGB values and transparency of the four corners can be set to 0. Then, the RGB values and transparency of the pixels at the four corners can be determined according to the drawing parameters of the first window, so that the display parameters of the first window can be used to replace the display parameters of the second window.
[0075] In summary, the above embodiments of this disclosure can update the data in the buffer in a scenario where the buffer is reused, thus avoiding the failure of the first window to be drawn if there is data in the buffer.
[0076] The technical solutions of this disclosure will be further described in detail below with reference to specific application embodiments.
[0077] The following is a method for drawing rounded corners of an application window provided in this disclosure. This method is mainly used to solve problems such as GPU resource shortage, GPU resource contention, and frame dropping caused by the high GPU pressure and load when Surface Flinger draws rounded corners of windows using GPU compositing. The specific content of the method is as follows.
[0078] This method establishes a seamless corner radius update path across three Android modules: WM Shell -> WM Core -> App. It directly manipulates the root layout to draw rounded corners, achieving a consistent corner radius effect with the Surface Flinger window on the application side. This approach eliminates the need for GPU rendering in Surface Flinger. The specific implementation is as follows:
[0079] 1. Because Android natively requests the drawing of rounded corners in the WM Shell, it's impossible to obtain the application's view information here; only the corresponding Surface Control service can be obtained. When the system needs to draw rounded corners, the WM Shell reads the default initial rounded corner value stored in the system and sets it for the Surface Control. The Surface Control directly passes the set rounded corner information to the Surface Composer Client of the GUI library (libgui) through the binder communication mechanism, and then sets this attribute directly to the corresponding layer. Finally, this rounded corner information is used during GPU compositing.
[0080] To pass the default corner radius read from the WM Shell to the application (APP), corner radius information needs to be passed through WMCore, requiring two rounds of binder communication for the APP to receive the corner radius information. There are separate data synchronization mechanisms between WM Shell and WMCore, and between WM Core and the APP. We add two corner radius value listeners to each of these mechanisms, recording the current corner radius value for each module. When WM Shell performs animations, it sometimes generates scaling information, which causes corresponding scaling changes in the corner radius value. Therefore, it's necessary to synchronize these changes to the APP's root layout (DecorView).
[0081] Each time WM Shell updates, our data listener checks if any rounded corner values have been passed. If so, it compares the current rounded corner value with the previous one. If they are different, it performs the next round of binder passing and updates the rounded corner radius stored in this module. If the passed rounded corner radius is the same as the previous one, it does not need to perform the next round of binder passing. This reduces the frequency of rounded corner value passing.
[0082] The rounded corner information is obtained in the root layout DecorView and then passed to the outline parameter of the root layout. The outline, which defines the style and size of the DecorView, ensures that the content of the entire page will not exceed the size and style of this outline. Normally, the buffer in an application is drawn as a rectangle. When we add a rounded corner attribute to the outline, it is drawn as a rounded rectangle. We achieve rounded corner clipping of the entire window through the outline. As the root layout of the entire window, clipping it prevents its internal child layouts from exceeding this boundary, thus achieving the same effect as rounded corners on the window itself. A detailed functional diagram is shown below. Figure 4 As shown, its architecture diagram is as follows: Figure 5 As shown.
[0083] 2. In addition, some special processing is required to ensure that the rounded corners drawn on the application side are displayed correctly.
[0084] Because HWUI features buffer reuse, typically three to four buffers are used in a loop. Taking three buffers as an example, if the application doesn't perform rounded corner drawing for Decorview in the first frame, the first buffer will be a rectangle filled with color. Starting from the second frame when the application begins rounded corner drawing, the four corners of the second buffer will not be filled with color. Similarly, if rounded corner drawing continues in the third frame, the four corners of the third buffer will also not be filled with color. Since the first three buffers are empty before the content is drawn (i.e., there is no dirty data), no exceptions will occur regardless of whether we draw rounded rectangles or rectangles.
[0085] When drawing the fourth frame, buffer reuse is required. At this time, the application will take the first buffer to draw rounded corners. However, since the buffer is filled with a rectangle, the four corners of the top left and bottom right already have drawing content. The subsequent rounded corner drawing cannot cover the content of the original four corners, resulting in the visual phenomenon that the rounded corners were not successfully drawn.
[0086] To avoid this problem, this solution marks different buffers and the rounded corner information of each buffer in the previous and current drawing. If, during a drawing on a certain buffer, it is found that the rounded corner information of this buffer is different from that in the previous drawing, the four rounded corner areas to be drawn on this buffer will be cleared, thereby avoiding the rounded corner drawing failure caused by buffer reuse at the lowest cost.
[0087] In summary, the above-described examples effectively solve the problems of GPU resource shortage, GPU resource contention, and frame drops caused by the high GPU pressure and load when Surface Flinger renders rounded corners of windows. They reduce the GPU load in multi-window scenarios and minimize the occurrence of GPU resource contention issues.
[0088] Figure 6 This is a schematic diagram of the structure of a window drawing device 600 provided in an embodiment of this disclosure. Figure 6 As shown, the device includes: an acquisition module 610, used by the first frame layer module to acquire the drawing parameter information of the first window and pass the drawing parameter information of the first window to the second frame layer module; a processing module 620, used by the application layer module to receive the drawing parameter information of the first window passed by the second frame layer module and update the outline parameters of the first window in the root layout according to the drawing parameter information of the first window; and a drawing module 630, used by the application layer module to draw the first window according to the outline parameters and obtain the drawing result of the first window.
[0089] In some embodiments, the window drawing apparatus further includes a first processing unit, configured to have the application layer module store the drawing result of the first window into a first buffer; and the first local layer module obtain the drawing result of the first window from the first buffer, the drawing result being used by the hardware compositing module to compose the layers of the first window.
[0090] In some embodiments, the processing module is further configured to have the first frame layer module transmit the drawing parameter information of the first window to the second frame layer module through the first binder communication; and the second frame layer module transmits the drawing parameter information of the first window to the application layer module through the second binder communication.
[0091] In some embodiments, the processing module is further configured to detect whether the information transmitted by the first frame layer module contains drawing parameter information of the first window; if it contains drawing parameter information of the first window, the second frame layer module determines whether the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time; if the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time, the second frame layer module transmits the drawing parameter information transmitted this time to the application layer module.
[0092] In some embodiments, the drawing module is further configured to have the application layer module schedule the second local layer module to determine the display parameters of the first window based on the contour parameters, wherein the display parameters include at least one of RGB values and transparency; and the second local layer module generates the drawing result of the first window based on the display parameters of the first window.
[0093] In some embodiments, the first processing unit is further configured to determine whether the display parameters of the second window stored in the first buffer are different from the display parameters of the first window; when the display parameters of the second window are different from the display parameters of the first window, the display parameters of the first window are used to replace the display parameters of the second window.
[0094] In summary, the window drawing device 600 can transmit the drawing parameters of rounded corners to the application layer module. Directly operating on the root layout of the application layer module can synthesize rounded corners through hardware, avoiding the problems of poor performance and high power consumption caused by GPU synthesis of rounded corners.
[0095] The methods and apparatus provided in the embodiments of this application have been described above. To implement the functions of the methods provided in the embodiments of this application, the electronic device may include a hardware structure and software modules, and may implement the above functions in the form of a hardware structure, software modules, or a hardware structure plus software modules. One of the above functions may be executed in the form of a hardware structure, software modules, or a hardware structure plus software modules.
[0096] Figure 7 This is a block diagram illustrating an electronic device 700 for implementing the above-described method according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, computer, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0097] Reference Figure 7 The electronic device 700 may include one or more of the following components: a processing component 702, a memory 704, a power supply component 706, a multimedia component 708, an audio component 710, an input / output (I / O) interface 712, a sensor component 714, and a communication component 716.
[0098] Processing component 702 typically controls the overall operation of electronic device 700, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 702 may include one or more modules to facilitate interaction between processing component 702 and other components. For example, processing component 702 may include a multimedia module to facilitate interaction between multimedia component 708 and processing component 702.
[0099] Memory 704 is configured to store various types of data to support the operation of electronic device 700. Examples of this data include instructions for any application or method operating on electronic device 700, contact data, phonebook data, messages, pictures, videos, etc. Memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0100] Power supply component 706 provides power to various components of electronic device 700. Power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 700.
[0101] Multimedia component 708 includes a screen that provides an output interface between electronic device 700 and user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 708 includes a front-facing camera and / or a rear-facing camera. When electronic device 700 is in an operating mode, such as a shooting mode or video mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0102] Audio component 710 is configured to output and / or input audio signals. For example, audio component 710 includes a microphone (MIC) configured to receive external audio signals when electronic device 700 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 704 or transmitted via communication component 716. In some embodiments, audio component 710 also includes a speaker for outputting audio signals.
[0103] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0104] Sensor assembly 714 includes one or more sensors for providing state assessments of various aspects of electronic device 700. For example, sensor assembly 714 may detect the on / off state of electronic device 700, the relative positioning of components such as the display and keypad of electronic device 700, changes in position of electronic device 700 or a component of electronic device 700, the presence or absence of user contact with electronic device 700, orientation or acceleration / deceleration of electronic device 700, and temperature changes of electronic device 700. Sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 714 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0105] Communication component 716 is configured to facilitate wired or wireless communication between electronic device 700 and other devices. Electronic device 700 can access wireless networks based on communication standards, such as WiFi, 2G or 3G, 4G LTE, 5G NR (NewRadio), or combinations thereof. In one exemplary embodiment, communication component 716 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 716 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0106] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0107] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, which can be executed by a processor 720 of an electronic device 700 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0108] Embodiments of this disclosure also provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the methods described in the above embodiments of this disclosure.
[0109] The embodiments of this disclosure also propose a communication system including a terminal and a network device. The terminal is used to implement the method described in the first aspect of the embodiments of this disclosure, and the network device can be used to implement the method described in the second aspect of the embodiments of this disclosure.
[0110] Figure 8 This is a schematic diagram illustrating the structure of a chip 800 for implementing the above method according to an exemplary embodiment. (Refer to...) Figure 8 The chip 800 includes a communication interface 801 and at least one processor 802. The communication interface 801 is used to receive signals input to the chip 800 or signals output from the chip 800. The processor 802 communicates with the communication interface 801 and implements the methods described in the above embodiments of this disclosure through logic circuits or executing code instructions.
[0111] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0112] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in at least one embodiment or example.
[0113] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0114] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processing module, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having at least one wiring (control method), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0115] It should be understood that various parts of the embodiments of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0116] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0117] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc.
[0118] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for drawing a window, characterized in that, The method includes: The first frame layer module obtains the drawing parameter information of the first window and passes the drawing parameter information of the first window to the second frame layer module; The application layer module receives the drawing parameter information of the first window from the second frame layer module, and updates the outline parameters of the first window in the root layout according to the drawing parameter information of the first window. The application layer module draws the first window based on the contour parameters, and obtains the drawing result of the first window.
2. The method according to claim 1, characterized in that, The method further includes: The application layer module stores the drawing result of the first window into the first buffer; The first local layer module obtains the drawing result of the first window from the first buffer, and the drawing result is used by the hardware compositing module to compose the layers of the first window.
3. The method according to claim 1, characterized in that, The method further includes: The first frame layer module transmits the drawing parameter information of the first window to the second frame layer module through the first binder communication; The second frame layer module transmits the drawing parameter information of the first window to the application layer module through the second binder communication.
4. The method according to claim 1, characterized in that, The method further includes: The second frame layer module detects whether the information passed by the first frame layer module contains the drawing parameter information of the first window; If the drawing parameter information of the first window is included, the second frame layer module determines whether the drawing parameter information transmitted this time is different from the drawing parameter information transmitted last time; When the drawing parameter information transmitted this time differs from the drawing parameter information transmitted last time, the second framework layer module transmits the drawing parameter information transmitted this time to the application layer module.
5. The method according to claim 2, characterized in that, The application layer module draws the first window based on the contour parameters, and the drawing result of the first window includes: The application layer module schedules the second local layer module to determine the display parameters of the first window based on the outline parameters, wherein the display parameters include at least one of RGB values and transparency. The second local layer module generates the drawing result of the first window based on the display parameters of the first window.
6. The method according to claim 5, characterized in that, The application layer module stores the drawing result of the first window into the first buffer, including: Determine whether the display parameters of the second window stored in the first buffer are different from the display parameters of the first window; When the display parameters of the second window differ from those of the first window, the display parameters of the first window are used to replace the display parameters of the second window.
7. A window drawing apparatus, the apparatus comprising: The acquisition module is used by the first frame layer module to acquire the drawing parameter information of the first window and pass the drawing parameter information of the first window to the second frame layer module. The processing module is used to receive the drawing parameter information of the first window from the second frame layer module and update the outline parameters of the first window in the root layout according to the drawing parameter information of the first window. A drawing module is used by the application layer module to draw the first window based on the contour parameters, and obtain the drawing result of the first window.
8. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-6.
10. A chip, characterized in that, It includes at least one processor and a communication interface; the communication interface is used to receive signals input to the chip or signals output from the chip, and the processor communicates with the communication interface and implements the method as described in any one of claims 1 to 6 through logic circuits or executing code instructions.