Drawing method and electronic device
By adopting the segmented rendering method in lightweight devices, the problem of difficulty in completing rendering of complex components within the frame rate cycle is solved, lags are avoided, and the user experience is improved.
Patent Information
- Application Number
- CN202111509224.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-12-10
AI Technical Summary
Due to hardware limitations, lightweight devices cannot complete the drawing of complex components within one frame rate cycle, resulting in abnormal frame drawing and lagging, which affects the user experience.
By drawing the complex component in segments before the component is refreshed and displayed, the time interval within the frame rate cycle is used to generate and refresh part of the drawing data of the target component, so as to avoid completing all drawing within one frame rate cycle and use segmented drawing.
It effectively avoids lagging caused by frame drops, ensures the high frame rate display requirements of complex interfaces, and improves the user experience.
Smart Images

Figure CN116257235B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of terminal technology, and in particular to a drawing method and an electronic device. Background Art
[0002] With the development of terminal technology, electronic devices are equipped with more functions and display richer content. However, lightweight devices (such as smart watches) have poor hardware conditions and lack multi-task concurrent processing capabilities, making it difficult to display complex interfaces including multiple components.
[0003] For example, for some interfaces that need to display multiple components including simple components and complex components, lightweight devices are limited by hardware conditions and need to wait for the drawing logic of all components to be executed before they can perform rendering and display multiple components. However, since the graphics drawing process of complex components in combined drawing takes a long time, it is difficult to complete the drawing of all components within a frame rate cycle, making the corresponding frame drawing abnormal and unable to be displayed, which will cause the display of lightweight devices to be stuck abnormally, affecting the user experience. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application provide a drawing method and an electronic device. The technical solution provided by the embodiments of the present application draws the component in a time period when the complex component does not need to be drawn before the component is refreshed, meeting the requirements of complex display scenarios of lightweight devices.
[0005] In order to achieve the above technical objectives, the embodiments of the present application provide the following technical solutions:
[0006] In a first aspect, a drawing method is provided, which is applied to an electronic device. The method includes: refreshing a first image to a second image at a first time point, wherein a target component in the second image is different from a target component in the first image. Between the first time point and the second time point, generating first drawing data of a target component to be displayed after being refreshed at a third time point, and refreshing the image at least once, wherein the target component in the image after each refresh is the same as the target component in the second image. Refreshing the image at a third time point according to the first drawing data, wherein the target component in the refreshed third image is different from the target component in the second image.
[0007] In some embodiments, the time sequence of the first time point, the second time point and the third time point is that the first time point is before the second time point, and the second time point is before the third time point.
[0008] In this way, the rendering method provided in the embodiment of the present application does not require hardware modification for lightweight devices, such as increasing the CPU processing speed or expanding the hardware acceleration processing module, and can also avoid the jamming phenomenon caused by frame drops during the display of complex interfaces by means of segmented rendering. While ensuring the user's demand for high frame rate display of complex interfaces, the user's experience is improved.
[0009] According to the first aspect, before generating first drawing data of a target component to be displayed after refreshing at a third time point between a first time point and a second time point, the method further includes: determining at the first time point that the target component displayed after refreshing at the third time point is different from the target component in the second image; or, determining at the first time point that the target component displayed after refreshing at a third time point at a preset time interval is different from the target component in the second image.
[0010] Exemplarily, the electronic device obtains parameter information of the target component at a first time point, such as drawing parameters and time parameters. If the electronic device obtains the time point of the next refresh as a third time point at the first time point based on the time parameters, it can be determined that the target component displayed after the refresh at the third time point is different from the target component displayed before the refresh. Therefore, it is determined that the target component needs to be drawn in segments. Alternatively, the electronic device determines that the number of time units in each refresh interval of the target component is a fixed number greater than 0 based on the time parameters, and it can be determined that the target component needs to be drawn in segments, that is, the target component is drawn in segments according to the number of time units in the interval.
[0011] In this way, the electronic device can determine whether the component needs to be drawn in segments according to the obtained parameter information, and then determine the specific drawing method of the segmented drawing, thereby effectively avoiding the abnormal jamming caused by complex components in a frame rate cycle.
[0012] According to the first aspect, or any implementation of the first aspect above, between a first time point and a second time point, generating first drawing data of a target component to be displayed after being refreshed at a third time point includes: determining that the time interval between the first time point and the second time point is a first number of frame rate cycles, the second time point and the third time point differ by a frame rate cycle, and the electronic device refreshes the image according to the frame rate cycle. The data to be drawn of the target component to be displayed after being refreshed at the third time point is evenly divided according to the first number. Based on the division result, the first drawing data is generated between the first time point and the second time point.
[0013] Exemplary, for example, the electronic device refreshes component A in the first frame and the fourth frame, and the refreshed component A is different from the component A before the refresh. After the electronic device determines that component A needs to be drawn in segments, it determines that the current frame is the first frame, and there are three frames of time from the fourth frame to the next refresh, which can be used to draw the graphic data of component A in segments. Therefore, the electronic device can split the graphic data of component A according to preset rules to determine the graphic data that needs to be drawn in each frame. For example, the electronic device divides the graphic data of component A into three parts, such as A1, A2 and A3, according to the three frame times of the first frame, the second frame and the third frame. Among them, the splitting of the graphic data of the component can be determined according to the data structure of the component. For example, the developer determines the matrix information of component A to be displayed, and divides the matrix corresponding to component A equally, and A1, A2 and A3 correspond to one-third of the matrix respectively.
[0014] In this way, according to the number of frame rate cycles between two refreshes, it is determined that the complex components are drawn in a manner of evenly dividing the components, and the amount of data of each component to be drawn is small, thus avoiding the occurrence of abnormal jamming.
[0015] According to the first aspect, or any implementation of the first aspect above, the first number is N, where N is an integer greater than or equal to 2; based on the division result, first drawing data is generated between the first time point and the second time point, including: drawing one N of the to-be-drawn data of the target component to be displayed after being refreshed at the third time point in each refresh cycle between the first time point and the second time point, to generate the first drawing data.
[0016] Exemplarily, the electronic device first completes the drawing of the graphic data of component B in the first frame, and then determines to draw A1. After A1 is drawn, A1 is cached in a buffer (i.e., a target storage area). In the second frame, after the view system completes the drawing of the graphic data of component B, it draws A2 and puts the drawn A2 into the buffer. In the third frame, after the view system completes the drawing of the graphic data of component B, it draws A3 and puts the drawn A3 into the buffer. Among them, A1, A2, and A3 are each one-third of component A.
[0017] In this way, only a small amount of graphics data needs to be drawn in each frame rate cycle, effectively avoiding lag.
[0018] According to the first aspect, or any implementation method of the first aspect above, first drawing data is generated between a first time point and a second time point according to a division result, including: according to the division result, in each frame rate period within a first frame rate period between the first time point and the second time point, data to be drawn of a target component to be displayed after being refreshed at a third time point is drawn to generate the first drawing data, and data to be drawn of the target component to be displayed after being refreshed at the third time point is not drawn in the remaining second frame rate period; wherein a usage rate of a central processing unit CPU in the first frame rate period is less than or equal to a first threshold, and a usage rate of the CPU in the second frame rate period is greater than the first threshold.
[0019] Exemplarily, if the electronic device also divides component A into three parts, A1, A2 and A3, according to the three frames in which component A does not need to be refreshed. Among them, if the original graphics data to be drawn in the second frame includes the graphics data of component B and the graphics data of component C. After the electronic device determines to draw the graphics data of component B and the graphics data of component C, the CPU is no longer idle (that is, the usage rate is greater than the first threshold). If the time taken to draw the graphics data of component B and the graphics data of component C is equal to the frame rate cycle length, or the remaining time is not enough to draw A2. Then, the electronic device determines to delay the drawing of A2. Afterwards, after the electronic device draws the graphics data of component B and A3 in the third frame, it determines whether the CPU is idle (whether the usage rate is less than or equal to the first threshold). If it is idle (that is, the usage rate is less than or equal to the first threshold), the delayed drawing A2 can be drawn. Alternatively, after the graphics data of component B and A3 are drawn in the third frame, it is determined that the CPU is not idle, or the remaining time is not enough to draw A2, A2 can be postponed until the frame before the refreshed frame or the CPU idle period in the refreshed frame, A2 is drawn. For example, draw A2 in the fourth frame and composite the layer of component A.
[0020] In this way, even if the component segmentation has been completed in advance, the drawing can be adjusted according to the actual CPU occupancy to avoid affecting the drawing of other components and causing abnormal lag.
[0021] According to the first aspect, or any implementation of the first aspect above, the period between the first time point and the second time point includes (a+b) frame rate periods, a and b are integers, and the first drawing data of the target component to be displayed after being refreshed at the third time point is generated between the first time point and the second time point, including: drawing the data to be drawn of the target component to be displayed after being refreshed at the third time point in a frame rate period between the first time point and the second time point, generating the first drawing data, and not drawing the data to be drawn of the target component to be displayed after being refreshed at the third time point in b frame rate periods between the first time point and the second time point. Among them, the CPU usage rate in a frame rate period is less than or equal to the first threshold, and the CPU usage rate in b frame rate period is greater than the first threshold. Alternatively, the drawing of the data to be drawn of the target component to be displayed after being refreshed at the third time point has been completed in a frame rate period in which the CPU usage rate is less than or equal to the first threshold.
[0022] According to the first aspect, or any implementation of the first aspect, in the a frame rate cycles except the last frame rate cycle in chronological order, after generating the first drawing data, the CPU usage is greater than or equal to the first threshold.
[0023] Exemplarily, the electronic device determines that component A is a complex graphic, and determines that component A can be drawn in segments in the first frame, the second frame, and the third frame according to the acquired time parameter for the next refresh of component A. Then, after the electronic device completes drawing the graphic data of component B in the first frame, it determines that the CPU is idle (that is, the usage rate is less than or equal to the first threshold), and the remaining time of the current frame can be determined as the time for drawing part of the graphic data in the graphic data of component A. The electronic device determines that the remaining time can draw the graphic data of A4 data at most, and A4 can be split out from the graphic data of component A, and the drawing of A4 is completed in the first frame. That is, the duration of the first frame is determined as the longest drawing time, and the graphic data is drawn according to the longest drawing time, which will also not cause frame drops. Alternatively, the longest drawing time threshold is set, and the longest drawing time threshold is less than or equal to the duration of the frame rate cycle, and the electronic device draws the graphic data according to the longest drawing time threshold. Afterwards, in the second frame, the electronic device can also draw the graphic data according to the longest drawing time threshold. For example, if it is determined that the remaining graphic data of component A (such as A5) is drawn after the second frame is completely drawn, there is still remaining time in the second frame, and the electronic device can no longer draw the graphics in the current frame.
[0024] That is to say, the electronic device can adaptively adjust whether to draw the target component in the frame rate period between the first time point and the second time point, and the size of the first drawing data for drawing the target component, according to the length of the frame rate period and the CPU usage rate. Then, if the target component is drawn according to the longest drawing time, then the frame rate periods other than the last frame rate period in the time sequence among the a frame rate periods used to draw the target component should meet the requirement of the longest drawing time, that is, the CPU usage rate after drawing is greater than or equal to the first threshold. After the target component is drawn in the last frame rate period, the CPU usage rate may be greater than or equal to the first threshold, or less than the first threshold.
[0025] In this way, the electronic device can adaptively adjust the drawing of complex components according to the CPU usage rate, ensure the drawing of complex components and other components, and avoid abnormal freezing.
[0026] According to the first aspect, or any implementation of the first aspect above, the first drawing data is all or part of the drawing data of the target component to be displayed after being refreshed at the third time point.
[0027] According to the first aspect, or any implementation of the first aspect above, the first drawing data is part of the drawing data of the target component to be displayed after being refreshed at the third time point, and the method further includes: if the proportion of the first drawing data to the total drawing data of the target component to be displayed after being refreshed at the third time point is greater than or equal to a second threshold, generating the remaining second drawing data between the second time point and the third time point. If the proportion of the first drawing data to the total drawing data of the target component to be displayed after being refreshed at the third time point is less than the second threshold, discarding the first drawing data.
[0028] For example, the second threshold is a percentage threshold. For example, the second threshold is 80% of the target component data volume. The electronic device determines that the target component has completed 90% of the drawing in the frame corresponding to the refresh timing, and can draw the remaining 10% of the data in the frame. For another example, the second threshold is 80% of the target component data volume. The electronic device determines that the target component has only completed 30% of the drawing in the frame corresponding to the refresh timing, and can redraw the component in the frame. Thereby, the display efficiency is improved while ensuring the normal display of the target component.
[0029] According to the first aspect, or any implementation of the first aspect above, after generating first drawing data of a target component to be refreshed and displayed at a third time point between the first time point and the second time point, the method further includes: saving the first drawing data to a target storage area.
[0030] In some embodiments, a target storage area for storing segmented rendering data is preconfigured to ensure that the execution of the segmented rendering process does not conflict with the rendering of other components.
[0031] In a second aspect, an electronic device is provided. The electronic device includes: a processor, a memory, and a computer program, wherein the computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device executes: refreshing a first image to a second image at a first time point, wherein the target component in the second image is different from the target component in the first image. Between the first time point and the second time point, first drawing data of a target component to be displayed after being refreshed at a third time point is generated, and the image is refreshed at least once, wherein the target component in the image after each refresh is the same as the target component in the second image. According to the first drawing data, the image is refreshed at a third time point, wherein the target component in the refreshed third image is different from the target component in the second image.
[0032] According to the second aspect, when the processor reads computer instructions from the memory, it also causes the electronic device to perform the following operations: determining at the first time point that the target component displayed after refreshing at the third time point is different from the target component in the second image; or determining at the first time point that the target component displayed after refreshing at the third time point within a preset time interval is different from the target component in the second image.
[0033] According to the second aspect, or any implementation of the second aspect above, between the first time point and the second time point, generating first drawing data of a target component to be displayed after being refreshed at a third time point includes: determining that the time interval between the first time point and the second time point is a first number of frame rate cycles, the second time point and the third time point differ by a frame rate cycle, and the electronic device refreshes the image according to the frame rate cycle. The data to be drawn of the target component to be displayed after being refreshed at the third time point is evenly divided according to the first number. Based on the division result, the first drawing data is generated between the first time point and the second time point.
[0034] According to the second aspect, or any implementation of the second aspect above, the first number is N, where N is an integer greater than or equal to 2; based on the division result, first drawing data is generated between the first time point and the second time point, including: drawing one N of the data to be drawn of the target component to be displayed after being refreshed at the third time point in each refresh cycle between the first time point and the second time point, to generate the first drawing data.
[0035] According to the second aspect, or any implementation method of the second aspect above, first drawing data is generated between the first time point and the second time point according to the division result, including: according to the division result, in each frame rate period within the first frame rate period between the first time point and the second time point, a target component to be displayed after being refreshed at a third time point is drawn to generate the first drawing data, and the target component to be displayed after being refreshed at the third time point is not drawn in the remaining second frame rate period; wherein the usage rate of the central processing unit CPU in the first frame rate period is less than or equal to the first threshold, and the usage rate of the CPU in the second frame rate period is greater than the first threshold.
[0036] According to the second aspect, or any implementation of the second aspect above, the period between the first time point and the second time point includes (a+b) frame rate periods, a and b are integers, and the first drawing data of the target component to be displayed after being refreshed at the third time point is generated between the first time point and the second time point, including: drawing the target component to be displayed after being refreshed at the third time point in a frame rate period between the first time point and the second time point, generating the first drawing data, and not drawing the target component to be displayed after being refreshed at the third time point in b frame rate periods between the first time point and the second time point. Among them, the CPU usage rate in a frame rate period is less than or equal to the first threshold, and the CPU usage rate in b frame rate period is greater than the first threshold. Alternatively, the drawing of the data to be drawn of the target component to be displayed after being refreshed at the third time point has been completed in a frame rate period in which the CPU usage rate is less than or equal to the first threshold.
[0037] According to the second aspect, or any implementation of the second aspect, in the a frame rate cycles except the last frame rate cycle in chronological order, after generating the first drawing data, the CPU usage is greater than or equal to the first threshold.
[0038] According to the second aspect, or any implementation of the second aspect, the first drawing data is all or part of the drawing data of the target component to be displayed after being refreshed at the third time point.
[0039] According to the second aspect, or any implementation of the second aspect above, when the processor reads the computer instruction from the memory, the electronic device is further caused to perform the following operations: if the proportion of the first drawing data to the total drawing data of the target component to be displayed after being refreshed at the third time point is greater than or equal to the second threshold, between the second time point and the third time point, the remaining second drawing data is generated. If the proportion of the first drawing data to the total drawing data of the target component to be displayed after being refreshed at the third time point is less than the second threshold, the first drawing data is discarded.
[0040] According to the second aspect, or any implementation of the second aspect, when the processor reads the computer instruction from the memory, the electronic device is also caused to perform the following operation: saving the first drawing data to the target storage area.
[0041] The technical effects corresponding to the second aspect and any implementation method of the second aspect can be found in the technical effects corresponding to the above-mentioned first aspect and any implementation method of the first aspect, and will not be repeated here.
[0042] In a third aspect, an embodiment of the present application provides an electronic device having the function of implementing the drawing method described in the first aspect and any possible implementation thereof. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0043] The technical effects corresponding to the third aspect and any one of the implementation methods of the third aspect can be found in the technical effects corresponding to the above-mentioned first aspect and any one of the implementation methods of the first aspect, and will not be repeated here.
[0044] In a fourth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program (also referred to as an instruction or code), and when the computer program is executed by an electronic device, the electronic device executes the method of the first aspect or any one of the implementations of the first aspect.
[0045] The technical effects corresponding to the fourth aspect and any one of the implementation methods of the fourth aspect can be found in the technical effects corresponding to the above-mentioned first aspect and any one of the implementation methods of the first aspect, and will not be repeated here.
[0046] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device executes the method of the first aspect or any one of the implementations of the first aspect.
[0047] The technical effects corresponding to the fifth aspect and any one of the implementation methods of the fifth aspect can be found in the technical effects corresponding to the above-mentioned first aspect and any one of the implementation methods of the first aspect, and will not be repeated here.
[0048] In a sixth aspect, an embodiment of the present application provides a circuit system, the circuit system includes a processing circuit, and the processing circuit is configured to execute the method of the first aspect or any one of the implementations of the first aspect.
[0049] The technical effects corresponding to the sixth aspect and any one of the implementation methods of the sixth aspect can be found in the technical effects corresponding to the above-mentioned first aspect and any one of the implementation methods of the first aspect, and will not be repeated here.
[0050] In the seventh aspect, an embodiment of the present application provides a chip system, comprising at least one processor and at least one interface circuit, wherein the at least one interface circuit is used to perform transceiver functions and send instructions to the at least one processor, and when the at least one processor executes the instructions, the at least one processor executes the method of the first aspect or any one of the embodiments of the first aspect.
[0051] The technical effects corresponding to the seventh aspect and any one of the implementation methods of the seventh aspect can be found in the technical effects corresponding to the above-mentioned first aspect and any one of the implementation methods of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A schematic diagram of an interface provided in an embodiment of the present application;
[0053] Figure 2A Schematic diagram of the graphics drawing scene provided in the embodiment of the present application Figure 1 ;
[0054] Figure 2B Schematic diagram 2 of a graphics drawing scene provided in an embodiment of the present application;
[0055] Figure 3 A schematic diagram of an electronic device provided in an embodiment of the present application;
[0056] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0057] Figure 5 A schematic diagram of a software structure block diagram of an electronic device provided in an embodiment of the present application;
[0058] Fig. 6A Schematic diagram of the graphics drawing scene provided in the embodiment of the present application Figure 3 ;
[0059] Figure 6B Schematic diagram of the graphics drawing scene provided in the embodiment of the present application Figure 4 ;
[0060] Figure 6C Schematic diagram of the graphics drawing scene provided in the embodiment of the present application Figure 5 ;
[0061] Fig.6D Schematic diagram 6 of a graphics drawing scene provided in an embodiment of the present application;
[0062] Figure 7 Schematic diagram of the graphics drawing scene provided in the embodiment of the present application Figure 7 ;
[0063] Figure 8Schematic diagram of the graphics drawing scene provided in the embodiment of the present application Figure 8 ;
[0064] Fig. 9 A flowchart of the drawing method provided in the embodiment of the present application Figure 1 ;
[0065] Fig.10 Schematic diagram 2 of the flow chart of the drawing method provided in the embodiment of the present application;
[0066] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0067] The technical solutions in the embodiments of the present application are described below in conjunction with the accompanying drawings in the embodiments of the present application. Wherein, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to include expressions such as "one or more", unless there is a clear indication to the contrary in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two).
[0068] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0069] In the embodiments of the present application, the words "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of 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 "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0070] In some scenarios, as the functions of electronic devices become richer, electronic devices can also display more animation effects. For example, Figure 1 The smartwatch shown can be equipped with multiple functions such as timing function, heart rate monitoring function, step counting function, etc. Then, the smartwatch can display a dial 101 for indicating time, and can also display multiple sub-dials on the dial, such as a stopwatch dial 102, a dial for displaying heart rate, a dial for displaying step count, etc. Among them, the minute hand 11 displayed on the dial 101 needs to change the display position once every minute, and the pointer 12 displayed on the stopwatch dial 102 needs to change the display position once every second. Then in a certain frame, the smartwatch needs to simultaneously display the minute hand 11 and the pointer 12 after the display position has changed, that is, the smartwatch needs to draw multiple components in this frame.
[0071] However, for lightweight devices such as smart watches, due to their low hardware specifications, poor computing and processing capabilities, and lack of multi-process and multi-task concurrent processing capabilities, their graphics drawing and display processes usually rely on software drawing algorithms, and the drawing of each graphic is executed serially. For complex interfaces containing multiple graphics, serial execution of drawing is difficult to meet the display frame rate requirements of electronic devices, and abnormalities such as freezing occur. That is, the time required for lightweight devices to draw, render, and synthesize layers is difficult to meet the single-frame rendering requirements (such as the required time is greater than or equal to one frame rate cycle).
[0072] For example, some electronic devices are equipped with a display screen with a refresh rate of 60 Hz per second, so the corresponding frame rate period T = 1 / 60 = 0.01667 seconds (s) = 16.667 milliseconds (ms). Accordingly, lightweight devices need to complete the drawing and rendering of the corresponding graphics within 16.667ms, so that the display requirements of the corresponding frame can be met after the refresh. Figure 1 As shown in the figure, if the time changes from 11:05 to 11:06, then the minute hand 11 needs to be redrawn according to the display angle of the minute hand 11 when refreshing the frame changed to 11:06. If the pointer 12 also needs to refresh the display position in this frame, the smart watch needs to execute the drawing of the minute hand 11 and the pointer 12 serially within the frame rate period. If it cannot be completed, it will cause a freeze abnormality.
[0073] For example, Figure 2A As shown, if the complex graph (such as Figure 1 The time required for drawing the minute hand 11) alone is (t1-t2), and a simple graphic (such as Figure 1 The time required for drawing the pointer 12 shown in FIG. 1 is (t1-t3). Then, if the display positions of the components corresponding to the complex graphics and the simple graphics of a certain frame are changed, they need to be redrawn. Figure 2AThe waveform graph corresponding to the combined graph shown in the figure is drawn first, and the time required is (t1-t2), and then the simple graph is drawn, and the time required is (t2-t4). Therefore, if the frame image needs to be displayed, the time required is (t1-t4). If the frame rate cycle is (t1-t2), then the drawing time of the frame exceeds the frame rate cycle requirement, and a jamming exception will occur.
[0074] For example, corresponding to Figure 2A ,like Figure 2B As shown, if component A is a complex graphic, the display parameters need to be refreshed every two frames (such as drawing and refreshing the display in the first and fourth frames); if component B is a simple graphic, the display parameters need to be refreshed every frame (such as drawing and refreshing the display in each frame from the first frame to the fourth frame). Then, for component A and component B, the serial drawing, rendering and synthesis of the two components need to be completed in the first frame and the fourth frame before they can be sent to the display screen for display. Due to the hardware processing capabilities of lightweight devices, frame drops may occur, resulting in display freezes. If the drawing of component A and component B cannot be completed in the first frame and the fourth frame, the display cannot be refreshed in the first frame and the fourth frame, resulting in freezes caused by frame drops.
[0075] Based on this, an embodiment of the present application provides a drawing method, whereby an electronic device can draw the graphics in segments based on the graphics drawing parameter information and the time to be displayed, without relying on the optimization of hardware performance, to avoid frame drops, thereby providing users with smooth display of complex interfaces and improving the user experience.
[0076] The drawing method provided in the embodiment of the present application can be applied to the electronic device 100. For example, Figure 3 As shown, the electronic device 100 can be a wearable device (such as a smart watch 11, a smart bracelet 12, etc.), a large-screen display device, a mobile phone 22, a laptop computer, a tablet computer, a vehicle-mounted device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), an artificial intelligence device, and other terminal devices with display functions. The operating system installed in the electronic device 100 includes but is not limited to Or other operating systems. The electronic device 100 may not have an operating system installed. The present application does not limit the specific type of the electronic device 100, whether an operating system is installed, and the installed operating system. Optionally, the electronic device 100 is a lightweight device.
[0077] The execution subject of a drawing method provided in an embodiment of the present application may be a device for generating an image frame. The device for generating an image frame may be any of the above-mentioned electronic devices 100. Alternatively, the device for generating an image frame may also be a central processor unit (CPU) of the electronic device 100, or a graphics module (such as a view system) in the electronic device 100 for executing the drawing method. In the embodiment of the present application, the drawing method provided in the embodiment of the present application is described by taking the electronic device 100 executing the drawing method as an example.
[0078] For example, Figure 4 A schematic structural diagram of an electronic device 100 is shown.
[0079] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0080] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0081] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0082] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0083] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0084] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0085] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to a touch sensor, a charger, a flash, a camera 193, etc. through different I2C bus interfaces. For example, the processor 110 may be coupled to a touch sensor through an I2C interface, so that the processor 110 communicates with the touch sensor through the I2C bus interface to realize the touch function of the electronic device 100.
[0086] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.
[0087] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0088] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0089] The charging management module 140 is used to receive charging input from a charger. The charger can be a wireless charger or a wired charger. While the charging management module 140 charges the battery 142, it can also power the electronic device through the power management module 141.
[0090] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.
[0091] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0092] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0093] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0094] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0095] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0096] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0097] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0098] The sensor module 180 may include a pressure sensor, a gyro sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
[0099] Among them, the display screen 194 in the embodiment of the present application can be a touch screen. That is, a touch sensor is integrated in the display screen 194. The touch sensor can also be called a "touch panel". In other words, the display screen 194 can include a display panel and a touch panel, and the touch sensor and the display screen 194 form a touch screen, also known as a "touch screen". The touch sensor is used to detect touch operations acting on or near it. After the touch operation is detected by the touch sensor, it can be passed to the upper layer by the driver of the kernel layer (such as TP driver) to determine the type of touch event. Visual output related to the touch operation can be provided by the display screen 194. In other embodiments, the touch sensor can also be arranged on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0100] Exemplarily, when the electronic device 100 determines that the refreshed component data (such as display position information, etc.) has changed, it is necessary to redraw the component so that the refreshed component display meets the requirements.
[0101] For example, after the electronic device 100 is refreshed, it can obtain the drawing parameters and time parameters corresponding to the next refresh display position. Then the electronic device 100 can divide the component data to be drawn (which can be determined according to the drawing parameters) according to the time parameters, and draw them in segments. When refreshing next time, it can ensure that the drawing, rendering and synthesis of all components are completed within the frame rate period to avoid abnormal freezing.
[0102] For another example, after the electronic device 100 detects a user's touch operation on the display screen 194 using a touch sensor, it may trigger a change in the position of a control displayed on the display screen 194. In this case, when displaying subsequent frames of images, the layer data needs to be redrawn. Similarly, the electronic device 100 can obtain the drawing parameters and time parameters corresponding to the next refresh and perform segmented drawing.
[0103] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0104] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0105] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0106] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor.
[0107] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110. The electronic device 100 can implement audio functions through the audio module 170 and the application processor, etc. For example, music playback, recording, etc. Among them, the audio module may include a speaker, a receiver, a microphone, and a headphone interface.
[0108] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.
[0109] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0110] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0111] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 100 by inserting or removing the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
[0112] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0113] Figure 5 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.
[0114] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the system library of the Android runtime, and the kernel layer.
[0115] The application layer can include a series of application packages.
[0116] like Figure 5 As shown, the application package may include applications such as call, clock, camera, calendar, music, gallery, map, short message, Bluetooth, etc.
[0117] In some embodiments, the developer preconfigures component drawing parameters and timing parameters in the application development kit. Figure 1 In the scenario shown, the developer preconfigures the drawing parameters and time parameters corresponding to the refresh display position of the minute hand 11 every minute in the clock application development kit, such as the rotation center point, rotation angle, next rendering time parameters, etc.
[0118] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0119] like Figure 5 As shown, the application framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, and the like.
[0120] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0121] The activity manager is responsible for managing activities, starting, switching, and scheduling components in the system, and managing and scheduling applications.
[0122] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0123] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0124] In some embodiments, the view system obtains the drawing parameters and time parameters of the component through an API to complete the drawing, rendering, and synthesis of the component layer.
[0125] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0126] The notification manager enables applications to display notification information in the status bar, which can be used to convey informational messages and disappear automatically after a short stay without user interaction.
[0127] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0128] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0129] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0130] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0131] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0132] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0133] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0134] A two-dimensional graphics engine is a drawing engine for 2D drawing. Common graphics engines include Vulkan, Canvas, etc.
[0135] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.
[0136] In the following embodiments, the drawing method provided in the embodiments of the present application is described by taking the electronic device 100 as a lightweight electronic device as an example.
[0137] In some embodiments, the screen refresh rate of the display screen of the electronic device can be any value such as 30Hz, 40Hz, 60Hz, 70Hz, 75Hz, 80Hz or 144Hz. The electronic device refreshes the displayed image frame according to the frame rate period corresponding to the screen refresh rate. Taking the screen refresh rate of 60Hz as an example, 60Hz means that 60 image frames appear continuously in one second, and the frame rate period T = 1 / 60 = 0.01667 seconds (s) = 16.667 milliseconds (ms). The electronic device needs to complete the drawing (i.e. drawing and rendering) of an image frame within one frame rate period.
[0138] It should be noted that an electronic device may support multiple different screen refresh rates. For example, if the maximum screen refresh rate supported by an electronic device is 80 Hz. Then, the electronic device may support a screen refresh rate of 80 Hz, 60 Hz, or 40 Hz, etc. The screen refresh rate described in the embodiment of the present application is the screen refresh rate currently used by the electronic device. That is, the frame rate period T is the inverse of the screen refresh rate currently used by the electronic device.
[0139] In some embodiments, after a user interface (UI) event occurs in the electronic device or a user operation on the display screen (such as a touch operation or voice operation on the display screen) is detected, the electronic device is triggered to draw one or more layers, render the one or more layers, and perform layer synthesis on the drawn one or more layers (i.e., the rendered one or more layers) to obtain an image frame, and then the synthesized image frame can be refreshed on the display screen.
[0140] The above UI event may be automatically triggered by the electronic device. For example, when the foreground application of the electronic device automatically switches screens, the above UI event may be triggered. The foreground application is the application corresponding to the interface currently displayed on the display screen of the electronic device. Figure 1 In the scenario shown, the clock application is the foreground application currently displayed on the smart watch, and the display screen of the minute hand 11 is automatically switched every minute, that is, the smart watch refreshes the display screen of the minute hand 11 in a period of 1 minute.
[0141] In some embodiments, after the electronic device detects an event that triggers drawing, it needs to create a control tree (view tree) corresponding to the graphics to be drawn (such as controls and layouts), which is used to represent controls and layouts organized in a tree structure. Specifically, in the process of creating the control tree, the root view (root view) is first determined, and then the setContentView() method is called to complete the creation of other nodes above the root view. Afterwards, in the process of drawing the graphics, the electronic device starts from the root node (i.e., the root view) and executes the drawing process according to the node relationship included in the control tree.
[0142] For example, Figure 1 In the scenario shown, in the control tree created by the electronic device, the background of the entire dial can be set as the root node. After that, the backgrounds of each sub-dial that needs to be displayed on the dial are set as child nodes of the root node (that is, set as a parent-child node relationship), and the backgrounds of each sub-dial are set as a brother node relationship. The node relationship settings of each control and layout on the dial are completed in sequence, and the control tree is created so that the dial can be drawn according to the control tree later.
[0143] In some embodiments, as described above, the electronic device supports different screen refresh rates, and completes the drawing (i.e., drawing and rendering) of image frames according to the frame rate period corresponding to the currently used screen refresh rate, so that smooth display of image frames can be achieved after the display screen is refreshed.
[0144] In some scenarios, if the graphic data included in a frame of image to be displayed does not change relative to the graphic data included in the previous frame of image, then it is not necessary to redraw the graphic data. The graphic data includes, for example, control data, control layout data, etc. Optionally, if the control tree 1 corresponding to the frame of image to be displayed is determined to have some graphic data changed relative to the control tree 2 corresponding to the previous frame of image, the graphic data of the changed part may be drawn, and the graphic data of the unchanged part may not be drawn.
[0145] For example, Figure 1 In the scenario shown, the electronic device displays a dial 101. At a certain moment, the dial 101 is refreshed for the first time to display the time as 11:05. Then, within the next 59 seconds, the display position of the minute hand 11 will not change. For another example, the main interface of the electronic device displays application icons. The user long presses and drags one of the application icons to the blank display area for display. During the above-mentioned application icon dragging process, the position and display content of other application icons will not change. Therefore, the electronic device can no longer redraw the unchanged components in adjacent image frames to save power consumption of the electronic device.
[0146] In other scenarios, when adjacent image frames change, the electronic device needs to redraw the corresponding graphic data to display the changed image frame. Since some lightweight devices do not have the ability to handle multiple tasks concurrently, such as when there are many changing graphic data in adjacent image frames or when there are components with large amounts of graphic data to be drawn, the electronic device serially executes the drawing of each changing graphic data, which takes longer than the frame rate cycle, resulting in frame drops and affecting the display of image frames.
[0147] Therefore, for some components that can determine the changing image frame graphic data, developers can pre-configure the drawing parameters and time parameters corresponding to the component refresh change moment in the application package. Optionally, the time parameter is the time parameter information of the next refresh change (such as the adjacent image frame changes after the image frame is refreshed). Then, after the electronic device obtains the drawing parameters and time parameters corresponding to the next refresh, it can determine the next refresh time according to the time parameters, and draw the components in segments according to the drawing parameters before the next refresh time. Then, when it is necessary to refresh the image frame, the drawn graphic data can be directly obtained, and the various parts of the graphic data can be synthesized to generate complete graphic data. Based on the final complete graphic data, the rendering of the graphic data can be completed in a shorter time without exceeding the frame rate cycle, thereby ensuring the smoothness of the display.
[0148] For example, Figure 1 In the scenario shown, the electronic device refreshes the display screen at 11:05, and can obtain the drawing parameters of the minute hand 11 displayed this time, and can obtain the drawing parameters and time parameters of the next refresh display of the minute hand 11. If the next refresh time parameter information is 1 minute (i.e. 60 seconds), the drawing parameters are the rotation center point, rotation angle and other information of the minute hand 11 corresponding to the dial display 11:06. Then, if the screen refresh rate of the electronic device is 60Hz, the frame rate cycle T = 1 / 60 = 0.01667 seconds (s) = 16.667 milliseconds (ms). In other words, 1 second includes 60 frame rate cycles, and the next refresh includes 60*60 = 360 frame rate cycles. The electronic device needs to complete the drawing, rendering and synthesis of the minute hand 11 within 360 frame rate cycles to ensure the normal display of the minute hand 11. This avoids the problem of frame drops and display freezes caused by completing the serial drawing of multiple components (such as the minute hand 11 and the pointer 12) within the frame rate cycle corresponding to the refreshed frame.
[0149] The following takes drawing component A and component B, where component A is a complex graphic drawing and component B is a simple graphic drawing, as an example to illustrate the implementation method of the above segmented drawing.
[0150] It should be noted that the division of complex graphics and simple graphics can be determined by developers based on experience, experimental values, etc. For example, for components corresponding to certain functions, the graphic data of each frame is different and is redrawn, so it can be designed to draw simple graphics that take a short time. For another example, for components corresponding to certain functions, the graphic data of each frame changes after a certain number of frames, so it can be designed to draw complex graphics that take a long time and are drawn periodically.
[0151] For example, Fig. 6A As shown, if component A is refreshed and displayed once every two frames, component B is refreshed and displayed once every frame. For example, the graphic data of component A displayed in the second image frame is the same as the graphic data of component A displayed in the first frame, and the graphic data of component A displayed in the third image frame is the same as the graphic data of component A displayed in the second frame, then the electronic device does not need to redraw component A in the second and third frames. However, component A displayed in the fourth image frame is different from the previous three frames and needs to be redrawn. For another example, the graphic data of component B in each frame is different, and component B needs to be redrawn in each frame. Then, every two frames, the electronic device needs to refresh and display component A and component B at the same time. If the component drawing is executed serially according to the prior art, the following may occur in the first and fourth frames. Figure 2B The frame drop problem shown.
[0152] It should be noted that if Fig. 6A The lengths of the components shown in are used to represent the time of component drawing (ie, drawing and rendering), and the first frame, the second frame, the third frame, and the fourth frame correspond to the same frame rate period.
[0153] In some embodiments, the developer presets parameter information corresponding to complex graphics in the application development kit, such as drawing parameters and time parameters. After refreshing, the electronic device can obtain the parameter information of the next refresh corresponding to the complex graphics, and then realize segmented drawing. Among them, the drawing parameters include, for example, the shape, layer, coordinate position, transparency, color, size, scaling change, text content, marquee speed, text font format and other parameters that affect the display of the component. The time parameter includes, for example, the time length information from the moment the time parameter is obtained to the next refresh. For example, the time length from the next refresh (such as 16.667ms), or the number of frames from the next refresh (such as 3 frames), etc.
[0154] It should be noted that the electronic device refreshes the displayed image frame according to the screen refresh rate, the next refresh of the component is used to indicate the refresh timing of the component to be re-rendered and displayed, and the parameter information of the next refresh of the component is used to realize the rendering and display of the component at the refresh timing. Fig. 6AIn the scenario shown, the electronic device refreshes the displayed image frame every frame according to the screen refresh rate. After rendering and displaying component A and component B in the first frame, the next refresh time of component A is the fourth frame, and the next refresh time of component B is the second frame. That is, component B needs to be redrawn and rendered for each frame to achieve the refresh of component B according to the screen refresh rate. However, the screen needs to be refreshed at the time interval shown in the second and third frames, but component A does not need to be re-rendered. It can be determined that the second and third frames are not the refresh time of component A.
[0155] For example, Fig. 6A As shown, the view system in the electronic device can obtain the parameter information of the next refresh of component A preset in the application layer application development kit through the API in the first frame, such as the drawing parameters of component A that need to be refreshed and displayed in the fourth frame (such as Figure 1 The rotation angle of the minute hand 11 in the scene shown) and time parameters. Optionally, the developer pre-sets an API for transmitting the parameter information of the complex component. After the view system obtains the parameter information of the component from the API, it can determine that the component is a complex component and needs to be drawn in segments. Alternatively, the parameter information of the complex component carries a preset identifier (such as adding a preset identifier to the drawing parameters and / or time parameters). After the view system obtains the parameter information with the preset identifier, it determines that the component corresponding to the parameter information is a complex component and needs to be drawn in segments. Alternatively, after the view system obtains the parameter information of the component, it determines, based on the time parameters therein, that the time from the next refresh time exceeds a preset threshold, and the corresponding component can be drawn in segments. Alternatively, after the view system obtains the parameter information of the component, it determines, based on the time parameters therein, that the number of time units of each refresh interval of the component is a fixed number greater than 0, and the corresponding component can be drawn in segments according to the number of time units of the interval.
[0156] like Fig. 6A As shown, the view system can determine that component A needs to be drawn in segments according to any of the above methods. In addition, the view system can determine that the current frame is the first frame, and there are three frames of time from the fourth frame of the next refresh, which can be used to draw the graphic data of component A in segments. Therefore, the view system can split the graphic data of component A according to the preset rules and determine the graphic data that needs to be drawn in each frame. For example, the graphic data of component A is evenly divided according to the time parameter, and then in each frame before the refresh, the graphic data corresponding to the split component A is drawn after the graphic data of other components are drawn (as shown below Figure 6A-6C For another example, in the frame before the next refresh of component A, the view system uses the remaining time after drawing the graphic data of other components to draw component A according to the longest drawing time corresponding to the frame rate cycle of the electronic device (see below for details). Figure 8 content shown).
[0157] For example, the view system divides the graphic data of component A into three parts, such as A1, A2 and A3, according to the three frame times of the first frame, the second frame and the third frame. The division of the graphic data of the component can be determined according to the data structure of the component. Fig. 6A As shown, the developer determines the matrix information of the component A to be displayed, and divides the matrix corresponding to the component A equally, with A1, A2 and A3 corresponding to one third of the matrix respectively. It should be noted that the present application does not specifically limit the method for splitting the graphic data of the component.
[0158] Optionally, during the graphics drawing process, the view system gives priority to drawing the original graphics data to be drawn. After the original data to be drawn is drawn, it is determined whether the current CPU is idle. If it is idle, the divided graphics data can be drawn. Among them, the view system can determine whether the CPU is idle based on whether the current frame drawing time exceeds the frame rate cycle limit. For example, if the view system determines that the current frame drawing time does not exceed the frame rate cycle limit, it can be determined that the current CPU is idle.
[0159] So, if Fig. 6A As shown, the view system first completes the drawing of the graphic data of component B in the first frame, and then determines to draw A1. After A1 is drawn, A1 is cached in the buffer. Similarly, Figure 6B As shown in the figure, in the second frame, after the view system finishes drawing the graphics data of component B, it draws A2 and puts the drawn A2 into the buffer. Figure 6C As shown, in the third frame, after the view system completes drawing the graphics data of component B, it draws A3 and puts the drawn A3 into the buffer.
[0160] Afterwards, if Fig.6D As shown, the view system determines to refresh component A in the fourth frame. In the fourth frame, the view system obtains the cached A1, A2 and A3 from the buffer, and can directly synthesize the component A layer and render it, thereby realizing the refresh display of the fourth frame.
[0161] Optionally, the buffer used to store the graphics data drawn by the component segment is different from the buffer used to store other drawing data to be displayed. Figure 6A-6DIn the scenario shown, when the view system draws component B, the corresponding drawing data is stored in buffer 1. After component B is drawn, the data of component B can be taken out from buffer 1 and displayed. Among them, buffer 1 is used as a display buffer to store the graphic data to be displayed. After the view system draws component A in segments, it stores the segmented drawing data in buffer 2 which is different from buffer 1. Afterwards, at the refresh time, the view system takes all the segmented drawing data from buffer 2, synthesizes the layers and stores them in buffer 1 to realize the display of component A. Optionally, buffer 1 and buffer 2 can be distinguished by different values of the identification bit.
[0162] It is understandable that the component drawing process requires logical operations, such as calculating the display position of component A after refreshing, which takes a long time. Therefore, in the frames that do not need to be refreshed, the view system has completed the drawing of component A. Then, in the refreshed frames, the view system only needs to complete the rendering and synthesis work of component A, which takes less time. This effectively reduces the processing time of component A in the frames that need to be refreshed, and avoids frame drops and freezes caused by the inability to complete the drawing of all graphic data within a frame rate cycle. This ensures the smooth display of image frames and effectively improves the user experience.
[0163] In some embodiments, Fig.6D As shown, in the fourth frame, the electronic device refreshes the display screen to display a new image frame. In addition, in the fourth frame, the electronic device can also obtain the parameter information of the next refresh of component A (if the next refreshed frame is the seventh frame, the parameter information of component A corresponding to the seventh frame is obtained), and repeat the above segmented drawing method to complete the drawing of component A. Therefore, in the display process of the electronic device, the smoothness of the display process can be ensured by the segmented drawing method.
[0164] Optional, such as Figure 6A-6D In the scenario shown, after the view system synthesizes the component A layer in the fourth frame, it can clear the data corresponding to the synthesized component A in the buffer so that the buffer can cache the subsequent segmented drawing graphics data.
[0165] It should be noted that in the following embodiments, the electronic device can obtain the parameter information of the components in the next refreshed frame in a refreshed frame. And after the refresh, the data corresponding to the refresh in the buffer is cleared to ensure that the buffer can meet the subsequent cache requirements. This will not be described in detail below.
[0166] In some embodiments, as described above, before drawing the divided graphic data, the view system needs to first determine whether the CPU is idle and whether it can meet the drawing requirements to avoid failure to complete the drawing and frame drops. Then, there is a situation where, in one or more frames, the remaining time after drawing the original graphic data to be drawn is not enough to draw the divided graphic data. Then, these frames cannot draw the divided graphic data, and the view system can postpone the drawing of the divided graphic data that should be drawn in these frames to the subsequent frames where the CPU is idle to avoid the problem of frame drops.
[0167] For example, corresponding to Fig. 6A The scene shown, such as Figure 7 As shown, if the view system also divides component A into three parts, A1, A2 and A3, according to the three frames in which component A does not need to be refreshed. Among them, if the original graphics data to be drawn in the second frame includes the graphics data of component B and the graphics data of component C. After the view system determines to draw the graphics data of component B and the graphics data of component C, the CPU is no longer idle. If the time taken to draw the graphics data of component B and the graphics data of component C is equal to the frame rate cycle length, or the remaining time is not enough to draw A2. Then, the view system determines to postpone the drawing of A2. Afterwards, if Figure 7 As shown, after the view system finishes drawing the graphics data and A3 of component B in the third frame, it determines whether the CPU is idle. If it is idle, it can draw A2 that is delayed. In this way, in the fourth frame, the view system can also complete the synthesis of the layer of component A and refresh the display of component A. Alternatively, after the graphics data and A3 of component B are drawn in the third frame, it is determined that the CPU is not idle, or the remaining time is insufficient to draw A2, and A2 can be postponed until the frame before the refreshed frame or the CPU is idle in the refreshed frame, and A2 is drawn. For example, A2 is drawn in the fourth frame and the layer of component A is synthesized.
[0168] In this way, the electronic device adaptively adjusts the frames used to draw the divided graphic data to ensure that the refreshed frames can normally display the image frames while avoiding frame drops and abnormal freezes in other frames.
[0169] In some embodiments, the view system in the electronic device obtains the parameter information of the next refresh of component A preset in the application layer application development kit through an API (such as drawing parameters and time parameters), and can determine the size of the graphic data of component A according to the drawing parameters. Among them, in order to avoid frame drops, the total time for drawing graphic data within a frame rate cycle should be less than or equal to the frame rate cycle. If the screen refresh rate is 60Hz and the frame rate cycle T=16.667ms, then the total time for the view system to draw the graphic data for each frame should be less than or equal to 16.667ms. Therefore, the view system does not need to evenly divide the graphic data of component A in advance, but can draw the graphic data of component A according to the longest drawing time based on the time parameters and the frame rate cycle.
[0170] For example, corresponding to Fig. 6A The scene shown, such as Figure 8 As shown, the view system determines that component A is a complex graphic, and according to the obtained time parameter for the next refresh of component A, determines that component A can be drawn in segments in the first frame, the second frame, and the third frame. Then, after the view system finishes drawing the graphic data of component B in the first frame, it determines that the CPU is idle, and the remaining time of the current frame can be determined as the time for drawing part of the graphic data of component A. Figure 8 As shown, the view system determines that there is at most A4 graphics data in the remaining time, and can split A4 from the graphics data of component A, and complete the drawing of A4 in the first frame. That is, the duration of the first frame is determined as the longest drawing time, and the graphics data is drawn according to the longest drawing time, which will also not cause frame drops. Alternatively, a maximum drawing time threshold is set, and the maximum drawing time threshold is less than or equal to the duration of the frame rate cycle. The view system draws the graphics data according to the maximum drawing time threshold. Afterwards, as Figure 8 As shown, in the second frame, the view system can also draw the graphics data according to the longest drawing time threshold. For example, if the remaining graphics data of component A (such as A5) is determined, after the second frame is completely drawn, there is still remaining time in the second frame, and the view system can stop drawing graphics in the current frame. Figure 8 As shown, the view system can complete the drawing of all components A in the second frame, so when the fourth frame is refreshed, the layer synthesis of component A can be completed, and the drawing process of component A will not cause frame drops, ensuring the smoothness of the electronic device display.
[0171] In some embodiments, after the visual system of the electronic device evenly divides the graphics data of the component according to the time parameter of the component, it determines that the drawing time corresponding to each segment of the to-be-drawn data exceeds the frame rate period, and the visual system may draw the graphics data of the component according to the longest drawing time. Thereafter, the visual system draws the remaining to-be-drawn data at the frame corresponding to the refresh timing. Or, in the above Figure 7 or Figure 8In the scenario shown, the view system determines that part of the data to be drawn of the segmented drawn component still exists in the frame corresponding to the refresh timing, and the remaining data can be drawn in the frame to achieve display.
[0172] Optionally, a data size threshold is preset. If the view system determines that the component has not completed the segmented drawing of the component in the frame corresponding to the refresh timing, and the size of the drawn data is greater than or equal to the preset data size threshold, the drawing of the remaining data to be drawn can be completed in the frame, and then rendering and layer synthesis can be performed to realize component display. Alternatively, the view system determines that the component has not completed the segmented drawing in the frame corresponding to the refresh timing, but the drawn data is less than the preset data size threshold, and the component can be redrawn in the frame to realize component display. Optionally, the preset data size threshold is, for example, a percentage threshold. For example, the preset data size threshold is 80% of the component data volume, and the view system determines that the component has completed 90% of the drawing in the frame corresponding to the refresh timing, and the remaining 10% of the data can be drawn in the frame. For another example, the preset data size threshold is 80% of the component data volume, and the view system determines that the component has only completed 30% of the drawing in the frame corresponding to the refresh timing, and the component can be redrawn in the frame.
[0173] Specifically, since the data of components that do not require segmented drawing can be directly stored in buffer 1 for display, while the segmented drawing data needs to be stored in buffer 2 first, and then stored in buffer 1 for display, there is a certain delay in this process. Therefore, the preset data size threshold can be determined based on the delay. If it is determined in the refreshed frame that the drawn data is less than the preset data size threshold, the delay caused by continuing to draw the component in segmented drawing will be greater than the delay caused by directly drawing all the graphics data of the component. Based on this, when the view system determines that the drawn data is less than the preset data size threshold, it can redraw the component to ensure the normal display of the component.
[0174] In some embodiments, the view system can obtain parameter information of a preset refresh number, thereby reducing the number of times the view system obtains parameter information from the application layer through the API. Figure 1 In the regular clock hand change scenario shown in the figure, developers can pre-configure regular parameter information in the clock application development kit. For example, the rotation angle information of the minute hand 11 changes every minute. In this way, when the view system requests parameter information, it can directly obtain all the drawing parameters and time parameters of the minute hand 11 rotating and displaying one week for 60 minutes. After that, the view system automatically determines the drawing parameters and time parameters corresponding to the next refresh time according to all the drawing parameters and time parameters, without having to obtain the parameter information of the next refresh of the minute hand 11 from the application layer every time the refresh is performed, and the drawing of the graphic data of the minute hand 11 can also be executed.
[0175] In this way, the rendering method provided in the embodiment of the present application does not require hardware modification for lightweight devices, such as increasing the CPU processing speed or expanding the hardware acceleration processing module, and can also avoid the jamming phenomenon caused by frame drops during the display of complex interfaces by means of segmented rendering. While ensuring the user's demand for high frame rate display of complex interfaces, the user's experience is improved.
[0176] For example, Fig. 9 A schematic diagram of a drawing method provided in an embodiment of the present application. Fig. 9 As shown, the method includes the following steps.
[0177] S901: The electronic device obtains parameter information of component A.
[0178] In some embodiments, if component A is a complex graphic, the application development kit corresponding to component A has preset parameter information of component A after refreshing the image frame, wherein the parameter information includes drawing parameters and time parameters.
[0179] In some embodiments, after the electronic device detects an input event, it can obtain parameter information of component A and determine the graphic data that needs to be segmented to draw component A. The input event includes, for example, a UI event or a user's operation that triggers a change in the display screen (such as a touch operation on the display screen).
[0180] In some embodiments, after the electronic device obtains the parameter information of component A, it can determine whether it is necessary to draw the graphic data of component A in segments. That is, determine whether component A is a complex graphic. For example, the view system determines that the graphic data of component A needs to be drawn in segments based on a preset identifier carried by the parameter information of component A, or based on a time parameter. Then, the rules for segmented drawing can be further determined. For example, the graphic data of component A is drawn in segments by evenly dividing the graphic data of component A. Alternatively, the graphic data of component A is drawn in segments according to the longest drawing time corresponding to the frame rate cycle.
[0181] For example, Fig. 6A As shown, the view system in the electronic device obtains the parameter information of the next refresh of component A preset in the application layer application development kit through the API in the first frame, such as the drawing parameters and time parameters of component A that need to be refreshed and displayed in the fourth frame. The view system determines that component A needs to be drawn in segments based on the preset identifier carried in the parameter information. Then, the view system can split the graphic data of component A according to the drawing parameters and time parameters according to the preset rules, and determine to draw component A in segments in the frames before the next refresh time. For example, it is determined that one-third of the graphic data of component A needs to be drawn in each of the three frames before the fourth frame of the next refresh.
[0182] Another example is Figure 8 As shown, the view system in the electronic device obtains the parameter information of the next refresh of component A preset in the application layer application development kit through the API in the first frame, and determines the refresh display of component A at a fixed time unit (such as 2 frames) according to the time parameter therein. Then it can be determined that component A needs to be drawn in segments according to the longest drawing time in the three frames before the fourth frame of the next refresh of component A.
[0183] S902: The electronic device determines whether it is time to refresh component A. If not, execute step S903; if so, execute step S905.
[0184] In some embodiments, after the electronic device obtains the parameter information of component A and determines the rule for segmented drawing of component A, it is necessary to determine whether it is the refresh time of component A in chronological order. That is, determine whether the current frame needs to refresh component A. If it is determined that it is not the refresh time of component A, it can be determined whether component A can be segmented (i.e., execute the following step S903). If it is determined that it is the refresh time of component A, it can be determined that the graphic data of component A that has been segmented and drawn needs to be obtained (i.e., execute the following step S905) to realize the refresh display of component A.
[0185] S903: The electronic device determines whether a preset condition is met. If the preset condition is met, step S904 may be executed; if the preset condition is not met, component A may not be drawn.
[0186] In some embodiments, the preset conditions include, for example, the existence of graphic data of component A to be drawn, and / or the existence of an idle time period of the CPU.
[0187] For example, Figure 6B As shown, the view system determines that the second frame is not a refresh time for component A. In the above step S901, the view system has determined that it is necessary to draw one-third of the graphic data of component A in the second frame in segments (that is, it is determined that there is graphic data A2 to be drawn). In addition, it is determined that the CPU is idle for the remaining time after drawing component B in the current frame. That is, the view system determines that the preset conditions are met and can execute the following step S904.
[0188] Again exemplary, corresponding to Figure 6B The scene shown, such as Figure 7 As shown, the view system determines that the second frame is not the refresh time of component A. The view system determines that there is graphic data A2 to be drawn in the second frame, but after drawing components B and C in the second frame, the remaining time does not meet the demand for drawing graphic data A2, that is, the CPU is not idle. Then, the view system determines that the preset condition is not met and no longer draws component A in the second frame.
[0189] For example, Figure 8As shown, the view system determines that the third frame is not the refresh time of component A, and the CPU is idle after drawing component B. However, the view system determines that there is no graphics data of component A to be drawn (that is, the segmented drawing of the graphics data of component A has been completed in the first frame and the second frame). Then, the view system determines that the preset condition is not met, and component A is no longer drawn in the third frame.
[0190] S904: The electronic device draws component A in sections, and inputs the drawn graphic data into a cache.
[0191] In some embodiments, the electronic device determines that the current time is not the refresh time of component A and meets the preset conditions, and can segmentally draw the graphic data of component A according to the segmented drawing rule exemplified in step S901 above. In addition, the segmented drawing data of component A is input into the cache so as to be used for synthesizing component A later.
[0192] For example, Figure 6A-6C As shown, if the segmented drawing rule is to evenly divide the graphic data of component A to be drawn according to the time parameter, then the view system draws one third of the graphic data of component A in the first frame, the second frame and the third frame respectively, and inputs the drawn graphic data A1, graphic data A2 and graphic data A3 into the buffer for storing segmented drawing data.
[0193] Another example is Figure 8 As shown, if the rule of segmented drawing is to draw the graphic data of component A to be drawn according to the longest drawing time corresponding to the frame rate cycle. Then, after the view system completes drawing component B in the first frame, it uses all the remaining time of the current frame rate cycle to draw component A according to the longest drawing time, such as obtaining the drawn graphic data A4. And, the graphic data A4 is input into the buffer for storing segmented drawing data. Afterwards, after drawing component B in the second frame, the remaining graphic data of component A is drawn according to the longest drawing time, such as obtaining the drawn graphic data A5, and the drawing of component A is completed. And, the graphic data A5 is input into the buffer for storing segmented drawing data.
[0194] S905: The electronic device obtains the drawn graphic data of component A from the cache.
[0195] S906: The electronic device synthesizes the component A layer and displays the image frame corresponding to component A.
[0196] In some embodiments, in step S905 and step S906, the electronic device determines that it is currently the refresh time of component A, such as determining that the current frame needs to refresh and display component A. Then, the electronic device can obtain the graphic data of component A that has been drawn in segments from the cache, render it, and synthesize the layer of component A, so as to display the refreshed component A in the current frame.
[0197] For example, Fig.6D As shown, in the fourth frame, the view system obtains the segmented drawn graphic data A1, graphic data A2, and graphic data A3 from the buffer, synthesizes the three parts of graphic data, and realizes refreshing the display component A.
[0198] Another example is Figure 8 As shown, in the fourth frame, the view system obtains the segmented drawn graphic data A4 and graphic data A5 from the buffer, synthesizes these two parts of graphic data, and realizes refreshing the display component A.
[0199] Optional, such as Fig. 9 As shown, the above method flow may further include step S907.
[0200] S907: The electronic device clears the data corresponding to component A in the cache.
[0201] In some embodiments, the electronic device determines that the composition of the component A layer has been completed in the current frame, and can delete the relevant data of the component A cached in the previous frame in the buffer, thereby ensuring that the buffer can meet the caching requirements of subsequent graphic data.
[0202] For example, Fig.6D As shown or Figure 8 As shown, in the fourth frame, the view system has refreshed the display component A and can delete the relevant data of component A cached in the buffer.
[0203] Optionally, the rest of the above steps S901 to S907 can refer to the above Figure 6A-6D , Figure 7 or Figure 8 The relevant contents shown will not be repeated here.
[0204] In this way, the rendering method provided in the embodiment of the present application does not require hardware modification for lightweight devices, such as increasing the CPU processing speed or expanding the hardware acceleration processing module, and can also avoid the jamming phenomenon caused by frame drops during the display of complex interfaces by means of segmented rendering. While ensuring the user's demand for high frame rate display of complex interfaces, the user's experience is improved.
[0205] For example, Fig.10A schematic diagram of a flow chart of another drawing method provided in an embodiment of the present application. Fig.10 As shown, the method includes the following steps.
[0206] S1001. An electronic device refreshes a first image to a second image at a first time point.
[0207] In some embodiments, the target component in the second image is different from the target component in the first image, that is, some graphic data (such as the target component) in the image frames before and after the first time point are different, and the graphic data of the target component needs to be drawn.
[0208] For example, Figure 6A-Figure 8 In the scene shown, the first time point is the starting time point of the first frame.
[0209] S1002: Between the first time point and the second time point, the electronic device generates first drawing data of a target component to be refreshed and displayed at a third time point, and refreshes the image at least once.
[0210] In some embodiments, the time sequence of the first time point, the second time point and the third time point is that the first time point is before the second time point, and the second time point is before the third time point.
[0211] In some embodiments, the target component in each refreshed image is the same as the target component in the second image. That is, between the first time point and the second time point, the target component in the displayed image frame does not need to be redrawn.
[0212] For example, Figure 6A-Figure 8 In the scenario shown, the first time point is the starting time point of the first frame, and the second time point can be any time point among the starting time point of the second frame, the starting time point of the third frame, or the starting time point of the fourth frame. It can be understood that at the starting time point of each frame or at the end time point of each frame, the electronic device refreshes the displayed image.
[0213] In some embodiments, before determining between the first time point and the second time point, to generate the first drawing data of the target component to be displayed after refreshing at the third time point, it is necessary to determine at the first time point that the target component displayed after refreshing at the third time point is different from the target component in the second image. Alternatively, it is necessary to determine at the first time point that the target component displayed after refreshing at the third time point at a preset time interval is different from the target component in the second image. That is, before determining to draw the target component in sections, it is necessary to determine that the target component is a complex component and needs to be drawn in sections.
[0214] Exemplarily, the electronic device obtains parameter information of the target component at a first time point, such as drawing parameters and time parameters. If the electronic device obtains the time point of the next refresh as a third time point at the first time point based on the time parameters, it can be determined that the target component displayed after the refresh at the third time point is different from the target component displayed before the refresh. Therefore, it is determined that the target component needs to be drawn in segments. Alternatively, the electronic device determines that the number of time units in each refresh interval of the target component is a fixed number greater than 0 based on the time parameters, and it can be determined that the target component needs to be drawn in segments, that is, the target component is drawn in segments according to the number of time units in the interval.
[0215] In some embodiments, the electronic device determines that the time interval between the first time point and the second time point is a first number of frame rate cycles, the second time point and the third time point differ by one frame rate cycle, and the electronic device refreshes the image according to the frame rate cycle. The to-be-drawn data of the target component to be displayed after being refreshed at the third time point are evenly divided according to the first number. Based on the division result, the first drawing data is generated between the first time point and the second time point.
[0216] For example, Fig. 6A As shown, after the electronic device determines that component A needs to be drawn in segments, it determines that the current frame is the first frame, and there are three frames of time from the next refreshed fourth frame, which can be used to segmentally draw the graphic data of component A. Therefore, the electronic device can split the graphic data of component A according to preset rules to determine the graphic data that needs to be drawn in each frame. For example, the electronic device divides the graphic data of component A into three parts, such as A1, A2 and A3, according to the three frame times of the first frame, the second frame and the third frame. The splitting of the component's graphic data can be determined according to the data structure of the component. Fig. 6A As shown, the developer determines the matrix information of the component A to be displayed, and divides the matrix corresponding to the component A equally, with A1, A2 and A3 corresponding to one third of the matrix respectively.
[0217] In some embodiments, the electronic device may draw the component according to the number of segments of the to-be-drawn data of the component.
[0218] For example, the first number is N, where N is an integer greater than or equal to 2, and one N of the data to be drawn of the target component to be displayed after being refreshed at a third time point is drawn in each refresh cycle between the first time point and the second time point to generate first drawing data, and the first drawing data is saved to the target storage area.
[0219] For example, Fig. 6A As shown, the electronic device first completes the drawing of the graphic data of component B in the first frame, and then determines to draw A1. After A1 is drawn, A1 is cached in the buffer (i.e., the target storage area). Figure 6BAs shown in the figure, in the second frame, after the view system finishes drawing the graphics data of component B, it draws A2 and puts the drawn A2 into the buffer. Figure 6C As shown, in the third frame, after the view system completes drawing the graphics data of component B, it draws A3 and puts the drawn A3 into the buffer. Among them, A1, A2 and A3 are each one-third of component A.
[0220] For another example, according to the division result, in each frame rate period within the first frame rate period between the first time point and the second time point, the data to be drawn of the target component to be displayed after being refreshed at the third time point is drawn to generate the first drawing data, and in the remaining second frame rate period, the data to be drawn of the target component to be displayed after being refreshed at the third time point is not drawn. The CPU usage rate in the first frame rate period is less than or equal to the first threshold, and the CPU usage rate in the second frame rate period is greater than the first threshold.
[0221] For example, corresponding to Fig. 6A The scene shown, such as Figure 7 As shown, if the electronic device also divides component A into three parts, A1, A2 and A3, according to the three frames that do not need to refresh component A. Among them, if the original graphics data to be drawn in the second frame includes the graphics data of component B and the graphics data of component C. After the electronic device determines to draw the graphics data of component B and the graphics data of component C, the CPU is no longer idle (that is, the usage rate is greater than the first threshold). If the time taken to draw the graphics data of component B and the graphics data of component C is equal to the frame rate cycle length, or the remaining time is not enough to draw A2. Then, the electronic device determines to postpone the drawing of A2. Afterwards, if Figure 7 As shown, after the electronic device has finished drawing the graphic data and A3 of component B in the third frame, it determines whether the CPU is idle (whether the usage rate is less than or equal to the first threshold). If it is idle (i.e., the usage rate is less than or equal to the first threshold), the delayed A2 can be drawn. Alternatively, after the graphic data and A3 of component B are drawn in the third frame, it is determined that the CPU is not idle, or the remaining time is insufficient to draw A2, and A2 can be postponed until the frame before the refreshed frame or the CPU is idle in the refreshed frame, and A2 is drawn. For example, A2 is drawn in the fourth frame and the layer of component A is synthesized.
[0222] In some embodiments, the period between the first time point and the second time point includes (a+b) frame rate periods, where a and b are integers. The data to be drawn of the target component to be displayed after being refreshed at the third time point is drawn in the a frame rate periods between the first time point and the second time point to generate the first drawing data, and the data to be drawn of the target component to be displayed after being refreshed at the third time point is not drawn in the b frame rate periods between the first time point and the second time point. Among them, the CPU usage rate in the a frame rate periods is less than or equal to the first threshold, and the CPU usage rate in the b frame rate periods is greater than the first threshold. Alternatively, the drawing of the data to be drawn of the target component to be displayed after being refreshed at the third time point has been completed in the a frame rate periods in which the CPU usage rate is less than or equal to the first threshold.
[0223] Optionally, in the frame rate cycles among the a frame rate cycles except the last frame rate cycle in the chronological order, after generating the first drawing data, the CPU usage is greater than or equal to the first threshold.
[0224] For example, corresponding to Fig. 6A The scene shown, such as Figure 8 As shown, the electronic device determines that component A is a complex graphic, and according to the obtained time parameter of the next refresh of component A, determines that component A can be drawn in segments in the first frame, the second frame, and the third frame. Then, after the electronic device completes drawing the graphic data of component B in the first frame, it determines that the CPU is idle (that is, the usage rate is less than or equal to the first threshold), and the remaining time of the current frame can be determined as the time for drawing part of the graphic data of component A. Figure 8 As shown, the electronic device determines that the remaining time is limited to drawing A4 data size of graphic data, and can separate A4 from the graphic data of component A, and complete the drawing of A4 in the first frame. That is, the duration of the first frame is determined as the longest drawing time, and the graphic data is drawn according to the longest drawing time, which will also not cause frame drops. Alternatively, a maximum drawing time threshold is set, and the maximum drawing time threshold is less than or equal to the duration of the frame rate cycle, and the electronic device draws the graphic data according to the maximum drawing time threshold. Afterwards, as Figure 8 As shown, in the second frame, the electronic device can also draw the graphic data according to the longest drawing time threshold. For example, if the remaining graphic data of component A (such as A5) is determined and there is still remaining time in the second frame after the second frame is completely drawn, the electronic device can stop drawing graphics in the current frame.
[0225] That is to say, the electronic device can adaptively adjust whether to draw the target component in the frame rate period between the first time point and the second time point, and the size of the first drawing data for drawing the target component, according to the length of the frame rate period and the CPU usage rate. Then, if the target component is drawn according to the longest drawing time, then the frame rate periods other than the last frame rate period in the time sequence among the a frame rate periods used to draw the target component should meet the requirement of the longest drawing time, that is, the CPU usage rate after drawing is greater than or equal to the first threshold. After the target component is drawn in the last frame rate period, the CPU usage rate may be greater than or equal to the first threshold, or less than the first threshold.
[0226] S1003: The electronic device refreshes the image at a third time point according to the first drawing data.
[0227] In some embodiments, the target component in the refreshed third image is different from the target component in the second image.
[0228] For example, Fig.6D As shown, the electronic device determines to refresh component A in the fourth frame. In the fourth frame, the electronic device obtains the cached A1, A2 and A3 from the buffer (ie, the target storage area), and can directly synthesize the component A layer and render it, thereby realizing the refresh display of the fourth frame.
[0229] In some embodiments, the first drawing data is all or part of the drawing data of the target component to be displayed after being refreshed at the third time point.
[0230] For example, the first drawing data is part of the drawing data of the target component to be displayed after being refreshed at the third time point. Then, if the proportion of the first drawing data to the total drawing data of the target component to be displayed after being refreshed at the third time point is greater than or equal to the second threshold, the remaining second drawing data is generated between the second time point and the third time point. Alternatively, if the proportion of the first drawing data to the total drawing data of the target component to be displayed after being refreshed at the third time point is less than the second threshold, the first drawing data is discarded.
[0231] For example, the second threshold is a percentage threshold. For example, the second threshold is 80% of the target component data volume. The electronic device determines that the target component has completed 90% of the drawing in the frame corresponding to the refresh timing, and can draw the remaining 10% of the data in the frame. For another example, the second threshold is 80% of the target component data volume. The electronic device determines that the target component has only completed 30% of the drawing in the frame corresponding to the refresh timing, and can redraw the component in the frame. Thereby, the display efficiency is improved while ensuring the normal display of the target component.
[0232] In this way, the rendering method provided in the embodiment of the present application does not require hardware modification for lightweight devices, such as increasing the CPU processing speed or expanding the hardware acceleration processing module, and can also avoid the jamming phenomenon caused by frame drops during the display of complex interfaces by means of segmented rendering. While ensuring the user's demand for high frame rate display of complex interfaces, the user's experience is improved.
[0233] Combination of the above Figure 6A-Figure 10 The drawing method provided by the embodiment of the present application is described in detail. Fig.11 The drawing device provided in the embodiment of the present application is described in detail.
[0234] In one possible design, Fig.11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.11 As shown, the electronic device 1100 may include: a display unit 1101 and a processing unit 1102. The electronic device 1100 may be used to implement the functions of the electronic device involved in the above method embodiments.
[0235] Optionally, the display unit 1101 is used to support the electronic device 1100 to display interface content; and / or to support the electronic device 1100 to execute Fig. 9 The S906 in the.
[0236] Optionally, the processing unit 1102 is used to support the electronic device 1100 to execute Fig. 9 S901-S905, and S907; and / or, for supporting the electronic device 1100 to execute Fig.10 S1001-S1003 in.
[0237] Among them, the transceiver unit may include a receiving unit and a sending unit, and may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module. The operations and / or functions of each unit in the electronic device 1100 are respectively to implement the corresponding processes of the drawing method described in the above method embodiment. All relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional unit, and for the sake of brevity, they will not be repeated here.
[0238] Optionally, Fig.11 The electronic device 1100 shown may also include a storage unit ( Fig.11 (not shown), the storage unit stores a program or instruction. When the display unit 1101 and the processing unit 1102 execute the program or instruction, Fig.11 The electronic device 1100 shown can execute the drawing method described in the above method embodiment.
[0239] Fig.11The technical effects of the electronic device 1100 shown can refer to the technical effects of the drawing method described in the above method embodiment, which will not be repeated here.
[0240] In addition to being in the form of electronic device 1100, the technical solution provided in the present application may also be a functional unit or chip in the electronic device, or a device used in conjunction with the electronic device.
[0241] An embodiment of the present application also provides a chip system, including: a processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the chip system implements the method in any of the above method embodiments.
[0242] Optionally, the processor in the chip system may be one or more. The processor may be implemented by hardware or by software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented by software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.
[0243] Optionally, the memory in the chip system may also be one or more. The memory may be integrated with the processor or may be separately arranged with the processor, which is not limited in the embodiments of the present application. Exemplarily, the memory may be a non-transient processor, such as a read-only memory ROM, which may be integrated with the processor on the same chip or may be arranged on different chips respectively. The embodiments of the present application do not specifically limit the type of memory and the arrangement of the memory and the processor.
[0244] Exemplarily, the chip system can be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD) or other integrated chips.
[0245] It should be understood that each step in the above method embodiment can be completed by an integrated logic circuit of hardware in a processor or by instructions in the form of software. The method steps disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware processor, or by a combination of hardware and software modules in a processor.
[0246] The embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is run on a computer, the computer executes the above-mentioned related steps to implement the drawing method in the above-mentioned embodiment.
[0247] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement the drawing method in the above-mentioned embodiment.
[0248] In addition, an embodiment of the present application further provides a device. The device may be a component or a module, and the device may include one or more processors and a memory connected to each other. The memory is used to store a computer program. When the computer program is executed by one or more processors, the device performs the drawing method in each of the above method embodiments.
[0249] Among them, the device, computer-readable storage medium, computer program product or chip provided in the embodiments of the present application are used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0250] The steps of the method or algorithm described in conjunction with the disclosed content of the embodiments of the present application can be implemented in hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, read-only compact disks (CD-ROMs) or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC).
[0251] Through the description of the above implementation methods, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed; that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0252] In the several embodiments provided in the present application, it should be understood that the disclosed method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of modules or units, which can be electrical, mechanical or other forms.
[0253] 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0254] Computer-readable storage media include, but are not limited to, any of the following: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and other media that can store program codes.
[0255] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A drawing method, characterized in that: Applied to electronic equipment, the method comprises: Refreshing the first image to a second image at a first time point, wherein a target component in the second image is different from a target component in the first image, and pre-configured time parameter information of the target component in the second image is used to indicate a third time point; Between the first time point and the second time point, generating first drawing data of a target component to be displayed after being refreshed at the third time point, and refreshing the image at least once, wherein the target component in the image after each refresh is the same as the target component in the second image; refreshing an image at the third time point according to the first drawing data, wherein a target component in the refreshed third image is different from a target component in the second image; The step of generating first drawing data of a target component to be displayed after being refreshed at a third time point between the first time point and the second time point includes: Determine that the time interval between the first time point and the second time point is a first number of frame rate cycles, the second time point differs from the third time point by one frame rate cycle, and the electronic device refreshes the image according to the frame rate cycle, wherein the first number is N, and N is an integer greater than 2; evenly divide the to-be-drawn data of the target component to be displayed after being refreshed at the third time point according to the first number; According to the division result, generating the first drawing data between the first time point and the second time point; The step of generating the first drawing data between the first time point and the second time point according to the division result includes: One Nth of the to-be-drawn data of the target component to be displayed after being refreshed at the third time point is drawn in each refresh cycle between the first time point and the second time point, to generate the first drawing data.
2. The method according to claim 1, characterized in that Before generating the first drawing data of the target component to be displayed after being refreshed at a third time point between the first time point and the second time point, the method further includes: Determine at the first time point that the target component displayed after refreshing at the third time point is different from the target component in the second image; or determine at the first time point that the target component displayed after refreshing at the third time point at a preset time interval is different from the target component in the second image.
3. The method according to claim 1, characterized in that The step of generating the first drawing data between the first time point and the second time point according to the division result includes: According to the division result, in each frame rate period within the first frame rate period between the first time point and the second time point, the data to be drawn of the target component to be displayed after being refreshed at the third time point is drawn to generate the first drawing data, and in the remaining second frame rate period, the data to be drawn of the target component to be displayed after being refreshed at the third time point is not drawn; wherein the usage rate of the central processing unit CPU in the first frame rate period is less than or equal to the first threshold, and the usage rate of the CPU in the second frame rate period is greater than the first threshold.
4. The method according to claim 1 or 2, characterized in that: The period between the first time point and the second time point includes (a+b) frame rate cycles, where a and b are integers. The period between the first time point and the second time point, generating first drawing data of a target component to be displayed after being refreshed at a third time point, includes: Draw the data to be drawn of the target component to be refreshed and displayed at the third time point in a frame rate cycles between the first time point and the second time point to generate the first drawing data, and do not draw the data to be drawn of the target component to be refreshed and displayed at the third time point in b frame rate cycles between the first time point and the second time point; Wherein, in the a frame rate period, the CPU usage rate is less than or equal to the first threshold, and in the b frame rate period, the CPU usage rate is greater than the first threshold; Alternatively, the drawing of the to-be-drawn data of the target component to be displayed after being refreshed at the third time point has been completed in the a frame rate periods in which the CPU usage rate is less than or equal to the first threshold.
5. The method according to claim 4, characterized in that In the frame rate cycles among the a frame rate cycles except the last frame rate cycle in chronological order, after generating the first drawing data, the CPU usage rate is greater than or equal to the first threshold.
6. The method according to any one of claims 1 to 5, characterized in that: The first drawing data is all or part of the drawing data of the target component to be displayed after being refreshed at the third time point.
7. The method according to claim 6, characterized in that The first drawing data is partial drawing data of the target component to be displayed after being refreshed at the third time point, and the method further includes: If the proportion of the first drawing data to the total drawing data of the target component to be displayed after being refreshed at the third time point is greater than or equal to a second threshold, generating remaining second drawing data between the second time point and the third time point; If the proportion of the first drawing data to the entire drawing data of the target component to be displayed after being refreshed at the third time point is less than a second threshold, the first drawing data is discarded.
8. The method according to any one of claims 1 to 7, characterized in that: After generating first drawing data of a target component to be displayed after being refreshed at a third time point between the first time point and the second time point, the method further includes: The first drawing data is saved in a target storage area.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is coupled to the processor, and the memory is used to store computer-readable instructions. When the processor reads the computer-readable instructions from the memory, the electronic device executes the method as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises a computer program, and when the computer program is executed on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 8.
11. A computer program product, characterized in that When the computer program product is executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 8.
Citation Information
Cited By
Drawing method and electronic device
WO2023103800A1
