WO2023005751A1 - Rendering method and electronic device - Google Patents
Rendering method and electronic device Download PDFInfo
- Publication number
- WO2023005751A1 WO2023005751A1 PCT/CN2022/106621 CN2022106621W WO2023005751A1 WO 2023005751 A1 WO2023005751 A1 WO 2023005751A1 CN 2022106621 W CN2022106621 W CN 2022106621W WO 2023005751 A1 WO2023005751 A1 WO 2023005751A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- rendering
- data
- level
- electronic device
- same
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
Definitions
- the embodiments of the present application relate to the technical field of computer graphics, and in particular, to a rendering method and an electronic device.
- electronic devices such as mobile phones, large-screen devices, etc.
- some electronic devices are equipped with displays with a refresh rate of 144 hertz (Hz) per second.
- Hz hertz
- the higher refresh rate can make interface operations smoother.
- the rendering time of a single frame needs to be less than 6ms, and there may be a demand for a higher refresh rate in the future, which requires a shorter rendering time of a single frame. , it is already difficult to complete a single frame rendering within 6ms.
- the rendering method and electronic device provided by the embodiments of the present application can effectively reduce the rendering time of a single frame through parallel rendering, ensure a screen refresh rate, and improve user experience.
- the embodiment of the present application provides a rendering method applied to an electronic device, and the method may include: the electronic device, acquiring a rendering object to be displayed, where the rendering object includes a control and a layout, and acquiring a control including the rendering object to be displayed Tree. Traverse the control tree from the root node of the control tree: set different control tree levels to different rendering levels, set the intersecting rendering objects of the same control tree level to different rendering levels; render rendering objects of the same rendering level in parallel, and serialize Render objects of different rendering levels.
- control tree is used to represent controls and layouts organized in a tree structure.
- the control tree level is used to represent the tree node relationship between controls and layouts in the control tree determined after traversing the control tree.
- Each node in the control tree corresponds to a rendering object (that is, a control or a layout), and each control tree level contains one or more rendering objects (that is, including one or more controls, one or more layouts). Then, after obtaining the control tree level, it is necessary to determine whether the rendering objects (that is, controls and layouts) at the same control tree level in the control tree intersect, so as to divide the rendering level according to the intersection.
- serial rendering includes invoking threads to sequentially render rendering objects according to the order of rendering levels; parallel rendering includes invoking multiple rendering threads to simultaneously execute rendering tasks of the same rendering level.
- the rendering time can be effectively reduced, and the frame dropping phenomenon of the displayed image can be avoided. That is to say, the possibility of frame loss when an electronic device displays an image can be reduced by means of parallel rendering, and the smoothness of the image displayed on the display screen can be ensured, thereby improving the user's visual experience.
- the rendering objects of the same rendering level are rendered in parallel; including: parallel rendering of the constituent element data in the same instruction group in the rendering objects of the same rendering level, and serial rendering of different instructions in the rendering objects of the same rendering level The constituent element data in the group.
- the constituent element data includes one or more of the following contents: constituent element data of the foreground layer, constituent element data of the content layer, and constituent element data of the background layer.
- the background layer constituent element data corresponds to the background of the control or layout after rendering
- the content layer constituent elements correspond to the display content of the control or layout after rendering
- the foreground layer constituent element data corresponds to the foreground of the control or layout after rendering.
- the control is a text control
- the element data of the content layer of the control includes corresponding text data.
- the electronic device after the electronic device completes the division of the rendering levels, it can render the data of different rendering levels according to the order of the rendering levels, but for the data of the same rendering level, it is necessary to further determine the composition of the element data in the same rendering level. Rendering order.
- the data of the rendering object includes the following situations: if the rendering object is a control, the data of the rendering object is control data; if the rendering object is a layout, then the data of the rendering object is layout data.
- the data types of the constituent element data in the same instruction group are the same, and the data types of the constituent element data in different instruction groups are different; or, the constituent element data in the same instruction group are in the corresponding rendering object
- the execution order of the corresponding instructions in is the same, and the execution order of the corresponding instructions in the corresponding rendering objects of the constituent element data in different instruction groups is different.
- the background layer constituent elements in the same rendering level are divided into one instruction group data
- the content layer constituent elements are divided into one instruction group data
- the foreground layer constituent elements are divided into one instruction group data.
- divide the background data in the same rendering level into an instruction group divide the text data into an instruction group, and so on.
- record the instruction group group result mark into the corresponding control data or layout data then in the rendering process, the element data instruction group can be formed according to the background layer and the element data can be formed by the content layer in the same rendering level according to the mark
- the command group and the foreground layer are rendered in the order of the element data command group.
- the division of the rendering object data is quickly completed, and the data of the command group that can be rendered in parallel is determined to improve the rendering efficiency.
- setting the intersecting rendering objects at the same control tree level to different rendering levels includes: obtaining the smallest rectangular area corresponding to the rendering objects at the same control tree level; setting the smallest rectangle area at the same control tree level Render objects whose regions intersect are set to different rendering levels.
- the instruction execution order includes, for example, the original rendering order of the component data of the control data and the layout data.
- the original rendering order of the component data of the control data or layout data is generally to first render the background layer to form the element data, then render the content layer to form the element data, and finally render the foreground layer to form the element data.
- the control data or layout data does not include a certain layer or layers of constituent element data, it is allowed to skip this layer of data and directly render the next layer of constituent element data.
- the data with the same instruction execution sequence in the same rendering level is divided into the same instruction group, and the data with different instruction execution sequences is divided into different instruction groups.
- mark and record the grouping result of the instruction group into the corresponding control data or layout data and then perform rendering according to the marked grouping result of the instruction group and the execution order of the instruction group during the rendering process.
- the smallest rectangular area corresponding to the rendering object is a rectangular area covering the rendering object and having the smallest area.
- the control and the layout have a corresponding drawing area, and if the drawing area partially or completely intersects, it means that the corresponding control and the layout intersect.
- the corresponding drawing area can be obtained according to the control data and layout data, and the smallest rectangular area can be used to represent the drawing area of the control or layout.
- the smallest rectangular area includes, for example, the smallest area that can cover the corresponding control or layout.
- the electronic device determines the intersection of the rendering objects through the intersection of the smallest rectangular area.
- the method before rendering the rendering objects of the same rendering level in parallel, the method further includes: obtaining resource conditions. Based on resources, determines the maximum number of rendering threads that are allowed to be called in parallel.
- the electronic device allocates rendering threads to perform data rendering according to the resources available for operation in the CPU and GPU.
- the UI thread generates a rendering instruction based on the result of the rendering hierarchy division and the instruction group grouping result to trigger the rendering thread to perform data rendering, and the rendering thread performs data rendering after receiving the rendering instruction.
- rendering the rendering objects of the same rendering level in parallel includes: if the first number of rendering threads required to render the rendering objects of the same rendering level in parallel is less than or equal to the maximum number, calling the first number of Rendering threads render rendering objects of the same rendering level in parallel. If the first number is greater than the maximum number, call the maximum number of rendering threads to render the rendering objects of the same rendering level in parallel.
- the electronic device determines whether the number of rendering threads that can be called in parallel meets the rendering requirements of the instruction group according to the executable resources of the CPU and GPU. If the number satisfies the rendering requirements of the instruction group, a corresponding number of rendering threads will be called to render the data in the instruction group in parallel. If the number of threads that can be called in parallel does not meet the rendering requirements of the instruction group, call the maximum number of rendering threads to render part of the data in the instruction group in parallel, and render all the data in the instruction group in batches.
- the electronic device before executing the rendering task, the electronic device first determines the maximum number of rendering threads that are allowed to be called according to the resource situation, so as to ensure the smooth execution of parallel rendering tasks and avoid rendering exceptions.
- an embodiment of the present application provides an electronic device, including: a processor and a memory; the memory is coupled to the processor, and the memory is used to store computer program codes, and the computer program codes include computer instructions.
- the computer instructions enable the electronic device to perform the following operations to obtain a rendering object to be displayed, where the rendering object includes a control and a layout, and obtain a control tree including the rendering object to be displayed. Traverse the control tree from the root node of the control tree: set different control tree levels to different rendering levels, set the intersecting rendering objects of the same control tree level to different rendering levels; render rendering objects of the same rendering level in parallel, and serialize Render objects of different rendering levels.
- the rendering objects of the same rendering level are rendered in parallel; including: parallel rendering of the constituent element data in the same instruction group in the rendering objects of the same rendering level, and serial rendering of different instructions in the rendering objects of the same rendering level The constituent element data in the group.
- the constituent element data includes one or more of the following contents: constituent element data of the foreground layer, constituent element data of the content layer, and constituent element data of the background layer.
- the data types of the constituent element data in the same instruction group are the same, and the data types of the constituent element data in different instruction groups are different; or, the constituent element data in the same instruction group are in the corresponding rendering object
- the execution order of the corresponding instructions in is the same, and the execution order of the corresponding instructions in the corresponding rendering objects of the constituent element data in different instruction groups is different.
- setting the intersecting rendering objects at the same control tree level to different rendering levels includes: obtaining the smallest rectangular area corresponding to the rendering objects at the same control tree level; setting the smallest rectangle area at the same control tree level Render objects whose regions intersect are set to different rendering levels.
- the smallest rectangular area corresponding to the rendering object is a rectangular area covering the rendering object and having the smallest area.
- the processor when the processor reads the computer instruction from the memory, it further causes the electronic device to perform the following operation: obtain resource information. Based on resources, determines the maximum number of rendering threads that are allowed to be called in parallel.
- rendering the rendering objects of the same rendering level in parallel includes: if the first number of rendering threads required to render the rendering objects of the same rendering level in parallel is less than or equal to the maximum number, calling the first number of Rendering threads render rendering objects of the same rendering level in parallel. If the first number is greater than the maximum number, call the maximum number of rendering threads to render the rendering objects of the same rendering level in parallel.
- an embodiment of the present application provides an electronic device, where the electronic device has a function of implementing the rendering method described in the foregoing first aspect and any possible implementation manner thereof.
- This function may be implemented by hardware, or may be implemented by executing corresponding software on the hardware.
- the hardware or software includes one or more modules corresponding to the above functions.
- an embodiment of the present application provides a computer-readable storage medium, including computer instructions.
- the computer instructions When the computer instructions are run on the electronic device, the electronic device executes any of the steps in the first aspect and any possible implementation manners.
- One of the described rendering methods One of the described rendering methods.
- the embodiment of the present application provides a computer program product, which, when the computer program product is run on the electronic device, enables the electronic device to execute any one of the first aspect and any one of the possible implementations. rendering method.
- an embodiment of the present application provides a circuit system, where the circuit system includes a processing circuit configured to execute the rendering method described in the first aspect and any possible implementation manner thereof.
- the embodiment of the present application provides a chip system, including at least one processor and at least one interface circuit.
- at least one processor executes the rendering method described in the first aspect and any possible implementation manner thereof.
- Figure 1 is a schematic diagram of the interface provided by the embodiment of the present application.
- FIG. 2 is a schematic diagram of the form of an electronic device provided by an embodiment of the present application.
- FIG. 3 is a first schematic structural diagram of an electronic device provided by an embodiment of the present application.
- FIG. 4 is a schematic diagram of a software structure block diagram of an electronic device provided in an embodiment of the present application.
- FIG. 5 is a flowchart of a rendering method provided by an embodiment of the present application.
- FIG. 6 is a schematic diagram of a control tree structure provided by an embodiment of the present application.
- FIG. 7 is a schematic diagram of a rendering layered scene provided by an embodiment of the present application.
- FIG. 8 is a first schematic diagram of an instruction grouping scenario provided by an embodiment of the present application.
- FIG. 9 is a second schematic diagram of an instruction group grouping scenario provided by the embodiment of the present application.
- FIG. 10 is a schematic diagram of an image frame refresh cycle provided by an embodiment of the present application.
- FIG. 11 is a second structural schematic diagram of the electronic device provided by the embodiment of the present application.
- FIG. 12 is a third structural schematic diagram of the electronic device provided by the embodiment of the present application.
- plural means two or more.
- the "and/or” in this article is just an association relationship describing associated objects, which means that there can be three relationships, for example, A and/or B, which can mean: A exists alone, A and B exist at the same time, and B exists alone These three situations.
- a control also referred to as a component (widget) in some embodiments, is a user interface element that can serve as a human-computer interaction interface and receive user operations on electronic devices.
- the electronic device receives a control command input by the user by detecting the user's operation on the control.
- the control may include a text control (text view), a button (button), a picture control (image view), a progress bar (progress bar), etc.
- the main interface 101 shown in (a) in FIG. 1 has an application program icon displayed on the main interface 101.
- the application program icon can be used as a control to start the application program.
- the application program icon here is equivalent to a launcher
- the control of the application, the launcher is the launcher, that is, the system application that displays the desktop of the user's mobile phone, including displaying and managing application icons and various desktop controls on the desktop.
- the interface 102 shown in (b) in FIG. 1 is displayed.
- the controls may include a picture control 1021, a text control 1022, a button 1023, and the like.
- Control data generated by the application that includes the control.
- the above-mentioned application icon control of the launcher application is a control used by the launcher to display and facilitate the user to open other installed applications. Therefore, the control data is obtained and generated by the launcher according to the other installed applications, and the data of the control can also be changed in the launcher, for example, the user can adjust the position and size of the control.
- the electronic device draws the control according to the control data, so as to display the control visible to the user.
- the layout is used to indicate the position and size of a certain display area, and the position display effect of the controls in the display area.
- Types of layout include linear layout, relative layout, absolute layout, etc.
- the linear layout is used to indicate that the controls are displayed in a linear arrangement in a horizontal or vertical direction.
- Relative layout is used to indicate where a control is displayed relative to other controls.
- Absolute layout is used to indicate the display position of the control in the display interface.
- the layout of the control A includes that the center pixel of the control A coincides with the center point of the display screen, and the size is 200 pixels (pixels), then the layout of the control A is an absolute layout.
- the layout of control B includes that the center pixel of control B is located N pixels to the left of the center pixel of control A, and the size of control B is the same as that of control A, so the layout of control B is a relative layout.
- the type of layout corresponding to the display position of each setting option such as Bluetooth, mobile network, desktop and wallpaper includes a linear layout.
- the layout data includes information about the position and size of a certain display area, the controls contained in the display area, and the type of layout corresponding to the controls.
- the process of displaying images by the electronic device at least includes a user interface (user interface, UI) thread and a rendering thread.
- UI thread is used to control the display, update and control interaction of the UI interface, and can generate graphic data and rendering instructions.
- the rendering thread completes rendering of control data, layout data, etc. according to graphics data and rendering instructions, and generates image frames.
- UI threads and rendering threads are called.
- the UI thread in the embodiment of the present application can also be described as a UI process, UI task, etc. in different operating systems
- the rendering thread in the embodiment of the present application can also be described as a rendering process, rendering task, etc. in different operating systems. It will not be explained below.
- the display frame rate indicates the smoothness of the image displayed by the electronic device.
- users have higher and higher requirements on the display effect of electronic equipment.
- it is necessary to increase the display frame rate, which requires an increase in the image generation rate.
- the rendering time of control data, layout data, etc. has a great influence on the image generation rate.
- the electronic device needs to achieve a high display frame rate of 144HZ, it needs to ensure that the rendering time of a single frame image is less than 6ms.
- the rendering time of a single frame image is less than 6ms.
- Electronic devices display image freeze (i.e. frame loss).
- the embodiment of the present application provides a rendering method, which can effectively reduce the rendering time by layering and parallel rendering the control data and layout data to be rendered, meet the requirements of high display frame rate for image generation rate, and avoid the occurrence of electronic device display images Caton phenomenon.
- the rendering method provided in the embodiment of the present application may be applied to electronic devices.
- the electronic device can specifically be a large-screen display device 21, a mobile phone 22, a notebook computer 23, a tablet computer 24, a vehicle-mounted device 25, a wearable device (such as a smart watch 26), a super mobile personal computer ( Ultra-mobile personal computer, UMPC), netbook, personal digital assistant (personal digital assistant, PDA), artificial intelligence (artificial intelligence) equipment and other terminal equipment with display functions, the embodiment of this application does not make any restrictions on the specific type of electronic equipment .
- FIG. 3 shows a schematic structural diagram of the electronic device 100 .
- the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (subscriber identification module, SIM) card interface 195 wait.
- a processor 110 an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (subscriber identification module, SIM) card interface 195 wait.
- SIM subscriber identification module
- the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100 .
- the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components.
- the illustrated components can be realized in hardware, software or a combination of software and hardware.
- the processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
- application processor application processor, AP
- modem processor graphics processing unit
- GPU graphics processing unit
- image signal processor image signal processor
- ISP image signal processor
- controller video codec
- digital signal processor digital signal processor
- baseband processor baseband processor
- neural network processor neural-network processing unit
- the controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.
- a memory may also be provided in the processor 110 for storing instructions and data.
- the memory in processor 110 is a cache memory.
- the memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated access is avoided, and the waiting time of the processor 110 is reduced, thereby improving the efficiency of the system.
- processor 110 may include one or more interfaces.
- the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transmitter (universal asynchronous receiver/transmitter, UART) interface, mobile industry processor interface (mobile industry processor interface, MIPI), general-purpose input and output (general-purpose input/output, GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and /or universal serial bus (universal serial bus, USB) interface, etc.
- I2C integrated circuit
- I2S integrated circuit built-in audio
- PCM pulse code modulation
- PCM pulse code modulation
- UART universal asynchronous transmitter
- MIPI mobile industry processor interface
- GPIO general-purpose input and output
- subscriber identity module subscriber identity module
- SIM subscriber identity module
- USB universal serial bus
- the I2C interface is a bidirectional synchronous serial bus, including a serial data line (serial data line, SDA) and a serial clock line (derail clock line, SCL).
- processor 110 may include multiple sets of I2C buses.
- the processor 110 can be respectively coupled to a touch sensor, a charger, a flashlight, a camera 193 and the like through different I2C bus interfaces.
- the processor 110 may be coupled to the touch sensor through an I2C interface, so that the processor 110 communicates with the touch sensor through the I2C bus interface to realize the touch function of the electronic device 100 .
- the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 .
- MIPI interface includes camera serial interface (camera serial interface, CSI), display serial interface (display serial interface, DSI), etc.
- the processor 110 communicates with the camera 193 through the CSI interface to realize the shooting function of the electronic device 100 .
- the processor 110 communicates with the display screen 194 through the DSI interface to realize the display function of the electronic device 100 .
- the USB interface 130 is an interface conforming to the USB standard specification, specifically, it can be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
- the USB interface 130 can be used to connect a charger to charge the electronic device 100 , and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones and play audio through them. This interface can also be used to connect other electronic devices, such as AR devices.
- the interface connection relationship between the modules shown in the embodiment of the present application is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 .
- the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
- the charging management module 140 is configured to receive a charging input from a charger.
- the charger may be a wireless charger or a wired charger. While the charging management module 140 is charging the battery 142 , it can also provide power for electronic devices through the power management module 141 .
- the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
- the power management module 141 receives the input from the battery 142 and/or the charging management module 140 to provide power for the processor 110 , the internal memory 121 , the display screen 194 , the camera 193 , and the wireless communication module 160 .
- the wireless communication function of the electronic device 100 can be realized by the antenna 1 , the antenna 2 , the mobile communication module 150 , the wireless communication module 160 , a modem processor, a baseband processor, and the like.
- Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
- Each antenna in electronic device 100 may be used to cover single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas.
- Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.
- the antenna may be used in conjunction with a tuning switch.
- the mobile communication module 150 can provide wireless communication solutions including 2G/3G/4G/5G applied on the electronic device 100 .
- the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA) and the like.
- the mobile communication module 150 can receive electromagnetic waves through the antenna 1, filter and amplify the received electromagnetic waves, and send them to the modem processor for demodulation.
- the mobile communication module 150 can also amplify the signals modulated by the modem processor, and convert them into electromagnetic waves through the antenna 1 for radiation.
- at least part of the functional modules of the mobile communication module 150 may be set in the processor 110 .
- at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be set in the same device.
- the wireless communication module 160 can provide wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (Wireless Fidelity, Wi-Fi) network), bluetooth (bluetooth, BT), global navigation satellite, etc. applied on the electronic device 100.
- System global navigation satellite system, GNSS
- frequency modulation frequency modulation, FM
- near field communication technology near field communication, NFC
- infrared technology infrared, IR
- the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
- the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
- the wireless communication module 160 can also receive the signal to be sent from the processor 110 , frequency-modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
- the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
- the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR techniques, etc.
- GSM global system for mobile communications
- GPRS general packet radio service
- code division multiple access code division multiple access
- CDMA broadband Code division multiple access
- WCDMA wideband code division multiple access
- time division code division multiple access time-division code division multiple access
- TD-SCDMA time-division code division multiple access
- the GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (global navigation satellite system, GLONASS), a Beidou satellite navigation system (beidou navigation satellite system, BDS), a quasi-zenith satellite system (quasi -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
- GPS global positioning system
- GLONASS global navigation satellite system
- Beidou satellite navigation system beidou navigation satellite system
- BDS Beidou navigation satellite system
- QZSS quasi-zenith satellite system
- SBAS satellite based augmentation systems
- the electronic device 100 realizes the display function through the GPU, the display screen 194 , and the application processor.
- the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
- Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
- the display screen 194 is used to display images, videos and the like.
- the display screen 194 includes a display panel.
- the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), etc.
- the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.
- the sensor module 180 may include a pressure sensor, a gyro sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
- the display screen 194 in the embodiment of the present application may be a touch screen. That is, a touch sensor is integrated in the display screen 194 .
- the touch sensor may also be referred to as a "touch panel”. That is to say, the display screen 194 may include a display panel and a touch panel, and a touch screen composed of a touch sensor and the display screen 194 is also called a “touch screen”.
- the touch sensor is used to detect a touch operation on or near it. After the touch operation detected by the touch sensor, it can be passed to the upper layer by the driver of the kernel layer (such as the TP driver) to determine the type of the touch event. Visual output related to the touch operation can be provided through the display screen 194 .
- the touch sensor can also be disposed on the surface of the electronic device 100 , which is different from the position of the display screen 194 .
- the electronic device 100 uses the touch sensor to detect the user's touch operation on the display screen 194, it may trigger the position of the controls displayed on the display screen 194 to change, so when the next frame of image is displayed, it needs to re-align the image. layer data for rendering.
- the electronic device 100 detects that the user has long pressed and dragged the application icon, the position of the application icon (that is, the control) may change in each frame of the image during the dragging process, and the control data and layout Rendering of data.
- the electronic device 100 can realize the shooting function through the ISP, the camera 193 , the video codec, the GPU, the display screen 194 and the application processor.
- Camera 193 is used to capture still images or video.
- the object generates an optical image through the lens and projects it to the photosensitive element.
- the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
- CMOS complementary metal-oxide-semiconductor
- the photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
- the ISP outputs the digital image signal to the DSP for processing.
- DSP converts digital image signals into standard RGB, YUV and other image signals.
- the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
- the external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100.
- the external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. Such as saving music, video and other files in the external memory card.
- the internal memory 121 may be used to store computer-executable program codes including instructions.
- the internal memory 121 may include an area for storing programs and an area for storing data.
- the stored program area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.) and the like.
- the storage data area can store data created during the use of the electronic device 100 (such as audio data, phonebook, etc.) and the like.
- the processor 110 executes various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
- the audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal.
- the audio module 170 may also be used to encode and decode audio signals.
- the audio module 170 may be set in the processor 110 , or some functional modules of the audio module 170 may be set in the processor 110 .
- the electronic device 100 may implement audio functions through the audio module 170 and the application processor. Such as music playback, recording, etc.
- the audio module may include a loudspeaker, a receiver, a microphone, and an earphone jack.
- the keys 190 include a power key, a volume key and the like.
- the key 190 may be a mechanical key. It can also be a touch button.
- the electronic device 100 can receive key input and generate key signal input related to user settings and function control of the electronic device 100 .
- the motor 191 can generate a vibrating reminder.
- the motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback.
- touch operations applied to different applications may correspond to different vibration feedback effects.
- the motor 191 may also correspond to different vibration feedback effects for touch operations acting on different areas of the display screen 194 .
- Different application scenarios for example: time reminder, receiving information, alarm clock, games, etc.
- the touch vibration feedback effect can also support customization.
- the indicator 192 can be an indicator light, and can be used to indicate charging status, power change, and can also be used to indicate messages, missed calls, notifications, and the like.
- the SIM card interface 195 is used for connecting a SIM card.
- the SIM card can be connected and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195 .
- the electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
- the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture.
- the embodiment of the present application takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 .
- FIG. 4 is a block diagram of the software structure of the electronic device 100 according to the embodiment of the present application.
- the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate through software interfaces.
- the Android system is divided into four layers, which are respectively the application program layer, the application program framework layer, the system library of Android runtime (Android runtime), and the kernel layer from top to bottom.
- the application layer can consist of a series of application packages.
- the application package may include application programs such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
- application programs such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
- the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
- the application framework layer includes some predefined functions.
- the application framework layer can include window managers, content providers, view systems, resource managers, notification managers, etc.
- a window manager is used to manage window programs.
- the window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
- the activity manager is used to manage the Activity, and is responsible for the startup, switching, scheduling of each component in the system and the management and scheduling of the application program.
- Content providers are used to store and retrieve data and make it accessible to applications.
- Said data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebook, etc.
- the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on.
- the view system can be used to build applications.
- a display interface can consist of one or more views.
- a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
- the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
- the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction.
- the Android Runtime includes core library and virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
- the core library includes two parts: one part is the function function that the java language needs to call, and the other part is the core library of Android.
- the application layer and the application framework layer run in virtual machines.
- the virtual machine executes the java files of the application program layer and the application program framework layer as binary files.
- the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
- a system library can include multiple function modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
- the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
- the media library supports playback and recording of various commonly used audio and video formats, as well as still image files, etc.
- the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
- the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing, etc.
- the two-dimensional graphics engine is a graphics engine for 2D graphics.
- Common graphics engines include Vulkan, Canvas, etc., for example.
- the kernel layer is the layer between hardware and software.
- the kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.
- the kernel layer can generate a corresponding input event (such as an application program start event) according to the input operation, and report the event to the application framework layer. event.
- the view system of the application framework layer determines the corresponding control data and layout data of the application, and determines the process logic of the rendering engine rendering, and sends them to the two-dimensional graphics engine of the system library for processing, and then sends the processed data to the kernel
- the display driver of the layer is used to display the corresponding application interface on the display screen.
- FIG. 5 is a schematic diagram of a rendering method provided by an embodiment of the present application. The method may be applied to electronic devices. As shown in FIG. 5 , the method may include S501-S503.
- the electronic device after the electronic device detects an event that triggers rendering, it acquires the rendering object to be displayed and the control tree of the rendering object to be displayed (ie, the control tree to be drawn), and then determines the control of the rendering object in the control tree tree hierarchy.
- the rendering objects include controls and layouts.
- the data of the rendering object includes the following situations: if the rendering object is a control, the data of the rendering object is control data; if the rendering object is a layout, then the data of the rendering object is layout data.
- the event that triggers rendering is, for example, a user's touch operation on the display screen detected by the electronic device, such as clicking an interactive control, or the user's sliding on the display screen (such as sliding up and down, left and right sliding, etc.); or it may be the user’s voice input detected by the electronic device; or it may be an event that automatically switches the screen of the foreground application of the electronic device, etc., which are not limited here.
- the foreground application is an application corresponding to the interface currently displayed on the display screen of the electronic device.
- the screen content of the foreground application can include not only the screen that the user can see, but also the content without user interface, the content of transparent layer, or the content that is blocked by other application interfaces and is invisible to the user. Obtain all control data and layout data to be drawn corresponding to the screen content.
- a control tree (view tree) is used to represent controls and layouts organized in a tree structure.
- the confirmation of the control tree level is to traverse the control tree to determine the tree node relationship between the controls and the layout in the control tree, and fill in the determined controls and the control tree level of the layout into the corresponding control data and layout data, so as to facilitate subsequent
- the rendering levels are divided according to the control tree level.
- control data and layout data are used to indicate that control data exists alone, layout data exists alone, and there are three types of control data and layout data at the same time. situation, which will not be described further below.
- controls and layouts in the control tree include absolute layout 0, absolute layout 1, absolute layout 2, absolute layout 3, relative layout 1, button (button) 0, button 1, button 2, button 3, text ( text)0, text1, text2, and text3.
- FIG. 6 shows a schematic diagram of the positional relationship between controls and layouts in the control tree.
- the electronic device starts an Activity corresponding to a window (window) after detecting a user's touch operation on a display screen, and creates a corresponding control tree.
- control data and layout data in the control tree are obtained, and according to the node depth of the control tree where the control tree node is located, it is divided into the level corresponding to the depth of the control tree, and the corresponding control tree can be filled in the corresponding control data and layout data according to the level
- the level marks are used to divide the rendering levels in the subsequent step S502.
- the root view (root view) will be determined first, and then the setContentView() method will be called to complete the creation of other nodes above the root view. Then, the node relationship in the control tree can be determined according to the Z-axis value, and the Z-axis value is related to the order of creation of controls and layouts.
- the root view in the current control tree is absolute layout 0
- the level of absolute layout 0 in the control tree is control tree level 0
- the control tree The level 0 mark is filled in the layout data corresponding to absolute layout 0.
- Absolute Layout 1 For example, the child nodes of Absolute Layout 1 include Button 0 and button 1, the child nodes of absolute layout 2 include text 0 and text 1, and the child nodes of relative layout 1 include button 2, button 3 and absolute layout 3, then determine each child node as shown in (b) in Figure 6
- the level in the control tree is control tree level 2, and the mark of control tree level 2 is recorded in the corresponding control data and layout data.
- one or more steps in S501 may be completed by the electronic device calling a UI thread.
- the embodiment of the present application does not limit the creation order of nodes in the control tree.
- the creation order of nodes can be customized by the user. After obtaining the control tree, it is only necessary to determine the control tree level according to the node relationship in the control tree.
- control data and layout data included in the subsequent control tree have not changed, you only need to maintain the control tree, instead of traversing the control tree before rendering, only inherit previous data. Or, if the control data and layout data included in the control tree are changed, it is only necessary to reconfirm the control tree level and its sub-control tree levels of the changed part.
- control tree level 0 control tree level 1
- control tree level 2 control tree level 3
- control tree level 3 are used to represent the order of the control tree levels, which is only an exemplary illustration.
- control tree level can also be expressed as a control Tree level 1-control tree level 4, control tree level A-control tree level D, etc.
- each node in the control tree corresponds to a rendering object (that is, a control or a layout), and each control tree level contains one or more rendering objects (that is, including one or more controls, one or more layout). Then, after obtaining the control tree level, it is necessary to determine whether the rendering objects (that is, controls and layouts) at the same control tree level in the control tree intersect, so as to divide the rendering level according to the intersection.
- the controls and layouts are initially divided into the corresponding rendering levels (that is, different control tree levels are set to different rendering levels), and then on this basis, the intersecting controls and layouts in the same control tree level Divide into different rendering levels (that is, set intersecting rendering objects at the same control tree level to different rendering levels), and divide disjoint controls and layouts into the same rendering level to complete the division of rendering levels.
- fill in the determined rendering level tags of controls and layouts into corresponding control data and layout data so as to facilitate subsequent rendering of controls and layouts according to the rendering level in step S503.
- the control and the layout have a corresponding drawing area, and if the drawing area partially or completely intersects, it means that the corresponding control and the layout intersect.
- the corresponding drawing area can be obtained according to the control data and layout data, and the smallest rectangular area can be used to represent the drawing area of the control or layout.
- the smallest rectangular area includes, for example, the smallest area that can cover the corresponding control or layout.
- the area in the rectangular frame indicated by reference numeral 61 can completely cover the drawing area of text 2 and has the smallest area, then it is the smallest rectangular area corresponding to text 2, and reference numeral 62 indicates The area within the rectangular frame of can completely cover the drawing area of text 3 and has the smallest area, so it is the smallest rectangular area corresponding to text 3.
- both text 2 and text 3 have been set to control tree level 3 (that is, the same control tree level), then it is necessary to determine the two rendering objects (that is, text 2 and text 3 ) to determine the rendering level.
- control tree level 3 that is, the same control tree level
- the control tree level information of the control tree is obtained, and the level of the absolute layout 0 is the control tree level 0.
- the rendering level of the absolute layout 0 is divided into Render level 0.
- the rendering objects corresponding to control tree level 1 include absolute layout 1, absolute layout 2 and relative layout 1, as shown in (a) in Figure 6, relative layout 1 corresponds to If the minimum rectangular area does not intersect with the minimum rectangular area corresponding to absolute layout 1 and the minimum rectangular area corresponding to absolute layout 2, then it is determined that relative layout 1 does not intersect with both absolute layout 1 and absolute layout 2, then it corresponds to the control tree level, such as As shown in FIG. 7 , the rendering level of relative layout 1 is divided into rendering level 1.
- the rendering objects corresponding to control tree level 2 include button 0, button 1, text 0, text 1, button 2, button 3 and absolute layout 3.
- button 0 and button 1 intersect, and the intersecting area button 1 is above button 0; text 0 and text 1 intersect, and the intersecting area text 1 Above Text0; Button2, Button3, and AbsoluteLayout3 are all disjoint from other render objects.
- the rendering levels of button 0, button 2, button 3 and absolute layout 3 are divided into rendering level 2, and the rendering level of button 1 is divided into rendering level 3.
- the rendering objects corresponding to level 3 of the control tree include text 2 and text 3 .
- the rendering objects corresponding to level 3 of the control tree include text 2 and text 3 .
- the rendering level of text 2 is divided into rendering level 3
- the rendering level of text 3 is divided into rendering level 4 .
- rendering level 0 rendering level 1
- rendering level 2 rendering level 3
- rendering level 4 are used to indicate the rendering order, which is only an exemplary illustration.
- the rendering level can also be expressed as rendering level 1- Rendering level 5, rendering level A-rendering level E, etc.
- the division of rendering levels can be confirmed by the UI thread after confirming the control tree level, and then in step S503, the rendering thread directly obtains the rendering level for rendering; or after the rendering thread obtains the control tree level, it divides the rendering according to the control tree level Level; or divide the rendering level by other threads, and the rendering thread performs data rendering after receiving the confirmed rendering level division result and data.
- the electronic device invokes the rendering thread to render rendering objects (eg, including controls and layouts) in order of rendering levels. For example, render objects of different rendering levels serially according to the order of rendering levels, and render objects of the same rendering level in parallel.
- the current rendering level includes 5 levels, and the rendering thread is called to perform serial rendering in the order of rendering from rendering level 0 to rendering level 4, that is, serially rendering from a low rendering level to a high rendering level.
- the same rendering thread to sequentially render absolute layout 0, absolute layout 1, and button 0.
- the data in the same rendering level is rendered in parallel, for example, after rendering absolute layout 0, call two rendering threads to render absolute layout 1 and relative layout 1 in parallel.
- control data or layout data includes one or several items of background layer constituent element data, content layer constituent element data, and foreground layer constituent element data.
- the background layer constituent element data corresponds to the background of the control or layout after rendering
- the content layer constituent elements correspond to the display content of the control or layout after rendering
- the foreground layer constituent element data corresponds to the foreground of the control or layout after rendering.
- the control is a text control
- the element data of the content layer of the control includes corresponding text data.
- the electronic device completes the division of the rendering levels, the data of different rendering levels can be rendered according to the order of the rendering levels, but for the data of the same rendering level, the rendering order of the constituent element data in the same rendering level needs to be further determined.
- button 0 and button 2 are both divided into rendering level 2, assuming that button 0 includes background 1 and content 1, and button 2 only includes content 2. Then, although button 0 and button 1 are at the same rendering level, it is necessary to divide the rendering order of background 1, content 1 and content 2.
- Method 1 Group the control data and layout data in the same rendering level according to the data categories that make up the element data, divide the data of the same data category into the same instruction group, and divide the data of different data categories into different instruction groups.
- the background layer constituent elements in the same rendering level are divided into one instruction group data
- the content layer constituent elements are divided into one instruction group data
- the foreground layer constituent elements are divided into one instruction group data.
- divide the background data in the same rendering level into an instruction group divide the text data into an instruction group, and so on.
- record the instruction group group result mark into the corresponding control data or layout data then in the rendering process, the element data instruction group can be formed according to the background layer and the element data can be formed by the content layer in the same rendering level according to the mark
- the command group and the foreground layer are rendered in the order of the element data command group.
- step S502 determines the rendering levels of the control data and layout data included in the control tree, including rendering level 1 and rendering level 2, the data corresponding to rendering level 1 includes Text 1, Text 3, Text 5, Text 7, and Text 9, and the data corresponding to rendering level 2 include Text 2, Text 4, Text 6, Text 8, and Text 10.
- each text data includes background layer constituent element data and content layer constituent element data (i.e. text content), as shown in Figure 8, the background layer can be divided into each rendering level
- the constituent element data is divided into an instruction group (such as instruction group 1 or instruction group 3), and the content layer constituent element data is divided into an instruction group (such as instruction group 2 or instruction group 4).
- the data of rendering level 1 includes the data of instruction group 1 and the data of instruction group 2
- the data of rendering level 2 includes the data of instruction group 3 and the data of instruction group 4.
- Method 2 According to the execution order of the instructions constituting the element data, group the control data and layout data in the same rendering level into instruction groups. Data with different instruction execution sequences are divided into different instruction groups.
- the instruction execution order includes, for example, the original rendering order of the component data of the control data and the layout data.
- the original rendering order of the component data of the control data or layout data is generally to first render the background layer to form the element data, then render the content layer to form the element data, and finally render the foreground layer to form the element data.
- the control data or layout data does not include a certain layer or layers of constituent element data, it is allowed to skip this layer of data and directly render the next layer of constituent element data.
- the data with the same instruction execution sequence in the same rendering level is divided into the same instruction group, and the data with different instruction execution sequences is divided into different instruction groups.
- mark and record the grouping result of the instruction group into the corresponding control data or layout data and then perform rendering according to the marked grouping result of the instruction group and the execution order of the instruction group during the rendering process.
- step S502 determines the rendering levels of the control data and layout data included in the control tree, including rendering level 1 and rendering level 2, the data corresponding to rendering level 1 includes Text 1, Text 3, Text 5, Text 7, and Text 9, and the data corresponding to rendering level 2 include Text 2, Text 4, Text 6, Text 8, and Text 10.
- the text 1, text 5, text 7 and text 9 in the rendering level 1 all include the element data of the background layer and the element data of the content layer.
- Text 3 indicated by mark 91 includes only content layer constituent element data, and does not include background layer constituent element data.
- the order of instruction execution is to first execute the rendering of the background layer to form the element data, and then execute the rendering of the content layer to form the element data, then the text 3 can directly render the content layer to form the element data during the rendering process because the text 3 does not include the background layer to form the element data, and the rendering layer Other data in 1 need to render the element data of the background layer first, and then render the element data of the content layer. Therefore, if the instruction group is divided according to the element category, it will cause the rendering thread that is responsible for rendering the element data of the background layer of Text 3 to pause when rendering the element data composed of the background layers of Text 1, Text 5, Text 7, and Text 9 during the rendering process. Work, wait for the next instruction group to render, and increase unnecessary rendering waiting time.
- the electronic device can divide instruction groups according to the execution order of instructions in the control.
- the data of rendering level 1 includes the data of instruction group 1 and the data of instruction group 2
- the data of instruction group 1 includes The background layer constituent element data of text 1, text 5, text 7 and text 9, and the content layer constituent data of text 3
- the data of command group 2 includes the content layer constituent elements of text 1, text 5, text 7 and text 9 data.
- the command group group can be confirmed by the UI thread after dividing the rendering level, and then the rendering thread directly obtains the rendering level and the command group group for rendering during the rendering process; or, after the rendering thread obtains the control tree level, according to the control tree
- the level confirms the rendering level and instruction group grouping; or, the electronic device calls other threads to complete the rendering level layering and instruction group grouping according to the control tree level information determined by the UI thread, and then calls the rendering thread to perform rendering according to the rendering level and instruction group grouping.
- the data of different instruction groups in the same rendering level are rendered serially according to the instruction group order, and the data in the same instruction group are rendered in parallel rendering.
- the rendering order of the command group data corresponds to the rendering order of the element data of the background layer, the element data of the content layer, and the element data of the foreground layer. That is, the component element data in the same instruction group in the rendering objects of the same rendering level are rendered in parallel, and the component element data in different instruction groups in the rendering objects of the same rendering level are rendered serially.
- the control data and layout data in rendering level 1 should be rendered first, and then the control data and layout data in rendering level 2 should be rendered.
- the instruction group 1 data and instruction group 2 data belonging to the rendering level 1 are serially rendered, the background layer corresponding to instruction group 1 is rendered first to form element data, and then the content layer corresponding to instruction group 2 is rendered to form element data, and the same Parallel rendering within instruction groups.
- the background layer constituent element data that is, background data
- thread 1 thread 2, thread 3, thread 4 and thread 5 render in parallel the content layer in instruction group 2 to form element data (ie text data).
- the electronic device allocates rendering threads to perform data rendering according to the resources available for operation in the CPU and GPU.
- the UI thread generates a rendering instruction based on the result of the rendering hierarchy division and the instruction group grouping result to trigger the rendering thread to perform data rendering, and the rendering thread performs data rendering after receiving the rendering instruction.
- the electronic device determines whether the number of rendering threads that can be called in parallel meets the rendering requirements of the instruction group according to the executable resources of the CPU and GPU. If the number of threads that can be called in parallel meets the If the rendering requirement of the instruction group is met, a corresponding number of rendering threads are called to render the data in the instruction group in parallel. If the number of threads that can be called in parallel does not meet the rendering requirements of the instruction group, call the maximum number of rendering threads to render part of the data in the instruction group in parallel, and render all the data in the instruction group in batches.
- the electronic device determines that instruction group 1-instruction group 4 need to call 5 rendering threads for parallel rendering, and the electronic device determines the resources that can be run in the current CPU and GPU If the requirements are met (for example, the maximum number of rendering threads that can be invoked in parallel is greater than or equal to 5), the running resource allows 5 rendering threads to be invoked for parallel rendering, and then threads 1-5 are invoked for parallel rendering of data in the instruction group.
- the electronic device determines that there are 5 constituent element data (such as background 1-background 5 included in instruction group 1) that need to be rendered in parallel according to the grouping of the final instruction group, assuming that the electronic device determines the most Three rendering threads can be called for parallel rendering (that is, the maximum number of parallel calling rendering threads is 3), then the constituent element data in the command group that needs to be rendered in parallel are grouped again and then rendered serially. For example, among the 5 background layer constituent element data to be rendered included in instruction group 1 shown in FIG.
- three background layer constituent element data to be rendered are divided into one instruction group and the other two background constituent elements
- the element data is divided into an instruction group (for example, background 1-background 3 are divided into one instruction group, and background 4 and background 5 are divided into one instruction group).
- use the 3 rendering threads that can be called in parallel to first render the element data of the 3 background layers to be rendered in parallel, and then call any 2 of the rendering threads to render the remaining 2 background layers to be rendered.
- Render background 1-background 3, then render background 4 and background 5 in parallel that is to say, when there are insufficient running resources in the CPU and GPU, the constituent element data divided into parallel rendering is divided into partial serial rendering constituent element data again, so as to realize batch rendering of data to avoid rendering failure.
- the rendering of the rendering object can be performed by the display device, that is, after the electronic device completes the division of rendering levels and the grouping of instruction groups, it sends the result to the display device (that is, other electronic devices with display functions) for rendering and show.
- the display device that is, other electronic devices with display functions
- the display device can also reduce the power consumption of dividing rendering levels and dividing instruction groups.
- the rendering time can be effectively reduced, and the frame dropping phenomenon of the displayed image can be avoided. That is to say, the possibility of frame loss when an electronic device displays an image can be reduced by means of parallel rendering, and the smoothness of the image displayed on the display screen can be ensured, thereby improving the user's visual experience.
- the graphics data (such as control data and layout data) included in adjacent image frames does not change, the graphics data does not need to be redrawn.
- application icons are displayed on the main interface of the electronic device, and the user presses and drags one of the application icons to a blank display area for display.
- the position and display content of other application icons will not change, so the electronic device can no longer redraw the constant controls and layouts in adjacent image frames, so as to save the power of the electronic device. consumption. That is to say, the rendering method provided in step S501-step S503 above is applied to the graphic data that needs to be drawn, and for the graphic data that does not need to be re-rendered, the rendering result of the previous frame image can be obtained directly.
- the image display process includes an input event phase, a UI data update phase, a rendering phase, a synthesis phase, and a display phase.
- a vertical synchronization signal (vsync) is used to trigger different stages.
- the vertical synchronization signal 1 may be used to trigger drawing of one or more layers, and trigger rendering of the one or more layers.
- the electronic device in response to the vertical synchronization signal 1 , may draw one or more layers for each application through each of the multiple drawing threads.
- the electronic device in response to the vertical synchronization signal 1 , can simultaneously execute drawing tasks for one or more applications, so as to draw one or more layers corresponding to each application.
- the rendering method corresponding to each layer may be the rendering method described in the foregoing embodiments.
- the vertical sync signal 2 can be used to trigger image frame compositing after rendering.
- the vertical sync signal 3 can be used to trigger display of the synthesized image frame.
- the signal period of each vertical synchronization signal is determined according to the screen refresh rate of the display screen of the electronic device.
- the signal period of the vertical synchronization signal is the reciprocal of the screen refresh rate of the display screen (such as LCD or OLED) of the electronic device.
- the screen refresh rate of the electronic device may be the same as the frame rate of the electronic device.
- a high frame rate of an electronic device is a high screen refresh rate.
- the electronic device in response to the vertical synchronization signal 1, the electronic device processes the layer data to obtain the corresponding rendering object in the control tree and the control tree level corresponding to the rendering object, and then determines the rendering level of the rendering object. Finally, the rendering thread is called to render the rendering object.
- rendering a that is, rendering thread a
- rendering b that is, rendering thread b
- rendering c that is, rendering thread c
- rendering a, rendering b, and rendering c all need to be serially rendered in sequence, resulting in failure to complete the rendering task of rendering c within the signal period of the vertical synchronization signal, and the electronic device detection
- the vertical synchronous signal 2 there is no rendered image frame that can be synthesized, and then the image frame cannot be refreshed and displayed in response to the vertical synchronous signal 3, and the display screen of the LCD cannot be updated, and the phenomenon of frame loss will occur. In this way, the coherence and fluency of images displayed on the display screen will be affected, thereby affecting the user's visual experience.
- the name of the vertical synchronization signal may be different.
- the name of the signal used to trigger the processing of one or more layers of data ie, the vertical synchronization signal 1
- the vertical synchronization signal 1 may not be the vertical synchronization signal.
- the name of the signal is, as long as it is a synchronization signal with similar functions and conforms to the technical idea of the method provided by the embodiment of this application, it should be covered within the scope of protection of this application.
- the rendering method provided by the embodiment of the present application has been described in detail above with reference to FIGS. 5-10 .
- the electronic device provided by the embodiment of the present application will be described in detail below with reference to FIG. 11 and FIG. 12 .
- FIG. 11 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
- an electronic device 1100 includes: an acquiring unit 1101 , a dividing unit 1102 and a rendering unit 1103 .
- the electronic device 1100 may be used to implement the functions of the electronic device involved in the foregoing method embodiments.
- the electronic device 1100 may be the electronic device itself, or may be a functional unit or chip in the electronic device, or a device matched with the electronic device.
- the acquiring unit 1101 is configured to support the electronic device 1100 to execute step S501 in FIG. 5 .
- the dividing unit 1102 is configured to support the electronic device 1100 to execute step S502 in FIG. 5 .
- the rendering unit 1103 is configured to support the electronic device 1100 to execute step S503 in FIG. 5 .
- the electronic device 1100 shown in FIG. 11 may further include a sending unit (not shown in FIG. 11 ), which is configured to send signals to other communication devices.
- a sending unit (not shown in FIG. 11 ), which is configured to send signals to other communication devices.
- the electronic device 1100 shown in FIG. 11 may further include a storage unit (not shown in FIG. 11 ), which stores programs or instructions.
- a storage unit not shown in FIG. 11
- the electronic device 1100 shown in FIG. 11 can execute the rendering method shown in FIG. 5 .
- the acquisition unit and the sending unit may be collectively referred to as a transceiver unit, which may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module.
- the operations and/or functions of each unit in the electronic device 1100 are to implement the corresponding process of the rendering method described in the above method embodiment, and for the sake of brevity, details are not described here.
- FIG. 12 shows another possible composition diagram of the electronic device involved in the above embodiment.
- the electronic device 1200 may include: a processing module 1201 .
- the processing module 1201 is used to execute the steps performed by the acquiring unit 1101, the dividing unit 1102 and the rendering unit 1103 shown in FIG. For the sake of brevity, the corresponding process is not repeated here.
- the electronic device 1200 may also include a storage module for storing program codes and data of the electronic device.
- the storage module may be a memory.
- the processing module 1201 may be a processor or a controller. It can realize or execute various exemplary logical blocks, modules and circuits described in conjunction with the disclosed content of the embodiments of the present application.
- the processor can also be a combination of computing functions, for example, a combination of one or more microprocessors, a combination of DSP and a microprocessor, and so on.
- the embodiment of the present application also provides a chip system, including: a processor, the processor is coupled with a memory, and the memory is used to store programs or instructions, and when the programs or instructions are executed by the processor, the The system on chip implements the method in any one of the foregoing method embodiments.
- processors in the chip system there may be one or more processors in the chip system.
- the processor can be realized by hardware or by software.
- the processor may be a logic circuit, an integrated circuit, or the like.
- the processor may be a general-purpose processor implemented by reading software codes stored in a memory.
- the memory may be integrated with the processor, or may be configured separately from the processor, which is not limited in this embodiment of the present application.
- the memory can be a non-transitory processor, such as a read-only memory ROM, which can be integrated with the processor on the same chip, or can be respectively arranged on different chips.
- the embodiment of the present application is specific to the type of memory, and The arrangement manner of the memory and the processor is not specifically limited.
- the chip system may be a field programmable gate array (field programmable gate array, FPGA), an application specific integrated circuit (ASIC), or a system on chip (SoC), It can also be a central processing unit (central processor unit, CPU), it can also be a network processor (network processor, NP), it can also be a digital signal processing circuit (digital signal processor, DSP), it can also be a microcontroller (micro controller unit, MCU), and can also be a programmable logic device (programmable logic device, PLD) or other integrated chips.
- FPGA field programmable gate array
- ASIC application specific integrated circuit
- SoC system on chip
- each step in the foregoing method embodiments may be implemented by an integrated logic circuit of hardware in a processor or instructions in the form of software.
- the method steps disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.
- Embodiments of the present application also provide a storage medium for storing instructions used by the above-mentioned communication device.
- the embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores computer instructions, and when the computer instructions are run on the server, the server executes the above-mentioned related method steps to realize the rendering in the above-mentioned embodiments method.
- An embodiment of the present application further provides a computer program product, which, when running on a computer, causes the computer to execute the above-mentioned related steps, so as to implement the rendering method in the above-mentioned embodiment.
- the embodiment of the present application also provides a device, which may specifically be a component or a module, and the device may include one or more connected processors and memories; wherein, the memories are used to store computer programs, and one or more computers Programs include instructions.
- the instruction is executed by one or more processors, the device is executed to execute the rendering method in the foregoing method embodiments.
- the device, computer-readable storage medium, computer program product or chip provided in the embodiments of the present application are all used to execute the corresponding method provided above, therefore, the beneficial effects it can achieve can refer to the above-mentioned The beneficial effects of the corresponding method will not be repeated here.
- the steps of the methods or algorithms described in connection with the disclosure of the embodiments of the present application may be implemented in the form of hardware, or may be implemented in the form of a processor executing software instructions.
- the software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (random access memory, RAM), flash memory, read only memory (read only memory, ROM), erasable programmable read-only memory (erasable programmable ROM, EPROM), electrically erasable programmable read-only memory (electrically EPROM, EEPROM), registers, hard disk, removable hard disk, CD-ROM, or any other form of storage medium known in the art.
- An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium.
- the storage medium may also be a component of the processor.
- the processor and the storage medium may be located in an application specific integrated circuit (ASIC).
- ASIC application specific integrated circuit
- the disclosed method may be implemented in other ways.
- the device embodiments described above are only illustrative.
- the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods.
- multiple units or components can be Incorporation may either be integrated into another system, or some features may be omitted, or not implemented.
- the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of modules or units may be in electrical, mechanical or other forms.
- the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
- each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
- the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
- the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
- the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) execute all or part of the steps of the methods described in the various embodiments of the present application.
- the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disc and other media that can store program codes. .
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
Description
本申请要求于2021年07月30日提交国家知识产权局、申请号为202110875756.0、发明名称为“渲染方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the State Intellectual Property Office on July 30, 2021, with application number 202110875756.0, and the title of the invention is "Rendering Method and Electronic Equipment", the entire contents of which are incorporated by reference in this application.
本申请实施例涉及计算机图形技术领域,尤其涉及一种渲染方法及电子设备。The embodiments of the present application relate to the technical field of computer graphics, and in particular, to a rendering method and an electronic device.
随着终端技术的发展,电子设备(如手机、大屏设备等)能够为用户提供更好的显示体验。比如,现部分电子设备配置有每秒刷新速率达144赫兹(Hz)的显示器,相较于普通刷新速率一般为60Hz的显示器,较高的刷新速率能够使得界面操作更加流畅。With the development of terminal technology, electronic devices (such as mobile phones, large-screen devices, etc.) can provide users with better display experience. For example, some electronic devices are equipped with displays with a refresh rate of 144 hertz (Hz) per second. Compared with displays with a refresh rate of 60 Hz, the higher refresh rate can make interface operations smoother.
一般为了保证刷新速率,需要降低显示画面单帧渲染时长,否则很难保证高刷新速率的显示器的满帧显示效果,容易出现丢帧卡顿现象,影响用户使用体验。对于144Hz刷新率的显示器而言,单帧的渲染时长需要小于6ms,并且未来可能出现对更高刷新率的需求,这就要求更短的单帧渲染时长,但是目前对于复杂场景下的显示画面,已经很难在6ms内完成单帧渲染。Generally, in order to ensure the refresh rate, it is necessary to reduce the rendering time of a single frame of the display screen, otherwise it is difficult to ensure the full frame display effect of a high refresh rate display, and it is prone to frame loss and stuttering, which affects the user experience. For a display with a refresh rate of 144Hz, the rendering time of a single frame needs to be less than 6ms, and there may be a demand for a higher refresh rate in the future, which requires a shorter rendering time of a single frame. , it is already difficult to complete a single frame rendering within 6ms.
发明内容Contents of the invention
本申请实施例提供的渲染方法及电子设备,能够通过并行渲染的方式,有效减少单帧渲染时长,保证屏幕刷新率,提升用户使用体验。The rendering method and electronic device provided by the embodiments of the present application can effectively reduce the rendering time of a single frame through parallel rendering, ensure a screen refresh rate, and improve user experience.
为达到上述目的,本申请实施例采用如下技术方案:In order to achieve the above purpose, the embodiment of the present application adopts the following technical solutions:
第一方面,本申请实施例提供一种渲染方法,应用于电子设备,该方法可以包括:电子设备,获取待显示的渲染对象,渲染对象包括控件和布局,获取包括待显示的渲染对象的控件树。从控件树根节点开始遍历控件树:将不同的控件树层级设为不同的渲染层级,将同一控件树层级的相交的渲染对象设为不同的渲染层级;并行渲染同一渲染层级的渲染对象,串行渲染不同渲染层级的渲染对象。In the first aspect, the embodiment of the present application provides a rendering method applied to an electronic device, and the method may include: the electronic device, acquiring a rendering object to be displayed, where the rendering object includes a control and a layout, and acquiring a control including the rendering object to be displayed Tree. Traverse the control tree from the root node of the control tree: set different control tree levels to different rendering levels, set the intersecting rendering objects of the same control tree level to different rendering levels; render rendering objects of the same rendering level in parallel, and serialize Render objects of different rendering levels.
一些实施例中,控件树用于表示按照树形结构进行组织的控件、布局。控件树层级用于表示在遍历控件树后,确定的控件树中的控件、布局的树状节点关系。控件树中每一节点对应于一个渲染对象(即一个控件或一个布局),每一控件树层级包含一个或多个渲染对象(即包括一个或多个控件、一个或多个布局)。那么,在获取到控件树层级后,需要确定控件树中同一控件树层级的渲染对象(即控件、布局)是否相交,从而根据相交情况,划分渲染层级。In some embodiments, the control tree is used to represent controls and layouts organized in a tree structure. The control tree level is used to represent the tree node relationship between controls and layouts in the control tree determined after traversing the control tree. Each node in the control tree corresponds to a rendering object (that is, a control or a layout), and each control tree level contains one or more rendering objects (that is, including one or more controls, one or more layouts). Then, after obtaining the control tree level, it is necessary to determine whether the rendering objects (that is, controls and layouts) at the same control tree level in the control tree intersect, so as to divide the rendering level according to the intersection.
一些实施例中,串行渲染包括调用线程按照渲染层级顺序,顺序渲染渲染对象;并行渲染包括调用多个渲染线程同时执行同一渲染层级的渲染任务。In some embodiments, serial rendering includes invoking threads to sequentially render rendering objects according to the order of rendering levels; parallel rendering includes invoking multiple rendering threads to simultaneously execute rendering tasks of the same rendering level.
如此,通过本申请实施例提供的方法,可以有效降低渲染时长,避免显示图像出现丢帧现象。也就是说,通过并行渲染的方式可以降低电子设备显示图像时出现丢帧的可能性,保证显示屏显示图像的流畅性,从而提升用户的视觉体验。In this way, through the method provided by the embodiment of the present application, the rendering time can be effectively reduced, and the frame dropping phenomenon of the displayed image can be avoided. That is to say, the possibility of frame loss when an electronic device displays an image can be reduced by means of parallel rendering, and the smoothness of the image displayed on the display screen can be ensured, thereby improving the user's visual experience.
在一种可能的实现方式中,并行渲染同一渲染层级的渲染对象;包括:并行渲染 同一渲染层级的渲染对象中同一指令组中的构成元素数据,串行渲染同一渲染层级的渲染对象中不同指令组中的构成元素数据。In a possible implementation, the rendering objects of the same rendering level are rendered in parallel; including: parallel rendering of the constituent element data in the same instruction group in the rendering objects of the same rendering level, and serial rendering of different instructions in the rendering objects of the same rendering level The constituent element data in the group.
在一种可能的实现方式中,构成元素数据包括如下一项或几项内容:前景层构成元素数据、内容层构成元素数据、背景层构成元素数据。In a possible implementation manner, the constituent element data includes one or more of the following contents: constituent element data of the foreground layer, constituent element data of the content layer, and constituent element data of the background layer.
其中,背景层构成元素数据在渲染后对应于控件或布局的背景,内容层构成元素在渲染后对应于控件或布局的显示内容,前景层构成元素数据在渲染后对应于控件或布局的前景。比如,控件为文本控件,则该控件的内容层构成元素数据包括对应的文本数据。Among them, the background layer constituent element data corresponds to the background of the control or layout after rendering, the content layer constituent elements correspond to the display content of the control or layout after rendering, and the foreground layer constituent element data corresponds to the foreground of the control or layout after rendering. For example, if the control is a text control, the element data of the content layer of the control includes corresponding text data.
在一些实施例中,电子设备在完成渲染层级的划分后,对于不同渲染层级的数据可以按照渲染层级顺序进行渲染,但是对于同一渲染层级的数据还需要进一步确定同一渲染层级内的构成元素数据的渲染顺序。可选的,对同一渲染层级内的构成元素数据进行指令组分组,按照指令组分组结果进行控件、布局渲染。In some embodiments, after the electronic device completes the division of the rendering levels, it can render the data of different rendering levels according to the order of the rendering levels, but for the data of the same rendering level, it is necessary to further determine the composition of the element data in the same rendering level. Rendering order. Optionally, perform instruction grouping on the constituent element data in the same rendering level, and perform control and layout rendering according to the instruction grouping results.
如此,按照构成元素数据进一步对渲染对象的数据进行分类,能够进一步优化同一渲染层级中执行的并行渲染任务。其中,渲染对象的数据包括如下情况:若渲染对象为控件,则渲染对象的数据为控件数据;若渲染对象为布局,则渲染对象的数据为布局数据。In this way, further classifying the data of the rendering object according to the data of the constituent elements can further optimize the parallel rendering tasks executed in the same rendering level. Wherein, the data of the rendering object includes the following situations: if the rendering object is a control, the data of the rendering object is control data; if the rendering object is a layout, then the data of the rendering object is layout data.
在一种可能的实现方式中,同一指令组中的构成元素数据的数据类别相同,不同指令组中的构成元素数据的数据类别不同;或者,同一指令组中的构成元素数据在对应的渲染对象中对应的指令执行顺序相同,不同指令组中的构成元素数据在对应的渲染对象中对应的指令执行顺序不同。In a possible implementation, the data types of the constituent element data in the same instruction group are the same, and the data types of the constituent element data in different instruction groups are different; or, the constituent element data in the same instruction group are in the corresponding rendering object The execution order of the corresponding instructions in is the same, and the execution order of the corresponding instructions in the corresponding rendering objects of the constituent element data in different instruction groups is different.
一些实施例中,将同一渲染层级内的背景层构成元素划分至一个指令组数据,内容层构成元素划分至一个指令组数据,前景层构成元素划分至一个指令组数据。比如,将位于同一渲染层级内的背景数据划分为一个指令组、文本数据划分为一个指令组等。可选的,将指令组分组结果标记记录至对应的控件数据或布局数据中,那么之后在渲染过程中,按照标记同一渲染层级内就可以按照背景层构成元素数据指令组、内容层构成元素数据指令组、前景层构成元素数据指令组的顺序进行渲染。In some embodiments, the background layer constituent elements in the same rendering level are divided into one instruction group data, the content layer constituent elements are divided into one instruction group data, and the foreground layer constituent elements are divided into one instruction group data. For example, divide the background data in the same rendering level into an instruction group, divide the text data into an instruction group, and so on. Optionally, record the instruction group group result mark into the corresponding control data or layout data, then in the rendering process, the element data instruction group can be formed according to the background layer and the element data can be formed by the content layer in the same rendering level according to the mark The command group and the foreground layer are rendered in the order of the element data command group.
如此,按照构成元素数据的类别,快速完成渲染对象数据的划分,确定能够并行渲染的指令组的数据,提升渲染效率。In this way, according to the category of the constituent element data, the division of the rendering object data is quickly completed, and the data of the command group that can be rendered in parallel is determined to improve the rendering efficiency.
在一种可能的实现方式中,将同一控件树层级的相交的渲染对象设为不同的渲染层级,包括:获取同一控件树层级的渲染对象对应的最小矩形区域;将同一控件树层级中最小矩形区域相交的渲染对象设为不同的渲染层级。In a possible implementation, setting the intersecting rendering objects at the same control tree level to different rendering levels includes: obtaining the smallest rectangular area corresponding to the rendering objects at the same control tree level; setting the smallest rectangle area at the same control tree level Render objects whose regions intersect are set to different rendering levels.
一些实施例中,指令执行顺序例如包括控件数据、布局数据的构成元素数据的原渲染顺序。具体的,控件数据或布局数据的构成元素数据的原渲染顺序一般为先渲染背景层构成元素数据,再渲染内容层构成元素数据,最后渲染前景层构成元素数据。若控件数据或布局数据中不包括某一层或几层构成元素数据,则允许跳过该层数据直接渲染下一层构成元素数据。那么,按照指令执行顺序,将同一渲染层级中指令执行顺序相同的数据划分至同一指令组,不同指令执行顺序的数据划分至不同的指令组。可选的,将指令组分组结果标记记录至对应的控件数据或布局数据中,那么之后在渲染过程中,按照标记的指令组分组结果及指令组执行顺序,进行渲染。In some embodiments, the instruction execution order includes, for example, the original rendering order of the component data of the control data and the layout data. Specifically, the original rendering order of the component data of the control data or layout data is generally to first render the background layer to form the element data, then render the content layer to form the element data, and finally render the foreground layer to form the element data. If the control data or layout data does not include a certain layer or layers of constituent element data, it is allowed to skip this layer of data and directly render the next layer of constituent element data. Then, according to the instruction execution sequence, the data with the same instruction execution sequence in the same rendering level is divided into the same instruction group, and the data with different instruction execution sequences is divided into different instruction groups. Optionally, mark and record the grouping result of the instruction group into the corresponding control data or layout data, and then perform rendering according to the marked grouping result of the instruction group and the execution order of the instruction group during the rendering process.
如此,避免出现在存在渲染对象的数据中不包含某类别的构成元素数据的情况下,渲染线程暂停等待的问题,减少不必要的渲染等待时长。In this way, the problem that the rendering thread pauses and waits when the data of the rendering object does not contain a certain type of constituent element data is avoided, and unnecessary rendering waiting time is reduced.
在一种可能的实现方式中,渲染对象对应的最小矩形局域为覆盖渲染对象且面积最小的矩形区域。In a possible implementation manner, the smallest rectangular area corresponding to the rendering object is a rectangular area covering the rendering object and having the smallest area.
一些实施例中,在绘制控件和布局的过程中,控件和布局存在对应的绘制区域,若绘制区域部分或全部相交,则说明对应的控件、布局相交。可选的,根据控件数据、布局数据能够获得对应的绘制区域,可以利用最小矩形区域表示控件或布局的绘制区域,最小矩形区域例如包括能够覆盖对应的控件或布局且面积最小的区域。In some embodiments, during the process of drawing the control and the layout, the control and the layout have a corresponding drawing area, and if the drawing area partially or completely intersects, it means that the corresponding control and the layout intersect. Optionally, the corresponding drawing area can be obtained according to the control data and layout data, and the smallest rectangular area can be used to represent the drawing area of the control or layout. The smallest rectangular area includes, for example, the smallest area that can cover the corresponding control or layout.
如此,电子设备通过最小矩形区域的相交情况,确定渲染对象的相交情况。In this way, the electronic device determines the intersection of the rendering objects through the intersection of the smallest rectangular area.
在一种可能的实现方式中,在并行渲染同一渲染层级的渲染对象之前,方法还包括:获取资源情况。根据资源情况,确定允许并行调用的渲染线程的最大数量。In a possible implementation manner, before rendering the rendering objects of the same rendering level in parallel, the method further includes: obtaining resource conditions. Based on resources, determines the maximum number of rendering threads that are allowed to be called in parallel.
在一些实施例中,电子设备根据CPU、GPU中可运行的资源情况,分配渲染线程进行数据渲染。比如,UI线程根据渲染层级划分结果以及指令组分组结果,生成渲染指令触发渲染线程进行数据渲染,渲染线程接收到渲染指令后进行数据渲染。In some embodiments, the electronic device allocates rendering threads to perform data rendering according to the resources available for operation in the CPU and GPU. For example, the UI thread generates a rendering instruction based on the result of the rendering hierarchy division and the instruction group grouping result to trigger the rendering thread to perform data rendering, and the rendering thread performs data rendering after receiving the rendering instruction.
在一种可能的实现方式中,并行渲染同一渲染层级的渲染对象,包括:若并行渲染同一渲染层级的渲染对象所需的渲染线程的第一数量小于或等于最大数量,则调用第一数量的渲染线程并行渲染同一渲染层级的渲染对象。若第一数量大于最大数量,则调用最大数量的渲染线程并行渲染同一渲染层级的渲染对象。In a possible implementation, rendering the rendering objects of the same rendering level in parallel includes: if the first number of rendering threads required to render the rendering objects of the same rendering level in parallel is less than or equal to the maximum number, calling the first number of Rendering threads render rendering objects of the same rendering level in parallel. If the first number is greater than the maximum number, call the maximum number of rendering threads to render the rendering objects of the same rendering level in parallel.
在一些实施例中,电子设备完成待渲染数据的指令组分组后,根据CPU、GPU中可运行的资源,确定可并行调用的渲染线程数量是否满足指令组的渲染需求,若并行可调用的线程数量满足指令组的渲染需求,则调用相应数量的渲染线程并行渲染指令组内的数据。若并行可调用的线程数量不满足指令组的渲染需求,则调用最大数量的渲染线程并行渲染指令组内的部分数据,分批次渲染指令组内的全部数据。In some embodiments, after the electronic device completes the instruction group grouping of the data to be rendered, it determines whether the number of rendering threads that can be called in parallel meets the rendering requirements of the instruction group according to the executable resources of the CPU and GPU. If the number satisfies the rendering requirements of the instruction group, a corresponding number of rendering threads will be called to render the data in the instruction group in parallel. If the number of threads that can be called in parallel does not meet the rendering requirements of the instruction group, call the maximum number of rendering threads to render part of the data in the instruction group in parallel, and render all the data in the instruction group in batches.
如此,电子设备在执行渲染任务之前,先根据资源情况,确定允许调用的最大数量的渲染线程,保证并行渲染任务的顺利执行,避免出现渲染异常。In this way, before executing the rendering task, the electronic device first determines the maximum number of rendering threads that are allowed to be called according to the resource situation, so as to ensure the smooth execution of parallel rendering tasks and avoid rendering exceptions.
第二方面,本申请实施例提供一种电子设备,包括:处理器和存储器;存储器与处理器耦合,存储器用于存储计算机程序代码,计算机程序代码包括计算机指令,当处理器从存储器中读取计算机指令,使得电子设备执行如下操作获取待显示的渲染对象,渲染对象包括控件和布局,获取包括待显示的渲染对象的控件树。从控件树根节点开始遍历控件树:将不同的控件树层级设为不同的渲染层级,将同一控件树层级的相交的渲染对象设为不同的渲染层级;并行渲染同一渲染层级的渲染对象,串行渲染不同渲染层级的渲染对象。In a second aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory; the memory is coupled to the processor, and the memory is used to store computer program codes, and the computer program codes include computer instructions. When the processor reads from the memory The computer instructions enable the electronic device to perform the following operations to obtain a rendering object to be displayed, where the rendering object includes a control and a layout, and obtain a control tree including the rendering object to be displayed. Traverse the control tree from the root node of the control tree: set different control tree levels to different rendering levels, set the intersecting rendering objects of the same control tree level to different rendering levels; render rendering objects of the same rendering level in parallel, and serialize Render objects of different rendering levels.
在一种可能的实现方式中,并行渲染同一渲染层级的渲染对象;包括:并行渲染同一渲染层级的渲染对象中同一指令组中的构成元素数据,串行渲染同一渲染层级的渲染对象中不同指令组中的构成元素数据。In a possible implementation, the rendering objects of the same rendering level are rendered in parallel; including: parallel rendering of the constituent element data in the same instruction group in the rendering objects of the same rendering level, and serial rendering of different instructions in the rendering objects of the same rendering level The constituent element data in the group.
在一种可能的实现方式中,构成元素数据包括如下一项或几项内容:前景层构成元素数据、内容层构成元素数据、背景层构成元素数据。In a possible implementation manner, the constituent element data includes one or more of the following contents: constituent element data of the foreground layer, constituent element data of the content layer, and constituent element data of the background layer.
在一种可能的实现方式中,同一指令组中的构成元素数据的数据类别相同,不同指令组中的构成元素数据的数据类别不同;或者,同一指令组中的构成元素数据在对 应的渲染对象中对应的指令执行顺序相同,不同指令组中的构成元素数据在对应的渲染对象中对应的指令执行顺序不同。In a possible implementation, the data types of the constituent element data in the same instruction group are the same, and the data types of the constituent element data in different instruction groups are different; or, the constituent element data in the same instruction group are in the corresponding rendering object The execution order of the corresponding instructions in is the same, and the execution order of the corresponding instructions in the corresponding rendering objects of the constituent element data in different instruction groups is different.
在一种可能的实现方式中,将同一控件树层级的相交的渲染对象设为不同的渲染层级,包括:获取同一控件树层级的渲染对象对应的最小矩形区域;将同一控件树层级中最小矩形区域相交的渲染对象设为不同的渲染层级。In a possible implementation, setting the intersecting rendering objects at the same control tree level to different rendering levels includes: obtaining the smallest rectangular area corresponding to the rendering objects at the same control tree level; setting the smallest rectangle area at the same control tree level Render objects whose regions intersect are set to different rendering levels.
在一种可能的实现方式中,渲染对象对应的最小矩形局域为覆盖渲染对象且面积最小的矩形区域。In a possible implementation manner, the smallest rectangular area corresponding to the rendering object is a rectangular area covering the rendering object and having the smallest area.
在一种可能的实现方式中,当处理器从存储器中读取所述计算机指令,还使得电子设备执行如下操作:获取资源情况。根据资源情况,确定允许并行调用的渲染线程的最大数量。In a possible implementation manner, when the processor reads the computer instruction from the memory, it further causes the electronic device to perform the following operation: obtain resource information. Based on resources, determines the maximum number of rendering threads that are allowed to be called in parallel.
在一种可能的实现方式中,并行渲染同一渲染层级的渲染对象,包括:若并行渲染同一渲染层级的渲染对象所需的渲染线程的第一数量小于或等于最大数量,则调用第一数量的渲染线程并行渲染同一渲染层级的渲染对象。若第一数量大于最大数量,则调用最大数量的渲染线程并行渲染同一渲染层级的渲染对象。In a possible implementation, rendering the rendering objects of the same rendering level in parallel includes: if the first number of rendering threads required to render the rendering objects of the same rendering level in parallel is less than or equal to the maximum number, calling the first number of Rendering threads render rendering objects of the same rendering level in parallel. If the first number is greater than the maximum number, call the maximum number of rendering threads to render the rendering objects of the same rendering level in parallel.
此外,第二方面所述的电子设备的技术效果可以参考第一方面所述的渲染方法的技术效果,此处不再赘述。In addition, for the technical effect of the electronic device described in the second aspect, reference may be made to the technical effect of the rendering method described in the first aspect, which will not be repeated here.
第三方面,本申请实施例提供一种电子设备,该电子设备具有实现如上述第一方面及其中任一种可能的实现方式中所述的渲染方法的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。该硬件或软件包括一个或多个与上述功能相对应的模块。In a third aspect, an embodiment of the present application provides an electronic device, where the electronic device has a function of implementing the rendering method described in the foregoing first aspect and any possible implementation manner thereof. This function may be implemented by hardware, or may be implemented by executing corresponding software on the hardware. The hardware or software includes one or more modules corresponding to the above functions.
第四方面,本申请实施例提供一种计算机可读存储介质,包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行如第一方面及其中任一种可能的实现方式中任一项所述的渲染方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, including computer instructions. When the computer instructions are run on the electronic device, the electronic device executes any of the steps in the first aspect and any possible implementation manners. One of the described rendering methods.
第五方面,本申请实施例提供一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行如第一方面及其中任一种可能的实现方式中任一项所述的渲染方法。In the fifth aspect, the embodiment of the present application provides a computer program product, which, when the computer program product is run on the electronic device, enables the electronic device to execute any one of the first aspect and any one of the possible implementations. rendering method.
第六方面,本申请实施例提供一种电路系统,电路系统包括处理电路,处理电路被配置为执行如上述第一方面及其中任一种可能的实现方式中所述的渲染方法。In a sixth aspect, an embodiment of the present application provides a circuit system, where the circuit system includes a processing circuit configured to execute the rendering method described in the first aspect and any possible implementation manner thereof.
第七方面,本申请实施例提供一种芯片系统,包括至少一个处理器和至少一个接口电路,至少一个接口电路用于执行收发功能,并将指令发送给至少一个处理器,当至少一个处理器执行指令时,至少一个处理器执行如上述第一方面及其中任一种可能的实现方式中所述的渲染方法。In the seventh aspect, the embodiment of the present application provides a chip system, including at least one processor and at least one interface circuit. When executing the instruction, at least one processor executes the rendering method described in the first aspect and any possible implementation manner thereof.
图1为本申请实施例提供的界面示意图;Figure 1 is a schematic diagram of the interface provided by the embodiment of the present application;
图2为本申请实施例提供的电子设备的形态示意图;FIG. 2 is a schematic diagram of the form of an electronic device provided by an embodiment of the present application;
图3为本申请实施例提供的电子设备的结构示意图一;FIG. 3 is a first schematic structural diagram of an electronic device provided by an embodiment of the present application;
图4为本申请实施例提供的电子设备的软件结构框图示意图;FIG. 4 is a schematic diagram of a software structure block diagram of an electronic device provided in an embodiment of the present application;
图5为本申请实施例提供的渲染方法流程图;FIG. 5 is a flowchart of a rendering method provided by an embodiment of the present application;
图6为本申请实施例提供的控件树结构示意图;FIG. 6 is a schematic diagram of a control tree structure provided by an embodiment of the present application;
图7为本申请实施例提供的渲染层级分层场景示意图;FIG. 7 is a schematic diagram of a rendering layered scene provided by an embodiment of the present application;
图8为本申请实施例提供的指令组分组场景示意图一;FIG. 8 is a first schematic diagram of an instruction grouping scenario provided by an embodiment of the present application;
图9为本申请实施例提供的指令组分组场景示意图二;FIG. 9 is a second schematic diagram of an instruction group grouping scenario provided by the embodiment of the present application;
图10为本申请实施例提供的图像帧刷新周期示意图;FIG. 10 is a schematic diagram of an image frame refresh cycle provided by an embodiment of the present application;
图11为本申请实施例提供的电子设备的结构示意图二;FIG. 11 is a second structural schematic diagram of the electronic device provided by the embodiment of the present application;
图12为本申请实施例提供的电子设备的结构示意图三。FIG. 12 is a third structural schematic diagram of the electronic device provided by the embodiment of the present application.
下面结合附图对本申请实施例提供的渲染方法及电子设备进行详细地描述。The rendering method and the electronic device provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
本申请实施例的描述中所提到的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括其他没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "including" and "having" mentioned in the description of the embodiments of the present application and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes other unlisted steps or units, or optionally also includes Other steps or elements inherent to the process, method, product or apparatus are included.
需要说明的是,本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。It should be noted that, in the embodiments of the present application, words such as "exemplary" or "for example" are used as examples, illustrations or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of the present application shall not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete manner.
在本申请实施例的描述中,除非另有说明,“多个”的含义是指两个或两个以上。本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。In the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more. The "and/or" in this article is just an association relationship describing associated objects, which means that there can be three relationships, for example, A and/or B, which can mean: A exists alone, A and B exist at the same time, and B exists alone These three situations.
首先,为了便于理解,下面先对本申请实施例涉及的相关术语和概念进行介绍。First, for ease of understanding, related terms and concepts involved in the embodiments of the present application are firstly introduced below.
(1)控件和控件数据(1) Controls and control data
控件(view),在一些实施例中也称为部件(widget),是一种用户界面元素,能够作为人机交互接口,接收用户对电子设备的操作。比如,电子设备通过检测用户对控件的操作,接收用户输入的控制命令。其中,控件可以包括文本控件(text view),按钮(button),图片控件(image view),进度条(progress bar)等。A control (view), also referred to as a component (widget) in some embodiments, is a user interface element that can serve as a human-computer interaction interface and receive user operations on electronic devices. For example, the electronic device receives a control command input by the user by detecting the user's operation on the control. Wherein, the control may include a text control (text view), a button (button), a picture control (image view), a progress bar (progress bar), etc.
示例性的,如图1中(a)所示主界面101,在主界面101上显示有应用程序图标,应用程序图标作为控件可以用于启动应用程序,这里的应用程序图标,相当于启动器应用的控件,启动器即launcher,即显示用户手机桌面的系统应用,包括显示和管理桌面上的应用图标和各种桌面控件等。比如,手机检测到用户点击控件1011的操作后(这里以应用程序为“设置”应用举例),显示如图1中(b)所示界面102。如界面102所示,控件可以包括图片控件1021、文本控件1022、按钮1023等。Exemplarily, the
控件数据,是由包括控件的应用程序生成的。例如,上述启动器应用的应用程序图标控件,是启动器用于显示和便于用户打开安装的其他应用程序的控件。所以控件数据由启动器根据所述安装的其他应用程序来获取和生成,也可以在启动器中改变控件的数据,例如用户可以调整控件的位置和大小等。电子设备根据控件数据进行控件的绘制,以显示用户可见的控件。Control data, generated by the application that includes the control. For example, the above-mentioned application icon control of the launcher application is a control used by the launcher to display and facilitate the user to open other installed applications. Therefore, the control data is obtained and generated by the launcher according to the other installed applications, and the data of the control can also be changed in the launcher, for example, the user can adjust the position and size of the control. The electronic device draws the control according to the control data, so as to display the control visible to the user.
(2)布局和布局数据(2) Layout and layout data
布局(layout),用于指示某显示区域的位置和尺寸,以及所述显示区域内的控件的位置显示效果。布局的类型包括线性布局(linear layout),相对布局(relative layout), 绝对布局(absolute layout)等。其中,线性布局用于表示控件按照横向或纵向等方向线性排列显示。相对布局用于表示控件相对于其他控件的显示位置。绝对布局用于表示控件在显示界面中的显示位置。例如,控件A的布局包括控件A的中心像素点与显示屏的中心点重合,尺寸为200像素(pixels),则控件A的布局为绝对布局。控件B的布局包括控件B的中心像素点位于控件A中心像素点左侧N个像素点位置,控件B的尺寸与控件A相同,则控件B的布局为相对布局。The layout (layout) is used to indicate the position and size of a certain display area, and the position display effect of the controls in the display area. Types of layout include linear layout, relative layout, absolute layout, etc. Among them, the linear layout is used to indicate that the controls are displayed in a linear arrangement in a horizontal or vertical direction. Relative layout is used to indicate where a control is displayed relative to other controls. Absolute layout is used to indicate the display position of the control in the display interface. For example, the layout of the control A includes that the center pixel of the control A coincides with the center point of the display screen, and the size is 200 pixels (pixels), then the layout of the control A is an absolute layout. The layout of control B includes that the center pixel of control B is located N pixels to the left of the center pixel of control A, and the size of control B is the same as that of control A, so the layout of control B is a relative layout.
示例性的,如图1中(b)所示界面102,蓝牙、移动网络、桌面和壁纸等各个设置选项显示位置对应的布局的类型包括线性布局。Exemplarily, as shown in the
布局数据,包括某显示区域的位置和尺寸的信息,以及所述显示区域中包含的控件,以及控件对应的布局的类型等信息。The layout data includes information about the position and size of a certain display area, the controls contained in the display area, and the type of layout corresponding to the controls.
在一些实施例中,电子设备显示图像的进程中至少包括用户界面(user interface,UI)线程和渲染线程。其中,UI线程,用于控制UI界面的显示、更新和控件交互,可以生成图形数据和渲染指令。渲染线程,根据图形数据和渲染指令完成控件数据、布局数据等的渲染工作,生成图像帧。In some embodiments, the process of displaying images by the electronic device at least includes a user interface (user interface, UI) thread and a rendering thread. Among them, the UI thread is used to control the display, update and control interaction of the UI interface, and can generate graphic data and rendering instructions. The rendering thread completes rendering of control data, layout data, etc. according to graphics data and rendering instructions, and generates image frames.
需要说明的是,电子设备在图形绘制过程中,调用的UI线程和渲染线程的数量为一个或多个。本申请实施例中的UI线程在不同操作系统中也可以描述为UI进程、UI任务等,本申请实施例中的渲染线程在不同操作系统中也可以描述为渲染进程、渲染任务等,对此下文不再说明。It should be noted that, during the graphics drawing process of the electronic device, one or more UI threads and rendering threads are called. The UI thread in the embodiment of the present application can also be described as a UI process, UI task, etc. in different operating systems, and the rendering thread in the embodiment of the present application can also be described as a rendering process, rendering task, etc. in different operating systems. It will not be explained below.
在一些实施例中,显示帧率表示电子设备显示图像的流畅度,显示帧率越高,显示图像越流畅,越能实现更加逼真的显示效果。目前用户对电子设备显示效果要求越来越高,为了保证显示效果,需要提高显示帧率,这就要求提升图像生成速率。其中,控件数据、布局数据等的渲染工作时长对图像生成速率影响较大。In some embodiments, the display frame rate indicates the smoothness of the image displayed by the electronic device. The higher the display frame rate, the smoother the displayed image, and the more realistic display effect can be achieved. At present, users have higher and higher requirements on the display effect of electronic equipment. In order to ensure the display effect, it is necessary to increase the display frame rate, which requires an increase in the image generation rate. Among them, the rendering time of control data, layout data, etc. has a great influence on the image generation rate.
示例性的,电子设备如需达到144HZ的高显示帧率,需保证单帧图像渲染时长小于6ms。但是在复杂场景下,比如单帧图像中包括的控件较多时,单帧图像渲染时长很难保证小于6ms,电子设备在渲染周期内无法完成当前图像帧的渲染,导致该帧图像无法合成,造成电子设备显示图像出现卡顿(即丢帧)现象。Exemplarily, if the electronic device needs to achieve a high display frame rate of 144HZ, it needs to ensure that the rendering time of a single frame image is less than 6ms. However, in complex scenarios, such as when there are many controls included in a single frame image, it is difficult to ensure that the rendering time of a single frame image is less than 6ms. Electronic devices display image freeze (i.e. frame loss).
基于此,本申请实施例提供一种渲染方法,通过分层并行渲染待渲染的控件数据和布局数据,有效降低渲染时长,满足高显示帧率对图像生成速率的要求,避免电子设备显示图像出现卡顿现象。Based on this, the embodiment of the present application provides a rendering method, which can effectively reduce the rendering time by layering and parallel rendering the control data and layout data to be rendered, meet the requirements of high display frame rate for image generation rate, and avoid the occurrence of electronic device display images Caton phenomenon.
本申请实施例提供的渲染方法,可以应用于电子设备。例如,如图2所示,该电子设备具体可以是大屏显示设备21、手机22、笔记本电脑23、平板电脑24、车载设备25、可穿戴设备(如智能手表26)、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)、人工智能(artificial intelligence)设备等具有显示功能的终端设备,本申请实施例对电子设备的具体类型不作任何限制。The rendering method provided in the embodiment of the present application may be applied to electronic devices. For example, as shown in FIG. 2 , the electronic device can specifically be a large-
示例性的,图3示出了电子设备100的结构示意图。Exemplarily, FIG. 3 shows a schematic structural diagram of the electronic device 100 .
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,传 感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。The electronic device 100 may include a
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that, the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100 . In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components. The illustrated components can be realized in hardware, software or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments,
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包括多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器,使处理器110与触摸传感器通过I2C总线接口通信,实现电子设备100的触摸功能。The I2C interface is a bidirectional synchronous serial bus, including a serial data line (serial data line, SDA) and a serial clock line (derail clock line, SCL). In some embodiments,
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。The MIPI interface can be used to connect the
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。The USB interface 130 is an interface conforming to the USB standard specification, specifically, it can be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100 , and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones and play audio through them. This interface can also be used to connect other electronic devices, such as AR devices.
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules shown in the embodiment of the present application is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 . In other embodiments of the present application, the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。The
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。The
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 can be realized by the antenna 1 , the antenna 2 , the
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (Wireless Fidelity, Wi-Fi) network), bluetooth (bluetooth, BT), global navigation satellite, etc. applied on the electronic device 100. System (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(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,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system, GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 100 is coupled to the
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 realizes the display function through the GPU, the display screen 194 , and the application processor. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, videos and the like. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.
传感器模块180可以包括压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器,温度传感器,触摸传感器,环境光传感器,骨传导传感器等。The sensor module 180 may include a pressure sensor, a gyro sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
其中,本申请实施例中的显示屏194可以是触摸屏。即该显示屏194中集成了触摸传感器。该触摸传感器也可以称为“触控面板”。也就是说,显示屏194可以包括显示面板和触摸面板,由触摸传感器与显示屏194组成触摸屏,也称“触控屏”。触摸传感器用于检测作用于其上或附近的触摸操作。触摸传感器检测到的触摸操作后,可以由内核层的驱动(如TP驱动)传递给上层,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器也可以设置于电子设备100的表面,与显示屏194所处的位置不同。Wherein, the display screen 194 in the embodiment of the present application may be a touch screen. That is, a touch sensor is integrated in the display screen 194 . The touch sensor may also be referred to as a "touch panel". That is to say, the display screen 194 may include a display panel and a touch panel, and a touch screen composed of a touch sensor and the display screen 194 is also called a “touch screen”. The touch sensor is used to detect a touch operation on or near it. After the touch operation detected by the touch sensor, it can be passed to the upper layer by the driver of the kernel layer (such as the TP driver) to determine the type of the touch event. Visual output related to the touch operation can be provided through the display screen 194 . In some other embodiments, the touch sensor can also be disposed on the surface of the electronic device 100 , which is different from the position of the display screen 194 .
示例性的,电子设备100利用触摸传感器检测到用户在显示屏194上的触摸操作后,可能会触发显示屏194上显示的控件位置发生变化,那么在显示下一帧图像时,需要重新对图层数据进行渲染。例如,电子设备100检测到用户长按并拖动应用程序图标的操作后,在拖动过程中的每一帧图像,应用程序图标(即控件)位置都可能发生变化,需要进行控件数据和布局数据的渲染。Exemplarily, after the electronic device 100 uses the touch sensor to detect the user's touch operation on the display screen 194, it may trigger the position of the controls displayed on the display screen 194 to change, so when the next frame of image is displayed, it needs to re-align the image. layer data for rendering. For example, after the electronic device 100 detects that the user has long pressed and dragged the application icon, the position of the application icon (that is, the control) may change in each frame of the image during the dragging process, and the control data and layout Rendering of data.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can realize the shooting function through the ISP, the camera 193 , the video codec, the GPU, the display screen 194 and the application processor.
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。Camera 193 is used to capture still images or video. The object generates an optical image through the lens and projects it to the photosensitive element. The photosensitive element may 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, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. DSP converts digital image signals into standard RGB, YUV and other image signals. In some embodiments, the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子 设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 may 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
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能应用以及数据处理。The internal memory 121 may be used to store computer-executable program codes including instructions. The internal memory 121 may include an area for storing programs and an area for storing data. Wherein, the stored program area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.) and the like. The storage data area can store data created during the use of the electronic device 100 (such as audio data, phonebook, etc.) and the like. The
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。电子设备100可以通过音频模块170以及应用处理器等实现音频功能。例如音乐播放,录音等。其中,音频模块可以包括扬声器,受话器,麦克风,耳机接口。The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal. The audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be set in the
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The keys 190 include a power key, a volume key and the like. The key 190 may be a mechanical key. It can also be a touch button. The electronic device 100 can receive key input and generate key signal input related to user settings and function control of the electronic device 100 .
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。The motor 191 can generate a vibrating reminder. The motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations applied to different applications (such as taking pictures, playing audio, etc.) may correspond to different vibration feedback effects. The motor 191 may also correspond to different vibration feedback effects for touch operations acting on different areas of the display screen 194 . Different application scenarios (for example: time reminder, receiving information, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。The indicator 192 can be an indicator light, and can be used to indicate charging status, power change, and can also be used to indicate messages, missed calls, notifications, and the like.
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。The SIM card interface 195 is used for connecting a SIM card. The SIM card can be connected and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195 . The electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本申请实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 .
图4是本申请实施例的电子设备100的软件结构框图。FIG. 4 is a block diagram of the software structure of the electronic device 100 according to the embodiment of the present application.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)的系统库,以及内核层。The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate through software interfaces. In some embodiments, the Android system is divided into four layers, which are respectively the application program layer, the application program framework layer, the system library of Android runtime (Android runtime), and the kernel layer from top to bottom.
应用程序层可以包括一系列应用程序包。The application layer can consist of a series of application packages.
如图4所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。As shown in Figure 4, the application package may include application programs such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
如图4所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,资源管理器,通知管理器等。As shown in Figure 4, the application framework layer can include window managers, content providers, view systems, resource managers, notification managers, etc.
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。A window manager is used to manage window programs. The window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
活动管理器用于负责管理Activity,负责系统中各组件的启动、切换、调度及应用程序的管理和调度等工作。The activity manager is used to manage the Activity, and is responsible for the startup, switching, scheduling of each component in the system and the management and scheduling of the application program.
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。Content providers are used to store and retrieve data and make it accessible to applications. Said data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebook, etc.
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. The view system can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction.
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。Android Runtime includes core library and virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
核心库包括两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。The core library includes two parts: one part is the function function that the java language needs to call, and the other part is the core library of Android.
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in virtual machines. The virtual machine executes the java files of the application program layer and the application program framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),二维图形引擎(例如:SGL)等。A system library can include multiple function modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of various commonly used audio and video formats, as well as still image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing, etc.
二维图形引擎是2D绘图的绘图引擎,常见的图形引擎例如包括Vulkan,Canvas等。The two-dimensional graphics engine is a graphics engine for 2D graphics. Common graphics engines include Vulkan, Canvas, etc., for example.
内核层是硬件和软件之间的层。内核层至少包括显示驱动,摄像头驱动,音频驱动,传感器驱动。The kernel layer is the layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.
其中,用户对电子设备进行输入操作(如触发电子设备启动某个应用程序的操作),内核层可以根据输入操作产生相应的输入事件(如应用程序启动事件),并向应用程序框架层上报该事件。由应用程序框架层的视图系统确定应用程序对应的控件数据和布局数据,以及确定渲染引擎渲染的流程逻辑,并发送至系统库的二维图形引擎进行处理,之后将处理后的数据发送给内核层的显示驱动,由显示驱动在显示屏显示对应 的应用界面。Among them, when the user performs an input operation on the electronic device (such as triggering the electronic device to start an application program), the kernel layer can generate a corresponding input event (such as an application program start event) according to the input operation, and report the event to the application framework layer. event. The view system of the application framework layer determines the corresponding control data and layout data of the application, and determines the process logic of the rendering engine rendering, and sends them to the two-dimensional graphics engine of the system library for processing, and then sends the processed data to the kernel The display driver of the layer is used to display the corresponding application interface on the display screen.
图5所示为本申请实施例提供的一种渲染方法示意图,该方法可应用于电子设备,如图5所示,该方法可以包括S501-S503。FIG. 5 is a schematic diagram of a rendering method provided by an embodiment of the present application. The method may be applied to electronic devices. As shown in FIG. 5 , the method may include S501-S503.
S501、获取待绘制的控件树中的控件数据、布局数据,并确定控件树中控件、布局的控件树层级。S501. Obtain control data and layout data in the control tree to be drawn, and determine the control tree levels of the controls and layout in the control tree.
在一些实施例中,电子设备检测到触发渲染的事件后,获取待显示的渲染对象,以及待显示的渲染对象的控件树(即待绘制的控件树),之后确定控件树中渲染对象的控件树层级。其中,渲染对象包括控件和布局。渲染对象的数据包括如下情况:若渲染对象为控件,则渲染对象的数据为控件数据;若渲染对象为布局,则渲染对象的数据为布局数据。In some embodiments, after the electronic device detects an event that triggers rendering, it acquires the rendering object to be displayed and the control tree of the rendering object to be displayed (ie, the control tree to be drawn), and then determines the control of the rendering object in the control tree tree hierarchy. Among them, the rendering objects include controls and layouts. The data of the rendering object includes the following situations: if the rendering object is a control, the data of the rendering object is control data; if the rendering object is a layout, then the data of the rendering object is layout data.
一些实施例中,触发渲染的事件例如为电子设备检测到的用户在显示屏上的触摸操作,如点击某个可交互的控件的操作、或用户在显示屏上的滑动(如上下滑动、左右滑动等)操作;或者可以为电子设备检测到的用户的语音输入;或者可以为电子设备前台应用自动切换画面的事件等,在此不做限定。前台应用是电子设备的显示屏当前显示的界面对应的应用。In some embodiments, the event that triggers rendering is, for example, a user's touch operation on the display screen detected by the electronic device, such as clicking an interactive control, or the user's sliding on the display screen (such as sliding up and down, left and right sliding, etc.); or it may be the user’s voice input detected by the electronic device; or it may be an event that automatically switches the screen of the foreground application of the electronic device, etc., which are not limited here. The foreground application is an application corresponding to the interface currently displayed on the display screen of the electronic device.
需要说明的是,前台应用的画面内容不仅可以包括用户看的见的画面,还可以包括无用户界面的内容、透明图层的内容或者被其他应用界面遮挡对用户不可见的内容,电子设备需要获取画面内容对应的待绘制的全部控件数据、布局数据。It should be noted that the screen content of the foreground application can include not only the screen that the user can see, but also the content without user interface, the content of transparent layer, or the content that is blocked by other application interfaces and is invisible to the user. Obtain all control data and layout data to be drawn corresponding to the screen content.
一些实施例中,控件树(view tree)用于表示按照树形结构进行组织的控件、布局。控件树层级的确认,即为遍历控件树确定控件树中的控件、布局的树状节点关系,以及将确定的控件、布局的控件树层级填写至对应的控件数据、布局数据中,以便于后续步骤S502中根据控件树层级划分渲染层级。In some embodiments, a control tree (view tree) is used to represent controls and layouts organized in a tree structure. The confirmation of the control tree level is to traverse the control tree to determine the tree node relationship between the controls and the layout in the control tree, and fill in the determined controls and the control tree level of the layout into the corresponding control data and layout data, so as to facilitate subsequent In step S502, the rendering levels are divided according to the control tree level.
需要说明的是,“、”用于表示“和/或”的对象关联关系,如控件数据、布局数据用于表示单独存在控件数据,单独存在布局数据,同时存在控件数据和布局数据这三种情况,对此下文不再赘述。It should be noted that "," is used to indicate the object association relationship of "and/or". For example, control data and layout data are used to indicate that control data exists alone, layout data exists alone, and there are three types of control data and layout data at the same time. situation, which will not be described further below.
示例性的,假设控件树中的控件和布局包括绝对布局0、绝对布局1、绝对布局2、绝对布局3、相对布局1、按钮(button)0、按钮1、按钮2、按钮3、文本(text)0、文本1、文本2以及文本3。如图6中(a)所示,示出该控件树中的控件和布局的位置关系示意图。以电子设备配置安卓系统为例,电子设备在检测到用户在显示屏上的触摸操作后,启动窗口(window)对应的Activity,并创建对应的控件树。之后,获取控件树中的控件数据、布局数据,根据控件树节点所在控件树的节点深度,分到对应控件树深度的层级,可以根据层级给对应的控件数据、布局数据中填写对应的控件树层级标记,以便于后续步骤S502划分渲染层级。Exemplarily, it is assumed that controls and layouts in the control tree include absolute layout 0, absolute layout 1, absolute layout 2, absolute layout 3, relative layout 1, button (button) 0, button 1, button 2, button 3, text ( text)0, text1, text2, and text3. As shown in (a) of FIG. 6 , it shows a schematic diagram of the positional relationship between controls and layouts in the control tree. Taking an electronic device configured with an Android system as an example, the electronic device starts an Activity corresponding to a window (window) after detecting a user's touch operation on a display screen, and creates a corresponding control tree. After that, the control data and layout data in the control tree are obtained, and according to the node depth of the control tree where the control tree node is located, it is divided into the level corresponding to the depth of the control tree, and the corresponding control tree can be filled in the corresponding control data and layout data according to the level The level marks are used to divide the rendering levels in the subsequent step S502.
具体的,在控件树创建过程中,首先会确定根视图(root view),之后调用setContentView()方法,完成根视图之上的其他节点的创建。那么,控件树中的节点关系可以根据Z轴值确定,Z轴值与控件、布局的创建顺序相关。如图6中(a)所示,当前控件树中根视图为绝对布局0,则如图6中(b)所示,确定绝对布局0在控件树中的层级为控件树层级0,将控件树层级0标记填写到绝对布局0对应的布局数据中。Specifically, in the control tree creation process, the root view (root view) will be determined first, and then the setContentView() method will be called to complete the creation of other nodes above the root view. Then, the node relationship in the control tree can be determined according to the Z-axis value, and the Z-axis value is related to the order of creation of controls and layouts. As shown in (a) in Figure 6, the root view in the current control tree is absolute layout 0, then as shown in (b) in Figure 6, determine that the level of absolute layout 0 in the control tree is control tree level 0, and the control tree The level 0 mark is filled in the layout data corresponding to absolute layout 0.
之后,将绝对布局0作为父节点(parentCount),根据如图6中(a)所示的位置 关系,确定绝对布局0的子节点(childrenCount)包括绝对布局1、绝对布局2以及相对布局1。因此,如图6中(b)所示确定绝对布局1、绝对布局2以及相对布局1在控件树中的层级为控件树层级1,并将控件树层级1标记记录至对应的布局数据中。Afterwards, using absolute layout 0 as the parent node (parentCount), according to the positional relationship shown in (a) in Figure 6, determine that the child nodes (childrenCount) of absolute layout 0 include absolute layout 1, absolute layout 2, and relative layout 1. Therefore, as shown in (b) of FIG. 6 , determine the levels of absolute layout 1, absolute layout 2, and relative layout 1 in the control tree as control tree level 1, and record the mark of control tree level 1 into the corresponding layout data.
之后,再将绝对布局1、绝对布局2以及相对布局1分别作为父节点,根据如图6中(a)所示的位置关系确定各个父节点对应的子节点,例如绝对布局1的子节点包括按钮0和按钮1,绝对布局2的子节点包括文本0和文本1,相对布局1的子节点包括按钮2、按钮3以及绝对布局3,则如图6中(b)所示确定各个子节点在控件树中的层级为控件树层级2,并将控件树层级2标记记录至对应的控件数据和布局数据中。Afterwards, take Absolute Layout 1, Absolute Layout 2, and Relative Layout 1 respectively as parent nodes, and determine the child nodes corresponding to each parent node according to the positional relationship shown in Figure 6 (a), for example, the child nodes of Absolute Layout 1 include Button 0 and button 1, the child nodes of absolute layout 2 include text 0 and text 1, and the child nodes of relative layout 1 include button 2, button 3 and absolute layout 3, then determine each child node as shown in (b) in Figure 6 The level in the control tree is control tree level 2, and the mark of control tree level 2 is recorded in the corresponding control data and layout data.
最后,根据如图6中(a)所示的位置关系,将绝对布局3作为父节点,确定其子节点包括文本2和文本3,如图6中(b)所示确定绝对布局3在控件树中的层级为控件树层级3,并将控件树层级3标记记录至对应的控件数据中。Finally, according to the positional relationship shown in (a) in Figure 6, use absolute layout 3 as the parent node, and determine that its child nodes include text 2 and text 3, and determine that absolute layout 3 is in the control as shown in (b) in Figure 6 The level in the tree is level 3 of the control tree, and the mark of level 3 of the control tree is recorded in the corresponding control data.
如此,按照上述步骤完成控件树层级的确认,获得如图6中(b)所示的控件树的数据结构。可以理解的是,还可以利用其他遍历算法完成控件树的控件树层级的确认,在此不再赘述。In this way, the confirmation of the control tree level is completed according to the above steps, and the data structure of the control tree as shown in (b) in FIG. 6 is obtained. It can be understood that other traversal algorithms can also be used to complete the confirmation of the control tree level of the control tree, which will not be repeated here.
需要说明的是,S501中的某一步骤或多个步骤可以为电子设备调用UI线程完成。其中,本申请实施例不限制控件树中节点的创建顺序,如节点创建顺序可以为用户自定义确定,在获取到控件树后,只需根据控件树中的节点关系确定控件树层级即可。It should be noted that one or more steps in S501 may be completed by the electronic device calling a UI thread. Wherein, the embodiment of the present application does not limit the creation order of nodes in the control tree. For example, the creation order of nodes can be customized by the user. After obtaining the control tree, it is only necessary to determine the control tree level according to the node relationship in the control tree.
此外,在遍历控件树完成控件树层级的确认后,后续控件树中包括的控件数据、布局数据没发生变化,则只需对控件树进行维护,而不必再在渲染前遍历控件树,只继承之前的数据即可。或者,控件树中包括的控件数据、布局数据部分发生变化,则仅需再次对变化部分的控件树层级及其子控件树层级重新确认。In addition, after traversing the control tree to complete the confirmation of the control tree level, if the control data and layout data included in the subsequent control tree have not changed, you only need to maintain the control tree, instead of traversing the control tree before rendering, only inherit previous data. Or, if the control data and layout data included in the control tree are changed, it is only necessary to reconfirm the control tree level and its sub-control tree levels of the changed part.
可以理解的是,上述控件树层级0、控件树层级1、控件树层级2以及控件树层级3用于表示控件树层级顺序,仅为一种示例性说明,比如控件树层级还可以表示为控件树层级1-控件树层级4,控件树层级A-控件树层级D等。It can be understood that the above control tree level 0, control tree level 1, control tree level 2 and control tree level 3 are used to represent the order of the control tree levels, which is only an exemplary illustration. For example, the control tree level can also be expressed as a control Tree level 1-control tree level 4, control tree level A-control tree level D, etc.
S502、按照相交情况,划分渲染层级。S502. Divide the rendering levels according to the intersection condition.
在一些实施例中,控件树中每一节点对应于一个渲染对象(即一个控件或一个布局),每一控件树层级包含一个或多个渲染对象(即包括一个或多个控件、一个或多个布局)。那么,在获取到控件树层级后,需要确定控件树中同一控件树层级的渲染对象(即控件、布局)是否相交,从而根据相交情况,划分渲染层级。In some embodiments, each node in the control tree corresponds to a rendering object (that is, a control or a layout), and each control tree level contains one or more rendering objects (that is, including one or more controls, one or more layout). Then, after obtaining the control tree level, it is necessary to determine whether the rendering objects (that is, controls and layouts) at the same control tree level in the control tree intersect, so as to divide the rendering level according to the intersection.
比如,根据控件树层级先将控件、布局初步划分至对应的渲染层级(即将不同的控件树层级设为不同的渲染层级),之后在此基础上,将同一控件树层级中相交的控件、布局划分至不同的渲染层级(即将同一控件树层级的相交的渲染对象设为不同的渲染层级),不相交的控件、布局划分至同一渲染层级,完成渲染层级的划分。可选的,将确定的控件、布局的渲染层级标记填写至对应的控件数据、布局数据中,以便于后续在步骤S503中根据渲染层级进行控件、布局的渲染。For example, according to the control tree level, the controls and layouts are initially divided into the corresponding rendering levels (that is, different control tree levels are set to different rendering levels), and then on this basis, the intersecting controls and layouts in the same control tree level Divide into different rendering levels (that is, set intersecting rendering objects at the same control tree level to different rendering levels), and divide disjoint controls and layouts into the same rendering level to complete the division of rendering levels. Optionally, fill in the determined rendering level tags of controls and layouts into corresponding control data and layout data, so as to facilitate subsequent rendering of controls and layouts according to the rendering level in step S503.
一些实施例中,在绘制控件和布局的过程中,控件和布局存在对应的绘制区域,若绘制区域部分或全部相交,则说明对应的控件、布局相交。可选的,根据控件数据、布局数据能够获得对应的绘制区域,可以利用最小矩形区域表示控件或布局的绘制区域,最小矩形区域例如包括能够覆盖对应的控件或布局且面积最小的区域。In some embodiments, during the process of drawing the control and the layout, the control and the layout have a corresponding drawing area, and if the drawing area partially or completely intersects, it means that the corresponding control and the layout intersect. Optionally, the corresponding drawing area can be obtained according to the control data and layout data, and the smallest rectangular area can be used to represent the drawing area of the control or layout. The smallest rectangular area includes, for example, the smallest area that can cover the corresponding control or layout.
比如,如图6中(a)所示,附图标记61指示的矩形框内的区域能够完全覆盖文本2的绘制区域且面积最小,则为文本2对应的最小矩形区域,附图标记62指示的矩形框内的区域能够完全覆盖文本3的绘制区域且面积最小,则为文本3对应的最小矩形区域。进一步的,如图6中(b)所示,文本2和文本3均已设为控件树层级3(即同一个控件树层级),则需要确定这两个渲染对象(即文本2和文本3)是否相交,以确定渲染层级。如图6中(a)所示,通过判断最小矩形区域是否相交,进而判断这两个渲染对象是否相交。For example, as shown in (a) in Figure 6, the area in the rectangular frame indicated by
需要说明的是,图6中(a)所示的控件树中各个控件和布局的位置关系的示意图中,已经示出控件和布局对应的最小矩形区域,即为图中所示的各个矩形外边框以内的区域,下文对此不再进行说明。It should be noted that, in the schematic diagram of the positional relationship between each control and layout in the control tree shown in (a) in Figure 6, the minimum rectangular area corresponding to the control and layout has been shown, that is, the area outside each rectangle shown in the figure The area within the border, which will not be described below.
如下针对图6所示的控件树场景,说明如何按照相交情况,划分渲染层级。For the control tree scene shown in Figure 6, how to divide the rendering levels according to the intersection situation is described below.
示例性的,如图6中(b)所示,获取到控件树的控件树层级信息,绝对布局0的层级为控件树层级0,则如图7所示,划分绝对布局0的渲染层级为渲染层级0。Exemplarily, as shown in (b) in FIG. 6 , the control tree level information of the control tree is obtained, and the level of the absolute layout 0 is the control tree level 0. As shown in FIG. 7 , the rendering level of the absolute layout 0 is divided into Render level 0.
之后,按照控件树层级顺序,确定下一层级,即控件树层级1对应的渲染对象包括绝对布局1、绝对布局2以及相对布局1,如图6中(a)所示,相对布局1对应的最小矩形区域与绝对布局1对应的最小矩形区域以及绝对布局2对应的最小矩形区域均不相交,则确定相对布局1与绝对布局1和绝对布局2均不相交,那么对应于控件树层级,如图7所示,将相对布局1的渲染层级划分为渲染层级1。如图6中(a)所示,绝对布局2对应的最小矩形区域与绝对布局1对应的最小矩形区域相交,则确定绝对布局2与绝对布局1相交,且相交区域绝对布局2在绝对布局1之上。那么对应于控件树层级,如图7所示,将绝对布局1的渲染层级划分为渲染层级1;将绝对布局2的渲染层级在对应的控件树层级上加1,划分为渲染层级2。After that, determine the next level according to the order of the control tree level, that is, the rendering objects corresponding to control tree level 1 include absolute layout 1, absolute layout 2 and relative layout 1, as shown in (a) in Figure 6, relative layout 1 corresponds to If the minimum rectangular area does not intersect with the minimum rectangular area corresponding to absolute layout 1 and the minimum rectangular area corresponding to absolute layout 2, then it is determined that relative layout 1 does not intersect with both absolute layout 1 and absolute layout 2, then it corresponds to the control tree level, such as As shown in FIG. 7 , the rendering level of relative layout 1 is divided into rendering level 1. As shown in (a) of Figure 6, if the smallest rectangular area corresponding to absolute layout 2 intersects the smallest rectangular area corresponding to absolute layout 1, it is determined that absolute layout 2 intersects with absolute layout 1, and the intersecting area of absolute layout 2 is within absolute layout 1 above. Then corresponding to the control tree level, as shown in Figure 7, the rendering level of absolute layout 1 is divided into rendering level 1; the rendering level of absolute layout 2 is divided into rendering level 2 by adding 1 to the corresponding control tree level.
之后,如图6中(b)所示,再确认下一层级,即控件树层级2对应的渲染对象包括按钮0、按钮1、文本0、文本1、按钮2、按钮3以及绝对布局3。其中,如图6中(a)所示,根据对应的最小矩形区域,确定按钮0和按钮1相交,且相交区域按钮1在按钮0之上;文本0和文本1相交,且相交区域文本1在文本0之上;按钮2、按钮3以及绝对布局3与其他渲染对象均不相交。那么对应于控件树层级,如图7所示,将按钮0、按钮2、按钮3以及绝对布局3的渲染层级划分为渲染层级2,将按钮1的渲染层级划分为渲染层级3。并且,由于绝对布局2的渲染层级为渲染层级2,文本0和文本1为绝对布局2的子节点控件,那么将文本0的渲染层级在渲染层级2的基础上加1,划分为渲染层级3;将文本1的渲染层级在渲染层级3的基础上加1,划分为渲染层级4。After that, as shown in (b) in Figure 6, confirm the next level, that is, the rendering objects corresponding to control tree level 2 include button 0, button 1, text 0, text 1, button 2, button 3 and absolute layout 3. Among them, as shown in (a) in Figure 6, according to the corresponding minimum rectangular area, it is determined that button 0 and button 1 intersect, and the intersecting area button 1 is above button 0; text 0 and text 1 intersect, and the intersecting area text 1 Above Text0; Button2, Button3, and AbsoluteLayout3 are all disjoint from other render objects. Then corresponding to the control tree level, as shown in Figure 7, the rendering levels of button 0, button 2, button 3 and absolute layout 3 are divided into rendering level 2, and the rendering level of button 1 is divided into rendering level 3. And, since the rendering level of absolute layout 2 is rendering level 2, and text 0 and text 1 are child node controls of absolute layout 2, then add 1 to the rendering level of text 0 on the basis of rendering level 2, and divide it into rendering level 3 ; Add 1 to the rendering level of text 1 on the basis of rendering level 3, and divide it into rendering level 4.
最后,如图6中(b)所示,再确认下一层级,即控件树层级3对应的渲染对象包括文本2和文本3。其中,如图6中(a)所示,根据对应的最小矩形区域,确定文本2和文本3相交,且相交区域文本3在文本2之上。那么对应于控件树层级,如图7所示,将文本2的渲染层级划分为渲染层级3,将文本3的渲染层级划分为渲染层级4。Finally, as shown in (b) of FIG. 6 , confirm the next level, that is, the rendering objects corresponding to level 3 of the control tree include text 2 and text 3 . Wherein, as shown in (a) of FIG. 6 , according to the corresponding minimum rectangular area, it is determined that the text 2 and the text 3 intersect, and the text 3 is above the text 2 in the intersecting area. Then, corresponding to the control tree level, as shown in FIG. 7 , the rendering level of text 2 is divided into rendering level 3 , and the rendering level of text 3 is divided into rendering level 4 .
如此,遍历控件树层级,完成渲染对象的渲染层级的划分。In this way, the hierarchy of the control tree is traversed to complete the division of the rendering hierarchy of the rendering object.
可以理解的是,上述渲染层级0、渲染层级1、渲染层级2、渲染层级3以及渲染级4用于表示渲染顺序,仅为一种示例性说明,比如渲染层级还可以表示为渲染层级 1-渲染层级5,渲染层级A-渲染层级E等。It can be understood that the above rendering level 0, rendering level 1, rendering level 2, rendering level 3 and rendering level 4 are used to indicate the rendering order, which is only an exemplary illustration. For example, the rendering level can also be expressed as rendering level 1- Rendering level 5, rendering level A-rendering level E, etc.
需要说明的是,渲染层级的划分可以为UI线程在确认控件树层级后确认,之后在步骤S503中渲染线程直接获取渲染层级进行渲染;或者渲染线程获取控件树层级后,根据控件树层级划分渲染层级;或者通过其他线程划分渲染层级,渲染线程接收确认后的渲染层级划分结果以及数据之后执行数据渲染。It should be noted that the division of rendering levels can be confirmed by the UI thread after confirming the control tree level, and then in step S503, the rendering thread directly obtains the rendering level for rendering; or after the rendering thread obtains the control tree level, it divides the rendering according to the control tree level Level; or divide the rendering level by other threads, and the rendering thread performs data rendering after receiving the confirmed rendering level division result and data.
S503、调用渲染线程,渲染控件、布局。S503. Call the rendering thread to render the control and layout.
在一些实施例中,电子设备调用渲染线程,按照渲染层级顺序对渲染对象(如包括控件、布局)进行渲染。比如,按照渲染层级顺序串行渲染不同渲染层级的渲染对象,并行渲染相同渲染层级的渲染对象。其中,串行渲染包括调用线程按照渲染层级顺序,顺序渲染渲染对象;并行渲染包括调用多个渲染线程同时执行渲染任务。In some embodiments, the electronic device invokes the rendering thread to render rendering objects (eg, including controls and layouts) in order of rendering levels. For example, render objects of different rendering levels serially according to the order of rendering levels, and render objects of the same rendering level in parallel. Among them, serial rendering includes calling threads to render rendering objects sequentially according to the order of rendering levels; parallel rendering includes calling multiple rendering threads to perform rendering tasks at the same time.
示例性的,如图7所示,当前渲染层级包括5个层级,调用渲染线程按照渲染层级0至渲染层级4的渲染顺序进行串行渲染,即由低渲染层级串行渲染至渲染高层级。比如,调用同一个渲染线程,顺序渲染绝对布局0、绝对布局1和按钮0。并且,同一渲染层级内的数据并行渲染,如在渲染绝对布局0后,调用两个渲染线程并行渲染绝对布局1和相对布局1。Exemplarily, as shown in FIG. 7 , the current rendering level includes 5 levels, and the rendering thread is called to perform serial rendering in the order of rendering from rendering level 0 to rendering level 4, that is, serially rendering from a low rendering level to a high rendering level. For example, call the same rendering thread to sequentially render absolute layout 0, absolute layout 1, and button 0. Moreover, the data in the same rendering level is rendered in parallel, for example, after rendering absolute layout 0, call two rendering threads to render absolute layout 1 and relative layout 1 in parallel.
在一些场景中,控件数据或布局数据包括背景层构成元素数据、内容层构成元素数据以及前景层构成元素数据中的一项或几项内容。其中,背景层构成元素数据在渲染后对应于控件或布局的背景,内容层构成元素在渲染后对应于控件或布局的显示内容,前景层构成元素数据在渲染后对应于控件或布局的前景。比如,控件为文本控件,则该控件的内容层构成元素数据包括对应的文本数据。In some scenarios, the control data or layout data includes one or several items of background layer constituent element data, content layer constituent element data, and foreground layer constituent element data. Among them, the background layer constituent element data corresponds to the background of the control or layout after rendering, the content layer constituent elements correspond to the display content of the control or layout after rendering, and the foreground layer constituent element data corresponds to the foreground of the control or layout after rendering. For example, if the control is a text control, the element data of the content layer of the control includes corresponding text data.
因此,电子设备在完成渲染层级的划分后,对于不同渲染层级的数据可以按照渲染层级顺序进行渲染,但是对于同一渲染层级的数据还需要进一步确定同一渲染层级内的构成元素数据的渲染顺序。可选的,对同一渲染层级内的构成元素数据进行指令组分组,按照指令组分组结果进行控件、布局渲染。Therefore, after the electronic device completes the division of the rendering levels, the data of different rendering levels can be rendered according to the order of the rendering levels, but for the data of the same rendering level, the rendering order of the constituent element data in the same rendering level needs to be further determined. Optionally, perform instruction grouping on the constituent element data in the same rendering level, and perform control and layout rendering according to the instruction grouping results.
比如,如图7所示,按钮0和按钮2均划分为渲染层级2,假设按钮0中包括背景1和内容1,按钮2仅包括内容2。那么,尽管按钮0和按钮1位于同一渲染层级,还需要对背景1、内容1和内容2的渲染顺序进行划分。For example, as shown in FIG. 7 , button 0 and button 2 are both divided into rendering level 2, assuming that button 0 includes background 1 and content 1, and button 2 only includes content 2. Then, although button 0 and button 1 are at the same rendering level, it is necessary to divide the rendering order of background 1, content 1 and content 2.
如下介绍两种构成元素数据的指令组分组方法。Two instruction grouping methods constituting element data are described below.
方法一、按照构成元素数据的数据类别,对同一渲染层级内的控件数据、布局数据进行分组,相同数据类别的数据划分至同一指令组,不同数据类别的数据划分至不同的指令组。Method 1: Group the control data and layout data in the same rendering level according to the data categories that make up the element data, divide the data of the same data category into the same instruction group, and divide the data of different data categories into different instruction groups.
一些实施例中,将同一渲染层级内的背景层构成元素划分至一个指令组数据,内容层构成元素划分至一个指令组数据,前景层构成元素划分至一个指令组数据。比如,将位于同一渲染层级内的背景数据划分为一个指令组、文本数据划分为一个指令组等。可选的,将指令组分组结果标记记录至对应的控件数据或布局数据中,那么之后在渲染过程中,按照标记同一渲染层级内就可以按照背景层构成元素数据指令组、内容层构成元素数据指令组、前景层构成元素数据指令组的顺序进行渲染。In some embodiments, the background layer constituent elements in the same rendering level are divided into one instruction group data, the content layer constituent elements are divided into one instruction group data, and the foreground layer constituent elements are divided into one instruction group data. For example, divide the background data in the same rendering level into an instruction group, divide the text data into an instruction group, and so on. Optionally, record the instruction group group result mark into the corresponding control data or layout data, then in the rendering process, the element data instruction group can be formed according to the background layer and the element data can be formed by the content layer in the same rendering level according to the mark The command group and the foreground layer are rendered in the order of the element data command group.
示例性的,如图8所示,假设利用上述步骤S502所述的方法,确定控件树中包括的控件数据、布局数据的渲染层级包括渲染层级1和渲染层级2,渲染层级1对应的 数据包括文本1、文本3、文本5、文本7以及文本9,渲染层级2对应的数据包括文本2、文本4、文本6、文本8以及文本10。对同一渲染层级中的数据进行指令组划分,假设各个文本数据均包括背景层构成元素数据和内容层构成元素数据(即文本内容),如图8所示,每一渲染层级中可以将背景层构成元素数据划分为一个指令组(如指令组1或指令组3),内容层构成元素数据划分为一个指令组(如指令组2或指令组4)。划分指令组后,渲染层级1的数据包括指令组1的数据和指令组2的数据,渲染层级2的数据包括指令组3的数据和指令组4的数据。Exemplarily, as shown in FIG. 8 , assuming that the method described in step S502 is used to determine the rendering levels of the control data and layout data included in the control tree, including rendering level 1 and rendering level 2, the data corresponding to rendering level 1 includes Text 1, Text 3, Text 5, Text 7, and Text 9, and the data corresponding to rendering level 2 include Text 2, Text 4, Text 6, Text 8, and Text 10. Divide the data in the same rendering level into command groups, assuming that each text data includes background layer constituent element data and content layer constituent element data (i.e. text content), as shown in Figure 8, the background layer can be divided into each rendering level The constituent element data is divided into an instruction group (such as instruction group 1 or instruction group 3), and the content layer constituent element data is divided into an instruction group (such as instruction group 2 or instruction group 4). After the instruction group is divided, the data of rendering level 1 includes the data of instruction group 1 and the data of instruction group 2, and the data of rendering level 2 includes the data of instruction group 3 and the data of instruction group 4.
方法二、按照构成元素数据的指令执行顺序,对同一渲染层级内的控件数据、布局数据进行指令组分组,同一渲染层级内且指令执行顺序相同的数据划分至同一指令组,同一渲染层级内但指令执行顺序不相同的数据划分至不同的指令组。Method 2: According to the execution order of the instructions constituting the element data, group the control data and layout data in the same rendering level into instruction groups. Data with different instruction execution sequences are divided into different instruction groups.
一些实施例中,指令执行顺序例如包括控件数据、布局数据的构成元素数据的原渲染顺序。具体的,控件数据或布局数据的构成元素数据的原渲染顺序一般为先渲染背景层构成元素数据,再渲染内容层构成元素数据,最后渲染前景层构成元素数据。若控件数据或布局数据中不包括某一层或几层构成元素数据,则允许跳过该层数据直接渲染下一层构成元素数据。那么,按照指令执行顺序,将同一渲染层级中指令执行顺序相同的数据划分至同一指令组,不同指令执行顺序的数据划分至不同的指令组。可选的,将指令组分组结果标记记录至对应的控件数据或布局数据中,那么之后在渲染过程中,按照标记的指令组分组结果及指令组执行顺序,进行渲染。In some embodiments, the instruction execution order includes, for example, the original rendering order of the component data of the control data and the layout data. Specifically, the original rendering order of the component data of the control data or layout data is generally to first render the background layer to form the element data, then render the content layer to form the element data, and finally render the foreground layer to form the element data. If the control data or layout data does not include a certain layer or layers of constituent element data, it is allowed to skip this layer of data and directly render the next layer of constituent element data. Then, according to the instruction execution sequence, the data with the same instruction execution sequence in the same rendering level is divided into the same instruction group, and the data with different instruction execution sequences is divided into different instruction groups. Optionally, mark and record the grouping result of the instruction group into the corresponding control data or layout data, and then perform rendering according to the marked grouping result of the instruction group and the execution order of the instruction group during the rendering process.
示例性的,如图9所示,假设利用上述步骤S502所述的方法,确定控件树中包括的控件数据、布局数据的渲染层级包括渲染层级1和渲染层级2,渲染层级1对应的数据包括文本1、文本3、文本5、文本7以及文本9,渲染层级2对应的数据包括文本2、文本4、文本6、文本8以及文本10。对同一渲染层级中的数据进行指令组划分,如图9所示,渲染层级1中的文本1、文本5、文本7以及文本9均包括背景层构成元素数据和内容层构成元素数据,附图标记91指示的文本3仅包括内容层构成元素数据,不包括背景层构成元素数据。指令执行顺序为先执行渲染背景层构成元素数据,再执行渲染内容层构成元素数据,那么文本3由于不包括背景层构成元素数据则在渲染过程中能够直接渲染内容层构成元素数据,而渲染层级1中的其他数据需要先渲染背景层构成元素数据再渲染内容层构成元素数据。因此若按照元素类别进行划分指令组,则会导致渲染过程中,在渲染文本1、文本5、文本7以及文本9背景层构成元素数据时,负责渲染文本3背景层构成元素数据的渲染线程暂停工作,等待下一指令组再进行渲染,增加不必要的渲染等待时长。因此,电子设备可以按照控件中指令执行顺序划分指令组,如图9所示,划分指令组后,渲染层级1的数据包括指令组1的数据和指令组2的数据,指令组1的数据包括文本1、文本5、文本7以及文本9的背景层构成元素数据,以及文本3的内容层构成元素数据;指令组2的数据包括文本1、文本5、文本7以及文本9的内容层构成元素数据。Exemplarily, as shown in FIG. 9 , assuming that the method described in step S502 is used to determine the rendering levels of the control data and layout data included in the control tree, including rendering level 1 and rendering level 2, the data corresponding to rendering level 1 includes Text 1, Text 3, Text 5, Text 7, and Text 9, and the data corresponding to rendering level 2 include Text 2, Text 4, Text 6, Text 8, and Text 10. Divide the data in the same rendering level into command groups, as shown in Figure 9, the text 1, text 5, text 7 and text 9 in the rendering level 1 all include the element data of the background layer and the element data of the content layer. Text 3 indicated by
需要说明的是,指令组分组可以为UI线程在划分渲染层级后确认,之后在渲染过程中渲染线程直接获取渲染层级以及指令组分组进行渲染;或者,渲染线程获取控件树层级后,根据控件树层级确认渲染层级以及指令组分组;或者,电子设备调用其他线程根据UI线程确定的控件树层级信息,完成渲染层级分层以及指令组分组,之后调 用渲染线程按照渲染层级以及指令组分组进行渲染。It should be noted that the command group group can be confirmed by the UI thread after dividing the rendering level, and then the rendering thread directly obtains the rendering level and the command group group for rendering during the rendering process; or, after the rendering thread obtains the control tree level, according to the control tree The level confirms the rendering level and instruction group grouping; or, the electronic device calls other threads to complete the rendering level layering and instruction group grouping according to the control tree level information determined by the UI thread, and then calls the rendering thread to perform rendering according to the rendering level and instruction group grouping.
在一些实施例中,基于上述步骤S503中,在串行渲染不同渲染层级的渲染对象的基础上,将相同渲染层级内不同指令组数据按照指令组顺序串行渲染,相同指令组内的数据并行渲染。其中,指令组数据渲染顺序对应于背景层构成元素数据、内容层构成元素数据、前景层构成元素数据的渲染顺序。即并行渲染同一渲染层级的渲染对象中同一指令组中的构成元素数据,串行渲染同一渲染层级的渲染对象中不同指令组中的构成元素数据。In some embodiments, based on the above step S503, on the basis of serially rendering rendering objects of different rendering levels, the data of different instruction groups in the same rendering level are rendered serially according to the instruction group order, and the data in the same instruction group are rendered in parallel rendering. Wherein, the rendering order of the command group data corresponds to the rendering order of the element data of the background layer, the element data of the content layer, and the element data of the foreground layer. That is, the component element data in the same instruction group in the rendering objects of the same rendering level are rendered in parallel, and the component element data in different instruction groups in the rendering objects of the same rendering level are rendered serially.
示例性的,如图8所示,应先渲染渲染层级1内的控件数据、布局数据,再渲染渲染层级2内的控件数据、布局数据。其中,同属于渲染层级1内的指令组1数据和指令组2数据串行渲染,先渲染指令组1对应的背景层构成元素数据,再渲染指令组2对应的内容层构成元素数据,且同一指令组内并行渲染。如电子设备调用线程1、线程2、线程3、线程4和线程5并行渲染指令组1内的背景层构成元素数据(即背景数据)完成后,再调用线程1、线程2、线程3、线程4和线程5并行渲染指令组2内的内容层构成元素数据(即文本数据)。Exemplarily, as shown in FIG. 8 , the control data and layout data in rendering level 1 should be rendered first, and then the control data and layout data in rendering level 2 should be rendered. Among them, the instruction group 1 data and instruction group 2 data belonging to the rendering level 1 are serially rendered, the background layer corresponding to instruction group 1 is rendered first to form element data, and then the content layer corresponding to instruction group 2 is rendered to form element data, and the same Parallel rendering within instruction groups. For example, after the electronic device calls thread 1, thread 2, thread 3, thread 4, and thread 5 in parallel rendering instruction group 1, the background layer constituent element data (that is, background data) is completed, and then calls thread 1, thread 2, thread 3, thread 4 and thread 5 render in parallel the content layer in instruction group 2 to form element data (ie text data).
在一些实施例中,电子设备根据CPU、GPU中可运行的资源情况,分配渲染线程进行数据渲染。比如,UI线程根据渲染层级划分结果以及指令组分组结果,生成渲染指令触发渲染线程进行数据渲染,渲染线程接收到渲染指令后进行数据渲染。In some embodiments, the electronic device allocates rendering threads to perform data rendering according to the resources available for operation in the CPU and GPU. For example, the UI thread generates a rendering instruction based on the result of the rendering hierarchy division and the instruction group grouping result to trigger the rendering thread to perform data rendering, and the rendering thread performs data rendering after receiving the rendering instruction.
示例性的,电子设备完成待渲染数据的指令组分组后,根据CPU、GPU中可运行的资源,确定可并行调用的渲染线程数量是否满足指令组的渲染需求,若并行可调用的线程数量满足指令组的渲染需求,则调用相应数量的渲染线程并行渲染指令组内的数据。若并行可调用的线程数量不满足指令组的渲染需求,则调用最大数量的渲染线程并行渲染指令组内的部分数据,分批次渲染指令组内的全部数据。Exemplarily, after the electronic device completes the instruction group grouping of the data to be rendered, it determines whether the number of rendering threads that can be called in parallel meets the rendering requirements of the instruction group according to the executable resources of the CPU and GPU. If the number of threads that can be called in parallel meets the If the rendering requirement of the instruction group is met, a corresponding number of rendering threads are called to render the data in the instruction group in parallel. If the number of threads that can be called in parallel does not meet the rendering requirements of the instruction group, call the maximum number of rendering threads to render part of the data in the instruction group in parallel, and render all the data in the instruction group in batches.
比如,如图8所示场景中,电子设备根据最终指令组分组结果,确定指令组1-指令组4均需调用5个渲染线程进行并行渲染,电子设备确定当前CPU、GPU中可运行的资源满足需求(如可并行调用渲染线程的最大数量大于或等于5个),即可运行资源允许调用5个渲染线程进行并行渲染,则调用线程1-线程5进行指令组内数据的并行渲染。For example, in the scene shown in Figure 8, according to the grouping results of the final instruction group, the electronic device determines that instruction group 1-instruction group 4 need to call 5 rendering threads for parallel rendering, and the electronic device determines the resources that can be run in the current CPU and GPU If the requirements are met (for example, the maximum number of rendering threads that can be invoked in parallel is greater than or equal to 5), the running resource allows 5 rendering threads to be invoked for parallel rendering, and then threads 1-5 are invoked for parallel rendering of data in the instruction group.
又比如,如图8所示场景中,电子设备根据最终指令组分组情况,确定存在5个构成元素数据(如指令组1中包括的背景1-背景5)需要并行渲染,假设电子设备确定最多可调用3个渲染线程进行并行渲染(即可并行调用渲染线程的最大数量为3),则将指令组中需要并行渲染的构成元素数据再次分组后进行串行渲染。比如,将图8所示的指令组1中包括的5个待渲染的背景层构成元素数据中的3个待渲染的背景层构成元素数据划分至一个指令组和另外2个待渲染的背景构成元素数据划分至一个指令组(如将背景1-背景3划分至一个指令组,将背景4和背景5划分至一个指令组)。之后,利用可并行调用的3个渲染线程先并行渲染3个待渲染的背景层构成元素数据,再调用其中任2个渲染线程渲染剩余的2个待渲染的背景层构成元素数据(如先并行渲染背景1-背景3,之后再并行渲染背景4和背景5)。也即在CPU、GPU中可运行的资源不足时,将划分为并行渲染的构成元素数据再次划分为部分串行渲染的构成元素数据,实现数据的分批次渲染,以避免渲染失败。For another example, in the scene shown in Figure 8, the electronic device determines that there are 5 constituent element data (such as background 1-background 5 included in instruction group 1) that need to be rendered in parallel according to the grouping of the final instruction group, assuming that the electronic device determines the most Three rendering threads can be called for parallel rendering (that is, the maximum number of parallel calling rendering threads is 3), then the constituent element data in the command group that needs to be rendered in parallel are grouped again and then rendered serially. For example, among the 5 background layer constituent element data to be rendered included in instruction group 1 shown in FIG. 8, three background layer constituent element data to be rendered are divided into one instruction group and the other two background constituent elements The element data is divided into an instruction group (for example, background 1-background 3 are divided into one instruction group, and background 4 and background 5 are divided into one instruction group). Afterwards, use the 3 rendering threads that can be called in parallel to first render the element data of the 3 background layers to be rendered in parallel, and then call any 2 of the rendering threads to render the remaining 2 background layers to be rendered. Render background 1-background 3, then render background 4 and background 5 in parallel). That is to say, when there are insufficient running resources in the CPU and GPU, the constituent element data divided into parallel rendering is divided into partial serial rendering constituent element data again, so as to realize batch rendering of data to avoid rendering failure.
在一些实施例中,渲染对象的渲染可以由显示设备执行,即电子设备完成渲染层级的划分和指令组的分组后,将结果发送至显示设备(即其他具有显示功能的电子设备)进行渲染并显示。这样,显示设备在降低渲染时长的同时,还可以降低划分渲染层级以及划分指令组的功耗。In some embodiments, the rendering of the rendering object can be performed by the display device, that is, after the electronic device completes the division of rendering levels and the grouping of instruction groups, it sends the result to the display device (that is, other electronic devices with display functions) for rendering and show. In this way, while reducing the rendering time, the display device can also reduce the power consumption of dividing rendering levels and dividing instruction groups.
如此,通过本申请实施例提供的方法,可以有效降低渲染时长,避免显示图像出现丢帧现象。也就是说,通过并行渲染的方式可以降低电子设备显示图像时出现丢帧的可能性,保证显示屏显示图像的流畅性,从而提升用户的视觉体验。In this way, through the method provided by the embodiment of the present application, the rendering time can be effectively reduced, and the frame dropping phenomenon of the displayed image can be avoided. That is to say, the possibility of frame loss when an electronic device displays an image can be reduced by means of parallel rendering, and the smoothness of the image displayed on the display screen can be ensured, thereby improving the user's visual experience.
此外,在有些场景中,相邻图像帧中包括的图形数据(如包括控件数据、布局数据)不发生变化,则不需要重新绘制图形数据。比如,电子设备主界面显示应用程序图标,用户长按并拖动其中一个应用程序图标至空白显示区域显示。在上述应用程序图标拖动过程中,其他应用程序图标的位置及显示内容并不会发生变化,因此电子设备可以不再重新绘制相邻图像帧中不变的控件、布局,以节约电子设备功耗。也即上述步骤S501-步骤S503中提供的渲染方法应用于需要绘制的图形数据中,对于不需要重新绘制的图形数据,则直接获取前一帧图像的渲染结果即可。In addition, in some scenarios, if the graphics data (such as control data and layout data) included in adjacent image frames does not change, the graphics data does not need to be redrawn. For example, application icons are displayed on the main interface of the electronic device, and the user presses and drags one of the application icons to a blank display area for display. During the above application icon dragging process, the position and display content of other application icons will not change, so the electronic device can no longer redraw the constant controls and layouts in adjacent image frames, so as to save the power of the electronic device. consumption. That is to say, the rendering method provided in step S501-step S503 above is applied to the graphic data that needs to be drawn, and for the graphic data that does not need to be re-rendered, the rendering result of the previous frame image can be obtained directly.
示例性的,如图10所示,图像显示过程包括输入事件阶段、UI数据更新阶段、渲染阶段、合成阶段以及显示阶段。其中,如图10所示,利用垂直同步信号(vsync)触发不同阶段。比如,垂直同步信号1可以用于触发绘制一个或多个图层,并触发对该一个或多个图层进行渲染。本申请实施例中,电子设备响应于垂直同步信号1,可以通过多个绘制线程中的每个绘制线程分别针对每个应用绘制一个或多个图层。即电子设备响应于垂直同步信号1,可以同时针对一个或多个应用执行绘制任务,以绘制每个应用对应的一个或多个图层。其中,每一图层对应的渲染方法均可以为上述实施例中所述的渲染方法。垂直同步信号2可以用于触发渲染后的图像帧合成。垂直同步信号3可以用于触发显示合成后的图像帧。各个垂直同步信号的信号周期是根据电子设备的显示屏的屏幕刷新率确定的。比如,垂直同步信号的信号周期是电子设备的显示屏(如LCD或OLED)的屏幕刷新率的倒数。其中,电子设备的屏幕刷新率与该电子设备的帧率可以相同。电子设备的高帧率就是高屏幕刷新率。Exemplarily, as shown in FIG. 10 , the image display process includes an input event phase, a UI data update phase, a rendering phase, a synthesis phase, and a display phase. Wherein, as shown in FIG. 10 , a vertical synchronization signal (vsync) is used to trigger different stages. For example, the vertical synchronization signal 1 may be used to trigger drawing of one or more layers, and trigger rendering of the one or more layers. In the embodiment of the present application, in response to the vertical synchronization signal 1 , the electronic device may draw one or more layers for each application through each of the multiple drawing threads. That is, in response to the vertical synchronization signal 1 , the electronic device can simultaneously execute drawing tasks for one or more applications, so as to draw one or more layers corresponding to each application. Wherein, the rendering method corresponding to each layer may be the rendering method described in the foregoing embodiments. The vertical sync signal 2 can be used to trigger image frame compositing after rendering. The vertical sync signal 3 can be used to trigger display of the synthesized image frame. The signal period of each vertical synchronization signal is determined according to the screen refresh rate of the display screen of the electronic device. For example, the signal period of the vertical synchronization signal is the reciprocal of the screen refresh rate of the display screen (such as LCD or OLED) of the electronic device. Wherein, the screen refresh rate of the electronic device may be the same as the frame rate of the electronic device. A high frame rate of an electronic device is a high screen refresh rate.
如图10中(a)所示,响应于垂直同步信号1,电子设备处理图层数据获取对应的控件树中的渲染对象,以及渲染对象对应的控件树层级,之后确定渲染对象的渲染层级。最后调用渲染线程进行渲染对象的渲染。在渲染阶段,渲染a(即渲染线程a)和渲染b(即渲染线程b)并行渲染,之后再执行渲染c(即渲染线程c)。如此,在垂直同步信号的信号周期内完成渲染任务,保证后续步骤的执行。相对于如图10中(b)所示,渲染a、渲染b和渲染c均需要按照顺序依次串行渲染,导致在垂直同步信号的信号周期内未能完成渲染c的渲染任务,电子设备检测到垂直同步信号2后,也无渲染完成的图像帧可以合成,进而响应于垂直同步信号3无法刷新显示该图像帧,LCD的显示画面则无法更新,则会出现丢帧的现象。这样,会影响显示屏显示图像的连贯性和流畅性,从而影响用户的视觉体验。As shown in (a) in FIG. 10 , in response to the vertical synchronization signal 1, the electronic device processes the layer data to obtain the corresponding rendering object in the control tree and the control tree level corresponding to the rendering object, and then determines the rendering level of the rendering object. Finally, the rendering thread is called to render the rendering object. In the rendering phase, rendering a (that is, rendering thread a) and rendering b (that is, rendering thread b) are rendered in parallel, and then rendering c (that is, rendering thread c) is executed. In this way, the rendering task is completed within the signal period of the vertical synchronization signal to ensure the execution of subsequent steps. As shown in (b) in Figure 10, rendering a, rendering b, and rendering c all need to be serially rendered in sequence, resulting in failure to complete the rendering task of rendering c within the signal period of the vertical synchronization signal, and the electronic device detection After the vertical synchronous signal 2, there is no rendered image frame that can be synthesized, and then the image frame cannot be refreshed and displayed in response to the vertical synchronous signal 3, and the display screen of the LCD cannot be updated, and the phenomenon of frame loss will occur. In this way, the coherence and fluency of images displayed on the display screen will be affected, thereby affecting the user's visual experience.
需要注意的是,在不同的系统或者架构中,垂直同步信号的名称可能不同。例如,在一些系统或者架构中,上述用于触发处理一个或多个图层数据的信号(即垂直同步信号1)的名称可能不是垂直同步信号。但是,无论信号的名称是什么,只要是具备 类似功能的同步信号,符合本申请实施例提供的方法的技术思路,都应涵盖在本申请的保护范围之内。It should be noted that in different systems or architectures, the name of the vertical synchronization signal may be different. For example, in some systems or architectures, the name of the signal used to trigger the processing of one or more layers of data (ie, the vertical synchronization signal 1 ) may not be the vertical synchronization signal. However, no matter what the name of the signal is, as long as it is a synchronization signal with similar functions and conforms to the technical idea of the method provided by the embodiment of this application, it should be covered within the scope of protection of this application.
由图10中(a)可知,通过本申请实施例提供的方法,可以避免显示图像出现丢帧现象。也就是说,通过本申请实施例的方法可以降低电子设备显示图像时出现丢帧的可能性,可以保证显示屏显示图像的流畅性,从而提升用户的视觉体验。It can be seen from (a) in FIG. 10 that, through the method provided in the embodiment of the present application, frame loss of the displayed image can be avoided. That is to say, the method of the embodiment of the present application can reduce the possibility of frame loss when the electronic device displays an image, and can ensure the smoothness of the image displayed on the display screen, thereby improving the user's visual experience.
以上结合图5-图10详细说明了本申请实施例提供的渲染方法。以下结合图11和图12详细说明本申请实施例提供的电子设备。The rendering method provided by the embodiment of the present application has been described in detail above with reference to FIGS. 5-10 . The electronic device provided by the embodiment of the present application will be described in detail below with reference to FIG. 11 and FIG. 12 .
在一种可能的设计中,图11为本申请实施例提供的一种电子设备的结构示意图。如图11所示,电子设备1100包括:获取单元1101,划分单元1102以及渲染单元1103。电子设备1100可用于实现上述方法实施例中涉及的电子设备的功能。其中,电子设备1100可以为电子设备本身,也可以为电子设备中的功能单元或者芯片,或者与电子设备匹配使用的装置。In a possible design, FIG. 11 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. As shown in FIG. 11 , an electronic device 1100 includes: an acquiring
可选的,获取单元1101,用于支持电子设备1100执行图5中的步骤S501。Optionally, the acquiring
可选的,划分单元1102,用于支持电子设备1100执行图5中的步骤S502。Optionally, the
可选的,渲染单元1103,用于支持电子设备1100执行图5中的步骤S503。Optionally, the
可选的,图11所示的电子设备1100还可以包括发送单元(图11中未示出),该发送单元用于向其他通信装置发送信号。Optionally, the electronic device 1100 shown in FIG. 11 may further include a sending unit (not shown in FIG. 11 ), which is configured to send signals to other communication devices.
可选地,图11所示的电子设备1100还可以包括存储单元(图11中未示出),该存储单元存储有程序或指令。当获取单元1101,划分单元1102以及渲染单元1103执行该程序或指令时,使得图11所示的电子设备1100可以执行图5所示的渲染方法。Optionally, the electronic device 1100 shown in FIG. 11 may further include a storage unit (not shown in FIG. 11 ), which stores programs or instructions. When the acquiring
图11所示的电子设备1100的技术效果可以参考上述方法实施例中所述的技术效果,此处不再赘述。For technical effects of the electronic device 1100 shown in FIG. 11 , reference may be made to the technical effects described in the foregoing method embodiments, and details are not repeated here.
其中,获取单元和发送单元可以统称为收发单元,可以由收发器或收发器相关电路组件实现,可以为收发器或收发模块。该电子设备1100中的各个单元的操作和/或功能分别为了实现上述方法实施例所述的渲染方法的相应流程,为了简洁,在此不再赘述。Wherein, the acquisition unit and the sending unit may be collectively referred to as a transceiver unit, which may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module. The operations and/or functions of each unit in the electronic device 1100 are to implement the corresponding process of the rendering method described in the above method embodiment, and for the sake of brevity, details are not described here.
在采用集成的单元的情况下,图12示出了上述实施例中所涉及的电子设备的另一种可能的组成示意图。如图12所示,该电子设备1200可以包括:处理模块1201。In the case of using integrated units, FIG. 12 shows another possible composition diagram of the electronic device involved in the above embodiment. As shown in FIG. 12 , the electronic device 1200 may include: a
处理模块1201用于执行上述图11中所示的获取单元1101,划分单元1102以及渲染单元1103所执行的步骤,处理模块1201的操作和/或功能为了实现上述方法实施例所述的渲染方法的相应流程,为了简洁,在此不再赘述。The
电子设备1200还可以包括存储模块,用于存储电子设备的程序代码和数据。存储模块可以是存储器。The electronic device 1200 may also include a storage module for storing program codes and data of the electronic device. The storage module may be a memory.
其中,处理模块1201可以是处理器或控制器。其可以实现或执行结合本申请实施例公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包括一个或多个微处理器组合,DSP和微处理器的组合等等。Wherein, the
本申请实施例还提供一种芯片系统,包括:处理器,所述处理器与存储器耦合,所述存储器用于存储程序或指令,当所述程序或指令被所述处理器执行时,使得该芯片系统实现上述任一方法实施例中的方法。The embodiment of the present application also provides a chip system, including: a processor, the processor is coupled with a memory, and the memory is used to store programs or instructions, and when the programs or instructions are executed by the processor, the The system on chip implements the method in any one of the foregoing method embodiments.
可选地,该芯片系统中的处理器可以为一个或多个。该处理器可以通过硬件实现也可以通过软件实现。当通过硬件实现时,该处理器可以是逻辑电路、集成电路等。当通过软件实现时,该处理器可以是一个通用处理器,通过读取存储器中存储的软件代码来实现。Optionally, there may be one or more processors in the chip system. The processor can be realized by hardware or by software. When implemented in hardware, the processor may be a logic circuit, an integrated circuit, or the like. When implemented by software, the processor may be a general-purpose processor implemented by reading software codes stored in a memory.
可选地,该芯片系统中的存储器也可以为一个或多个。该存储器可以与处理器集成在一起,也可以和处理器分离设置,本申请实施例并不限定。示例性的,存储器可以是非瞬时性处理器,例如只读存储器ROM,其可以与处理器集成在同一块芯片上,也可以分别设置在不同的芯片上,本申请实施例对存储器的类型,以及存储器与处理器的设置方式不作具体限定。Optionally, there may be one or more memories in the chip system. The memory may be integrated with the processor, or may be configured separately from the processor, which is not limited in this embodiment of the present application. Exemplarily, the memory can be a non-transitory processor, such as a read-only memory ROM, which can be integrated with the processor on the same chip, or can be respectively arranged on different chips. The embodiment of the present application is specific to the type of memory, and The arrangement manner of the memory and the processor is not specifically limited.
示例性的,该芯片系统可以是现场可编程门阵列(field programmable gate array,FPGA),可以是专用集成芯片(application specific integrated circuit,ASIC),还可以是系统芯片(system on chip,SoC),还可以是中央处理器(central processor unit,CPU),还可以是网络处理器(network processor,NP),还可以是数字信号处理电路(digital signal processor,DSP),还可以是微控制器(micro controller unit,MCU),还可以是可编程控制器(programmable logic device,PLD)或其他集成芯片。Exemplarily, the chip system may be a field programmable gate array (field programmable gate array, FPGA), an application specific integrated circuit (ASIC), or a system on chip (SoC), It can also be a central processing unit (central processor unit, CPU), it can also be a network processor (network processor, NP), it can also be a digital signal processing circuit (digital signal processor, DSP), it can also be a microcontroller (micro controller unit, MCU), and can also be a programmable logic device (programmable logic device, PLD) or other integrated chips.
应理解,上述方法实施例中的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。It should be understood that each step in the foregoing method embodiments may be implemented by an integrated logic circuit of hardware in a processor or instructions in the form of software. The method steps disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.
本申请的实施例还提供了一种存储介质,用于存储为上述通信装置所用的指令。Embodiments of the present application also provide a storage medium for storing instructions used by the above-mentioned communication device.
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机指令,当该计算机指令在服务器上运行时,使得服务器执行上述相关方法步骤实现上述实施例中的渲染方法。The embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores computer instructions, and when the computer instructions are run on the server, the server executes the above-mentioned related method steps to realize the rendering in the above-mentioned embodiments method.
本申请实施例还提供一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的渲染方法。An embodiment of the present application further provides a computer program product, which, when running on a computer, causes the computer to execute the above-mentioned related steps, so as to implement the rendering method in the above-mentioned embodiment.
另外,本申请实施例还提供一种装置,该装置具体可以是组件或模块,该装置可包括相连的一个或多个处理器和存储器;其中,存储器用于存储计算机程序,一个或多个计算机程序包括指令。当该指令被一个或多个处理器执行时,以使装置执行上述各方法实施例中的渲染方法。In addition, the embodiment of the present application also provides a device, which may specifically be a component or a module, and the device may include one or more connected processors and memories; wherein, the memories are used to store computer programs, and one or more computers Programs include instructions. When the instruction is executed by one or more processors, the device is executed to execute the rendering method in the foregoing method embodiments.
其中,本申请实施例提供的装置、计算机可读存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。Wherein, the device, computer-readable storage medium, computer program product or chip provided in the embodiments of the present application are all used to execute the corresponding method provided above, therefore, the beneficial effects it can achieve can refer to the above-mentioned The beneficial effects of the corresponding method will not be repeated here.
结合本申请实施例公开内容所描述的方法或者算法的步骤可以硬件的方式来实现,也可以是由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于随机存取存储器(random access memory,RAM)、闪存、只读存储器(read only memory,ROM)、可擦除可编程只读存储器(erasable programmable ROM,EPROM)、电可擦可编程只读存储器(electrically EPROM,EEPROM)、寄存器、硬盘、移动硬盘、只读光盘(CD-ROM)或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。 处理器和存储介质可以位于专用集成电路(application specific integrated circuit,ASIC)中。The steps of the methods or algorithms described in connection with the disclosure of the embodiments of the present application may be implemented in the form of hardware, or may be implemented in the form of a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (random access memory, RAM), flash memory, read only memory (read only memory, ROM), erasable programmable read-only memory ( erasable programmable ROM, EPROM), electrically erasable programmable read-only memory (electrically EPROM, EEPROM), registers, hard disk, removable hard disk, CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may be located in an application specific integrated circuit (ASIC).
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of the description, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated according to needs It is completed by different functional modules, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. For the specific working process of the above-described system, device, and unit, reference may be made to the corresponding process in the foregoing method embodiments, and details are not repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,模块或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed method may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be Incorporation may either be integrated into another system, or some features may be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of modules or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disc and other media that can store program codes. .
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only a specific implementation of the application, but the protection scope of the application is not limited thereto, and any changes or replacements within the technical scope disclosed in the application should be covered within the protection scope of the application . Therefore, the protection scope of the present application should be determined by the protection scope of the claims.
Claims (11)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202110875756.0 | 2021-07-30 | ||
| CN202110875756.0A CN115686700B (en) | 2021-07-30 | 2021-07-30 | Rendering method and electronic equipment |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2023005751A1 true WO2023005751A1 (en) | 2023-02-02 |
Family
ID=85059609
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2022/106621 Ceased WO2023005751A1 (en) | 2021-07-30 | 2022-07-20 | Rendering method and electronic device |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN115686700B (en) |
| WO (1) | WO2023005751A1 (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2024183530A1 (en) * | 2023-03-08 | 2024-09-12 | 华为技术有限公司 | Rendering method, rendering apparatus, device and storage medium |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119440352A (en) * | 2023-07-28 | 2025-02-14 | 华为技术有限公司 | A widget display method and electronic device |
| CN120256031A (en) * | 2023-12-27 | 2025-07-04 | 荣耀终端股份有限公司 | Image frame rendering method, device and terminal equipment |
| CN117473188B (en) * | 2023-12-28 | 2024-04-09 | 中移(苏州)软件技术有限公司 | Display data rendering method and device, electronic equipment and storage medium |
| CN120669938A (en) * | 2024-05-30 | 2025-09-19 | 华为技术有限公司 | Rendering method and device of display object, electronic equipment and storage medium |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20130159893A1 (en) * | 2011-12-16 | 2013-06-20 | Research In Motion Limited | Method of rendering a user interface |
| CN110618847A (en) * | 2018-06-20 | 2019-12-27 | 华为技术有限公司 | User interface display method and terminal equipment |
| CN110955850A (en) * | 2019-11-18 | 2020-04-03 | 国云科技股份有限公司 | Processing method of modular tree control |
| CN111611032A (en) * | 2019-02-25 | 2020-09-01 | 阿里巴巴集团控股有限公司 | Detection method and device for user interface drawing level and over-drawing |
| CN112650899A (en) * | 2020-12-30 | 2021-04-13 | 中国平安人寿保险股份有限公司 | Data visualization rendering method and device, computer equipment and storage medium |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9508181B2 (en) * | 2011-08-31 | 2016-11-29 | Adobe Systems Incorporated | Ordering and rendering buffers for complex scenes with cyclic dependency |
| CN112417346A (en) * | 2021-01-25 | 2021-02-26 | 北京小米移动软件有限公司 | Rendering method, device, electronic device and storage medium |
-
2021
- 2021-07-30 CN CN202110875756.0A patent/CN115686700B/en active Active
-
2022
- 2022-07-20 WO PCT/CN2022/106621 patent/WO2023005751A1/en not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20130159893A1 (en) * | 2011-12-16 | 2013-06-20 | Research In Motion Limited | Method of rendering a user interface |
| CN110618847A (en) * | 2018-06-20 | 2019-12-27 | 华为技术有限公司 | User interface display method and terminal equipment |
| CN111611032A (en) * | 2019-02-25 | 2020-09-01 | 阿里巴巴集团控股有限公司 | Detection method and device for user interface drawing level and over-drawing |
| CN110955850A (en) * | 2019-11-18 | 2020-04-03 | 国云科技股份有限公司 | Processing method of modular tree control |
| CN112650899A (en) * | 2020-12-30 | 2021-04-13 | 中国平安人寿保险股份有限公司 | Data visualization rendering method and device, computer equipment and storage medium |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2024183530A1 (en) * | 2023-03-08 | 2024-09-12 | 华为技术有限公司 | Rendering method, rendering apparatus, device and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN115686700A (en) | 2023-02-03 |
| CN115686700B (en) | 2025-11-28 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2023005751A1 (en) | Rendering method and electronic device | |
| US20250013476A1 (en) | Interface generation method and electronic device | |
| WO2022252805A1 (en) | Display method and electronic device | |
| US20250061622A1 (en) | Drawing method and electronic device | |
| US12079537B2 (en) | Screen projection method and system, and related apparatus | |
| US20250004532A1 (en) | Power consumption control method and electronic device | |
| WO2023066177A1 (en) | Animation effect display method and electronic device | |
| WO2023001163A1 (en) | Screen refreshing method and device capable of improving dynamic effect performance | |
| CN116095413A (en) | Video processing method and electronic equipment | |
| WO2025167740A1 (en) | Display method, user interface, and related apparatus | |
| WO2023066165A1 (en) | Animation effect display method and electronic device | |
| WO2025209372A1 (en) | Wallpaper display method and electronic device | |
| US20260030040A1 (en) | Interface generation method and electronic device | |
| CN116700655B (en) | Interface display method and electronic device | |
| CN116672707A (en) | Method and electronic device for generating game prediction frame | |
| WO2023169276A1 (en) | Screen projection method, terminal device, and computer-readable storage medium | |
| CN116991532A (en) | A method, electronic device and system for displaying a virtual machine window | |
| CN115712373A (en) | Interface display method and electronic equipment | |
| CN116737291B (en) | Desktop application processing method and electronic device | |
| WO2024037346A1 (en) | Page management method and electronic device | |
| CN116055627A (en) | A screen off control method, electronic device and storage medium | |
| CN116166257A (en) | Interface generation method and electronic equipment | |
| US20250264976A1 (en) | Display method, display apparatus, and electronic device | |
| US20260011062A1 (en) | Image processing method and electronic device | |
| WO2024093431A1 (en) | Image drawing method and electronic device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22848356 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 22848356 Country of ref document: EP Kind code of ref document: A1 |