Method for generating interface image and electronic device
By obtaining and applying for layer cache in advance, the interface image generation delay problem caused by long memory application time of electronic devices when the layer changes greatly is solved, and a more stable interface display is achieved, reducing the risk of frame drops.
Patent Information
- Application Number
- CN202310688308.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-09
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2043-06-09
AI Technical Summary
When electronic devices generate interface images, due to large changes in the layer, the memory application time is long, which increases the interface image generation time, which may lead to the interface image not being prepared when the screen is refreshed, resulting in the problem of frame drops.
By obtaining the attribute information of the layer in advance, applying for cache (BufferCache) in advance, binding the cache to the buffer queue when receiving the vertical synchronization signal, and filling the layer content to avoid real-time application of memory when generating the layer.
This reduces the uncertainty of interface image generation time, avoids the situation where the interface image is not ready when the next vertical synchronization signal arrives, and significantly reduces the probability of frame dropping on the display screen.
Smart Images

Figure CN117724779B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a method for generating an interface image and an electronic device. Background Art
[0002] The display screen of an electronic device is composed of interface images frame by frame, and each interface image usually includes at least one layer. The system and application of the electronic device prepare the resources of each layer, generate each layer, and after rendering and synthesis, the interface images can be displayed frame by frame on the screen. In the process of generating layers, it is necessary to apply for memory for each layer separately for related processing of generating layers. In scenes with large changes in layers, there is a certain probability that the memory application time will be long, resulting in a long time to prepare the interface image. If some interface images are not ready when the electronic device refreshes the screen, the problem of frame loss in the display will occur. Summary of the invention
[0003] The embodiments of the present application provide a method for generating an interface image and an electronic device, which can solve the problem of too long time for generating the layer of the interface image and reduce the probability of frame loss of the electronic device display screen.
[0004] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0005] In a first aspect, a method for generating an interface image is provided, which is applied to an electronic device, on which a first application is installed, and the operating system of the electronic device includes a surface synthesis service and a synthesis rendering component, and the method includes: the surface synthesis service obtains the attribute information of the first layer of the first interface image of the first application; for example, the attribute information may include at least one of the layer width, layer height and pixel information of the interface image. The surface synthesis service applies for a first cache according to the attribute information of the first layer at a first moment; the surface synthesis service binds the first cache to the buffer queue corresponding to the first layer at a second moment (the moment when the first vertical synchronization Vsync signal is received); the surface synthesis service generates all layers according to the buffer queues corresponding to all layers contained in the first interface image; the synthesis rendering component renders and synthesizes all layers to generate the first interface image.
[0006] Among them, the first moment is earlier than the second moment. Because the cache (BufferCache) corresponding to the first layer is applied for in advance according to the attribute information of the first layer at the first moment. When the surface synthesis service (SurfaceFlinger service) receives the first Vsync signal to generate the first layer, the BufferCache applied in advance is directly bound to the buffer queue (BufferQueue) corresponding to the first layer, and then the layer content can be filled into the BufferCache according to the graphic data of the first layer. There is no need to apply for Buffer in real time when generating the first layer. Since the BufferCache of the first layer is applied in advance, only the BufferCache and the BufferQueue are bound when the first layer is generated, and then the content is filled into the BufferCache; the time to draw the first layer is not affected by the time to apply for memory, which avoids the problem that the first interface image is not ready when the next Vsync signal (second Vsync signal) arrives.
[0007] In combination with the first aspect, in one implementation, the surface synthesis service applies for a first cache based on the attribute information of the first layer, including: the surface synthesis service determines a first value based on the attribute information of the first layer, and the first value is the size of the space occupied by the first cache; the surface synthesis service applies for the first cache based on the first value.
[0008] The size of the space occupied by the cache corresponding to the layer is determined by the attribute information of the layer. The surface synthesis service needs to obtain the attribute information of the layer before applying for the layer buffer.
[0009] In combination with the first aspect, in one implementation, the method further includes: at a third moment, displaying the first interface image on the screen of the electronic device; the third moment is the moment when the second Vsync signal is sent, and the second Vsync signal is the next Vsync signal of the first Vsync signal.
[0010] That is to say, the layer is generated when the first Vsync signal is sent, and the interface image needs to be prepared before the second Vsync signal is sent, so that the interface image can be displayed when the second Vsync signal is sent, avoiding frame loss.
[0011] In combination with the first aspect, in one implementation, the first moment is the moment when the Activity corresponding to the first interface image is created or started.
[0012] During the cold start process of the first application, when the onCreate event or onStart event of the Activity corresponding to the application interface of the first application is detected, the BufferCache corresponding to each layer such as the application interface layer, the status bar layer, the navigation bar layer, and the wallpaper layer is applied. When the SurfaceFlinger service receives the Vsync signal to generate the layer, it only needs to bind each BufferCache applied in advance to the corresponding BufferQueue respectively, and there is no need to apply for memory in real time when generating the layer. The time consumed in applying for memory will not affect the speed of generating the interface image. This avoids the problem that the interface image is not ready when the next Vsync signal arrives, and reduces the probability of frame loss when the electronic device displays the screen.
[0013] In one implementation, the first layer is an application interface layer, and the surface synthesis service obtains attribute information of the first layer from the process of the first application.
[0014] In another implementation, the first layer is a status bar layer, a navigation bar layer, or a wallpaper layer, and the surface composition service obtains the attribute information of the first layer from the process of the operating system.
[0015] In some implementations, when an onCreate event or onStart event of an Activity corresponding to the application interface of the first application is detected, the first application sends the attribute information of the application interface layer to the surface synthesis service. In some implementations, the surface synthesis service obtains the attribute information of the application interface layer of the first application through learning.
[0016] In combination with the first aspect, in one implementation, the first moment is a moment when a horizontal screen switching to vertical screen event, a vertical screen switching to horizontal screen event, a folding screen unfolding event, or a folding screen folding event is detected.
[0017] During the running of the application, when the electronic device switches between horizontal and vertical screens, or the folding screen of the electronic device is unfolded or folded, the SurfaceFlinger service applies for the BufferCache corresponding to the changed layer (first layer). When the SurfaceFlinger service receives the Vsync signal to generate a layer, it only needs to bind the BufferCache of each layer applied in advance to the corresponding BufferQueue respectively, and there is no need to apply for memory in real time when generating the layer. The time consumed in applying for memory will not affect the speed of generating the interface image. This avoids the problem that the interface image is not ready when the next Vsync signal arrives, and reduces the probability of frame loss when the electronic device displays the screen.
[0018] In some embodiments, the first moment is the moment when a landscape-to-portrait switching event is detected, the first layer is an application interface layer, and the surface synthesis service applies for a first cache based on attribute information of the application interface layer in the portrait state of the electronic device.
[0019] In some embodiments, the first moment is the moment when a portrait-to-landscape switching event is detected, the first layer is the application interface layer, and the surface synthesis service applies for a first cache based on the attribute information of the application interface layer in the landscape state of the electronic device.
[0020] In some embodiments, the first moment is the moment when the folding screen expansion event is detected, the first layer includes at least one of a status bar layer, a navigation bar layer, and a wallpaper layer, and the surface synthesis service applies for a first cache based on the attribute information of the first layer when the folding screen of the electronic device is in the expanded state.
[0021] In some embodiments, the first moment is the moment when a folding event of the folding screen is detected, the first layer includes at least one of a status bar layer, a navigation bar layer, and a wallpaper layer, and the surface synthesis service applies for a first cache based on the attribute information of the first layer when the folding screen of the electronic device is in a folded state.
[0022] In a second aspect, an electronic device is provided, which has the function of implementing the method for generating an interface image described in the first aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0023] In a third aspect, an electronic device is provided, comprising: a processor, a memory and a display screen; the memory is used to store computer execution instructions, and when the electronic device is running, the processor executes the computer execution instructions stored in the memory to enable the electronic device to perform a method as described in any one of the above-mentioned first aspects.
[0024] In a fourth aspect, an electronic device is provided, comprising: a processor; the processor is used to couple with a memory, and after reading instructions in the memory, execute a method as described in any one of the above-mentioned first aspects according to the instructions.
[0025] In a fifth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is executed on a computer, the computer can execute any of the methods described in the first aspect.
[0026] In a sixth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the methods described in the first aspect.
[0027] In a seventh aspect, a device (for example, the device may be a chip system) is provided, the device including a processor for supporting an electronic device to implement the functions involved in the first aspect above. In one possible design, the device also includes a memory for storing program instructions and data necessary for the electronic device. When the device is a chip system, it may be composed of a chip, or may include a chip and other discrete devices.
[0028] Among them, the technical effects brought about by any design method in the second to seventh aspects can refer to the technical effects brought about by different design methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A schematic diagram of an example scenario applicable to the method for generating an interface image provided in an embodiment of the present application;
[0030] Figure 2 A schematic diagram of an example scenario applicable to the method for generating an interface image provided in an embodiment of the present application;
[0031] Figure 3 A flow chart for drawing a frame of interface image;
[0032] Figure 4 A schematic diagram of message tracking information during the process of drawing a frame of interface image;
[0033] Figure 5 A schematic diagram of why it takes a long time to apply for Buffer for SurfaceFlinger;
[0034] Figure 6 A schematic diagram of a principle of a method for generating an interface image provided in an embodiment of the present application;
[0035] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0036] Figure 8 A schematic diagram of a flow chart of a method for generating an interface image provided in an embodiment of the present application;
[0037] Fig. 9 A schematic diagram of a flow chart of a method for generating an interface image provided in an embodiment of the present application;
[0038] Fig.10 A schematic diagram of a flow chart of a method for generating an interface image provided in an embodiment of the present application;
[0039] Fig.11 A schematic diagram of a flow chart of a method for generating an interface image provided in an embodiment of the present application;
[0040] Fig.12 A schematic diagram of a flow chart of a method for generating an interface image provided in an embodiment of the present application;
[0041] Fig.13 A schematic diagram of a flow chart of a method for generating an interface image provided in an embodiment of the present application;
[0042] Fig.14 A schematic diagram of the structural composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and the appended claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include such expressions as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are a kind of "or" relationship.
[0044] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0045] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0046] The interface image displayed on the electronic device may include one or more layers, such as a status bar layer, a navigation bar layer, an application interface layer, a wallpaper layer, etc. The number of layers included in each different interface image may be different. Figure 1 As shown, the electronic device displays a desktop interface, and the desktop interface image includes a status bar layer, a navigation bar layer, an application interface layer, and a wallpaper layer. Figure 2 As shown, the electronic device displays a video call interface, and the video call interface image includes a status bar layer and an application interface layer. Among them, the status bar layer, the navigation bar layer and the wallpaper layer are generated and rendered by the system process of the electronic device, and the application interface layer is generated and rendered by the application process.
[0047] The screen of the electronic device is refreshed at a certain frequency, and one frame of the interface image is displayed each time it is refreshed. In the embodiment of the present application, the time interval for displaying two adjacent frames of the interface image is called a frame interval. For example, the refresh rate of the mobile phone screen is generally 60Hz or 120Hz. A refresh rate of 60Hz means 60 refreshes per second, that is, the time interval between the display of two adjacent frames of the interface image is approximately 16.67ms (one frame interval is 16.67ms); a refresh rate of 120Hz means 120 refreshes per second, that is, the time interval between the display of two adjacent frames of the interface image is approximately 8.33ms (one frame interval is 8.33ms).
[0048] After each frame of the interface image is displayed, the screen will send a vertical synchronization (Vsync) signal to the system process and application process. The system process and application process need to prepare (draw) the next frame of the interface image before the next Vsync signal arrives. In this way, the next frame of the interface image can be displayed normally when the screen is refreshed next time.
[0049] For example, Figure 3 A schematic diagram of a process of drawing a frame of interface image is shown.
[0050] like Figure 3As shown, the interface includes the status bar, application interface and navigation bar. After the screen sends the Vsync signal, the surface synthesis (SurfaceFlinger) applies for a buffer for the status bar layer and adds it to the buffer queue (BufferQueue) of the status bar layer; applies for a buffer for the navigation bar layer and adds it to the BufferQueue of the navigation bar layer; applies for a buffer for the application interface layer and adds it to the BufferQueue of the application interface layer. The system process puts the graphics data of the status bar layer into the Buffer of the status bar layer, and the graphics data of the navigation bar layer into the Buffer of the navigation bar layer. The application process puts the graphics data of the application interface layer into the Buffer of the application interface layer.
[0051] SurfaceFlinger traverses all BufferQueues, uses the graphics data in the most recently generated Buffer in each BufferQueue to generate the content of the corresponding layer, then merges the BufferQueue of the status bar layer, the BufferQueue of the navigation bar layer, and the BufferQueue of the application interface layer into one BufferQueue, calls the synthesis rendering component for rendering and synthesis, and generates the interface image of the interface. SurfaceFlinger sends the generated interface image to the display driver, so that the interface can be displayed on the screen when the next Vsync signal arrives.
[0052] In some scenarios, SurfaceFlinger takes a long time to apply for the buffer, resulting in the next frame of the interface image not being ready when the next Vsync signal arrives, which will cause the display frame to be dropped. For example, Figure 4 The message trace information in the process of drawing a frame of interface image is shown. Figure 4 As shown in the figure, during the process of drawing the interface image, the memory allocation service requests the kernel to allocate a buffer. Among them, the command response time of communication message 1 (HwBinder1) is abnormal. It takes about 34.5ms to request a buffer of about 10M, which is much longer than a frame interval (16.67ms or 8.33ms). This will cause the time to generate the interface image to be too long, and the interface image cannot be prepared when the next Vsync signal arrives, resulting in frame loss in the display.
[0053] Combine the following Figure 5 This section describes an example of why it takes a long time for SurfaceFlinger to apply for a Buffer.
[0054] like Figure 5As shown in the figure, the desktop interface of the mobile phone includes 4 layers, namely the status bar, application interface, wallpaper and navigation bar. SurfaceFlinger maintains the corresponding number of BufferQueues according to the number of layers, such as Figure 5 As shown, SurfaceFlinger maintains 4 BufferQueues, each BufferQueue includes 3 Buffers.
[0055] After the screen sends the Vsync signal, in response to the calls of the system process and the application process, SurfaceFlinger calls The memory request interface of the encapsulated memory manager (ION) applies for a Buffer from the kernel, which is used to store the graphic data of the status bar layer, application interface layer, wallpaper layer, and navigation bar layer.
[0056] SurfaceFlinger needs to complete the drawing of the interface image within a frame interval (16.67ms or 8.33ms), that is, the duration of SurfaceFlinger's buffer application cannot exceed a frame interval (16.67ms or 8.33ms). Otherwise, the drawing cannot be completed when the next Vsync signal arrives.
[0057] In one implementation, considering that the size of the buffer space that SurfaceFlinger applies to the kernel for is determined based on the attribute information of the interface image (e.g., the width and height of the layer, the pixel information of the interface image, etc.), and the attribute information of the interface images of different applications is different, when the application calls SurfaceFlinger to generate a layer, the buffer is applied in real time based on the attribute information corresponding to the layer sent by the system process or the application process. The time spent on applying for the buffer directly affects the speed of drawing the layer. If the time spent on applying for the buffer is too long, the interface image may not be ready when the next Vsync signal arrives.
[0058] In the current implementation, each layer of the interface corresponds to a BufferQueue. The more layers the interface includes, the larger the number of BufferQueues maintained by SurfaceFlinger. For example, Figure 5As shown in the figure, the desktop interface of the mobile phone includes 4 layers, and accordingly, SurfaceFlinger maintains 4 BufferQueues. SurfaceFlinger needs to apply for 4 blocks of memory from the kernel at a time, and each block of memory is a memory with a continuous physical address. Generally speaking, the buffer corresponding to a layer is about 10M. SurfaceFlinger applies for a large number of memories at one time (for example, 4 blocks), and the buffer corresponding to each layer is very large (about 10M), and each requested buffer is a memory with a continuous physical address. It is difficult for the kernel to allocate memory to meet SurfaceFlinger's request, so there will be a problem of long memory application time. The more layers the interface image includes, the higher the screen refresh frequency, and the greater the probability of problems. In addition, when the system load is high, the system memory is more tense, the system lacks continuous memory, and the probability of problems is greater.
[0059] Generally, in scenarios with many drawing layers, the above-mentioned slow memory application and long time-consuming situation are more likely to occur. For example, when the application is cold started, all layers of the interface image need to be redrawn, and the most and most complete resources are applied. After the application is started, the layers generally do not change. For example, when the electronic device switches between horizontal and vertical screens, or folds and unfolds the screen, all layers of the interface image need to be redrawn. Redrawing the layers will likely cause the problem of SurfaceFlinger taking a long time to apply for the Buffer.
[0060] The embodiment of the present application provides a method for generating an interface image, obtaining the attribute information of the layer in advance (before generating the layer), and applying for the cache (BufferCache) corresponding to the layer according to the attribute information of the layer. When the SurfaceFlinger service generates the layer, the BufferCache applied in advance is directly bound to the BufferQueue corresponding to the layer, and then the layer content is filled into the BufferCache according to the graphic data of the layer. There is no need to apply for Buffer in real time when generating the layer and fill the layer content according to the graphic data of the layer. Since the BufferCache of the layer is applied in advance, only the BufferCache is bound to the BufferQueue when generating the layer, and then the content is filled into the BufferCache to generate the interface image; the time length for drawing the layer is not affected by the time length for applying for memory, which avoids the problem that the interface image is not ready when the next Vsync signal arrives.
[0061] For example, Figure 6As shown in (a), in the current implementation, SurfaceFlinger applies for the buffer corresponding to the layer when generating the layer and fills the layer content. Applying for memory takes a long time, which will result in the interface image not being ready when the Vsync signal arrives.
[0062] like Figure 6 As shown in (b), in the method for generating an interface image provided by the embodiment of the present application, SurfaceFlinger applies for a cache (BufferCache) corresponding to the layer at a first moment, such as when the activity (Activity) corresponding to the application interface of the application is created (onCreate) or started (onStart). Then, at a second moment, such as when SurfaceFlinger generates a layer, the applied BufferCache is bound to the BufferQueue corresponding to the layer, and the layer content is filled into the BufferCache.
[0063] Among them, the first moment is earlier than the second moment. For example, generally speaking, the moment when the onCreate event occurs in the Activity of the interface (the first moment) is 50ms-60ms earlier than the moment when the layer is generated (the second moment). Even if it takes a long time to apply for memory (for example, 34.5ms), the memory application process can be completed at the moment of generating the layer (the second moment). In this way, it can be avoided that the long time spent on applying for memory leads to too slow generation of the interface image, and the interface image is not ready when the next Vsync signal arrives.
[0064] Among them, onCreate and onStart belong to the life cycle of Activity, which are briefly introduced below. The life cycle of Activity includes onCreate, onStart, onResume, onPause, onStop, onRestart and onDestroy.
[0065] onCreate: Executed when the Activity is first loaded. The onCreate event is executed when the interface is first started. After the Activity is destroyed, the onCreate event is re-executed after it is reloaded.
[0066] onStart: Executed after the onCreate event. After the interface is cut out, if you re-enter the interface after a period of time (the Activity is not destroyed), the onCreate event will be skipped and the onStart event will be executed directly.
[0067] onResume: Executed after the onStart event; or after the interface is swapped to the background, when the user views the interface again (the Activity has not been destroyed and the onStop event has not been executed), the onCreate and onStart events will be skipped and the onResume event will be executed directly.
[0068] onPause: Called when the interface is switched to the background.
[0069] onStop: Executed after the onPause event. If the interface is not returned within a period of time, the onStop event of the Activity of the interface will be executed. Or if the user directly removes the interface from the current page, the onStop event of the Activity of the interface will also be executed.
[0070] onRestart: After the onStop event is executed, if the interface and the process of the application are not destroyed by the system, when the user re-enters the interface, the onRestart event of the Activity of the interface will be executed. After the onRestart event, the onCreate event will be skipped and the onStart event will be executed directly.
[0071] onDestroy: Executed when the Activity is destroyed. After executing the onStop event, if the interface is not returned again, the Activity will be destroyed.
[0072] The method provided in the embodiment of the present application can be applied to electronic devices including display screens. The above-mentioned electronic devices may include mobile phones, tablet computers, laptop computers, personal computers (PCs), ultra-mobile personal computers (UMPCs), handheld computers, netbooks, smart home devices (e.g., smart TVs, smart screens, large screens, smart speakers, smart air conditioners, etc.), personal digital assistants (PDAs), wearable devices (e.g., smart watches, smart bracelets, etc.), vehicle-mounted devices, virtual reality devices, etc., and the embodiments of the present application do not impose any restrictions on this.
[0073] Figure 71 is a schematic diagram of the structure of an 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 (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a display screen 191, an indicator 192, a camera 193, etc. The sensor module 180 may include a touch sensor, a temperature sensor, a distance sensor, etc.
[0074] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0075] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0076] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0077] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0078] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0079] It is understandable that the interface connection relationship between the modules illustrated in this embodiment is only a schematic illustration and does not constitute a structural limitation of the electronic device. In other embodiments, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0080] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of an electronic device. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0081] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 191, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0082] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0083] The electronic device 100 implements the display function through a GPU, a display screen 191, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 191 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0084] The display screen 191 is used to display images, videos, etc. The display screen 191 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Mini-LED, Micro-OLED, Micro-OLED, quantum dot light-emitting diodes (QLED), etc.
[0085] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 191 and application processor.
[0086] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0087] Camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device may include 1 or N cameras 193, where N is a positive integer greater than 1. In the embodiment of the present application, the camera 193 can be used to capture video images.
[0088] Digital signal processors are used to process digital signals. In addition to processing digital image signals, they can also process other digital signals. For example, when an electronic device selects a frequency point, a digital signal processor is used to perform Fourier transform on the frequency point energy.
[0089] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. In this way, the electronic device can play or record videos in multiple coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0090] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and continuously self-learn. NPU can realize applications such as intelligent cognition of electronic devices, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0091] The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor, etc. For example, music playing, recording, etc. In the embodiment of the present application, the audio module 170 can be used to collect audio in recording video.
[0092] 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 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 are arranged in the processor 110. The speaker 170A, also known as the "speaker", is used to convert audio electrical signals into sound signals. The receiver 170B, also known as the "earpiece", is used to convert audio electrical signals into sound signals. The microphone 170C, also known as the "microphone" and "microphone", is used to convert sound signals into electrical signals. The headphone interface 170D is used to connect wired headphones. The headphone interface 170D can be a USB interface 130, or it can be a 3.5mm open mobile electronic equipment platform (open mobile terminal platform, OMTP) standard interface, and the cellular telecommunications industry association of the USA (cellular telecommunications industry association of the USA, CTIA) standard interface.
[0093] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, audio, video and other files are stored in the external memory card.
[0094] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory 121. For example, in an embodiment of the present application, the processor 110 can execute instructions stored in the internal memory 121, and the internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.). The data storage area may store data (such as video files) created during the use of the electronic device, etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0095] The button 190 includes a power button, a volume button, etc. The button 190 may be a mechanical button or a touch button. The indicator 192 may be an indicator light, which may be used to indicate the charging status, the change of the power, or may be used to indicate messages, missed calls, notifications, etc.
[0096] In the embodiment of the present application, the electronic device 100 is an electronic device that can run an operating system and install application programs. Optionally, the operating system running on the electronic device can be system, system, System, etc.
[0097] The following is a detailed introduction to the method for generating an interface image provided by an embodiment of the present application in conjunction with the accompanying drawings.
[0098] Scenario 1:
[0099] When the application is cold started, all layers of the interface image need to be redrawn, and the most and most complete resources are requested; the probability of a long time spent on memory request is relatively high.
[0100] In the method for generating an interface image provided by the embodiment of the present application, during the cold start of the application, when the onCreate event or onStart event of the Activity corresponding to the application interface of the application is detected, the BufferCache corresponding to each layer is applied. When SurfaceFlinger generates a layer, it only needs to bind the BufferCache applied in advance to the corresponding BufferQueue. The time consumed in applying for memory will not affect the speed of generating the interface image.
[0101] For example, Figure 8 As shown, the method for generating an interface image provided by the embodiment of the present application may include:
[0102] S801. The surface synthesis (SurfaceFlinger) service obtains the attribute information of each layer contained in a frame of interface image of the electronic device.
[0103] Exemplarily, if the interface image includes an application interface layer, the SurfaceFlinger service obtains the attribute information of the application interface layer. Optionally, if the interface image includes at least one of a status bar layer, a navigation bar layer, and a wallpaper layer, the SurfaceFlinger service also obtains the attribute information of at least one of the status bar layer, the navigation bar layer, and the wallpaper layer.
[0104] S802: When a creation (onCreate) event or a start (onStart) event of an activity (Activity) corresponding to the application interface of the application is detected, the application process notifies the surface synthesis (SurfaceFlinger) service to apply for the cache (BufferCache) corresponding to each layer of the interface image.
[0105] S803. The surface synthesis (SurfaceFlinger) service applies for the cache (BufferCache) corresponding to each layer according to the attribute information of each layer included in the electronic device interface image.
[0106] In one implementation, the surface synthesis (SurfaceFlinger) service applies for the cache (BufferCache) corresponding to the application interface layer according to the attribute information of the application interface layer. If there is attribute information of the status bar layer, the surface synthesis (SurfaceFlinger) service also applies for the cache (BufferCache) corresponding to the status bar layer according to the attribute information of the status bar layer; if there is attribute information of the navigation bar layer, the surface synthesis (SurfaceFlinger) service also applies for the cache (BufferCache) corresponding to the navigation bar layer according to the attribute information of the navigation bar layer; if there is attribute information of the wallpaper layer, the surface synthesis (SurfaceFlinger) service also applies for the cache (BufferCache) corresponding to the wallpaper layer according to the attribute information of the wallpaper layer.
[0107] S804, upon receiving the Vsync signal, the surface synthesis (SurfaceFlinger) service puts the graphic data of each layer into the buffer cache (BufferCache) corresponding to the layer, and binds the buffer cache (BufferCache) of each layer to the buffer queue (BufferQueue) of the corresponding layer.
[0108] In one implementation, after receiving the Vsync signal, the SurfaceFlinger service determines the size of the space occupied by the cache corresponding to the layer based on the saved attribute information of the layer, and searches for the corresponding cache (BufferCache) that has been applied for in advance based on the size of the space occupied by the cache. The SurfaceFlinger service puts the graphic data of the layer into the cache (BufferCache) corresponding to the layer, and binds the cache (BufferCache) of each layer to the buffer queue (BufferQueue) of the corresponding layer.
[0109] S805: The SurfaceFlinger service generates an application interface layer. Optionally, the SurfaceFlinger service also generates at least one of a status bar layer, a wallpaper layer, and a navigation bar layer.
[0110] S806, the synthesis rendering component (Composer) renders and synthesizes each layer to generate an electronic device interface image.
[0111] S807: When the next Vsync signal arrives, the display driver displays the electronic device interface image on the screen.
[0112] During this process, the surface synthesis (SurfaceFlinger) service can obtain the attribute information of each layer contained in a frame of the interface image of the electronic device in a variety of different ways.
[0113] In some embodiments, a software development kit (SDK) is provided for application process calls. The application process detects that the application interface Activity is executed by the onCreate event or the onStart event, and calls the SDK to transmit the attribute information of the application interface layer to the SurfaceFlinger service. The attribute information of the layer may include the width and height of the layer, the pixel information of the interface image, etc.
[0114] For example, Fig. 9 As shown, in response to the user clicking the application icon on the desktop, the application starts. The application interface Activity is executed with the onCreate event (or onStart event), and the application process calls the SDK to transmit the attribute information of the application interface layer to the SurfaceFlinger service. The SurfaceFlinger service obtains the attribute information of the application interface layer.
[0115] Optionally, the SurfaceFlinger service also obtains property information of the status bar layer, wallpaper layer, and navigation bar layer from the system process.
[0116] In this way, the SurfaceFlinger service obtains the attribute information of each layer contained in a frame of the interface image of the electronic device. Optionally, the SurfaceFlinger service saves the attribute information of each layer contained in a frame of the interface image, which may include the attribute information of the application interface layer, the attribute information of the status bar layer, the attribute information of the wallpaper layer, and the attribute information of the navigation bar layer. It can be understood that the interface images of different applications may include different numbers of display layers. For example, in some examples, the interface image includes the application interface layer and the status bar layer, and the SurfaceFlinger service obtains the attribute information of the application interface layer through the SDK interface, and obtains the attribute information of the status bar layer from the system process. In other examples, the interface image includes the application interface layer, and the SurfaceFlinger service obtains the attribute information of the application interface layer through the SDK interface. In some other examples, the interface image includes the application interface layer, the status bar layer, and the navigation bar layer, and the SurfaceFlinger service obtains the attribute information of the application interface layer through the SDK interface, and obtains the attribute information of the status bar layer and the attribute information of the navigation bar layer from the system process.
[0117] In one implementation, when the application is cold started for the first time, the application process calls the SDK to transmit the attribute information of the application interface layer to the SurfaceFlinger service. The SurfaceFlinger service saves the attribute information of each layer of the interface image. The application process then sends a first command to the SurfaceFlinger service to notify the SurfaceFlinger service to apply for the cache corresponding to each layer. When the application is cold started subsequently, the application process detects that the application interface Activity is executed by the onCreate event or the onStart event, and sends the first command to the SurfaceFlinger service. Of course, in another implementation, the application process can also call the SDK to transmit the attribute information of the application interface layer to the SurfaceFlinger service every time it is cold started. The embodiments of the present application are not limited to this.
[0118] The SurfaceFlinger service receives the first command and applies for the cache (BufferCache) corresponding to each layer according to the attribute information of each layer contained in the saved interface image. For example, the SurfaceFlinger service determines that the size of the space occupied by the cache (BufferCache) corresponding to the application interface layer is the first value according to the attribute information of the application interface layer, and applies to the kernel for the cache with the first value as the cache corresponding to the application interface layer. For example, the SurfaceFlinger service determines that the size of the space occupied by the cache (BufferCache) corresponding to the status bar layer is the second value according to the attribute information of the status bar layer, and applies to the kernel for the cache with the second value as the cache corresponding to the status bar layer. For example, the SurfaceFlinger service determines that the size of the space occupied by the cache (BufferCache) corresponding to the navigation bar layer is the third value according to the attribute information of the navigation bar layer, and applies to the kernel for the cache with the third value as the cache corresponding to the navigation bar layer. For example, the SurfaceFlinger service determines that the size of the space occupied by the cache (BufferCache) corresponding to the wallpaper layer is the fourth value according to the attribute information of the wallpaper layer, and applies to the kernel for the cache with the fourth value as the cache corresponding to the wallpaper layer.
[0119] The screen periodically sends Vsync signals to the application process and the system process. When the first Vsync signal is received, the SurfaceFlinger service puts the graphics data of the application interface layer into the buffer cache corresponding to the application interface layer that has been applied for in advance, and binds the buffer cache corresponding to the application interface layer to the buffer queue corresponding to the application interface layer. The SurfaceFlinger service generates the application interface layer.
[0120] If the interface image includes any one of the status bar layer, wallpaper layer and navigation bar layer, the surface synthesis (SurfaceFlinger) service also generates the corresponding layer. Among them, if the interface image includes the status bar layer, the surface synthesis (SurfaceFlinger) service puts the graphics data of the status bar layer into the cache (BufferCache) corresponding to the status bar layer applied in advance, and binds the cache (BufferCache) corresponding to the status bar layer to the buffer queue (BufferQueue) corresponding to the status bar layer; if the interface image includes the navigation bar layer, the surface synthesis (SurfaceFlinger) service puts the graphics data of the navigation bar layer into the cache (BufferCache) corresponding to the navigation bar layer applied in advance, and binds the cache (BufferCache) corresponding to the navigation bar layer to the buffer queue (BufferQueue) corresponding to the navigation bar layer; if the interface image includes the wallpaper layer, the surface synthesis (SurfaceFlinger) service puts the graphics data of the wallpaper layer into the cache (BufferCache) corresponding to the wallpaper layer applied in advance, and binds the cache (BufferCache) corresponding to the wallpaper layer to the buffer queue (BufferQueue) corresponding to the wallpaper layer.
[0121] The composite rendering component (Composer) renders and synthesizes each layer of the interface image to generate an electronic device interface image. When the next Vsync signal (second Vsync signal) arrives, the display driver displays the electronic device interface image on the screen.
[0122] In one implementation, when an application is uninstalled from an electronic device, a surface composition (SurfaceFlinger) service clears the attribute information of each layer included in the saved interface image of the application.
[0123] In other implementations, for applications that do not use the SDK, the SurfaceFlinger service obtains the attribute information of the application interface layer through dynamic learning.
[0124] For example, Fig.10 As shown, in the first N cold starts of an application, Figure 6 The memory application method shown in (a) applies for layer cache. That is, after receiving the attribute information of the application interface layer sent by the application process, the layer cache is applied when the layer is generated. Wherein, N is a preset value, for example, N=5.
[0125] After receiving the attribute information of the application interface layer sent by the application process, the SurfaceFlinger service learns the attribute information of the application interface layer. In one implementation, if it is determined that the attribute information of the application interface layer sent by the same application process n times (n is less than or equal to N) is the same, the attribute information of the application interface layer of the application process is obtained.
[0126] Optionally, the SurfaceFlinger service also obtains property information of the status bar layer, wallpaper layer, and navigation bar layer from the system process.
[0127] In this way, the SurfaceFlinger service obtains the attribute information of each layer contained in a frame of the interface image of the electronic device. Optionally, the SurfaceFlinger service saves the attribute information of each layer contained in a frame of the interface image, which may include the attribute information of the application interface layer, the attribute information of the status bar layer, the attribute information of the wallpaper layer, and the attribute information of the navigation bar layer.
[0128] refer to Fig.11 , when the application is cold started later, the application process detects that the application interface Activity is executed with the onCreate event or onStart event, and sends a first command to the SurfaceFlinger service. The SurfaceFlinger service receives the first command and applies for the cache (BufferCache) corresponding to each layer according to the attribute information of each layer contained in the saved interface image. For example, the SurfaceFlinger service determines that the size of the space occupied by the cache (BufferCache) corresponding to the application interface layer is the first value according to the attribute information of the application interface layer, and applies to the kernel for the cache with the first value as the cache corresponding to the application interface layer. For example, the SurfaceFlinger service determines that the size of the space occupied by the cache (BufferCache) corresponding to the status bar layer is the second value according to the attribute information of the status bar layer, and applies to the kernel for the cache with the second value as the cache corresponding to the status bar layer. For example, the SurfaceFlinger service determines that the size of the space occupied by the cache (BufferCache) corresponding to the navigation bar layer is the third value according to the attribute information of the navigation bar layer, and applies to the kernel for the cache with the third value as the cache corresponding to the navigation bar layer. For example, the SurfaceFlinger service determines that the size of the space occupied by the cache (BufferCache) corresponding to the wallpaper layer is a fourth value according to the attribute information of the wallpaper layer, and applies to the kernel for the cache occupying the fourth value as the cache corresponding to the wallpaper layer.
[0129] The screen periodically sends Vsync signals to the application process and the system process. When the first Vsync signal is received, the SurfaceFlinger service puts the graphics data of the application interface layer into the buffer cache corresponding to the application interface layer that has been applied for in advance, and binds the buffer cache corresponding to the application interface layer to the buffer queue corresponding to the application interface layer. The SurfaceFlinger service generates the application interface layer.
[0130] If the interface image includes any one of the status bar layer, wallpaper layer and navigation bar layer, the surface synthesis (SurfaceFlinger) service generates the corresponding layer. Among them, if the interface image includes the status bar layer, the surface synthesis (SurfaceFlinger) service puts the graphics data of the status bar layer into the cache (BufferCache) corresponding to the status bar layer that has been applied for in advance, and binds the cache (BufferCache) corresponding to the status bar layer to the buffer queue (BufferQueue) corresponding to the status bar layer; if the interface image includes the navigation bar layer, the surface synthesis (SurfaceFlinger) service puts the graphics data of the navigation bar layer into the cache (BufferCache) corresponding to the navigation bar layer that has been applied for in advance, and binds the cache (BufferCache) corresponding to the navigation bar layer to the buffer queue (BufferQueue) corresponding to the navigation bar layer; if the interface image includes the wallpaper layer, the surface synthesis (SurfaceFlinger) service puts the graphics data of the wallpaper layer into the cache (BufferCache) corresponding to the wallpaper layer that has been applied for in advance, and binds the cache (BufferCache) corresponding to the wallpaper layer to the buffer queue (BufferQueue) corresponding to the wallpaper layer.
[0131] The composite rendering component (Composer) renders and synthesizes each layer of the interface image to generate an electronic device interface image. When the next Vsync signal (second Vsync signal) arrives, the display driver displays the electronic device interface image on the screen.
[0132] In one implementation, when an application is uninstalled from an electronic device, a surface composition (SurfaceFlinger) service clears the attribute information of each layer included in the saved interface image of the application.
[0133] The method for generating an interface image provided by an embodiment of the present application, during the cold start process of the application, when the onCreate event or onStart event of the Activity corresponding to the application interface of the application is detected, the BufferCache corresponding to each layer such as the application interface layer, the status bar layer, the navigation bar layer, the wallpaper layer, etc. is applied. When the SurfaceFlinger service receives the Vsync signal to generate the layer, it only needs to bind each BufferCache applied in advance to the corresponding BufferQueue respectively, and there is no need to apply for memory in real time when generating the layer. The time consumed in applying for memory will not affect the speed of generating the interface image. In this way, the problem of the interface image not being ready when the next Vsync signal arrives is avoided, and the probability of frame loss on the display of the electronic device is reduced.
[0134] Scenario 2:
[0135] When the application is running in the foreground, the electronic device switches between horizontal and vertical screens, or the folding screen of the electronic device is unfolded or folded, some layers of the electronic device interface image change and need to be redrawn, and the probability of a long memory application time is relatively high. For example, when the horizontal and vertical screens are switched, the application interface layer of the electronic device interface image changes and needs to be redrawn. For example, when the folding screen is unfolded or folded, the status bar layer, navigation bar layer, and wallpaper layer of the electronic device interface image will change and need to be redrawn.
[0136] In the method for generating an interface image provided by an embodiment of the present application, when a horizontal or vertical screen switching event or a folding screen unfolding event or a folding screen folding event is detected during the application running process, the BufferCache corresponding to each layer that has changed is applied. When SurfaceFlinger generates a layer, it only needs to bind the BufferCache applied in advance to the corresponding BufferQueue. The time consumed in applying for memory will not affect the speed of generating the interface image.
[0137] For example, Fig.12 As shown, the method for generating an interface image provided by the embodiment of the present application may include:
[0138] S901. In the first stage, the surface synthesis (SurfaceFlinger) service obtains through learning the attribute information of each layer of the electronic device interface image that changes when a horizontal or vertical screen switching event, a folding screen expansion event, or a folding screen folding event occurs.
[0139] The first stage is to learn the attribute information of each layer of the electronic device interface image that changes when a horizontal or vertical screen switching event, a folding screen unfolding event, or a folding screen folding event occurs. For example, the first stage is a preset period of time, or the first stage is the process of an application running on the electronic device for S (S is a preset value) times.
[0140] For example, in the first stage, when a horizontal or vertical screen switching event or a folding screen expansion event or a folding screen folding event occurs during the application running, a memory application method in conventional technology is used to apply for layer cache. That is, a layer cache is applied when a layer is generated.
[0141] refer to Fig.13 In one example, a horizontal-to-vertical switching event occurs during the running of an application. After the SurfaceFlinger service receives the attribute information of the application interface layer in the vertical state of the electronic device sent by the application process, the SurfaceFlinger service applies for the cache of the application interface layer based on the attribute information of the application interface layer in the vertical state of the electronic device, and adds it to the cache queue of the application interface layer. The SurfaceFlinger service learns the attribute information of the application interface layer in the vertical state of the electronic device. In one implementation method, if it is determined that m horizontal-to-vertical switching events occur during the running of the application, and the attribute information of the application interface layer in the vertical state of the electronic device sent by each application process is the same, then the attribute information of the application interface layer of the application process in the vertical state of the electronic device is obtained. Wherein, m is a preset value, such as m=5.
[0142] In another example, when a switching event from portrait to landscape occurs during the running of an application, after the SurfaceFlinger service receives the attribute information of the application interface layer of the electronic device in the landscape state sent by the application process, the SurfaceFlinger service applies for the cache of the application interface layer according to the attribute information of the application interface layer of the electronic device in the landscape state, and adds it to the cache queue of the application interface layer. The SurfaceFlinger service learns the attribute information of the application interface layer of the electronic device in the landscape state. In one implementation method, if it is determined that when the switching event from portrait to landscape occurs m times during the running of the application, the attribute information of the application interface layer of the electronic device in the landscape state sent by each application process is the same, then the attribute information of the application interface layer of the application process in the landscape state of the electronic device is obtained.
[0143] In another example, if the interface image includes at least one of a status bar layer, a navigation bar layer, and a wallpaper layer. When a folding screen unfolding event occurs during the running of the application, after the SurfaceFlinger service receives at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the unfolded state of the folding screen sent by the system process, the SurfaceFlinger service applies for a cache of the corresponding layer according to at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the unfolded state of the folding screen, and joins the cache queue of the corresponding layer. The SurfaceFlinger service learns at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the unfolded state of the folding screen. In one implementation, if it is determined that m folding screen unfolding events occur during the running of the application, at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the unfolded state of the folding screen sent by the system process each time is the same, then at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the unfolded state of the folding screen is obtained.
[0144] In another example, if the interface image includes at least one of a status bar layer, a navigation bar layer, and a wallpaper layer. When a folding screen folding event occurs during the running of the application, after the SurfaceFlinger service receives at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the folding screen folding state sent by the system process, the SurfaceFlinger service applies for a cache of the corresponding layer according to at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the folding screen folding state, and joins the cache queue of the corresponding layer. The SurfaceFlinger service learns at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the folding screen folding state. In one implementation, if it is determined that m folding screen folding events occur during the running of the application, at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the folding screen folding state sent by the system process each time is the same, then at least one of the status bar layer attribute information, the navigation bar layer attribute information, and the wallpaper layer attribute information of the electronic device in the folding screen folding state is obtained.
[0145] In this way, the SurfaceFlinger service obtains the attribute information of the layers that have changed in the various layers contained in the electronic device interface image when a horizontal or vertical screen switching event or a folding screen expansion event or a folding screen folding event occurs. Optionally, the SurfaceFlinger service saves the attribute information of each layer contained in the interface image, which may include the attribute information of the application interface layer, the attribute information of the status bar layer, the attribute information of the wallpaper layer, and the attribute information of the navigation bar layer. It can also include the attribute information of each layer contained in the interface image when the electronic device is in the vertical screen state, the electronic device is in the horizontal screen state, the electronic device is in the expanded state of the folding screen, and the electronic device is in the folded state of the folding screen.
[0146] S902. In the second stage, a horizontal screen switching to vertical screen event, a vertical screen switching to horizontal screen event, a folding screen expansion event, or a folding screen folding event is detected, and the application process notifies the surface synthesis (SurfaceFlinger) service to apply for the cache (BufferCache) corresponding to the changed layer.
[0147] The second stage is the stage where the attribute information of each layer contained in the interface image has been obtained when the electronic device is in the vertical screen state, the horizontal screen state, the unfolded state of the electronic device's folding screen, and the folded state of the electronic device's folding screen.
[0148] In one example, the application process detects a landscape-to-portrait switching event, a portrait-to-landscape switching event, a folding screen expansion event, or a folding screen folding event, and sends the landscape-to-portrait switching event, the portrait-to-landscape switching event, the folding screen expansion event, or the folding screen folding event to the surface synthesis (SurfaceFlinger) service.
[0149] S903. The surface synthesis (SurfaceFlinger) service applies for the cache (BufferCache) of the corresponding layer according to the saved attribute information of the changed layer. The surface synthesis (SurfaceFlinger) service also updates the saved attribute information of the changed layer.
[0150] In one implementation, upon receiving an event of switching from landscape to portrait, the surface synthesis (SurfaceFlinger) service applies for a cache (BufferCache) corresponding to the application interface layer based on the saved attribute information of the application interface layer in the portrait state of the electronic device. Optionally, the surface synthesis (SurfaceFlinger) service also releases the cache (BufferCache) corresponding to the application interface layer applied for in the landscape state of the electronic device last time. Furthermore, the surface synthesis (SurfaceFlinger) service updates the saved attribute information of the application interface layer to the attribute information of the application interface layer in the portrait state of the electronic device.
[0151] In one implementation, upon receiving an event of switching from portrait to landscape, the surface synthesis (SurfaceFlinger) service applies for a cache (BufferCache) corresponding to the application interface layer based on the saved attribute information of the application interface layer in the landscape state of the electronic device. Optionally, the surface synthesis (SurfaceFlinger) service also releases the cache (BufferCache) corresponding to the application interface layer applied for in the portrait state of the electronic device last time. Furthermore, the surface synthesis (SurfaceFlinger) service updates the saved attribute information of the application interface layer to the attribute information of the application interface layer in the landscape state of the electronic device.
[0152] In one implementation, upon receiving a folding screen unfolding event, the surface synthesis (SurfaceFlinger) service applies for the cache (BufferCache) corresponding to each layer according to at least one of the saved status bar layer attribute information, navigation bar layer attribute information, and wallpaper layer attribute information when the folding screen of the electronic device is unfolded. Optionally, the surface synthesis (SurfaceFlinger) service also releases the cache (BufferCache) corresponding to at least one of the status bar layer, navigation bar layer, and wallpaper layer applied for the last time when the folding screen of the electronic device was folded. Furthermore, the surface synthesis (SurfaceFlinger) service updates the saved attribute information of at least one of the status bar layer, navigation bar layer, and wallpaper layer to the attribute information of at least one of the status bar layer, navigation bar layer, and wallpaper layer when the folding screen of the electronic device is unfolded.
[0153] In one implementation, when a folding screen event is received, the surface synthesis (SurfaceFlinger) service applies for the cache (BufferCache) corresponding to each layer according to at least one of the saved attribute information of the status bar layer, the attribute information of the navigation bar layer, and the attribute information of the wallpaper layer when the folding screen of the electronic device is folded. Optionally, the surface synthesis (SurfaceFlinger) service also releases the cache (BufferCache) corresponding to at least one of the status bar layer, the navigation bar layer, and the wallpaper layer applied for when the folding screen of the electronic device was unfolded the last time. Furthermore, the surface synthesis (SurfaceFlinger) service updates the saved attribute information of at least one of the status bar layer, the navigation bar layer, and the wallpaper layer to the attribute information of at least one of the status bar layer, the navigation bar layer, and the wallpaper layer when the folding screen of the electronic device is folded.
[0154] S904, upon receiving the Vsync signal, the surface synthesis (SurfaceFlinger) service puts the graphic data of each layer into the buffer cache (BufferCache) corresponding to the layer, and binds the buffer cache (BufferCache) of each layer to the buffer queue (BufferQueue) of the corresponding layer.
[0155] In one implementation, after receiving the Vsync signal, the SurfaceFlinger service determines the size of the space occupied by the cache corresponding to each layer based on the saved attribute information of each layer, and searches for the corresponding cache (BufferCache) that has been applied for in advance based on the size of the space occupied by the cache. The SurfaceFlinger service puts the graphic data of the layer into the cache (BufferCache) corresponding to the layer, and binds the cache (BufferCache) of each layer to the buffer queue (BufferQueue) of the corresponding layer.
[0156] S905: The SurfaceFlinger service generates an application interface layer. Optionally, the SurfaceFlinger service also generates at least one of a status bar layer, a wallpaper layer, and a navigation bar layer.
[0157] S906, the synthesis rendering component (Composer) renders and synthesizes each layer to generate an electronic device interface image.
[0158] S907: When the next Vsync signal arrives, the display driver displays the electronic device interface image on the screen.
[0159] In one implementation, when an application is uninstalled from an electronic device, a surface synthesis (SurfaceFlinger) service clears the attribute information of various layers contained in the saved interface image of the application when the electronic device is in portrait mode, landscape mode, unfolded mode, and folded mode.
[0160] In the method for generating an interface image provided by an embodiment of the present application, during the operation of the application, when the electronic device switches between horizontal and vertical screens, or when the folding screen of the electronic device is unfolded or folded, the SurfaceFlinger service applies for the BufferCache corresponding to the changed layer. When the SurfaceFlinger service receives a Vsync signal to generate a layer, it only needs to bind the BufferCache of each layer applied in advance to the corresponding BufferQueue respectively, and there is no need to apply for memory in real time when generating the layer. The time consumed in applying for memory will not affect the speed of generating the interface image. This avoids the problem of the interface image not being ready when the next Vsync signal arrives, and reduces the probability of frame loss when the electronic device displays the screen.
[0161] It is understandable that the electronic device provided in the embodiment of the present application includes a hardware structure and / or software module corresponding to each function in order to realize the above functions. Those skilled in the art should easily realize that, in conjunction with the units and algorithm steps of each example described in the embodiment disclosed herein, the embodiment of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiment of the present application.
[0162] The embodiment of the present application can divide the functional modules of the above-mentioned electronic device according to the above-mentioned method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0163] In one example, see Fig.14 , which shows a possible structural diagram of the electronic device involved in the above embodiment. The electronic device 1400 includes: a processing unit 1410 , a storage unit 1420 and a display unit 1430 .
[0164] The processing unit 1410 is used to control and manage the actions of the electronic device 1400 .
[0165] The storage unit 1420 is used to store program codes and data of the electronic device 1400 .
[0166] The display unit 1430 is used to display the interface of the electronic device 1400 .
[0167] Of course, the unit modules in the above-mentioned electronic device 1400 include but are not limited to the above-mentioned processing unit 1410, storage unit 1420 and display unit 1430.
[0168] Optionally, the electronic device 1400 may further include an audio unit, a communication unit, etc. The audio unit is used to collect audio, play audio, etc. The communication unit is used to support the electronic device 1400 to communicate with other devices.
[0169] The processing unit 1410 may be a processor or a controller, for example, a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The storage unit 1420 may be a memory. The display unit 1430 may be a display screen, etc. The audio unit may include a microphone, a speaker, etc. The communication unit may include a mobile communication unit and / or a wireless communication unit.
[0170] For example, the processing unit 1410 is a processor (such as Figure 7 The processor 110 shown in FIG. 14 ), the storage unit 1420 may be a memory (such as Figure 7 The internal memory 121 shown in FIG. 14 ), the display unit 1430 may be a display screen (such as Figure 7 The audio unit may be an audio module (such as Figure 7 The communication unit may include a mobile communication unit (such as Figure 7 The mobile communication module 150 shown) and the wireless communication unit (such as Figure 7 The wireless communication module 160 shown in FIG. 1 ). The electronic device 1400 provided in the embodiment of the present application may be Figure 7 The electronic device 100 shown in FIG. The processor, memory, display screen, etc. mentioned above may be connected together, for example, via a bus.
[0171] The embodiment of the present application also provides a chip system, which includes at least one processor and at least one interface circuit. The processor and the interface circuit can be interconnected by lines. For example, the interface circuit can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit can be used to send signals to other devices (such as a processor). Exemplarily, the interface circuit can read instructions stored in the memory and send the instructions to the processor. When the instructions are executed by the processor, the electronic device can perform the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiment of the present application.
[0172] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes each function or step executed by the mobile phone in the above-mentioned method embodiment.
[0173] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the mobile phone in the above method embodiment.
[0174] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0175] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0176] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0177] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0178] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0179] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A method for generating an interface image, applied to an electronic device, wherein a first application is installed on the electronic device, and an operating system of the electronic device includes a surface synthesis service and a synthesis rendering component, characterized in that: The method comprises: The surface synthesis service obtains attribute information of a first layer of a first interface image; the first interface image is an interface image of the first application, and the attribute information includes at least one of layer width, layer height, and pixel information of the interface image; At a first moment, the surface synthesis service applies for a first cache according to the attribute information of the first layer; At a second moment, the surface synthesis service binds the first cache to a buffer queue corresponding to the first layer; the second moment is a moment when the surface synthesis service receives a first vertical synchronization Vsync signal, and the first moment is earlier than the second moment; The surface synthesis service generates all the layers according to the buffer queues corresponding to all the layers included in the first interface image; The synthesis rendering component renders and synthesizes all the layers to generate the first interface image; At a third moment, the first interface image is displayed on the screen of the electronic device; the third moment is the moment when the second Vsync signal is sent, and the second Vsync signal is the next Vsync signal of the first vertical synchronization Vsync signal.
2. The method according to claim 1, characterized in that The surface synthesis service applies for a first cache according to the attribute information of the first layer, including: The surface synthesis service determines a first value according to the attribute information of the first layer, where the first value is the size of the space occupied by the first cache; The surface synthesis service applies for a first cache according to the first value.
3. The method according to claim 1 or 2, characterized in that: The first moment is the moment when the Activity corresponding to the first interface image is created or started.
4. The method according to claim 3, characterized in that The first layer is an application interface layer, and the surface synthesis service obtains the property information of the first layer of the first interface image including: The surface composition service obtains attribute information of the first layer from the process of the first application.
5. The method according to claim 3, characterized in that: The first layer is a status bar layer, a navigation bar layer or a wallpaper layer, and the surface synthesis service obtains the property information of the first layer of the first interface image including: The surface composition service obtains attribute information of the first layer from a process of the operating system.
6. The method according to claim 1 or 2, characterized in that: The first moment is the moment when a horizontal screen switching to vertical screen event, a vertical screen switching to horizontal screen event, a folding screen unfolding event, or a folding screen folding event is detected.
7. The method according to claim 6, characterized in that The first moment is the moment when a horizontal screen switching vertical screen event is detected, the first layer is an application interface layer, and the surface synthesis service applies for a first cache according to the attribute information of the first layer, including: The surface synthesis service applies for a first cache according to the attribute information of the application interface layer in the vertical screen state of the electronic device.
8. The method according to claim 6, characterized in that The first moment is the moment when a vertical screen switching horizontal screen event is detected, the first layer is an application interface layer, and the surface synthesis service applies for a first cache according to the attribute information of the first layer, including: The surface synthesis service applies for a first cache according to the attribute information of the application interface layer when the electronic device is in the horizontal screen state.
9. The method according to claim 6, characterized in that The first moment is a moment when a folding screen unfolding event is detected, the first layer includes at least one of a status bar layer, a navigation bar layer, and a wallpaper layer, and the surface synthesis service applies for a first cache according to attribute information of the first layer, including: The surface synthesis service applies for a first cache according to the attribute information of the first layer when the folding screen of the electronic device is in an unfolded state.
10. The method according to claim 6, characterized in that The first moment is a moment when a folding event of the folding screen is detected, the first layer includes at least one of a status bar layer, a navigation bar layer, and a wallpaper layer, and the surface synthesis service applies for a first cache according to attribute information of the first layer, including: The surface synthesis service applies for a first cache according to the attribute information of the first layer when the folding screen of the electronic device is in a folded state.
11. An electronic device, characterized in that: The electronic device comprises: a processor, a memory and a display screen, wherein the processor and the display screen are coupled to the memory; the memory is used to store computer program code; the computer program code comprises computer instructions, and when the processor executes the above-mentioned computer instructions, the electronic device executes the method described in any one of claims 1-10.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Image processing method and electronic equipment
CN115631258A
