Statistical method, decision-making method, electronic equipment, storage medium and program product
By counting the number of drawing operations for each view in a view group and combining this with the number of reused frames and the score, the problem of the inability to effectively decide on off-screen rendering strategies in existing technologies is solved, thus improving the speed of counting the number of view drawing operations and system performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-10-24
- Publication Date
- 2026-04-24
AI Technical Summary
The lack of a method for counting the number of view drawing operations in existing technologies makes it impossible to effectively decide on the off-screen rendering strategy for views, thus increasing system performance overhead.
The second number of drawing operations for the target view is obtained by summing the number of first drawing operations for each view in the view group, and the off-screen rendering strategy for the view is determined by combining the number of reused frames and the score.
It improved the speed of counting the number of view drawing operations, reduced system performance overhead, optimized off-screen rendering decisions, and reduced the overall system performance overhead.
Smart Images

Figure CN121918784A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically to a statistical method, a decision-making method, an electronic device, a storage medium, and a program product. Background Technology
[0002] Typically, a frame of an image displayed on the screen of an electronic device consists of multiple views. When a frame of an image needs to be displayed on the screen of an electronic device, the multiple views in the image are first drawn separately; then the multiple views are rendered to obtain a frame of an image used for display on the screen.
[0003] In some application scenarios (such as swipe and click operations), the display interface of electronic devices may contain views that remain unchanged for multiple consecutive frames. Understandably, this results in a large amount of repetitive rendering. To reduce the overhead of repetitive rendering, off-screen rendering can be used for views that remain unchanged for multiple consecutive frames. This means that during graphics processing, a new buffer is created outside the current screen buffer for rendering operations, and the off-screen rendered view can be reused across multiple frames.
[0004] It's understandable that different views have different rendering overhead. For example, simple views have lower rendering overhead, while complex views have higher rendering overhead. Furthermore, compared to on-screen rendering, off-screen rendering of a view incurs additional performance overhead related to the off-screen rendering operation. If the view's own rendering overhead is low, the increased performance overhead from off-screen rendering may exceed the view's own rendering overhead, leading to an increase in overall system performance overhead after off-screen rendering. Therefore, not all views that remain unchanged for multiple consecutive frames are suitable for off-screen rendering. Before off-screen rendering a view, it's necessary to decide on the off-screen rendering strategy based on the view's own characteristics, i.e., whether to off-screen render the view at all.
[0005] Typically, drawing a view requires one or more drawing operations. The applicant's research revealed that the number of view drawing operations significantly impacts the overhead of repeated rendering. However, existing technologies lack a statistical method for calculating the number of view drawing operations, making it impossible to use the number of view drawing operations to determine off-screen rendering strategies.
[0006] It should be noted that the information disclosed in the background section of this application is intended only to enhance the understanding of the general background of this application, and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention
[0007] This application provides a method for counting the number of view drawing operations, a method for making off-screen rendering decisions for views, an electronic device, a storage medium, and a program product, in order to solve the problem in the prior art that the lack of a method for counting the number of view drawing operations makes it impossible to make decisions on off-screen rendering strategies based on the number of view drawing operations.
[0008] In a first aspect, embodiments of this application provide a method for counting the number of drawing operations of a view, comprising: determining the first number of drawing operations for each view in a view group, wherein the view group is a view group in a view tree of a frame with a target view as the root view, and the first number of drawing operations is the number of drawing operations performed by the view itself; and summing the first number of drawing operations for each view in the view group to obtain the second number of drawing operations corresponding to the target view.
[0009] In this embodiment, the number of first drawing operations of all views in the view group with the target view as the root view is accumulated to obtain the number of second drawing operations corresponding to the target view, that is, the total number of drawing operations corresponding to the target view. Then, the off-screen rendering strategy of the target view can be decided by the total number of drawing operations corresponding to the target view.
[0010] In one possible implementation, determining the first drawing operation count for each view in the view group includes: during the drawing process of a frame, counting the number of drawing operations performed by each view in the view tree of the frame to obtain the first drawing operation count for each view in the view tree of the frame; performing a depth-first traversal of the view tree of the frame to determine the view group with the target view as the root view in the view tree of the frame.
[0011] In this embodiment of the application, the number of first drawing operations for each view in the screen is counted during the drawing process. This eliminates the need to re-traverse the drawing operations in the view after the drawing is completed, thereby improving the speed of counting the number of drawing operations and reducing the performance overhead of the system.
[0012] In one possible implementation, performing a depth-first traversal of the view tree of the screen to determine the view group with the target view as the root view in the view tree of the screen includes: performing a first depth-first traversal of the view tree of the screen to determine the rendering level of the screen and the view group with the target view as the root view in the view tree of the screen, wherein the rendering level is used to characterize the rendering order of the view tree of the screen.
[0013] In this embodiment of the application, by performing a depth traversal, both the "rendering level of the image" and the "view group in the view tree with the target view as the root view" can be determined simultaneously, which can improve the speed of counting the number of drawing operations and reduce the performance overhead of the system.
[0014] In one possible implementation, the step of performing a depth-first traversal of the view tree of the screen to determine the view group with the target view as the root view in the view tree of the screen includes: performing a second depth-first traversal of the view tree of the screen with the target view as the root view to determine the view group with the target view as the root view in the view tree of the screen.
[0015] In this embodiment, an independent depth traversal process is set up to count the number of drawing operations, resulting in lower coupling between modules in the software.
[0016] In one possible implementation, determining the first number of drawing operations for each view in the view group includes: after drawing a frame, performing a depth-first traversal of the view tree of the frame to determine the view group with the target view as the root view in the view tree of the frame, and the first number of drawing operations for each view in the view group.
[0017] In one possible implementation, the step of performing a depth-first traversal of the view tree of the screen after rendering a frame, and determining the view group with the target view as the root view in the view tree of the screen, and the number of first rendering operations for each view in the view group, includes: performing a first depth-first traversal of the view tree of the screen after rendering a frame, and determining the rendering level of the screen, the view group with the target view as the root view in the view tree of the screen, and the number of first rendering operations for each view in the view group, wherein the rendering level is used to characterize the rendering order of the view tree of the screen.
[0018] In one possible implementation, the step of performing a depth-first traversal of the view tree of the screen after a frame is drawn, and determining the view group with the target view as the root view in the view tree of the screen, and the first number of drawing operations for each view in the view group, includes: performing a second depth-first traversal of the view tree of the screen with the target view as the root view after a frame is drawn, and determining the view group with the target view as the root view in the view tree of the screen, and the first number of drawing operations for each view in the view group.
[0019] In one possible implementation, the step of summing the first drawing operation counts of each view in the view group to obtain the second drawing operation count corresponding to the target view includes: summing the first drawing operation counts of each view in each subview group to obtain the second drawing operation count corresponding to each subview of the target view, wherein the subview group is a view group with the subviews of the target view as root views; and summing the first drawing operation count of the target view and the second drawing operation count corresponding to each subview to obtain the second drawing operation count corresponding to the target view.
[0020] Secondly, embodiments of this application provide an off-screen rendering decision method for a view, comprising: calculating a second number of drawing operations corresponding to a target view using the method described in any one of the first aspects; and making a decision on an off-screen rendering strategy for the target view based on the second number of drawing operations corresponding to the target view, wherein the off-screen rendering strategy includes performing off-screen rendering and not performing off-screen rendering.
[0021] In one possible implementation, the step of deciding on the off-screen rendering strategy of the target view based on the second number of drawing operations corresponding to the target view includes: deciding on the off-screen rendering strategy of the target view based on the second number of drawing operations corresponding to the target view, the number of reused frames, and a score; wherein the number of reused frames is the number of frames of the target view that are reused consecutively, and the score is used to characterize the complexity of the target view.
[0022] Thirdly, embodiments of this application provide an electronic device, including: a processor; a memory; and a computer program stored on the memory, wherein the processor executes the computer program to implement the method described in either the first or second aspect.
[0023] Fourthly, embodiments of this application provide a computer-readable storage medium, comprising: the computer-readable storage medium storing a computer program, wherein when the computer program is executed, it implements the method described in either the first aspect or the second aspect.
[0024] Fifthly, embodiments of this application provide a computer program product, including: a computer program, which, when executed, implements the method described in either the first or second aspect. Attached Figure Description
[0025] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0027] Figure 2 A hardware structure block diagram of an electronic device provided in an embodiment of this application;
[0028] Figure 3 A software structure block diagram of an electronic device provided in an embodiment of this application;
[0029] Figure 4 A schematic diagram of a frame provided in an embodiment of this application;
[0030] Figure 5 An embodiment provided in this application Figure 4 The diagram shown illustrates the display principle of a single frame of an image.
[0031] Figure 6 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0032] Figure 7 A schematic flowchart of a method for counting the number of drawing operations of a view provided in an embodiment of this application;
[0033] Figure 8 A schematic diagram of a view provided for an embodiment of this application;
[0034] Figure 9 A list of instructions for a view group provided in an embodiment of this application;
[0035] Figure 10 A schematic flowchart of a method for counting the number of drawing operations of another view provided in an embodiment of this application;
[0036] Figure 11 A schematic flowchart of a method for counting the number of drawing operations of another view provided in an embodiment of this application;
[0037] Figure 12 A flowchart illustrating a method for counting the number of drawing operations of a view, as provided in an embodiment of this application;
[0038] Figure 13 A schematic flowchart of a method for counting the number of drawing operations of another view provided in an embodiment of this application;
[0039] Figure 14 A flowchart illustrating a method for counting the number of drawing operations of another view provided in an embodiment of this application;
[0040] Figure 15 A schematic flowchart of a method for counting the number of drawing operations of another view provided in an embodiment of this application;
[0041] Figure 16 This is a schematic diagram of a method for counting the number of drawing operations of another view provided in an embodiment of this application;
[0042] Figure 17 A flowchart illustrating an instruction for a method of counting the number of drawing operations of a view, provided in an embodiment of this application.
[0043] Figure 18 A schematic diagram of an off-screen rendering decision method for a view provided in an embodiment of this application;
[0044] Figure 19 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0045] To better understand the technical solution of this application, the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0046] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0047] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0048] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0049] See Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 1As shown, the electronic device is a terminal device 100, specifically a mobile phone. Of course, besides mobile phones, the terminal device 100 can also be a tablet computer, a personal computer (PC), a personal digital assistant (PDA), a smartwatch, a netbook, a wearable electronic device, an augmented reality (AR) device, a virtual reality (VR) device, an in-vehicle device, a robot, smart glasses, etc. This application embodiment does not impose specific limitations on these.
[0050] See Figure 2 This is a hardware structure block diagram of an electronic device provided in an embodiment of this application. Figure 2 As shown, 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 speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0051] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0052] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.
[0053] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0054] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0055] In some embodiments, the processor 110 may include one or more interfaces. Interfaces 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.
[0056] 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 I2C buses. The processor 110 can couple to the touch sensor 180K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 110 can couple to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0057] The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the I2S interface to enable the function of answering phone calls through a Bluetooth headset.
[0058] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via the PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface, enabling the function of answering phone calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0059] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 via the UART interface to implement Bluetooth functionality. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the UART interface to enable music playback through Bluetooth headphones.
[0060] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to enable the electronic device 100 to capture images. The processor 110 and the display screen 194 communicate via the DSI interface to enable the electronic device 100 to display images.
[0061] The GPIO interface can be configured via software. It can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to a camera 193, a display screen 194, a wireless communication module 160, an audio module 170, a sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0062] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0063] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0064] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0065] The power management module 141 connects 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, providing power to the processor 110, internal memory 121, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0066] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0067] 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 one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0068] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0069] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0070] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. 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 antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0071] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via 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 technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0072] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0073] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0074] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0075] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0076] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0077] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP performs Fourier transforms on the frequency energy.
[0078] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0079] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0080] The external storage 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 storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0081] Internal memory 121 can be used to store computer executable program code, which includes instructions. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 110 executes various functional applications and data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory located in the processor.
[0082] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0083] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0084] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0085] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.
[0086] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.
[0087] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.
[0088] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A can be disposed on display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. A capacitive pressure sensor may include at least two parallel plates with conductive material. When force is applied to pressure sensor 180A, the capacitance between the electrodes changes. Electronic device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to display screen 194, electronic device 100 detects the intensity of the touch operation based on pressure sensor 180A. Electronic device 100 can also calculate the touch position based on the detection signal from pressure sensor 180A. In some embodiments, touch operations applied to the same touch position but with different touch operation intensities can correspond to different operation commands. For example, when a touch operation with an intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS is executed.
[0089] The gyroscope sensor 180B can be used to determine the motion attitude of the electronic device 100. In some embodiments, the gyroscope sensor 180B can determine the angular velocity of the electronic device 100 about three axes (i.e., the x, y, and z axes). The gyroscope sensor 180B can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of the shake of the electronic device 100, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to counteract the shake of the electronic device 100 by moving in the opposite direction, thus achieving image stabilization. The gyroscope sensor 180B can also be used in navigation and motion-sensing game scenarios.
[0090] The barometric pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates altitude using the air pressure value measured by the barometric pressure sensor 180C to assist in positioning and navigation.
[0091] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip cover. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover using the magnetic sensor 180D. Then, based on the detected opening and closing state of the cover or the flip cover, features such as automatic flip unlocking can be set.
[0092] The 180E accelerometer can detect the magnitude of acceleration of electronic device 100 in various directions (typically three axes). When electronic device 100 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the posture of electronic devices and applied to applications such as screen orientation switching and pedometers.
[0093] A distance sensor 180F is used to measure distance. Electronic device 100 can measure distance via infrared or laser. In some embodiments, during a shooting scene, electronic device 100 can utilize the distance sensor 180F to measure distance for rapid focusing.
[0094] The proximity sensor 180G may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The LED may be an infrared LED. The electronic device 100 emits infrared light outward through the LED. The electronic device 100 uses the photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 may use the proximity sensor 180G to detect when a user holds the electronic device 100 close to their ear for a call, so as to automatically turn off the screen to save power. The proximity sensor 180G can also be used in holster mode and pocket mode for automatic unlocking and locking of the screen.
[0095] The ambient light sensor 180L is used to sense the brightness of ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 194 based on the sensed ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also work with the proximity sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
[0096] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can utilize the characteristics of the collected fingerprints to achieve fingerprint unlocking, accessing application locks, taking photos with fingerprints, answering calls with fingerprints, etc.
[0097] Temperature sensor 180J is used to detect temperature. In some embodiments, electronic device 100 uses the temperature detected by temperature sensor 180J to execute a temperature handling strategy. For example, when the temperature reported by temperature sensor 180J exceeds a threshold, electronic device 100 performs thermal protection by reducing the performance of a processor located near temperature sensor 180J to reduce power consumption. In other embodiments, when the temperature is below another threshold, electronic device 100 heats battery 142 to prevent abnormal shutdown of electronic device 100 due to low temperature. In still other embodiments, when the temperature is below yet another threshold, electronic device 100 boosts the output voltage of battery 142 to prevent abnormal shutdown due to low temperature.
[0098] Touch sensor 180K, also known as a "touch device," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touchscreen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194.
[0099] The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire vibration signals from the vibrating bone segments of the human vocal cords. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure signals. In some embodiments, the bone conduction sensor 180M can also be incorporated into headphones to form bone conduction headphones. The audio module 170 can parse the voice signals from the vibrating bone segments of the vocal cords acquired by the bone conduction sensor 180M to realize voice functionality. The application processor can parse heart rate information from the blood pressure signals acquired by the bone conduction sensor 180M to realize heart rate detection functionality.
[0100] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0101] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can correspond to touch operations performed on different applications (such as taking photos, playing audio, etc.). Motor 191 can also correspond to different vibration feedback effects for touch operations performed on different areas of the display screen 194. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.
[0102] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0103] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to make contact with and separate from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0104] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0105] See Figure 3 This is a software structure block diagram of an electronic device provided in an embodiment of this application. Figure 3 As shown, the layered architecture divides the software into several layers, each with a clear role and function. 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 Android runtime and system libraries, and the kernel layer.
[0106] The application layer can include a series of application packages. For example... Figure 3 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0107] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0108] like Figure 3 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0109] The Window Manager Service (WMS) is used to manage window applications. The Window Manager can obtain the screen size, determine if a status bar is present, lock the screen, and capture screenshots, among other things.
[0110] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0111] The view system includes views, ViewRootlmpl, etc. A display interface can consist of one or more views. For example, a display interface including a text message notification icon can include views that display text and views that display images. ViewRootlmpl is the top of a view hierarchy and can be understood as the manager of the root view of all views in a window. ViewRootlmpl is used to implement the communication between views and the Windows Management System (WMS) to control the rendering of the window.
[0112] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0113] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0114] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0115] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0116] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0117] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0118] System libraries can include multiple functional modules. Examples include: surface manager, media libraries, 3D graphics processing libraries, and 2D graphics engines.
[0119] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0120] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0121] A 2D graphics engine is a drawing engine for 2D graphics. Examples include Hardware UI (HWUI) and Skia Graphics Library (SGL). HWUI is a component in the Android system used to handle UI rendering operations for applications. Compared to traditional software rendering methods, HWUI can utilize GPU hardware to draw the interface, improving drawing efficiency and smoothness, while supporting advanced features such as view stacking, animation, and custom drawing. Skia is middleware for converting HWUI to OpenGLES commands. Skia provides basic drawing functions, including graphics, text, and bitmaps. It supports hardware-accelerated rendering, fully utilizing the GPU for concurrent computing to speed up UI rendering. Skia also provides powerful API interfaces, facilitating developers to customize image drawing and processing.
[0122] DisplayList, SkiaDisplayList, DisplayListData, SkiaDisplayListWrapper, DrawFrameTask, RenderNode, RenderNodeDrawable, SkiaRecordingCanvas, CanvasContext, etc. are defined in HWUI and SGL.
[0123] DisplayList is HWUI's display list, recording drawing operations along with their position, size, and other information. During the drawing process, these operations are explicitly cached for faster subsequent processing. DisplayList also allows the same parts of the view tree to be reused across multiple frames, thus saving considerable memory and bandwidth.
[0124] SkiaDisplayList contains DisplayListData, which is used to package and store DisplayList drawing commands.
[0125] SkiaDisplayListWrapper is a wrapper class that wraps an mImpl object of type SkiaDisplayList.
[0126] DrawFrameTask is responsible for managing each frame of rendering tasks in hardware rendering, including layout measurement and construction, multi-level management, etc.
[0127] RenderNode is the rendering node in HWUI, corresponding to a node in a view hierarchy. Whenever the display state of a View changes, it recalculates the layout and position of all its child items and generates a new DisplayList. Various attributes used during the View drawing process, such as opacity and border, are saved and managed through RenderNode.
[0128] RenderNodeDrawable is a subclass of the Drawable class, used to render folder contents. A folder is a special view that can contain multiple subviews and can have its background set.
[0129] SkiaRecordingCanvas is used to create corresponding DisplayList drawing commands when drawing operations such as drawLine and drawRect are called in the onDraw drawing function.
[0130] CanvasContext is responsible for rendering nodes and managing the rendering pipeline.
[0131] 3D graphics processing libraries are used to implement 3D graphics drawing, image rendering, compositing, and layer processing. For example, there's the Open Graphics Library for Embedded Systems (OpenGL ES). OpenGL ES acts as a bridge between HWUI and the GPU, responsible for translating Skia-generated drawing commands into a sequence of instructions that the GPU can execute. OpenGL ES 3.0 is the default version of HWUI, offering improved functionality and performance, such as the addition of important texture compression formats and multisampling anti-aliasing.
[0132] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0133] Typically, a single frame displayed on the screen of an electronic device includes multiple views. When a frame needs to be displayed on the screen of an electronic device, the multiple views in the frame are first drawn (also known as "recorded") to obtain multiple display lists corresponding to the multiple views; then, the multiple views are rendered (also known as "playback") according to the multiple display lists to obtain a single frame for display on the screen.
[0134] See Figure 4 This is a schematic diagram of a frame provided in an embodiment of this application; see also Figure 5 This is a method provided in the embodiments of this application. Figure 4 The diagram shown illustrates the display principle of a single frame. Figure 4 and combined Figure 5 As shown, a frame of an image displayed on the screen of an electronic device includes multiple views, which have a tree-like topological relationship, forming a view hierarchy. Specifically, the root view of the view hierarchy is view0, which includes subviews view1 and view2; view1 includes subviews view11, view12 and view13; and view2 includes subview view21.
[0135] When drawing a view, each view is drawn sequentially from top to bottom according to the tree structure of the view tree, resulting in a displaylist tree corresponding to the view tree. Specifically, view 0 is drawn first, followed by views 1 and 2, and then views 11, 12, 13, and 21. When rendering a view, each view is rendered sequentially from top to bottom according to the tree structure of the displaylist tree. Specifically, view 11 is rendered first based on display list DL0, followed by views 1 and 2 based on display lists DL1 and DL2, and then views 11, 12, 13, and 21 based on display lists DL11, DL12, DL13, and DL21, resulting in a single frame displayed on the screen.
[0136] It should be noted that the "top and bottom" in the embodiments of this application refers to the top and bottom in the tree structure of the view tree, not the top and bottom of the display hierarchy of views in the display interface. It can be understood that a "higher-level view in the view tree" is usually located at a "lower-level view in the display hierarchy of the display interface." For example, in... Figure 5 In the middle, the topmost view, View0, is usually located at the bottom of the display hierarchy in the display interface.
[0137] In some application scenarios (such as swipe operations, click operations, etc.), the display interface of electronic devices may contain multiple consecutive frames of unchanging views. Understandably, this results in a large amount of repetitive rendering.
[0138] See Figure 6 This is a schematic diagram illustrating an application scenario provided by an embodiment of this application. For example... Figure 6As shown, the display interface of an electronic device displays a frame of a shopping application. From top to bottom, the frame includes a search box 601, a top navigation bar 602, a product display area 603, and a bottom navigation bar 604. Users can scroll through the products displayed in the product display area 603 by swiping up or down. For example, when a user swipes up within the product display area 603, the products displayed in that area scroll upwards, meaning the area corresponding to the product display area 603 changes. However, the areas corresponding to the search box 601, top navigation bar 602, and bottom navigation bar 604 do not change. In other words, the views corresponding to the search box 601, top navigation bar 602, and bottom navigation bar 604 do not change. It is understandable that when the display interface is refreshed, the views corresponding to the search box 601, top navigation bar 602, and bottom navigation bar 604 will undergo extensive re-rendering.
[0139] To reduce the overhead of repeated rendering, off-screen rendering can be used for views that remain unchanged for multiple consecutive frames. This means that in graphics processing, a new buffer is opened outside the current screen buffer for rendering operations, and the off-screen rendered view can be reused in multiple frames.
[0140] It's understandable that different views have different rendering overhead. For example, simple views have lower rendering overhead, while complex views have higher rendering overhead. Furthermore, compared to on-screen rendering, off-screen rendering of a view incurs additional performance overhead related to the off-screen rendering operation. If the view's own rendering overhead is low, the increased performance overhead from off-screen rendering may exceed the view's own rendering overhead, leading to an increase in overall system performance overhead after off-screen rendering. Therefore, not all views that remain unchanged for multiple consecutive frames are suitable for off-screen rendering. Before off-screen rendering a view, it's necessary to decide on the off-screen rendering strategy based on the view's own characteristics, i.e., whether to off-screen render the view at all.
[0141] Typically, drawing a view requires one or more drawing operations. The applicant's research revealed that the number of view drawing operations significantly impacts the overhead of repeated rendering. However, existing technologies lack a statistical method for calculating the number of view drawing operations, making it impossible to use the number of view drawing operations to determine off-screen rendering strategies.
[0142] See Figure 7 This is a schematic flowchart illustrating a method for counting the number of view drawing operations provided in an embodiment of this application. This method can be applied to... Figures 1-3 The electronic devices shown, such as Figure 7As shown, it mainly includes the following steps.
[0143] Step S701: Determine the number of first drawing operations for each view in the view group.
[0144] In this embodiment, the target view can be any view in the view tree of a frame. The view group is a collection of views in the view tree of a frame with the target view as the root view. For example, in... Figure 5 In this context, when View0 is the target view, the view group includes View0; its subviews View1 and View2; View1's subviews View11, View12, and View13; and View2's subview View21. When View1 is the target view, the view group includes View1; and View1's subviews View11, View12, and View13. A special case is when the target view has no subviews; in this case, the view group contains only one view, the target view. For example, in... Figure 5 In the context of View11 being the target view, the view group contains only View11. Similarly, when View21 is the target view, the view group contains only View21.
[0145] For ease of explanation, in other parts of this document, all views in a view group other than the target view will be collectively referred to as "descendant views" of the target view. For example, in... Figure 5 In this context, when View0 is the target view, its descendant views include: View1, View2, View11, View12, View13, and View21. When View1 is the target view, its descendant views include: View11, View12, and View13. Of course, the view group corresponding to the target view may contain even more levels. Regardless of the number of levels in the view group, all views in the view group other than the target view are collectively referred to as "descendant views" of the target view.
[0146] Drawing a view typically involves executing one or more drawing operations, or drawing operation instructions. A drawing operation is usually used to draw an element (also called a "drawing element"). Examples include paths, rectangles, text, and images. For instance, in... Figure 8The view shown includes four drawing elements: a path (801), text (802), and two rectangles (803 / 804). Normally, one drawing element corresponds to one drawing operation, so four drawing operations are required to draw this view. A special case is that some views may not contain any drawing elements, in which case no drawing operations are performed. For example, the root view in a view group, which only serves as a container for child views, does not perform any drawing operations.
[0147] The applicant discovered through research that the number of view drawing operations has a significant impact on the overhead of repeated rendering. Therefore, this application embodiment counts the number of view drawing operations to inform off-screen rendering strategy decisions. Specifically, the number of drawing operations performed on each view in the view group is counted to obtain the number of drawing operations for each view in the view group. For ease of distinction, in this application embodiment, the number of drawing operations performed on the view itself (excluding its descendant views) is referred to as the "first number of drawing operations." That is, in this application embodiment, the first number of drawing operations for each view in the view group is determined separately.
[0148] In HWUI, drawing operations are specifically DisplayList Operations, or "DL OPs" for short. DL OPs are stored in DisplayLists, and each view typically corresponds to one DisplayList. Therefore, the number of first drawing operations for a given view is the number of DL OPs in the DisplayList corresponding to that view.
[0149] Step S702: Sum the number of first drawing operations for each view in the view group to obtain the number of second drawing operations for the target view.
[0150] In this embodiment, if a view contains descendant views, when that view is rendered off-screen, its corresponding descendant views should also be rendered off-screen. That is, off-screen rendering is performed on a per-view-group basis, and the total number of drawing operations for all views in the view group better reflects the rendering overhead. Therefore, when determining whether a target view can be rendered off-screen, in addition to counting the number of drawing operations for the target view itself, it is also necessary to count the number of drawing operations for its descendant views. Specifically, the first number of drawing operations for each view in the view group is summed to obtain the total number of drawing operations in the view group with the target view as the root view, which is the second number of drawing operations corresponding to the target view.
[0151] For example, in Figure 5In the context of the diagram, when View1 is the target view, the view group includes View1, View11, View12, and View13. The number of first-stage drawing operations for View1, View11, View12, and View13 is summed to obtain the number of second-stage drawing operations for View1. Similarly, when View2 is the target view, the view group includes View2 and View21. The number of first-stage drawing operations for View2 and View21 is summed to obtain the number of second-stage drawing operations for View2.
[0152] A special case is when the target view has no subviews, and the view group contains only one view, namely the target view. In this case, the first number of drawing operations for the target view is the same as its corresponding second number of drawing operations; that is, the first number of drawing operations for the target view is determined to be the second number of drawing operations for the target view.
[0153] For example, in Figure 5 In this context, when View11 is the target view, the view group contains only View11. In this case, the first number of drawing operations for View11 is determined to be its corresponding second number of drawing operations.
[0154] See Figure 9 This is an instruction list for a view group provided in an embodiment of this application. In this embodiment, the target view has no drawing operations, that is, the number of first drawing operations for the target view is 0. Additionally, the target view includes 5 descendant views. Figure 9 Each dashed box corresponds to a drawing instruction for a descendant view of the target view. The number of first drawing operations for the five descendant views are 1, 1, 2, 4, and 1, respectively. The number of first drawing operations for the target view and the five descendant views are summed to determine that the number of second drawing operations for the target view is 10.
[0155] In this embodiment, the number of first drawing operations of all views in the view group with the target view as the root view is accumulated to obtain the number of second drawing operations corresponding to the target view, that is, the total number of drawing operations corresponding to the target view. Then, the off-screen rendering strategy of the target view can be decided by the total number of drawing operations corresponding to the target view.
[0156] It should be noted that the embodiments of this application mainly involve the method for counting the number of view drawing operations. The relevant content of the off-screen rendering strategy will be explained below.
[0157] See Figure 10 This is a schematic diagram of a method for counting the number of drawing operations for another view provided in an embodiment of this application. Figure 10 As shown, the method is in Figure 7 Based on the illustrated embodiment, step S701 specifically includes the following steps.
[0158] Step S1001: During the drawing process of a frame, count the number of drawing operations performed on each view in the view tree of the frame, and obtain the first drawing operation count for each view in the view tree of the frame.
[0159] As mentioned above, the display of a screen mainly includes two stages: drawing and rendering. In this embodiment, during the drawing of a frame, the number of drawing operations performed on each view in the screen's view tree is counted to obtain the first drawing operation count for each view in the screen's view tree. In other words, during the drawing process, the counting of the first drawing operations for each view is completed.
[0160] Specifically, during the drawing process of a view, a counter can be used to record the number of drawing operations for that view. Each time a drawing operation is completed, the counter value increments by 1. It can be understood that when the drawing of that view is completed, the counter value represents the first number of drawing operations for that view.
[0161] Typically, when drawing a view of a frame, each view can be drawn sequentially from top to bottom according to the tree structure of the view tree. Correspondingly, while drawing each view sequentially from top to bottom, the number of first drawing operations for each view can be counted sequentially from top to bottom.
[0162] For example, in Figure 5 First, view View0 is drawn, and the number of first drawing operations for view View0 is counted during the drawing process. Then, views View1 and View2 are drawn, and the number of first drawing operations for each view View1 and View2 is counted during the drawing process. Then, views View11, View12, View13 and View21 are drawn, and the number of first drawing operations for each view View11, View12, View13 and View21 is counted during the drawing process.
[0163] Conversely, if the number of the first drawing operations for a view is not counted during the view's drawing process, then to obtain the number of the first drawing operations, it is necessary to re-traverse the drawing operations in the view after the view is drawn. Understandably, re-tracing the drawing operations in the view reduces the speed of counting the number of drawing operations and increases the system's performance overhead.
[0164] Step S1002: Perform a depth-first traversal of the view tree of the screen to determine the view group with the target view as the root view in the view tree of the screen.
[0165] Understandably, after counting the number of first drawing operations for all views in the view tree corresponding to a frame, it is necessary to further determine which views are included in the view group with the target view as the root view in the view tree, so that the number of first drawing operations for each view in the view group can be accumulated in subsequent steps.
[0166] Specifically, a depth-first traversal is performed on the view tree of the screen to determine the view group rooted at the target view, that is, to determine which views are included in the view group rooted at the target view. For example, in... Figure 5 If the target view is View1, then by performing a depth-first traversal of the view tree, it can be determined that the view group with View1 as the root view includes View1, View11, View12, and View13.
[0167] In this embodiment of the application, the number of first drawing operations for each view in the screen is counted during the drawing process. This eliminates the need to re-traverse the drawing operations in the view after the drawing is completed, thereby improving the speed of counting the number of drawing operations and reducing the performance overhead of the system.
[0168] See Figure 11 This is a schematic diagram of a method for counting the number of drawing operations for another view provided in an embodiment of this application. Figure 11 As shown, the method is in Figure 10 Based on the illustrated embodiment, step S1002 specifically includes the following steps.
[0169] Step S1101: Perform a first depth-first traversal of the view tree of the screen to determine the rendering level of the screen and the view group in the view tree with the target view as the root view.
[0170] As mentioned above, the display of a screen mainly includes two stages: drawing and rendering. In the rendering stage, a depth-first traversal of the screen's view tree is typically required to determine the rendering level, which characterizes the rendering order of the view tree. For ease of explanation, in this embodiment, the depth-first traversal used to determine the rendering level is referred to as the "first depth-first traversal." It can be understood that the first depth-first traversal is the original process of the rendering stage.
[0171] In addition, to determine the view group rooted at the target view in the view tree, a depth-first traversal of the view tree is also required. In this embodiment, the view group rooted at the target view in the view tree is determined by the original first depth-first traversal in the rendering process. That is, through one depth-first traversal, both the "rendering level of the screen" and the "view group rooted at the target view in the view tree" are determined simultaneously.
[0172] Conversely, if the operation of "determining the view group rooted in the target view in the view tree" is not performed during the first depth traversal, an additional depth traversal process is required to determine the view group rooted in the target view in the view tree. For ease of explanation, in this embodiment, the added depth traversal process is referred to as the "second depth traversal".
[0173] It is understandable that increasing the depth traversal process will reduce the speed of calculating the number of drawing operations and increase the system's performance overhead. Therefore, in this embodiment, by determining both the "rendering level of the screen" and the "view group in the view tree with the target view as the root view" in a single depth traversal, the speed of calculating the number of drawing operations can be improved and the system's performance overhead can be reduced.
[0174] See Figure 12 This is a flowchart illustrating a method for counting the number of view drawing operations provided in an embodiment of this application. Figure 12 The diagram illustrates the main thread data flow and the rendering thread data flow, which correspond to the relevant operations in the drawing and rendering phases, respectively. For example... Figure 12 As shown, it mainly includes the following steps.
[0175] Step S1201: The View updates its content.
[0176] Specifically, the application layer may include multiple applications. When a user performs a certain action in one of the applications (e.g., click, swipe, etc.), the application layer may trigger the View to update its content.
[0177] Step S1202: ViewRootlmpl triggers full-frame rendering.
[0178] Specifically, after the View updates its content, ViewRootlmpl triggers a full-frame rendering and creates a ThreadedRenderer (rendering thread).
[0179] Step S1203: ThreadedRenderer traverses the view tree.
[0180] Specifically, after the ThreadedRenderer is created, a depth-first traversal is performed on the view tree to determine its tree structure. It should be noted that this depth-first traversal is used to determine the rendering order of the views within the view tree.
[0181] Step S1204: The View performs a drawing operation.
[0182] Specifically, after completing the depth-first traversal of the view tree, each view is drawn sequentially from top to bottom according to the tree structure of the view tree. For example, in... Figure 5 In the process, view 0 is drawn first, then views 1 and 2 are drawn, and then views 11, 12, 13 and 21 are drawn.
[0183] Step S1205: SkiaRecordingCanvas records the drawing operations.
[0184] Specifically, during the drawing process of a view, SkiaRecordingCanvas can record each drawing operation of that view sequentially. For example, in... Figure 5 In the process of drawing View0, each drawing operation of View0 is recorded in sequence and synchronized to DisplayListData; in the process of drawing View1, each drawing operation of View1 is recorded in sequence and synchronized to DisplayListData; and so on, to complete the recording of each drawing operation in the view tree.
[0185] Step S1206: DisplayListData records the drawing operations.
[0186] Specifically, DisplayListData is used to record relevant data. For example, the drawing operations corresponding to each view in the view tree, the number of first drawing operations for each view, and the number of second drawing operations for each view.
[0187] In HWUI, drawing operations are specifically called DL OPs, which are stored in a DisplayList, and each view typically corresponds to one DisplayList. Therefore, DisplayListData includes the DisplayList corresponding to each view. It can be understood that the number of DL OPs in the DisplayList corresponding to a particular view represents the number of the first drawing operations for that view.
[0188] Step S1207: DisplayListData records the number of the first drawing operation.
[0189] Specifically, while recording the drawing operations for a particular view, DisplayListData can count the number of recorded drawing operations, thus obtaining the first drawing operation count for that view. In other words, after the View has completed drawing all views, DisplayListData will record the first drawing operation count for each view in the view tree. For example, in... Figure 5 In the application scenario shown, DisplayListData records the number of first drawing operations n0, n1, n2, n11, n12, n13, and n21 for views View0, View1, View2, View11, View12, View13, and View21, respectively.
[0190] Step S1208: Wake up the rendering thread.
[0191] Specifically, after all views are drawn in the main thread, the rendering thread is woken up to begin rendering the views.
[0192] Step S1209: DrawFrameTask synchronizes frame information.
[0193] Step S1210: RenderNode performs the first depth traversal.
[0194] In this embodiment of the application, the first depth traversal is an existing process in the rendering thread. In the rendering thread, the rendering level of the view tree can be determined by the first depth traversal, and the preparatory work before rendering can be completed.
[0195] Step S1211: SkiaDisplayList calculates the number of second drawing operations for each view.
[0196] Specifically, during the first depth-first traversal, the parent-child relationships of each view in the view tree can be determined. Based on these parent-child relationships and the number of first drawing operations recorded in DisplayListData, the number of second drawing operations corresponding to the target view can be calculated. Since the target view can be any view in the view tree, the number of second drawing operations corresponding to each view can be determined in this step.
[0197] For example, in Figure 5In the application scenario shown, the number of first drawing operations for views View0, View1, View2, View11, View12, View13, and View21 are n0, n1, n2, n11, n12, n13, and n21, respectively. Based on the parent-child relationship of each view in the view tree, the number of second drawing operations for view View11 is determined as follows: N11 = n11; N12 = n12; N13 = n13; N21 = n21; N1 = n1 + n11 + n12 + n13; N2 = n2 + n21; and N0 = n0n1 + n11 + n12 + n13 + n2 + n21.
[0198] Step S1212: DisplayListData records the number of second drawing operations corresponding to each view.
[0199] Specifically, after determining the number of second drawing operations corresponding to each view, the number of second drawing operations corresponding to each view is stored in DisplayListData.
[0200] Step S1213: RenderNode obtains the number of second drawing operations.
[0201] Specifically, RenderNode can obtain the number of second drawing operations corresponding to the view in DisplayListData, so as to make decisions on the off-screen rendering strategy based on the number of second drawing operations.
[0202] In this embodiment, the first drawing operation count for each view is completed during the view drawing process, eliminating the need to re-traverse the drawing operations in the view after drawing is complete. During the rendering phase, the second drawing operation count for each view is determined using the existing first depth traversal process, without requiring an additional depth traversal process. Therefore, the speed of calculating the number of drawing operations can be improved, and the system's performance overhead can be reduced.
[0203] See Figure 13 This is a schematic diagram of a method for counting the number of drawing operations for another view provided in an embodiment of this application. Figure 13 As shown, the method is in Figure 10 Based on the illustrated embodiment, step S1002 specifically includes the following steps.
[0204] Step S1301: Perform a second depth traversal on the view tree of the screen with the target view as the root view to determine the view group in the view tree of the screen with the target view as the root view.
[0205] Specifically, a first depth-first traversal is performed on the view tree of the image to determine the rendering level of the image; a second depth-first traversal is performed on the view tree of the image with the target view as the root view to determine the view group in the view tree with the target view as the root view. In other words, this embodiment adds a depth-first traversal process, i.e., a second depth-first traversal, to the original first depth-first traversal. The second depth-first traversal determines the view group in the view tree with the target view as the root view.
[0206] It should be further explained that, since the second depth-first traversal is only used to determine the view group in the view tree rooted at the target view, a depth-first traversal can be performed only with the target view as the root. In other words, it may be necessary to perform a depth-first traversal on only a portion of the view tree, without needing to perform a full depth-first traversal of the view tree. For example, in Figure 5 In this context, when the target view is View1, only a depth-first traversal is needed with View1 as the root view to determine the subviews View11, View12, and View13 of View1. Views View0, View2, and View21 do not need to be traversed.
[0207] A special case is when the target view includes the root view of the view tree, in which case a full depth-first traversal of the view tree is also required. For example, in... Figure 5 In the process, when the target view is View0, a depth traversal is required with View0 as the root view, which means a depth traversal of the entire view tree is required.
[0208] In this embodiment, an independent depth traversal process is set up to count the number of drawing operations, resulting in lower coupling between modules in the software.
[0209] See Figure 14 This is a flowchart illustrating another method for counting the number of drawing operations for a view, provided in an embodiment of this application. Figure 14 The diagram illustrates the main thread data flow and the rendering thread data flow, which correspond to the relevant operations in the drawing and rendering phases, respectively. For example... Figure 14 As shown, it mainly includes the following steps.
[0210] Step S1401: The View updates its content.
[0211] Step S1402: ViewRootlmpl triggers full-frame rendering.
[0212] Step S1403: ThreadedRenderer traverses the view tree.
[0213] Step S1404: The View performs a drawing operation.
[0214] Step S1405: SkiaRecordingCanvas records the drawing operations.
[0215] Step S1406: DisplayListData records the drawing operations.
[0216] Step S1407: DisplayListData records the number of the first drawing operation.
[0217] Step S1408: Wake up the rendering thread.
[0218] Step S1409: DrawFrameTask synchronizes frame information.
[0219] Step S1410: RenderNode performs the first depth traversal.
[0220] For details regarding steps S1401-S1410, please refer to the description of steps S1201-S1210 above. For the sake of brevity, they will not be repeated here.
[0221] Step S1411: GLHandler performs a second depth-first traversal.
[0222] In this embodiment, the second depth-first traversal is an additional traversal process. The second depth-first traversal determines the view group in the view tree with the target view as the root view, and then, in subsequent steps, the number of second drawing operations corresponding to the target view is counted. Since the target view can be any view in the view tree, in this step, a view group with each view as the root view can be determined.
[0223] Step S1412: Iterate through the DisplayListData to count the first draw operations for each view. Since the DisplayListData records the count of the first draw operations for each view in the view tree, after determining the view group with the target view as the root view, we can iterate through the count of the first draw operations for each view in the view group. This allows us to calculate the count of the second draw operations for the target view in subsequent steps. Because the target view can be any view in the view tree, this step requires iterating through the count of the first draw operations for each view in the view tree.
[0224] Step S1413: DisplaylistOpHelper calculates the number of second drawing operations for each view. Specifically, during the second depth-first traversal, the parent-child relationship between views in the view tree can be determined. Based on this parent-child relationship and the number of first drawing operations recorded in DisplayListData, the number of second drawing operations for the target view can be calculated. Since the target view can be any view in the view tree, the number of second drawing operations for each view can be determined in this step.
[0225] Step S1414: RenderNode obtains the number of second drawing operations.
[0226] Specifically, RenderNode can obtain the number of second draw operations corresponding to the view in DisplaylistOpHelper, so as to make decisions on the off-screen rendering strategy based on the number of second draw operations.
[0227] In this embodiment, the first number of drawing operations for each view is counted during the view drawing process, eliminating the need to re-traverse the drawing operations in the view after drawing is complete. During the rendering phase, a second depth-first traversal process is added to determine the second number of drawing operations for each view. Since it is unnecessary to re-traverse the drawing operations in the view after drawing is complete, the speed of counting the number of drawing operations can be improved to some extent, and the system's performance overhead can be reduced.
[0228] contrast Figure 12 and Figure 14 The implementation method shown is as follows: Figure 12 In the implementation shown, by reusing the original first traversal process, the speed of calculating the number of drawing operations can be maximized while reducing system performance overhead; Figure 14 In the implementation shown, the coupling between modules in the software is lower because the statistical process of the number of drawing operations can be encapsulated into independent classes (e.g., GLHandler and DisplaylistOpHelper).
[0229] See Figure 15 This is a schematic diagram of a method for counting the number of drawing operations for another view provided in an embodiment of this application. Figure 15 As shown, the method is in Figure 7 Based on the illustrated embodiment, step S701 specifically includes the following steps.
[0230] Step S1501: After a frame is drawn, perform a depth traversal of the view tree of the image to determine the view group with the target view as the root view in the view tree of the image, and the number of first drawing operations for each view in the view group.
[0231] In this embodiment of the application, during the drawing process of the screen, only the drawing operations are recorded, and the number of drawing operations of the view is not counted. After the screen is drawn, a depth-first traversal is performed on the view tree of the screen to determine the view group with the target view as the root view in the view tree of the screen, and the first drawing operation count of each view in the view group.
[0232] It's understandable that after the screen is drawn, the drawing operations performed by each view are recorded. Therefore, during depth traversal, the number of the first drawing operations for each view in the view group can be obtained by counting the number of drawing operations performed by each view itself.
[0233] For example, in Figure 5 In this process, the target view is View1, and a depth-first traversal is performed with View1 as the root view. When traversing to View1, the number of drawing operations performed by View1 itself is counted to obtain the first number of drawing operations n1; when traversing to View11, the number of drawing operations performed by View11 itself is counted to obtain the first number of drawing operations n11; when traversing to View12, the number of drawing operations performed by View12 itself is counted to obtain the first number of drawing operations n12; when traversing to View13, the number of drawing operations performed by View13 itself is counted to obtain the first number of drawing operations n13.
[0234] In one possible implementation, after a frame is drawn, a first depth-first traversal is performed on the view tree of the image to determine the rendering level of the image, the view group with the target view as the root view in the view tree of the image, and the number of first drawing operations for each view in the view group.
[0235] As mentioned above, the first depth-first traversal is the original depth-first traversal process in the rendering stage. In this embodiment, the rendering level of the image, the view group with the target view as the root view in the image's view tree, and the number of first drawing operations for each view in the view group are determined through the original first depth-first traversal in the rendering stage. That is, through one depth-first traversal, the "rendering level of the image," the "view group with the target view as the root view in the image's view tree," and the "number of first drawing operations for each view in the view group" are determined simultaneously.
[0236] It should be noted that the embodiments of this application are similar to... Figure 11The difference in the illustrated embodiment is that the present application embodiment completes the counting of the first drawing operations during the first depth-first traversal. For other details regarding the embodiments of this application, please refer to... Figure 11 The description of the embodiments shown is omitted here for the sake of brevity.
[0237] In one possible implementation, after a frame is drawn, a second depth-first traversal is performed on the view tree of the image with the target view as the root view to determine the view group with the target view as the root view in the view tree of the image, and the first number of drawing operations for each view in the view group.
[0238] Specifically, after a frame is rendered, a first depth-first traversal is performed on the view tree to determine the rendering level of the frame. A second depth-first traversal is then performed on the view tree with the target view as the root view to determine the view group within the view tree rooted at the target view, and the number of first rendering operations for each view in the view group. In other words, this embodiment adds a second depth-first traversal to the original first depth-first traversal. The second depth-first traversal determines the view group within the view tree rooted at the target view, and the number of first rendering operations for each view in the view group.
[0239] It should be noted that the embodiments of this application are similar to... Figure 13 The difference in the illustrated embodiment is that the present application embodiment completes the counting of the number of first drawing operations during the second depth traversal. For other details regarding the embodiments of this application, please refer to... Figure 13 The description of the embodiments shown is omitted here for the sake of brevity.
[0240] See Figure 16 This is a schematic diagram of a method for counting the number of drawing operations of another view provided in an embodiment of this application. Figure 16 As shown, the method is in Figure 7 Based on the illustrated embodiment, step S702 specifically includes the following steps.
[0241] Step S1601: Accumulate the number of first drawing operations for each view in each subview group to obtain the number of second drawing operations for each subview of the target view;
[0242] Step S1602: Accumulate the number of second drawing operations corresponding to each subview to obtain the number of second drawing operations corresponding to the target view. In this embodiment, the subview group is a view group with the subviews of the target view as the root view. In this embodiment, the number of second drawing operations for the subviews is calculated first, and then the number of second drawing operations for the parent view is calculated based on the number of second drawing operations for the subviews. This reduces the amount of computation, thereby improving the speed of calculating the number of drawing operations and reducing the performance overhead of the system.
[0243] For example, in Figure 5 In the diagram, the number of second drawing operations for views View11, View12, View13, and View21 are n11, n12, n13, and n21, respectively; the number of second drawing operations for view View1 is N1 = n1 + n11 + n12 + n13; the number of second drawing operations for view View2 is N2 = n2 + n21; and the number of second drawing operations for view View0 is N0 = n0 + N1 + N2. It can be understood that compared to the calculation method of "N0 = n0n1 + n11 + n12 + n13 + n2 + n21", this method reduces the computational load, thereby increasing the speed of calculating the number of drawing operations and reducing system performance overhead.
[0244] See Figure 17 This is an instruction flowchart illustrating a method for counting the number of view drawing operations provided in an embodiment of this application. Figure 17 It shows Figure 12 The interaction process of the illustrated embodiment will be described in detail below.
[0245] RecordingCanvas calls the functions: onDrawxxx(), drawxxx();
[0246] DisplayListData calls the function: drawxxx();
[0247] DramFrameTask calls the following functions: run(); syncFrameState(); prepareTree();
[0248] Calling the CanvasContext function: prepareTree();
[0249] RenderNode calls functions: prepareTreelmpl(); pushStagingDisplayListChanges(); syncDisplayList(); prepareListAndChildren();
[0250] SkiaDisplayListWrapper calls the function: prepareListAndChildren();
[0251] SkiaDisplayList and RenderNodeDrawable call functions: prepareTreelmpl(); getRenderNode(); resetNestedOpCount(); setNestedOpCount().
[0252] In this process, DisplayListData counts the number of drawing operations within the drawxxx functions to obtain the first drawing operation count for each view. SkiaDisplayList resets (e.g., clears to 0) the second drawing operation count for the previous view stored in the temporary storage area using the resetNestedOpCount() function, so that the second drawing operation count for the next view can be calculated; it also calculates the second drawing operation count for the current view using the setNestedOpCount() function. For other functions in the interaction flowchart, please refer to the relevant descriptions in the existing technology; for the sake of brevity, they will not be elaborated upon here.
[0253] Corresponding to the above embodiments, this application also provides an off-screen rendering decision method for views.
[0254] See Figure 18 This is a schematic flowchart illustrating an off-screen rendering decision-making method for a view, provided in an embodiment of this application. This method can be applied to... Figures 1-3 The electronic devices shown, such as Figure 18 As shown, it mainly includes the following steps.
[0255] Step S1801: Count the number of second drawing operations corresponding to the target view.
[0256] Specifically, the number of second drawing operations corresponding to the target view is calculated using any of the methods described in the above embodiments. The method for calculating the number of second drawing operations can be found in the description of the above embodiments, and will not be repeated here for the sake of brevity.
[0257] Step S1802: Make a decision on the off-screen rendering strategy of the target view based on the second number of drawing operations corresponding to the target view. The off-screen rendering strategy includes performing off-screen rendering and not performing off-screen rendering.
[0258] In this embodiment, the number of second drawing operations is used as an evaluation factor for the off-screen rendering strategy. It can be understood that the higher the number of second drawing operations, the greater the overhead of repeated rendering, and therefore the more necessary off-screen rendering should be.
[0259] In this embodiment of the application, since the number of view drawing operations has a significant impact on the overhead of repeated rendering, using the number of second drawing operations as a decision factor in the off-screen rendering strategy can improve the accuracy of off-screen rendering decisions and thus improve the overall performance of the electronic device.
[0260] In one possible implementation, the evaluation factors for the off-screen rendering strategy also include the number of reused frames and a score. Specifically, the off-screen rendering strategy for the target view is decided based on the number of second drawing operations corresponding to the target view, the number of reused frames, and the score. The number of reused frames refers to the number of consecutive frames of the target view reused. For example, if a view remains unchanged for K consecutive frames, then the number of reused frames is K. It can be understood that the more reused frames, the greater the overhead of repeated rendering, and therefore, off-screen rendering should be performed. The score is used to characterize the complexity of the target view. In a specific implementation, a pre-defined scoring standard can be used to score the complexity of the target view. It can be understood that the higher the complexity of the view, the greater the overhead of repeated rendering, and therefore, off-screen rendering should be performed.
[0261] Corresponding to the above embodiments, this application also provides an electronic device.
[0262] See Figure 19 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 19 As shown, the electronic device 1900 may include a processor 1901, a memory 1902, and a communication unit 1903. These components communicate via one or more buses. Those skilled in the art will understand that the electronic device structure shown in the figures does not constitute a limitation on the embodiments of this application. It may be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0263] The communication unit 1903 is used to establish a communication channel, thereby enabling the electronic device to communicate with other devices.
[0264] The processor 1901 serves as the control center of the electronic device, connecting various parts of the device via various interfaces and lines. It executes software programs and / or modules stored in the memory 1902, and calls data stored in the memory to perform various functions and / or process data. The processor can be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 1901 may consist only of a central processing unit (CPU). In this embodiment, the CPU may have a single processing core or include multiple processing cores.
[0265] Memory 1902 is used to store the execution instructions of processor 1901. Memory 1902 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0266] When the execution instructions in memory 1902 are executed by processor 1901, the electronic device 1900 is able to perform some or all of the steps in the above method embodiments.
[0267] Corresponding to the above embodiments, this application also provides a computer-readable storage medium, wherein the computer-readable storage medium may store a program, wherein when the program runs, it can control the device where the computer-readable storage medium is located to execute some or all of the steps in the above method embodiments. Specifically, the computer-readable storage medium may be a magnetic disk, an optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0268] Corresponding to the above embodiments, this application also provides a computer program product containing executable instructions that, when executed on a computer, cause the computer to perform some or all of the steps in the above method embodiments.
[0269] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, the simultaneous existence of A and B, or the existence of B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0270] Those skilled in the art will recognize that the units and algorithm steps described in the embodiments disclosed herein can be implemented using electronic hardware, computer software, or a combination of electronic hardware and software. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0271] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0272] In the several embodiments provided in this application, any function, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0273] The above description is merely a specific embodiment of this application. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application. The protection scope of this application should be determined by the protection scope of the claims.
Claims
1. A method for counting the number of drawing operations on a view, characterized in that, include: The first number of drawing operations for each view in the view group is determined. The view group is a view group with the target view as the root view in the view tree of a frame. The first number of drawing operations is the number of drawing operations performed by the view itself. The number of the first drawing operations for each view in the view group is summed to obtain the number of the second drawing operations for the target view.
2. The method according to claim 1, characterized in that, The determination of the number of first drawing operations for each view in the view group includes: During the process of drawing a frame, the number of drawing operations performed on each view in the view tree of the frame is counted to obtain the first number of drawing operations for each view in the view tree of the frame. Perform a depth-first traversal of the view tree of the screen to determine the view group with the target view as the root view in the view tree of the screen.
3. The method according to claim 2, characterized in that, The step of performing a depth-first traversal of the view tree of the screen to determine the view group with the target view as the root view in the view tree includes: A first depth-first traversal is performed on the view tree of the screen to determine the rendering level of the screen and the view group in the view tree of the screen with the target view as the root view. The rendering level is used to characterize the rendering order of the view tree of the screen.
4. The method according to claim 2, characterized in that, The step of performing a depth-first traversal of the view tree of the screen to determine the view group with the target view as the root view in the view tree includes: A second depth-first traversal is performed on the view tree of the screen with the target view as the root view to determine the view group in the view tree of the screen with the target view as the root view.
5. The method according to claim 1, characterized in that, The determination of the number of first drawing operations for each view in the view group includes: After a frame is drawn, a depth-first traversal is performed on the view tree of the frame to determine the view group with the target view as the root view in the view tree of the frame, and the first drawing operation number of each view in the view group.
6. The method according to claim 5, characterized in that, After a frame is rendered, a depth-first traversal is performed on the view tree of the frame to determine the view group with the target view as the root view in the view tree, and the number of first rendering operations for each view in the view group, including: After a frame is drawn, a first depth-first traversal is performed on the view tree of the frame to determine the rendering level of the frame, the view group with the target view as the root view in the view tree of the frame, and the number of first drawing operations for each view in the view group. The rendering level is used to characterize the rendering order of the view tree of the frame.
7. The method according to claim 5, characterized in that, After a frame is rendered, a depth-first traversal is performed on the view tree of the frame to determine the view group with the target view as the root view in the view tree, and the number of first rendering operations for each view in the view group, including: After a frame is drawn, a second depth-first traversal is performed on the view tree of the frame with the target view as the root view to determine the view group with the target view as the root view in the view tree of the frame, and the first drawing operation number of each view in the view group.
8. The method according to any one of claims 1-7, characterized in that, The step of summing the first drawing operation counts for each view in the view group to obtain the second drawing operation count for the target view includes: The number of first drawing operations for each view in each subview group is summed to obtain the number of second drawing operations for each subview of the target view. The subview group is a view group with the subview of the target view as the root view. The number of first drawing operations for the target view and the number of second drawing operations for each subview are summed to obtain the number of second drawing operations for the target view.
9. A method for making off-screen rendering decisions for a view, characterized in that, include: The number of second drawing operations corresponding to the target view is calculated using the method described in any one of claims 1-8; The off-screen rendering strategy for the target view is decided based on the second number of drawing operations corresponding to the target view. The off-screen rendering strategy includes performing off-screen rendering and not performing off-screen rendering.
10. The method according to claim 9, characterized in that, The step of deciding on the off-screen rendering strategy for the target view based on the second number of drawing operations corresponding to the target view includes: The off-screen rendering strategy for the target view is determined based on the number of second drawing operations, the number of reused frames, and the score corresponding to the target view. The number of reused frames refers to the number of frames of the target view that are reused consecutively, and the score is used to characterize the complexity of the target view.
11. An electronic device, characterized in that, include: processor; Memory; And a computer program stored on the memory, the processor executing the computer program to implement the method of any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that, include: The computer-readable storage medium stores a computer program that, when executed, implements the method described in any one of claims 1 to 10.
13. A computer program product, characterized in that, include: A computer program, which, when executed, implements the method described in any one of claims 1 to 10.