WO2025217876A1 - 一种图像显示方法及相关设备 - Google Patents
一种图像显示方法及相关设备Info
- Publication number
- WO2025217876A1 WO2025217876A1 PCT/CN2024/088577 CN2024088577W WO2025217876A1 WO 2025217876 A1 WO2025217876 A1 WO 2025217876A1 CN 2024088577 W CN2024088577 W CN 2024088577W WO 2025217876 A1 WO2025217876 A1 WO 2025217876A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- application
- refresh rate
- electronic device
- screen
- rendering
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3234—Power saving characterised by the action undertaken
Definitions
- the present application relates to the field of terminal technology, and in particular to an image display method and related equipment.
- terminal devices also known as electronic devices
- screen refresh rate also known as the system refresh rate, or simply the refresh rate
- a high refresh rate can provide users with a better sliding interaction experience in complex scenarios.
- terminal devices In complex scenarios, terminal devices generally display multiple windows of multiple applications, but the focus of user operations at the same time is often only one window of an application.
- the present application provides an image display method and related devices. According to this method, when an electronic device simultaneously displays multiple windows of multiple applications, for the focus application and the application in the fling state, the electronic device can use a rendering frame rate equal to the current screen refresh rate to draw and render its screen, while for the non-focus application in the non-fling state, the electronic device can use a rendering frame rate lower than the current screen refresh rate to draw and render its screen. This method can avoid useless rendering caused by the non-focus application using a higher rendering frame rate, thereby reducing system load and power consumption.
- the present application provides an image display method.
- the method can be applied to an electronic device including a display screen.
- the electronic device can render the screen of the first application at a first frame rate to obtain a first screen, render the screen of the second application at a second frame rate to obtain a second screen, and synthesize the first screen and the second screen to obtain a first image, and then display the first image on the display screen at a first refresh rate.
- the first application is an application in a fling state or a focus application
- the second application is a non-focus application in a non-fling state (or a non-focus application that is not in a fling state).
- the first refresh rate is greater than the first threshold
- the first frame rate is equal to the first refresh rate
- the second frame rate is less than the first refresh rate.
- the electronic device can set different rendering frame rates for different applications, synthesize the application screens rendered at these different rendering frame rates, and then display the synthesized screens on the display screen, so as to achieve flexible adjustment of the application rendering frame rate.
- the electronic device can set a rendering frame rate lower than the screen refresh rate for some applications, thereby reducing the system load and power consumption caused by the rendering.
- the first application may belong to the Class A application mentioned below
- the second application may belong to the Class B application mentioned below.
- the first application may be a reading application as shown in FIG7A
- the second application may be a video application as shown in FIG7A
- the first screen may be the screen of window 2a
- the second screen may be Assuming that the screen of window 1a is used
- the first image may be an image synthesized by the screen of window 1a and the screen of window 2a as shown in FIG7A .
- the first frame rate may be r mentioned below, and the second frame rate may be Ri mentioned below.
- the first threshold may be the first refresh rate threshold mentioned below.
- the first refresh rate is the screen refresh rate used by the electronic device in the process of displaying the first image on the display screen.
- first application and the second application are applications that request the APP-VSync signal.
- the first image may change, that is, the screen of the first application included in the first image (that is, the first screen) may change, and the screen of the second application included in the first image (that is, the second screen) may also change.
- the method may further include: the electronic device may generate a VSync signal based on the first timer every first timing duration, and generate a second VSync signal accordingly every time Y first VSync signals are generated.
- the first timing duration is the reciprocal of the first refresh rate, and Y is an integer greater than 1.
- the electronic device renders the screen of the first application at the first frame rate, which may specifically include: the electronic device may render the screen of the first application based on the first VSync signal.
- the electronic device renders the screen of the second application at the second frame rate, which may specifically include: the electronic device renders the screen of the second application based on the second VSync signal.
- the electronic device can render the screen of the first application and the screen of the second application based on the VSync software timer that triggers the generation of the VSync signal, that is, an original timer of the electronic device is used to be responsible for the issuance of APP-VSync signals of multiple applications.
- VSync software timer that triggers the generation of the VSync signal
- an original timer of the electronic device is used to be responsible for the issuance of APP-VSync signals of multiple applications.
- there is no need to synchronize and calibrate multiple timers which is more convenient and has lower power consumption.
- the first VSync signal may be the VSync signal mentioned below (a hardware VSync signal or a software VSync signal), and the second VSync signal may be the APP-VSync signal mentioned below.
- the first timer may be the VSync software timer mentioned below, and the first timing duration may be understood as a VSync period.
- the first application renders its screen once each time it receives a first VSync signal.
- the second application renders its screen once each time it receives a second VSync signal.
- the electronic device may generate an App-VSync signal every x VSync cycles (or z VSync cycles) based on the first timer, and send the App-VSync signal to the second application.
- the first refresh rate is Y times the second frame rate.
- the method may further include: the electronic device may generate a first VSync signal based on a first timer at intervals of a first timing duration, and generate a second VSync signal based on a second timer at intervals of a second timing duration.
- the first timing duration is the inverse of the first refresh rate.
- the electronic device renders the screen of the first application at a first frame rate, which may specifically include: the electronic device may render the screen of the first application based on the first VSync signal.
- the electronic device renders the screen of the second application at a second frame rate, which may specifically include: the electronic device may render the screen of the second application based on the second frame rate.
- the VSync signal renders the screen of the second application, wherein the second timing duration is the inverse of the second frame rate.
- an electronic device can render the screen of a first application based on a VSync software timer that triggers the generation of a VSync signal, while creating another timer to render the screen of a second application.
- the electronic device can distribute App-VSync signals to the first application and the second application respectively based on two timers, without considering whether there is a multiple relationship between the rendering frame rate of the application and the first frame rate.
- the electronic device can more flexibly adjust the rendering frame rate of the application, without being limited to the application rendering frame rate must be divided by the screen refresh rate.
- the second timing duration can be understood as the timing duration defined by the second timer mentioned below. It is understood that the second timing duration can be an integer multiple of the first timing duration, or it can not be an integer multiple of the first timing duration. Its specific value can be set according to actual needs, and this application does not impose any restrictions on this.
- the first refresh rate is a first multiple of the second frame rate, and the first multiple is an integer greater than 1.
- the electronic device can use the original timer (for example, the VSync software timer) to distribute App-VSync signals to the first application and the second application.
- the original timer for example, the VSync software timer
- this method is more convenient, does not require synchronization calibration of multiple timers, and has lower power consumption.
- the first multiple may be equal to Y.
- the first refresh rate is not an integer multiple of the second frame rate.
- the electronic device when setting the second frame rate, is not limited to the application's rendering frame rate being an integer divisible by the screen refresh rate. This method can further increase the flexibility of adjusting the rendering frame rate. For example, when the first refresh rate is 120Hz, the electronic device can set the second frame rate to 90Hz, rather than being limited to 20Hz, 30Hz, 40Hz, and 60Hz.
- the method before rendering the screen of the first application at the first frame rate, may further include: in response to the first VSync signal, the electronic device may obtain the focus application (or the current focus application), the interaction state of the first application, and the interaction state of the second application, and determine the first frame rate and the second frame rate based on the focus application, the interaction state of the first application, and the interaction state of the second application.
- the interaction state includes a fling state and a non-fling state;
- electronic devices can use different rendering frame rates for different applications.
- electronic devices can use a high rendering frame rate, and for applications without user interaction, electronic devices can use a low rendering frame rate. This avoids useless rendering caused by using a high rendering frame rate for applications without user interaction, and can also reduce system load and power consumption.
- the first application may be a focus application that is not in a fling state.
- the method may further include: in response to a user operation on a screen of the second application in the first image (for example, a second screen), the electronic device may update the focus application from the first application to the second application; the electronic device may also set the screen refresh rate to the second refresh rate.
- the second refresh rate The refresh rate may be the highest refresh rate corresponding to the second application.
- the electronic device when a user triggers a change in the focus application, the electronic device can reset the screen refresh rate.
- the screen refresh rate can be set to the highest target refresh rate corresponding to the focus application. That is, the electronic device can set the current screen refresh rate based on the target refresh rate corresponding to the application that interacts with the user. In this way, the rendering resources can be better focused on the application that interacts with the user, thereby improving the user experience.
- the highest refresh rate corresponding to the application can be the upper limit of the target refresh rate range mentioned below, that is, the highest target refresh rate, and the lowest refresh rate corresponding to the application can be the lower limit of the target refresh rate range mentioned below, that is, the lowest target refresh rate.
- the method may further include: when the second refresh rate is greater than the first threshold, the electronic device may render the screen of the first application at a third frame rate to obtain a third screen, and render the screen of the second application at a fourth frame rate to obtain a fourth screen, and synthesize the third and fourth screens to obtain a second image, and then display the second image on the display screen at the second refresh rate.
- the third frame rate is less than the second refresh rate, and the fourth frame rate is equal to the second refresh rate.
- the electronic device when the focus application changes, can set the current screen refresh rate based on the highest target refresh rate corresponding to the focus application. Furthermore, the electronic device can determine whether the current screen refresh rate is at a high level (for example, whether the current screen refresh rate is greater than a first threshold). When the current screen refresh rate is high (or the highest target refresh rate corresponding to the focus application is high), the electronic device can reduce the rendering frame rate of some applications to reduce useless rendering.
- the second image when the electronic device displays the second image on the display screen at the second refresh rate, the second image may change, that is, the screen of the first application included in the second image (that is, the third screen) may change, and the screen of the second application included in the second image (that is, the fourth screen) may also change.
- the electronic device can determine whether the current screen refresh rate is greater than a first threshold. When the current screen refresh rate is greater than the first threshold, the electronic device can set the rendering frame rate of the first application and the rendering frame rate of the second application based on the focus application, the interaction state of the first application, and the interaction state of the second application.
- the method may further include: when the second refresh rate is less than or equal to the first threshold, the electronic device may render the screen of the first application at a fourth frame rate to obtain a fifth screen, and render the screen of the second application at a fourth frame rate to obtain a fourth screen, and synthesize the fifth screen and the fourth screen to obtain a third image. That is, when the second refresh rate is less than or equal to the first threshold, the electronic device may render the screen of the first application and the screen of the second application at a fourth frame rate, and synthesize the screen of the first application and the screen of the second application rendered at the fourth frame rate to obtain a third image. After obtaining the third image, the electronic device may also display the third image on the display screen at the second refresh rate.
- the electronic device when the focus application changes, can set the current screen refresh rate based on the highest target refresh rate corresponding to the focus application. Further, the electronic device can determine the current screen refresh rate. Whether the current screen refresh rate is at a high level (for example, whether the current screen refresh rate is greater than a first threshold). If the current screen refresh rate is not at a high level, the electronic device can directly render the first application and the second application based on the current screen refresh rate, that is, send an APP-VSync signal to the first application and the second application based on the screen refresh rate. Through this method, the electronic device does not lower the rendering frame rate of the application based on the screen refresh rate under all circumstances. For scenarios where the screen refresh rate is not high, the electronic device does not need to adjust the rendering frame rate of the application separately, so that the rendering frame rate of the application is equal to the screen refresh rate, which can simplify the process and reduce power consumption to a certain extent.
- the third image may change, that is, the screen of the first application included in the third image (that is, the fifth screen) may change, and the screen of the second application included in the third image (that is, the sixth screen) may also change.
- the method may further include: if no user operation on the image displayed on the display screen is detected within a preset time period, setting the screen refresh rate to a third refresh rate.
- the third refresh rate is less than the second refresh rate and greater than or equal to the minimum refresh rate corresponding to the second application.
- the electronic device can reduce the screen refresh rate and does not need to maintain it at a high level, thereby reducing power consumption.
- the preset duration can be set according to actual needs, and this application does not impose any specific restrictions on this.
- the present application provides an electronic device comprising a display screen, one or more memories, and one or more processors; the display screen is coupled to the one or more memories and the one or more processors, the display screen is used to display the drawn, rendered and synthesized images, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method described in the first aspect or any one of the implementations of the first aspect.
- the present application provides a computer storage medium comprising computer instructions, which, when executed on an electronic device, causes the electronic device to execute the method described in the first aspect or any one of the implementations of the first aspect.
- an embodiment of the present application provides a chip.
- the chip can be applied to an electronic device, and the chip includes one or more processors configured to invoke computer instructions to cause the electronic device to execute the method described in the first aspect or any one of the implementations of the first aspect.
- the chip system may be an application processor (AP) or a system on chip (SoC) including an AP.
- AP application processor
- SoC system on chip
- the method described in the first aspect or any one of the implementations of the first aspect may be implemented by an AP, and the method described in the second aspect or any one of the implementations of the second aspect may be implemented by an AP.
- the chip system may include an AP and other modules, wherein the other modules may be a modem processor (also referred to as a baseband processor).
- a modem processor also referred to as a baseband processor
- an embodiment of the present application provides a computer program product comprising instructions.
- the computer program product When the computer program product is run on an electronic device, the electronic device executes the method described in the first aspect or any one of the implementations of the first aspect. Described method.
- the electronic device provided in the second aspect, the computer storage medium provided in the third aspect, the chip provided in the fourth aspect, and the computer program product provided in the fifth aspect are all used to perform the method described in the first aspect or any one of the implementations of the first aspect. Therefore, the beneficial effects that can be achieved can be referenced to the beneficial effects of any possible implementation of the first aspect, and will not be repeated here.
- FIG1 is a schematic diagram of a user interface provided in an embodiment of the present application.
- FIG2 is a schematic diagram of another user interface provided in an embodiment of the present application.
- FIG3 is a schematic diagram of a rendering process provided by an embodiment of the present application.
- FIG4 is a schematic diagram of VSync signal distribution provided in an embodiment of the present application.
- FIG5 is a flow chart of an image display method provided in an embodiment of the present application.
- 6A-6C are schematic diagrams of triggering a fling state according to an embodiment of the present application.
- FIGS. 7A-7C are another set of user interface schematic diagrams provided in an embodiment of the present application.
- 7D-7E are schematic diagrams showing changes in a window sliding state according to an embodiment of the present application.
- FIG8A is a flowchart of another image display method provided in an embodiment of the present application.
- FIG8B is a flowchart of another image display method provided in an embodiment of the present application.
- FIG9A is a schematic diagram of another VSync signal distribution according to an embodiment of the present application.
- FIG9B is a schematic diagram of another VSync signal distribution according to an embodiment of the present application.
- FIG10 is a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application.
- FIG. 11A and 11B are flowcharts of another image display method provided in an embodiment of the present application.
- FIG12 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
- GUI Graphical User Interface
- control Components can include visual interface elements such as icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc.
- references to "embodiments” in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application.
- the appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments.
- an electronic device can display multiple windows of multiple applications, and can also display multiple windows of one application. It is understandable that the user interface of the application is displayed in the window of the application.
- the application running on the electronic device can be preset with a target refresh rate interval, such as: [60,60], [60,120], etc.
- the electronic device can refresh the screen displayed by the electronic device based on the target refresh rate interval set for the application (which can be simply referred to as the target refresh rate interval corresponding to the application).
- the target refresh rate intervals of different applications may be the same or different.
- the electronic device can refresh the screen displayed by the electronic device based on the target refresh rate interval of one of the applications.
- the overall system refresh rate policy adopted by the electronic device is to set the screen refresh rate based on the target refresh rate interval.
- a user can interact with one window of a single application at a time, and the multiple windows of the multiple applications displayed on the electronic device are refreshed according to the target refresh rate range corresponding to the application the user is interacting with. If the upper limit of the target refresh rate range corresponding to the application the user is interacting with is too high, the system load and power consumption will increase significantly, affecting the long-term stability of the system.
- this application records the application with which the user interacts as the focus application, the application window with which the user interacts as the focus window, and the application with which the user does not interact as the non-focus application.
- the screen refresh rate of the electronic device (i.e., the system refresh rate) can be set based on the target refresh rate interval corresponding to the focus application. Specifically, when the user has interactive operations on the electronic device, the screen refresh rate of the electronic device can be maintained at the upper limit of the target refresh rate interval corresponding to the focus application (for example, 90Hz or 120Hz). When the user stops interacting (for example, the user raises his hand after sliding on the display screen of the electronic device), the screen refresh rate of the electronic device can fall back to the lower limit of the target refresh rate interval corresponding to the focus application (for example, 60Hz or lower frequency).
- the screen refresh rate of the electronic device can be set to a value lower than the upper limit of the target refresh rate interval and higher than the lower limit of the target refresh rate interval.
- the upper limit of the target refresh rate interval can also be referred to as the maximum target refresh rate
- the lower limit of the target refresh rate interval can also be referred to as the minimum target refresh rate.
- the electronic device can simultaneously display the user interface of application 1 and the user interface of application 2, and detect a user operation on the user interface of application 2. That is, application 2 is the focus application, and application 1 is the non-focus application.
- the upper limit of the target refresh rate interval originally set for application 1 by the electronic device i.e., the highest target refresh rate corresponding to application 1
- the upper limit of the target refresh rate interval originally set for application 2 i.e., the highest target refresh rate corresponding to application 2
- the electronic device detects the user operation acting on the user interface of application 2, it can refresh its displayed screen (including the user interface of application 1 and the user interface of application 2) according to the highest target refresh rate corresponding to the focus application (i.e., application 2), i.e., 120Hz.
- the highest target refresh rate corresponding to application 1 is only 60Hz.
- the electronic device refreshes the user interface of application 1 at 120Hz, its refresh frequency will exceed expectations (i.e., the actual refresh frequency used will be greater than the highest target refresh rate), and application 1 is a non-focus application. Using a high refresh rate will cause useless rendering and increase additional system load.
- the refresh frequency mentioned here and the rendering refresh frequency mentioned in Table 1 can be understood as the rendering frame rate mentioned later, that is, the frequency at which the application draws and renders the screen (or a frame of image).
- the upper limit of the target refresh rate range originally set by the electronic device for Application 1 and Application 2 is 60Hz, that is, the maximum target refresh rate corresponding to Application 1 and Application 2 is 60Hz.
- the electronic device detects the user operation acting on the user interface of Application 2, it can refresh its displayed screen (including the user interface of Application 1 and the user interface of Application 2) according to the maximum target refresh rate corresponding to Application 2, that is, 60Hz.
- the maximum target refresh rate corresponding to Application 1 is 60Hz, and it is expected that the electronic device refreshes its user interface at 60Hz without adding additional system load.
- the upper limit of the target refresh rate range originally set by the electronic device for Application 1 and Application 2 is 120Hz, that is, the maximum target refresh rate corresponding to Application 1 and Application 2 is 120Hz.
- the electronic device detects the user operation acting on the user interface of Application 2, it can refresh its displayed screen (including the user interface of Application 1 and the user interface of Application 2) according to the maximum target refresh rate corresponding to the focus application (i.e., Application 2), i.e., 120Hz.
- the maximum target refresh rate corresponding to Application 1 is also 120Hz, Application 1 is a non-focus application, and using a high refresh rate will cause useless rendering and increase additional system load.
- the upper limits of the target refresh rate ranges originally set by the electronic device for Application 1 and Application 2 are 120Hz and 60Hz respectively, that is, the maximum target refresh rate corresponding to Application 1 is 120Hz, and the maximum target refresh rate corresponding to Application 2 is 60Hz.
- the electronic device detects that the user acting on Application 2 After a user operation on the interface, the displayed screen (including the user interface of Application 1 and the user interface of Application 2) can be refreshed according to the highest target refresh rate corresponding to the focus application (i.e., Application 2), i.e., 60Hz. It can be understood that the highest target refresh rate corresponding to Application 1 is 120Hz, and Application 1 is a non-focus application.
- the electronic device uses 60Hz to refresh the user interface of Application 1 without causing useless rendering, and naturally does not increase additional system load.
- the electronic device will refresh the user interface of the focused application and the user interface of non-focused applications according to the target refresh rate range corresponding to the focused application. If the highest target refresh rate corresponding to the focused application is high, the above refresh method may cause the refresh frequency of non-focused applications to exceed the expected level, resulting in useless rendering and increasing system load.
- a window 1a and a window 2a may be displayed on the display screen of an electronic device.
- Window 1a displays the user interface of a video application
- window 2a displays the user interface of a reading application.
- the maximum target refresh rate corresponding to the video application is 60 Hz
- the maximum target refresh rate corresponding to the reading application is 120 Hz.
- the electronic device can detect a user operation (e.g., a click operation) acting on window 2a. In response to the user operation, the electronic device can determine that window 2a is the focus window and the reading application is the focus application.
- the electronic device can use the maximum target refresh rate corresponding to the reading application to refresh the entire screen displayed on the display screen (including the screen displayed in window 1a and the screen displayed in window 2a).
- the maximum target refresh rate corresponding to the video application is only 60 Hz. If the electronic device refreshes the user interface of the video application at 120 Hz, its refresh frequency will exceed expectations (i.e., the actual refresh frequency used will be greater than the maximum target refresh rate), and the video application is a non-focus application. Using a high refresh rate will cause useless rendering and increase additional system load.
- window 3a, window 3b and window 2a may be displayed on the display screen of the electronic device.
- window 3a and window 3b display the user interface of a shopping application
- window 2a displays the user interface of a reading application.
- the highest target refresh rate corresponding to the shopping application and the reading application is 120Hz.
- the electronic device can detect the user operation (for example, a click operation) acting on window 2a. In response to the user operation, the electronic device can determine that window 2a is the focus window and the reading application is the focus application. Furthermore, the electronic device can use the highest target refresh rate corresponding to the reading application to refresh the entire screen displayed on the display screen (including the screen displayed in window 3a, window 3b, and the screen displayed in window 2a).
- the shopping application is a non-focus application, and using a high refresh rate will cause useless rendering and increase additional system load.
- an embodiment of the present application provides an image display method and related equipment. According to this method, when an electronic device displays multiple windows of multiple applications at the same time, for the focus application and the application in the fling state of interaction, the electronic device can use the current screen refresh rate as its rendering frame rate for drawing and rendering, and for the non-focus application in the non-fling state of interaction, the electronic device can use a rendering frame rate lower than the current screen refresh rate for drawing and rendering. This method can avoid useless rendering caused by the high rendering frame rate used by the non-focus application, thereby reducing system load and power consumption.
- This application relates to a rendering mechanism. To facilitate understanding, the following first briefly introduces the rendering mechanism (also known as the VSync mechanism).
- the graphics rendering pipeline involves the application (referred to as the application), the image synthesis system (SurfaceFlinger) and the display Screen (also known as screen).
- SurfaceFlinger can also be called an image synthesizer.
- the application first needs to draw and render it, and then SurfaceFlinger merges and renders it into the frame buffer (framebuffer), and finally sends it to the display for display.
- VSync vertical synchronization
- the application starts UI rendering
- the second VSync cycle arrives (or the second VSync signal is generated)
- SurfaceFlinge can synthesize the layers
- the display obtains the synthesized data and displays it on the display to present it to the user.
- the application when the first VSync cycle arrives, the application can complete the UI rendering of the first frame; when the second VSync cycle arrives, SurfaceFlinge can complete the layer synthesis of the first frame, and the application can complete the UI rendering of the second frame; when the third VSync cycle arrives, the display can complete the display of the first frame, SurfaceFlinge can complete the layer synthesis of the second frame, and the application can complete the UI rendering of the third frame; when the fourth VSync cycle arrives, the display can complete the display of the second frame, SurfaceFlinge can complete the layer synthesis of the third frame, and the application can complete the UI rendering of the fourth frame; when the fifth VSync cycle arrives, the display can complete the display of the third frame, SurfaceFlinge can complete the layer synthesis of the fourth frame, and the application can complete the UI rendering of the fifth frame.
- VSync signal generated by hardware (for example, a hardware module related to a hardware synthesizer), and simulated by software (for example, VSyncThread).
- hardware or software can generate a VSync signal according to a fixed period, and the fixed period can be referred to as a VSync period.
- the VSync signal generated by hardware can be referred to as a hardware VSync signal
- the VSync signal generated by software can be referred to as a software VSync signal.
- the VSync period is determined by the screen refresh rate.
- the screen refresh rate can be 60Hz
- the VSync period can be the inverse of the screen refresh rate, that is, 16.67 milliseconds (ms).
- the hardware-generated VSync signal (also referred to as an HW-VSync signal) may be a pulse signal.
- software simulation of the VSync signal may include: the electronic device samples the hardware-generated VSync signal, creates a model, and then outputs the VSync signal.
- the VSync signal generated by the hardware may be a hardware VSync event received by a hardware synthesizer (HWC).
- HWC hardware synthesizer
- a hardware VSync event callback can be registered in the HWC, and when a hardware VSync event arrives, the vsync function of the HWC is called back.
- the HWC After the HWC receives the hardware VSync event, it adds the hardware VSync event to the VSync event sample of the DispSync through SurfaceFlinger.
- the hardware VSync event is stopped, and the software generates a VSync event based on the calculation result of the sample, that is, generates a VSync signal.
- the electronic device needs to regenerate the VSync event through the hardware and collect the hardware VSync event sample again.
- the electronic device can generate a VSync signal through hardware or simulate a VSync signal through software (the hardware VSync signal/software VSync signal shown in Figure 4), and virtualize the VSync signal into an App-VSync signal (also called a VSync-app signal) and an SF-VSync signal (also called a VSync-sf signal) through a VSync signal virtualization thread (for example, DispSyncThread).
- the electronic device can receive the VSync signal through two event threads (EventThread) respectively.
- EventThread two event threads
- EventThread(APP) receives the APP-VSync signal
- EventThread(SF) the event thread that receives the SF-VSync signal
- EventThread(SF) the event thread that receives the SF-VSync signal
- EventThread(SF) the event thread that receives the SF-VSync signal
- it can wake up the corresponding application and drive the application to perform UI rendering.
- the UI thread of the application is awakened, it performs UI rendering work (including input event processing, animation, drawing, etc.).
- EventThread(SF) receives the SF-VSync signal, it can wake up SurfaceFlinger and drive SurfaceFlinger to perform layer merging.
- Figure 5 is a flow chart of an image display method provided by an embodiment of the present application.
- the rendering frame rate adjustment method can be applied to electronic devices, and includes but is not limited to the following steps:
- the electronic device can set the rendering frame rate of the N applications based on the interaction status of the focus application and N applications, and these N applications are N applications that have been started by the electronic device.
- these N applications are applications that request APP-VSync signals from the electronic device, specifically, they can be: applications that request APP-VSync signals from the event thread (as shown in Figure 4). It can be understood that the present application does not limit the order in which the electronic device starts the N applications.
- N is an integer greater than 1. For example, N can be 2. For another example, N can be 3.
- the electronic device sets the rendering frame rate of the N applications based on the interaction status of the focus application and the N applications. Specifically, it may include: the electronic device maintains the rendering frame rate of the focus application or the application in the fling state among the N applications the same as the current screen refresh rate, and sets the rendering frame rate of the non-focus application in the N applications that is not in the fling state to be lower than the current screen refresh rate.
- the electronic device in response to the generated VSync signal, can determine whether the current screen refresh rate is greater than a first refresh rate threshold.
- the rendering frame rate of the N applications is set based on the interaction status of the focus application and the N applications.
- the electronic device generates a VSync signal, which may specifically include: the electronic device generates the VSync signal through its hardware, or the electronic device simulates and generates the VSync signal through its software (synchronized with the VSync signal generated by the hardware).
- each time the electronic device generates a VSync signal in response to the generated VSync signal, the electronic device can determine whether the current screen refresh rate is greater than a first refresh rate threshold.
- the rendering frame rate of the N applications is set based on the interaction status of the focus application and the N applications.
- each time a VSync signal is generated it can be specifically understood as: each VSync cycle arrives.
- the VSync period is the inverse of the screen refresh rate (or system refresh rate).
- the screen refresh rate of an electronic device may be 120 Hz, and accordingly, the VSync period may be 1/120 s, or 8.3 ms (rounded to one decimal place).
- the screen refresh rate that an electronic device can support is mainly determined by the specifications of the display screen of the electronic device itself (for example, the bandwidth, resolution, refresh rate, etc. of the display screen).
- the screen refresh rate of the electronic device is a fixed value.
- the screen refresh rate of the electronic device is fixed at 60 Hz.
- the electronic device may support multiple screen refresh rate specifications, that is, the screen refresh rate of the electronic device can be changed.
- the electronic device supports a screen refresh rate of 120Hz (that is, the display screen refreshes the screen 120 times per second) and a screen refresh rate of 60Hz (that is, the display screen refreshes the screen 60 times per second).
- the electronic device can automatically adjust the screen refresh rate according to the current usage scenario, or the user can trigger the electronic device to adjust the screen refresh rate.
- the default system refresh rate set in the electronic device is 60Hz, and the user can trigger the system refresh rate of the electronic device to be adjusted to 120Hz.
- the initial screen refresh rate used by the electronic device can be set according to actual needs.
- the initial screen refresh rate set in the electronic device can be 60Hz.
- the electronic device may be provided with a VSync software timer, and the VSync signal may be managed and controlled by the VSync software timer.
- the timing duration defined by the VSync software timer is a VSync cycle. Specifically, every time the timing duration of the VSync software timer reaches its defined timing duration (i.e., a VSync cycle), the electronic device generates a VSync signal. Furthermore, as shown in Figure 4, the electronic device can generate an App-VSync signal and an SF-VSync signal based on the generated VSync signal, and distribute the App-VSync signal and the SF-VSync signal.
- the VSync period will also change accordingly, and the timing duration defined by the VSync software timer will also change accordingly.
- each time the timing duration of the VSync software timer reaches its defined timing duration i.e., one VSync cycle
- it can stop timing and be cleared to zero, and then restart timing until the timing duration reaches its defined timing duration again, then stop timing and be cleared to zero, and then restart timing, and repeat the cycle.
- the electronic device can record the focus application, so that the electronic device can view the record to determine the current focus application.
- the electronic device can record the package name of the focus application.
- the electronic device can detect the user operation acting on the display screen, and in response to the user operation, the electronic device can update and record the focus application and/or focus window based on the specific position of the user operation on the display screen.
- the electronic device in response to the user's touch operation on the display screen displaying windows of N applications, the electronic device can determine that the window where the user touches is located is the focus window, and based on the correspondence between each window and the application, determine that the application corresponding to the focus window is the focus application.
- an electronic device displays window 1a and window 2a on a display screen, wherein window 1a is a window corresponding to a video application, and the user interface of the video application is displayed in window 1a; window 2a is a window corresponding to a reading application, and the user interface of the reading application is displayed in window 2a.
- the electronic device can detect a user operation of clicking on window 2a (or a user operation of clicking on the user interface in window 2a). After detecting the click operation, the electronic device can update the focus window to window 2a and update the focus application to the application corresponding to window 2a, i.e., the reading application.
- the electronic device may set the screen refresh rate based on the target refresh rate interval corresponding to the focus application. Specifically, after the electronic device detects a user operation, it may determine whether the focus application has changed. If the focus application has not changed, the electronic device may set the screen refresh rate based on the target refresh rate interval corresponding to the focus application (i.e., the unchanged focus application). If the focus application has changed, the electronic device may set the screen refresh rate based on the target refresh rate interval corresponding to the changed focus application.
- the electronic device may set the screen refresh rate to the highest target refresh rate corresponding to the focus application. After the user operation ceases, the electronic device may reduce the screen refresh rate within the target refresh rate range corresponding to the focus application, that is, set the screen refresh rate to be less than the highest target refresh rate corresponding to the focus application and not less than the lowest target refresh rate corresponding to the focus application. For example, after the user operation ceases, the electronic device may set the screen refresh rate to the lowest target refresh rate corresponding to the focus application.
- the electronic device may set the screen refresh rate to the highest target refresh rate corresponding to the changed focus application. After the user operation stops, the electronic device may reduce the screen refresh rate within the target refresh rate range corresponding to the changed focus application, that is, set the screen refresh rate to be less than the highest target refresh rate corresponding to the changed focus application, and the set screen refresh rate is not less than the lowest target refresh rate corresponding to the changed focus application. For example, after the user operation stops, the electronic device may set the screen refresh rate to the lowest target refresh rate corresponding to the changed focus application.
- the electronic device stores a correspondence between one or more applications and target refresh rate intervals. It is understood that the target refresh rate intervals corresponding to multiple applications in the electronic device can be exactly the same, partially the same, or completely different, and this application does not limit this.
- the target refresh rate interval corresponding to the application can be set according to actual needs, and this application does not impose any restrictions on this.
- the refresh rate contained in the target refresh rate interval corresponding to the application is the screen refresh rate supported by the electronic device.
- the electronic device can select the refresh rate supported by the electronic device within the target refresh rate interval corresponding to the application to set the screen refresh rate, rather than every value in the target refresh rate interval corresponding to the application can be set as the screen refresh rate.
- the screen refresh rates supported by the electronic device include 144Hz, 120Hz, 90Hz, 60Hz, 40Hz and 30Hz.
- the upper and lower limits of the target refresh rate interval corresponding to each application in the electronic device can be selected from the above refresh rates and cannot be other screen refresh rates not supported by the electronic device.
- the target refresh rate interval corresponding to the application in the electronic device can be [60,90], but not [20,110].
- the target refresh rate interval corresponding to the application is pre-set before leaving the factory.
- the target refresh rate interval corresponding to the application may change (for example, the upper limit of the target refresh rate interval is increased), but the upper and lower limits of the target refresh rate interval after the change are also the screen refresh rates supported by the electronic device.
- the screen refresh rates supported by the electronic device include 120Hz and 60Hz.
- the highest target refresh rate corresponding to application 1 before the upgrade is 60Hz, and the highest target refresh rate corresponding to application 1 after the upgrade becomes 120Hz.
- the electronic device can set its corresponding target refresh rate range based on the application type and its own operating requirements.
- the electronic device needs to set the target refresh rate range corresponding to the application within the range of the screen refresh rate it supports.
- some applications carry relevant information of their corresponding target refresh rate intervals.
- the electronic device can obtain relevant information of the corresponding target refresh rate range and determine the corresponding target refresh rate range.
- the user can change the target refresh rate interval corresponding to the application.
- the user needs to set the target refresh rate interval corresponding to the application within the range of the screen refresh rate supported by the electronic device.
- the electronic device can set the corresponding upper limit of the target refresh rate range (i.e., the maximum target refresh rate) to a higher level.
- the corresponding upper limit of the target refresh rate range can be set to the maximum screen refresh rate (for example, 144Hz).
- the electronic device can record the interaction status of each application that has been launched. Similar to recording the focus application above, the electronic device can update and record the interaction status of each application based on the user operation acting on the display screen.
- the interaction status of the application may include: non-fling (or inertial sliding, in English, fling) state and fling state.
- Fling means: after the user slides the user interface of the application on the display screen and raises his hand, the user interface of the application displayed on the display screen automatically slides (the user does not touch the user interface of the application at this time), specifically refers to continuing to scroll in the direction of the finger sliding along the inertia until it stops.
- the fling operation is triggered from the moment the finger leaves the display screen and ends when the scrolling stops.
- the non-fling state refers to other states except the fling state. For example, the user interface of the application does not slide.
- the fling state is described in detail below with reference to FIG. 6A to FIG. 6C .
- the electronic device displays two windows (i.e., window w1 and window w2) on the display screen, each of which corresponds to an application. It should be noted that Figures 6A-6C are only an example provided by this application, and the electronic device can also display more windows of more applications on the display screen, and this application does not limit this.
- Figures 6A-6C show the process of a user sliding his finger on the display screen and triggering a fling.
- the user's finger falls on the display screen (the first touch on the display screen during this sliding process).
- the icon 1 in window w2 is at position 1.
- the user's finger falls on the display screen, it can slide upward on the display screen (the upward sliding trajectory of the finger is shown in Figures 6A and 6B), and during this sliding process, the user interface displayed in window w2 slides upward as the finger slides.
- the position of icon 1 in the user interface displayed in window w2 changes from position 1 to position 2 ( Figure 6B shows the change in the position of icon 1 during this sliding process).
- Figure 6B shows the change in the position of icon 1 during this sliding process.
- the user raises his hand i.e., the user's finger leaves the display screen.
- icon 1 in window w2 is at position 2.
- (4) in FIG6C after the user raises his hand, if the sliding speed exceeds the speed threshold, a fling is triggered, and the user interface in window w2 continues to slide upward (automatically slides upward).
- the position of icon 1 changes from position 2 to position 3.
- the user interface in window w2 stops sliding.
- the electronic device may display a window 1a corresponding to a video application and a window 2a corresponding to a reading application on the display screen.
- the electronic device may detect an upward sliding operation on window 2a.
- the user interface in window 2a slides upward as the user's finger slides.
- the upward sliding operation shown in FIG7A may include the operation of the finger falling on the display screen as shown in FIG6A , and the operation of the finger sliding upward on the display screen as shown in FIG6B .
- the electronic device may detect a hand-raising operation on window 2a.
- the electronic device may detect a hand-raising operation on window 2a. After the hand-raising operation on window 2a, the user interface in window 2a can continue to slide upward. The sliding at this time is the automatic sliding of the user interface in window 2a, rather than the sliding of the user interface driven by the user's finger.
- the electronic device can display the content shown in Figure 7C on the display screen. As shown in Figure 7C, the electronic device can display window 1a, window 1b and window 2a on the display screen.
- window 1b is also a window corresponding to the video application.
- the user interface in window 2a is different from the user interface in window 2a shown in Figure 7B. This means that in the process of the focus application changing from the reading application to the video application, the user interface in window 2a is still sliding upward and is not affected by the user clicking the video 1 control (for example, the sliding does not stop because the user clicks the video 1 control). And, as shown in Figure 7C, the user interface in window 2a can continue to slide upward.
- FIG7D and FIG7E illustrate the specific changes in the user interface in window 2a when the user's finger slides upward in window 2a and triggers a fling.
- the user's finger falls on the display screen and slides upward on the display screen.
- the user interface in window 2a of the electronic device slides upward as the finger slides.
- the window 2a of the electronic device may display user interfaces as shown in (1) and (2) in FIG7D . It can be understood that, as shown in (1)-(3) in FIG7D , the user interface in window 2a also changes accordingly when the user's finger slides upward on the display screen.
- the user's finger can be lifted after sliding upward on the display screen for a distance.
- the user interface in window 2a of the electronic device can continue to slide upward automatically.
- the window 2a of the electronic device may display the user interface as shown in (2) in FIG7E .
- the user interface in window 2a of the electronic device can stop sliding after sliding upward for a distance.
- the sliding speed may be the speed at which a user's finger slides on a display screen, specifically, the sliding speed in a certain direction.
- the speed threshold can be set according to actual needs, and this application does not impose any restrictions on this.
- Touch events can include the following three types of events: drop events (for example, MotionEvent.ACTION_DOWN), move events (for example, MotionEvent.ACTION_MOVE), and leave events (for example, MotionEvent.ACTION_UP).
- drop events for example, MotionEvent.ACTION_DOWN
- move events for example, MotionEvent.ACTION_MOVE
- leave events for example, MotionEvent.ACTION_UP.
- a complete touch display operation starts with a drop event, there may be no or one or more move events in the middle, and finally ends with a leave event. For example, in the process of a user clicking on the display with a finger, the user's finger falling on the display will trigger the electronic device to generate a drop event, and the user's finger leaving the display will trigger the electronic device to generate a leave event.
- the user's finger falling on the display will trigger the electronic device to generate a drop event
- the user's finger sliding on the display after falling on the display will trigger the electronic device to generate multiple move events
- the user's finger leaving the display will trigger the electronic device to generate a leave event.
- fling is an action that occurs after the user's finger leaves the display (that is, the finger is completely lifted).
- a user's finger falls on the display screen.
- the electronic device In response to the user operation, the electronic device generates a drop event and updates the focus window.
- the electronic device may perform a fling operation.
- the electronic device may calculate the current sliding speed by calling the computeCurrentVelocity() method.
- the electronic device can determine the sliding distance based on the coordinates of the drop event and the leave event, as well as the sliding duration (specifically, the duration between generating the drop event and generating the leave event), and then calculate the sliding speed based on the sliding distance and the sliding duration.
- the electronic device can determine whether the current screen refresh rate adjustment is greater than the first refresh rate threshold.
- the electronic device can determine whether it is a focus application and whether its interaction state is a fling state. Specifically, for the focus application or the application in the fling state among the N applications, the electronic device can keep its rendering frame rate the same as the current screen refresh rate.
- the electronic device can set (or adjust) its rendering frame rate to a rendering frame rate that is less than the current screen refresh rate.
- the first refresh rate threshold can be set according to actual needs, and this application does not limit this.
- the first refresh rate threshold can be 60 Hz.
- this application records the focus application or the application in the fling state among the N applications corresponding to the window displayed on the display screen of the electronic device as Class A applications, and records the non-focus application that is not in the fling state among the N applications as Class B applications.
- each time a VSync signal is generated when the current screen refresh rate is greater than the first refresh rate threshold, for Class A applications among the N applications, the electronic device can determine that its rendering frame rate is the current screen refresh rate; for Class B applications among the N applications, the electronic device can determine that its rendering frame rate is less than the current screen refresh rate.
- this application denotes the number of Category A applications in the N applications corresponding to the windows displayed on the display screen of an electronic device as u, and the number of Category B applications as s.
- u applications are in the fling state or are in focus
- this application may also record the current screen refresh rate as r, and the rendering frame rate set corresponding to the Class B application as Ri.
- i is an integer not greater than s. That is to say, the rendering frame rate set corresponding to the Class B application in the N applications corresponding to the window displayed on the display screen of the electronic device is ⁇ R1, ..., Ri, ..., Rs ⁇ .
- R1 to Rs are the rendering frame rates set for the s Class B applications in the N applications respectively.
- each time a VSync signal is generated if the current screen refresh rate is greater than a first refresh rate threshold, the electronic device may maintain the rendering frame rate of the Class A application among the N applications corresponding to the window displayed on the display screen of the electronic device at the current screen refresh rate.
- the rendering frame rate set for each of the u Class A applications among the N applications is r.
- r can be set according to actual needs and is not limited in this application.
- r can be 120 Hz.
- the specific value of r depends on the application requirements and type.
- each time a VSync signal is generated if the current screen refresh rate is greater than a first refresh rate threshold, the electronic device may set the rendering frame rate of a Class B application among the N applications corresponding to the window displayed on the display screen of the electronic device to a rendering frame rate that is less than the current screen refresh rate.
- Ri is less than r.
- the rendering frame rates set for the Class B applications among the N applications may be the lower limits of their corresponding target refresh rate ranges, that is, the lowest target refresh rates.
- the rendering frame rate of the Class B application in the N applications is set to be no less than a threshold 1, that is, Ri is no less than a threshold 1. It is understood that the threshold 1 can be set according to actual needs and is not limited in this application. For example, the threshold 1 can be 30 Hz.
- the electronic device when each VSync cycle arrives, when the current screen refresh rate is greater than the first refresh rate threshold, for Class B applications among the N applications corresponding to the window displayed by the electronic device on the display screen, when r is greater than the threshold 2, the electronic device can set its rendering frame rate to be less than r, that is, Ri is less than r, and when r is less than or equal to the threshold 2, the electronic device can set its rendering frame rate to be less than or equal to r, that is, Ri is less than or equal to r.
- the rendering frame rates (i.e., the adjusted rendering frame rates) set for the s Class B applications in the N applications can be the same or different.
- Ri can remain unchanged or change.
- an electronic device can display windows of Application 1, Application 2, Application 3, and Application 4 on a display screen, and the screen refresh rate of the electronic device is 60Hz.
- Application 1 is the focus application
- Application 2 is in the fling state
- Application 3 and Application 4 are neither the focus application nor in the fling state
- the highest target refresh rate corresponding to Application 1 is 120Hz.
- the electronic device can set the screen refresh rate to 120Hz, that is, the screen refresh rate changes from 60Hz to 120Hz, keep the rendering frame rate of Application 1 and Application 2 at 120Hz, and set the rendering frame rate of Application 3 and Application 4 to 60Hz.
- an electronic device can display windows of Application 1, Application 2, Application 3, and Application 4 on a display screen, and the screen refresh rate of the electronic device is 60Hz.
- Application 1 is the focus application
- Application 2 is in the fling state
- Application 3 and Application 4 are neither the focus application nor in the fling state
- the highest target refresh rate corresponding to Application 1 is 120Hz.
- the electronic device can set the screen refresh rate to 120Hz, that is, the screen refresh rate changes from 60Hz to 120Hz, maintain the rendering frame rate of Application 1 and Application 2 at 120Hz, set the rendering frame rate of Application 3 to 30Hz, and set the rendering frame rate of Application 4 to 60Hz.
- r k * Ri. That is, the rendering frame rate of the Class B application among the N applications corresponding to the window displayed on the electronic device's display screen can be divided by r, and the quotient is k.
- k is an integer greater than 1.
- k can be 1.
- k can be 3. It is understood that when s is greater than 1, k may or may not change.
- Ri and k remain unchanged for different values of i.
- r 120 Hz
- k 60 Hz
- the electronic device can display windows of Application 1, Application 2, Application 3, and Application 4 on the display screen, and the screen refresh rate of the electronic device is 60Hz.
- Application 1 is the focus application
- Application 2 is in the fling state
- Application 3 and Application 4 are neither the focus application nor in the fling state
- the highest target refresh rate corresponding to Application 1 is 120Hz.
- the electronic device can set the screen refresh rate to 120Hz, that is, the screen refresh rate changes from 60Hz to 120Hz, keep the rendering frame rate of Application 1 and Application 2 at 120Hz, set the rendering frame rate of Application 3 to 30Hz (divisible by 120Hz), and set the rendering frame rate of Application 4 to 45Hz (not divisible by 120Hz).
- S102 Rendering images of the N applications based on the rendering frame rates of the N applications respectively.
- the electronic device can render its picture (or the picture in its corresponding window) based on the current screen refresh rate.
- the electronic device can render its picture (or the picture in its corresponding window) based on its rendering frame rate that is lower than the current screen refresh rate.
- the VSync cycle (which can be understood as the interval between two adjacent VSync signals) changes with the change of the screen refresh rate, that is, the frequency of generating VSync signals changes with the change of the screen refresh rate, and the APP-VSync signal and SF-VSync signal are distributed based on the VSync cycle, which means that the distribution frequency of the App-VSync signal and SF-VSync signal will also change with the change of the VSync cycle.
- the electronic device can send the APP-VSync signal to the application at the frequency of generating the VSync signal. That is, each time the electronic device generates a VSync signal, it can generate an App-VSync signal based on the VSync signal and send the App-VSync signal to the application. Accordingly, after receiving the App-VSync signal, the application in the electronic device can start drawing and rendering the screen in its corresponding window.
- the electronic device may send an APP-VSync signal to the application according to a multiple of the current screen refresh rate and the rendering frame rate of the application.
- the electronic device when the rendering frame rate of the application is lower than the current screen refresh rate, the electronic device sends an App-VSync signal to the application at least every 2 VSync cycles.
- this application denotes the multiple of the rendering rate of the application closest to the current screen refresh rate as z, where z is a positive integer.
- the electronic device when z is greater than 1, after the electronic device generates a VSync signal, it can send an APP-VSync signal generated based on the VSync signal to the application, and then wait until z VSync cycles later when the VSync signal is generated again, and then send the APP-VSync signal generated based on the regenerated VSync signal to the application, and then repeat the above steps of sending the APP-VSync signal every z VSync cycles. It should be noted that when z is greater than 1, during the z VSync cycles, the electronic device can still generate a VSync signal according to the VSync cycle, but does not send the APP-VSync signal to the application. Correspondingly, after receiving the App-VSync signal, the application in the electronic device can start drawing and rendering the image in its corresponding window.
- this application denotes the quotient of the current screen refresh rate and the application's rendering frame rate as x.
- x is a positive integer. It is understood that x can be equal to z or z-1 (in which case z is at least 3).
- the electronic device when x is greater than 1, after the electronic device generates a VSync signal, it may send an APP-VSync signal generated based on the VSync signal to the application, and then wait until x VSync cycles later when the VSync signal is generated again, and then send an APP-VSync signal generated based on the regenerated VSync signal to the application, and then repeat the above step of sending an APP-VSync signal every x VSync cycles. It should be noted that when x is greater than 1, during the x VSync cycles, the electronic device can still generate VSync signals according to the VSync cycle, but will not send an APP-VSync signal to the application. Accordingly, after receiving the App-VSync signal, the application in the electronic device can start drawing and rendering the screen in its corresponding window.
- x and z may be equal to the k mentioned above.
- the electronic device when the rendering frame rate of an application is less than the current screen refresh rate, if the application requests an APP-VSync signal, and its rendering frame rate can be divided evenly by the current screen refresh rate, the electronic device can be based on a defined timing duration as a VSync software timer to remind the electronic device to send an APP-VSync signal to the application, that is, the electronic device can generate an App-VSync signal once every x VSync cycles (or z VSync cycles) based on the VSync software timer, and send the App-VSync signal to the application.
- the electronic device can set up an additional VSync software timer to remind the electronic device to send an App-VSync signal to the application.
- the timing duration defined by the additionally set VSync software timer is not the same as the VSync cycle.
- the timing duration defined by the additionally set VSync software timer is the inverse of the rendering frame rate of the application.
- each time the electronic device generates a VSync signal it can directly send the APP-VSync signal generated based on the VSync signal to the application, without adding a certain time offset to the generated VSync signal before sending the APP-VSync signal.
- each time the electronic device generates a VSync signal may add a certain time offset and then send an APP-VSync signal generated based on the VSync signal to the application.
- the electronic device when the electronic device executes step S101 and step S102, for each of the N applications, the electronic device may execute the steps shown in FIG8A , which may specifically include but are not limited to the following steps:
- the electronic device may determine whether the application is the current focus application. If the application is the current focus application, the electronic device may continue to perform step S202. If the application is not the current focus application, the electronic device may continue to perform step S203, that is, determine whether the application is in a fling state.
- the electronic device may determine that the rendering frame rate of the application is the current screen refresh rate and maintain the rendering frame rate.
- the electronic device may determine whether the application is in a fling state. If the application is in a fling state, the electronic device may continue to execute step S202; if the application is not in a fling state, the electronic device may continue to execute step S204.
- the electronic device may determine whether the current screen refresh rate is greater than threshold 2. If the current screen refresh rate is greater than threshold 2, the electronic device may continue to execute step S204; if the current screen refresh rate is less than or equal to threshold 2, the electronic device may execute step S202 or step S204, that is, the electronic device may determine that the rendering frame rate of the application is equal to or less than the current screen refresh rate.
- the electronic device can set the rendering frame rate of the application so that the corresponding rendering frame rate of the application is less than the current screen refresh rate.
- the specific setting method can refer to the relevant description of step S102, and this application will not repeat it here.
- S205 Send an App-VSync signal to the application based on the rendering frame rate of the application.
- the application may request an App-VSync signal. After determining that the application's rendering frame rate is equal to the current screen refresh rate, or setting the application's rendering frame rate to be less than the current screen refresh rate, if the application requests an App-VSync signal, the electronic device may send an App-VSync signal to the application based on the application's rendering frame rate.
- step S101 the VSync period will also change with the change of the current screen refresh rate.
- the electronic device can directly send an App-VSync signal to the application based on the VSync cycle. Specifically, after generating a VSync signal, the electronic device can directly send an APP-VSync signal obtained based on the VSync signal to the application, and then after generating a VSync signal next time, send an APP-VSync signal obtained based on the VSync signal to the application again, and repeat the above step of sending an APP-VSync signal obtained based on the VSync signal to the application again after generating a VSync signal next time.
- the electronic device can send an APP-VSync signal to the application based on the multiple relationship between the interval length and the VSync cycle (i.e., the multiple relationship between the current screen refresh rate and the rendering frame rate of the application).
- the specific implementation method can be referred to above and will not be repeated in this application.
- the electronic device can send an APP-VSync signal to the application by setting a timer (e.g., a first timer), and the timing duration defined by the timer is a VSync cycle. Specifically, the electronic device can determine how many VSync cycles to send an APP-VSync signal based on the multiple relationship between the current screen refresh rate and the rendering frame rate of the application, and send an APP-VSync signal to the application when the total timing duration of the VSync software timer reaches the corresponding VSync cycle.
- a timer e.g., a first timer
- this application refers to the thread where the timer is located as timer distribution thread 1. That is to say, regardless of whether the rendering frame rate of the application is equal to the current screen refresh rate or less than the current screen refresh rate, the electronic device can send an APP-VSync signal to the application through timer distribution thread 1.
- the timing duration defined by the timer in timer distribution thread 1 is one VSync cycle, or the timing duration corresponding to timer distribution thread 1 is one VSync cycle. This means that the timing duration corresponding to timer distribution thread 1 changes with the change of the VSync cycle, that is, it changes with the change of the current screen refresh rate.
- an electronic device may display windows corresponding to Application 1, Application 2, Application 3, Application 4, and Application 5 on a display screen.
- the electronic device may determine that the currently focused application is Focus 1, whose corresponding maximum target refresh rate is 120 Hz.
- the electronic device may then set the current screen refresh rate to 120 Hz, and the VSync period will correspondingly become 1/120 second, meaning the electronic device will generate a VSync signal every 1/120 second.
- the electronic device may generate a VSync signal each time the timing duration of Timer Distribution Thread 1 reaches its corresponding timing duration. Since Focus 1 is the focused application, the electronic device may determine that its rendering frame rate is 120 Hz.
- the electronic device may set the rendering frame rates of Application 2, Application 3, Application 4, and Application 5 to lower than 120 Hz. Specifically, the electronic device may set the rendering frame rates of Application 2 and Application 3 to 60 Hz, Application 4 to 45 Hz, and Application 5 to 90 Hz.
- the current screen refresh rate can be divided by the rendering frame rate set by application 2 and application 3, and the quotient of the current screen refresh rate divided by the rendering frame rate set by application 2/application 3 is 2, then the electronic device can send an APP-VSync signal to application 2 and application 3 every 2 VSync cycles.
- the current screen refresh rate cannot be divided by the rendering frame rate set by application 4, and (120-45*2)>(45*3-120), that is, with the current screen refresh rate
- the multiple of the rendering frame rate set for application 4, which is closest to the current screen refresh rate, is 3.
- the electronic device can send an APP-VSync signal to application 4 every 3 VSync cycles.
- the electronic device after the electronic device generates the first VSync signal, it can generate an APP-VSync signal and an SF-VSync signal based on the VSync signal.
- the electronic device can send an APP-VSync signal to Application 1, Application 2, Application 3, Application 4, and Application 5 for the first time, and send an SF-VSync signal to SurfaceFlinger for the first time.
- the electronic device After an interval of one VSync cycle (that is, the timer distribution thread 1 starts timing after generating the VSync signal until its timing duration reaches its defined timing duration), the electronic device can generate a second VSync signal and generate an APP-VSync signal and an SF-VSync signal based on the VSync signal.
- the electronic device can send an APP-VSync signal to Application 1 for the second time, and send an SF-VSync signal to SurfaceFlinger for the second time.
- the electronic device can generate a third VSync signal, and generate an APP-VSync signal and an SF-VSync signal based on the VSync signal.
- the electronic device can send an APP-VSync signal to application 1 for the third time, and send an APP-VSync signal to application 2, application 3, and application 5 for the second time, and send an SF-VSync signal to SurfaceFlinger for the third time.
- the electronic device can generate a fourth VSync signal, and generate an APP-VSync signal and an SF-VSync signal based on the VSync signal.
- the electronic device can send an APP-VSync signal to application 1 for the fourth time, send an APP-VSync signal to application 4 for the second time, and send an SF-VSync signal to SurfaceFlinger for the fourth time.
- the distribution of the APP-VSync signal for application 1, application 2, application 3, application 4, and application 5 is all completed by timer distribution thread 1, and the timing duration corresponding to timer distribution thread 1 is 1/120s.
- step S102 and step S103 when the electronic device executes step S102 and step S103, for each of the N applications corresponding to the window displayed on the display screen of the electronic device, the electronic device may execute the steps shown in FIG8B , which may specifically include but are not limited to the following steps:
- the electronic device may determine whether the application is the current focus application. If the application is the current focus application, the electronic device may continue to perform step S302. If the application is not the current focus application, the electronic device may continue to perform step S303, that is, determine whether the application is in a fling state.
- the electronic device may determine that the rendering frame rate of the application is the current screen refresh rate and maintain the rendering frame rate. In this case, the electronic device may execute step S306.
- the electronic device may determine whether the application is in a fling state. If the application is in a fling state, the electronic device may continue to execute step S302; if the application is not in a fling state, the electronic device may continue to execute step S304.
- the electronic device may determine whether the current screen refresh rate is greater than threshold 2. If the current screen refresh rate is greater than threshold 2, the electronic device may continue to execute step S304; if the current screen refresh rate is less than or equal to threshold 2, the electronic device may execute step S302 or step S304, that is, the electronic device may determine that the rendering frame rate of the application is equal to or less than the current screen refresh rate.
- the electronic device can adjust the rendering frame rate of the application so that the rendering frame rate set by the application is less than the current screen refresh rate.
- the specific adjustment method can refer to the relevant description of step S102, which will not be repeated here. In this case, the electronic device can continue to perform step S305.
- the electronic device can determine whether the rendering frame rate set by the application is divisible by the current screen refresh rate, that is, the electronic device can determine whether the current screen refresh rate is divisible by the rendering frame rate set by the application.
- the electronic device can execute step S306; if the rendering frame rate set by the application is not divisible by the current screen refresh rate (i.e., the current screen refresh rate is not divisible by the rendering frame rate set by the application), the electronic device can execute step S307.
- S306 Send an App-VSync signal to the application via timer distribution thread 1.
- the timing duration corresponding to timer distribution thread 1 is determined based on the current screen refresh rate.
- the electronic device can send an APP-VSync signal to the application through timer distribution thread 1.
- the timing duration corresponding to timer distribution thread 1 is one VSync cycle, that is, the inverse of the current screen refresh rate. The relevant description of timer distribution thread 1 can be found above and will not be repeated here in this application.
- the electronic device can use the timer distribution thread 1 to remind the application to send an APP-VSync signal once every x VSync cycles (or z VSync cycles).
- the electronic device after the electronic device generates a VSync signal, it can send an APP-VSync signal generated based on the VSync signal to the application, and then wait until x VSync cycles later (specifically, it can be determined through the timer distribution thread 1 that x VSync cycles have passed since the last time the APP-VSync signal was sent) to generate a VSync signal again, and then send an APP-VSync signal generated based on the regenerated VSync signal to the application, and then repeat the above steps of sending the APP-VSync signal every x VSync cycles.
- this application refers to the timer set in the timer distribution thread 1 as the first timer.
- the timing duration defined by the first timer is one VSync cycle.
- the first timer can be understood as the VSync software timer mentioned above.
- the electronic device can send the SF-VSync signal to SurfaceFlinger through the timer distribution thread 1. Specifically, when the timing duration of the first timer reaches its defined timing duration (i.e., a VSync cycle), the electronic device can generate a VSync signal, and then generate an SF-VSync signal based on the VSync signal. And send the SF-VSync signal to SurfaceFlinger. That is to say, every time the electronic device generates a VSync signal, it can generate a corresponding SF-VSync signal.
- S307 Send an App-VSync signal to the application via timer distribution thread 2.
- the timing duration corresponding to timer distribution thread 2 is determined based on the rendering frame rate set by the application.
- the electronic device may send an APP-VSync signal to the application through timer distribution thread 2.
- Timer distribution thread 2 is a thread independent of timer distribution thread 1, and its corresponding timing duration is the inverse of the rendering frame rate set for the application.
- an electronic device may display windows corresponding to Application 1, Application 2, Application 3, Application 4, and Application 5 on a display screen.
- the electronic device may determine that the currently focused application is Application 1, whose target refresh rate is 120 Hz.
- the electronic device may then set the current screen refresh rate to 120 Hz, and the VSync period will correspondingly become 1/120 second, meaning the electronic device will generate a VSync signal every 1/120 second.
- the electronic device may generate a VSync signal each time the timing duration of Timer Distribution Thread 1 reaches its corresponding timing duration. Since Application 1 is the focused application, the electronic device may determine that its rendering frame rate is 120 Hz.
- the electronic device may set the rendering frame rates of Application 2, Application 3, Application 4, and Application 5 to lower than 120 Hz. Specifically, the electronic device may adjust the rendering frame rates of Application 2 and Application 3 to 60 Hz, the rendering frame rate of Application 4 to 45 Hz, and the rendering frame rate of Application 5 to 90 Hz.
- the timing duration corresponding to the timer distribution thread 1 is one VSync cycle, and the electronic device can generate a VSync signal according to the timing duration corresponding to the timer distribution thread 1, and send an APP-VSync signal to the application 1.
- the current screen refresh rate can be divided by the rendering frame rates set by Application 2 and Application 3, and the electronic device can send an APP-VSync signal to Application 2 and Application 3 once every 2 VSync cycles through Timer Distribution Thread 1.
- the current screen refresh rate cannot be divided by the rendering frame rate set by Application 4, nor can it be divided by the rendering frame rate set by Application 5, but there is a multiple relationship of 2 between the rendering frame rate set by Application 4 and the rendering frame rate set by Application 5.
- the electronic device can send an APP-VSync signal to Application 4 and Application 5 through Timer Distribution Thread 2, and the timing duration corresponding to Timer Distribution Thread 2 can be determined based on the highest frame rate among the rendering frame rates set by Application 4 and Application 5, that is, Timer Distribution Thread 2 can be the inverse of the rendering frame rate set by Application 5, that is, 1/90s.
- the timing duration corresponding to Timer Distribution Thread 2 is 4/3 of the VSync cycle.
- timer distribution thread 1 and timer distribution thread 2 start timing synchronously.
- the following example illustrates the specific process of timer distribution thread 1 sending APP-VSync signal:
- the electronic device after the electronic device generates the first VSync signal, it can generate an APP-VSync signal and an SF-VSync signal based on the VSync signal.
- the electronic device can send the APP-VSync signal to Application 1, Application 2, and Application 3 for the first time, and send the SF-VSync signal to SurfaceFlinger for the first time.
- the electronic device After a VSync cycle (that is, the timer distribution thread 1 starts timing after generating the first VSync signal until its timing duration reaches its defined timing duration), the electronic device can generate a second VSync signal, and generate an APP-VSync signal and an SF-VSync signal based on the VSync signal.
- the electronic device can send an APP-VSync signal to Application 1 for the second time, and send an SF-VSync signal to SurfaceFlinger for the second time.
- the electronic device can generate a third VSync signal, and generate an APP-VSync signal and an SF-VSync signal based on the VSync signal.
- the electronic device can send an APP-VSync signal to Application 1 for the third time, and send an APP-VSync signal to Application 2, Application 3 and Application 5 for the second time, and send an SF-VSync signal to SurfaceFlinger for the third time.
- the electronic device can generate a fourth VSync signal and generate an APP-VSync signal and an SF-VSync signal based on the VSync signal.
- the electronic device can send an APP-VSync signal to application 1 for the fourth time, send an APP-VSync signal to application 4 for the second time, and send an SF-VSync signal to SurfaceFlinger for the fourth time.
- timer distribution thread 2 and timer distribution thread 1 sending APP-VSync signals to the application is independent and synchronous.
- the following example illustrates the specific process of timer distribution thread 2 sending APP-VSync signals:
- the electronic device after the electronic device generates the first VSync signal, it can generate an APP-VSync signal and an SF-VSync signal based on the VSync signal. In this case, the electronic device can send the APP-VSync signal to Application 4 and Application 5 for the first time. After an interval of 4/3 VSync cycles (i.e., timer distribution thread 2 starts timing after generating the first VSync signal until its timing reaches its defined timing duration), the electronic device can send the APP-VSync signal to Application 5 for the second time.
- an interval of 4/3 VSync cycles i.e., timer distribution thread 2 starts timing after generating the first VSync signal until its timing reaches its defined timing duration
- the electronic device can send the APP-VSync signal to Application 5 for the third time and the APP-VSync signal to Application 4 for the second time.
- the electronic device can send the APP-VSync signal to Application 5 for the fourth time.
- this application refers to the timer set in timer distribution thread 2 as the second timer.
- the timing duration defined by the second timer is the inverse of the rendering frame rate set for the application (i.e., the adjusted rendering frame rate corresponding to the application).
- the second timer can be understood as the VSync software timer mentioned above.
- the electronic device can determine whether there is a multiple relationship between the rendering frame rates set by the multiple applications. If there is a multiple relationship between the rendering frame rates set by the multiple applications, the electronic device can send APP-VSync signals to the multiple applications through timer distribution thread 2.
- the electronic device can also set one or more timer distribution threads to send APP-VSync signals to other applications in the multiple applications.
- the electronic device can display windows corresponding to Application 1, Application 2, Application 3, Application 4, Application 5, and Application 6 on the display screen.
- Application 1 is the focus application, and its corresponding target refresh rate is 120Hz, then the electronic device can adjust the current screen refresh rate to 120Hz.
- Application 2, Application 3, Application 4, Application 5, and Application 6 are all non-focus applications that are not in the fling state.
- the rendering frame rate of Application 1-Application 5 is the same as the rendering frame rate of Application 1-Application 5 shown in Figures 9A and 9B, while the corresponding rendering frame rate of Application 6 is set to 50Hz.
- the electronic device can send APP-VSync signals to Application 1, Application 2, and Application 3 through timer distribution thread 1, and send APP-VSync signals to Application 4 and Application 5 through timer distribution thread 2.
- the rendering frame rate set for application 6 cannot be divided evenly by the current screen refresh rate, and there is no multiple relationship between the rendering frame rate set for application 6 and the rendering frame rate set for application 4, and there is no multiple relationship between the rendering frame rate set for application 6 and the rendering frame rate set for application 5.
- the electronic device can send an APP-VSync signal to application 6 through timer distribution thread 3.
- timer distribution thread 3 is a thread independent of timer distribution thread 1 and timer distribution thread 2, and its corresponding timing duration is the reciprocal of the rendering frame rate set for application 6. Similar to timer distribution thread 1 and timer distribution thread 2, a timer can also be set in timer distribution thread 3, and the timing duration defined by the timer in timer distribution thread 3 is the reciprocal of the rendering frame rate set for application 6.
- S103 Displaying the images of the N applications on the display screen according to the current screen refresh rate.
- the electronic device After the electronic device renders the images of the N applications (or the images in the windows of the N applications), it can display the images of the N applications on the display screen according to the current screen refresh rate.
- the N applications there may be some applications whose rendering frame rate is lower than the current screen refresh rate, and SurfaceFlinger synthesizes the layer according to the current screen refresh rate, and the display screen displays according to the current screen refresh rate.
- SurfaceFlinger when SurfaceFlinger is preparing to synthesize the layer, the applications whose rendering frame rate is lower than the current screen refresh rate may not have rendered a new image. In this case, the applications whose rendering frame rate is lower than the current screen refresh rate can send the previous frame of image rendered by them to SurfaceFlinger for synthesis.
- the windows of N applications displayed on the display screen of the electronic device may include M windows, where M is an integer not less than N.
- M is an integer not less than N.
- one application may correspond to one window or multiple windows, and this application does not impose any restrictions on this.
- N may be 2, and the electronic device may display window 1a and window 2a on the display screen.
- Window 1a is a window corresponding to a video application
- window 2a is a window corresponding to a reading application.
- the electronic device creates window 1a after launching the video application, and similarly, creates window 2a after launching the reading application.
- N can be 2, and the electronic device can display window 3a, window 3b, and window 2a on the display screen.
- Window 3a and window 3b correspond to a shopping application
- window 2a corresponds to a reading application.
- the electronic device creates window 3a and window 3b after launching the shopping application.
- N application windows on a display screen the number of applications that have been launched is not less than N.
- the electronic device can launch more than N applications, but only displays the windows of the N applications on the display screen, and other launched applications can run in the background.
- the operating system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a microservice architecture, or a cloud architecture.
- the embodiment of the present application takes the Android operating system with a layered architecture as an example to illustrate the software structure of the electronic device. It should be noted that although the embodiment of the present application is described using the Android operating system (which may be referred to as the Android system) as an example, its basic principles are also applicable to electronic devices based on operating systems such as iOS or Windows.
- FIG10 is a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application.
- the software structure of an electronic device adopts a layered architecture, which divides the software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces.
- the Android system's software structure is divided into five layers: from top to bottom, the application layer, the application framework layer (Framework), the Android runtime (Android runtime) and system library, the hardware abstraction layer (HAL), and the kernel layer (Kernel).
- the application layer can include a series of application packages.
- Application packages may include applications such as camera, gallery, calendar, call, map, WLAN, Bluetooth, music, video, short message, etc.
- the application layer can also include system UI (System User Interface, system UI). System UI is used to display the interface of the electronic device, such as displaying the signal icon corresponding to the SIM card, displaying the call interface, etc.
- the application layer can also include application 1 and application 2. It is understandable that application 1 can be a system application or a third-party application. Similarly, application 2 can be a system application or a third-party application.
- the application framework layer provides an application programming interface (API) and programming framework for applications in the application layer.
- the application framework layer may include predefined functions.
- the application framework layer may include a window manager (WM) and a view system.
- the WM is used to manage system and application windows (e.g., adding, removing, and updating) and draw them. Its main functions include window creation and management, window hierarchy management, window event distribution, window management for external applications, and window style control.
- the view system is used to build applications, specifically drawing and rendering the application's display interface (or user interface).
- a user interface can be composed of one or more views.
- the view system can call upon the 3D graphics processing library and 2D graphics engine in the system library to draw the user interface.
- the view system may include a rendering orchestrator (or rendering manager), also known as Choreographer.
- Choreographer works with the VSync mechanism to provide a stable drawing processing window for upper-layer applications. Specifically, when the VSync cycle arrives, the electronic device can wake up Choreographer to perform the application's drawing and rendering operations. Choreographer plays a connecting role in the Android rendering chain.
- the application framework layer may also include an input event management module.
- the input event management module can collect, process, and distribute various input events (e.g., key events, touch events, etc.).
- the input event management module may be inputflinger.
- Inputflinger is a service responsible for processing input events. It can receive raw input events from hardware devices and convert them into events that the Android system can understand, such as touch events.
- the application framework layer may also include widgets.
- Widgets may include OverScrollers. OverScrollers are classes that can add listeners to the user interface to determine whether the current interactive state of the user interface is a fling state.
- the application framework layer can also include a surface control interface.
- the surface control interface can be used to implement WM and Interaction with SurfaceFlinger.
- the surface control interface may be surfaceControl.
- the runtime is responsible for system scheduling and management. It consists of core libraries and a virtual machine.
- the core libraries consist of two parts: one containing the functions called by programming languages (e.g., Java) and the other containing the system's core libraries.
- the application layer and application framework layer run in the virtual machine.
- the virtual machine executes the application layer and application framework layer programming files (e.g., Java files) as binary files.
- the virtual machine manages object lifecycles, stacks, threads, security, exceptions, and garbage collection.
- the system library can include multiple functional modules. For example, SurfaceFlinger, Media Libraries, 3D graphics processing libraries (e.g., OpenGL ES), and 2D graphics engines (e.g., SGL).
- SurfaceFlinger is responsible for managing the UI display of all applications. By interacting with the Hardware Abstraction Layer (HAL) and GPU driver, it is also responsible for composing application UI elements (such as text, images, views, etc.) into a complete screen image.
- SurfaceFlinger can include a touch focus layer management module, a connection management module, a slide state management module, a Vsync signal modulation module, and a layer composition management module.
- the touch focus layer management module can be used to manage and maintain the focus window, specifically updating the focus window based on user operations.
- connection management module can be used to manage and maintain the connection channel between SurfaceFlinger and the application (also understood as the distribution channel for the App-VSync signal).
- the connection channel can be a socket channel (or socket connection).
- the slide state management module can be used to manage and update the window interaction state (e.g., the application interaction state mentioned above), specifically including the slide state (including the fling state and the non-fling state).
- the Vsync signal modulation module can be used to distribute App-VSync signals to applications based on their rendering frame rates.
- the layer composition management module can be used to combine UI elements from different applications, and/or multiple UI elements from a single application, into a complete screen image. It is understood that the specific meanings and functions of other functional modules in the system library can be found in the relevant technical documentation and will not be explained in detail here.
- the Hardware Abstraction Layer is an interface layer between the operating system kernel and upper-level software. Its purpose is to abstract the hardware.
- the HAL is an abstract interface driven by the device kernel, providing application programming interfaces (APIs) that access the underlying device to higher-level Java API frameworks.
- APIs application programming interfaces
- the HAL provides a standard interface that exposes device hardware capabilities to higher-level Java API frameworks.
- the HAL consists of multiple library modules (for example, the camera HAL, audio HAL, etc.). When the system framework API requests access to the portable device's hardware, the operating system loads the library module for that hardware component.
- the kernel layer is the foundation of the Android system. It is responsible for hardware drivers, networking, power supply, system security, and memory management.
- the kernel layer acts as an intermediate layer between hardware and software, relaying application requests to the hardware.
- the kernel layer includes audio drivers, display drivers, camera drivers, and sensor drivers.
- the audio driver acting as an intermediate layer between audio software and audio hardware, relays access requests to the audio hardware from upper-layer software modules.
- FIGS 11A and 11B are flowcharts of another image display method provided in an embodiment of the present application.
- the method may include but is not limited to the following steps:
- the user can trigger the electronic device to start application 1. After receiving the user operation to trigger the start of application 1, the electronic device can create a window of application 1 through the WM startup window creation process.
- WM can send application connection request 1 to SurfaceFlinger through the surface control interface.
- SurfaceFlinger can receive application connection request 1 sent by WM through the surface control interface.
- application connection request 1 may include the package name of application 1.
- the package name is a unique identification string for the application, which is usually named in reverse domain name to ensure global uniqueness of the package name.
- SurfaceFlinger can obtain the user identification (UID) and process identification (PID) of application 1 through the Binder mechanism.
- the Binder mechanism is an interprocess communication (IPC) mechanism.
- IPC interprocess communication
- Different operating systems have their own IPC mechanisms.
- Traditional methods of process communication include sockets, pipes, shared memory, and message queues.
- a UID can be used to uniquely identify an application.
- Each application is assigned a unique UID, which determines the application's access rights to system resources.
- each process has a unique PID.
- the system automatically assigns a PID to the corresponding process.
- the PID is assigned by the system while the process is running and does not represent a specific process. While a process is running, its PID does not change, but after the process terminates, its PID is recycled by the system. The system may reassign the recycled PID to another newly running program.
- S3 SurfaceFlinger creates a window for application 1, establishes connection channel 1 with application 1, and manages information related to application 1.
- SurfaceFlinger After SurfaceFlinger receives application connection request 1 sent by WM through the surface control interface, it can create a window of application 1 and establish a connection channel with application 1, namely connection channel 1. It can also manage application 1 related information carried in application connection request 1 (for example, the package name of application 1).
- connection channel may be a socket channel.
- the application 1 related information may further include the UID and PID of the application 1.
- the application connection request 1 sent by WM through the surface control interface it may obtain the UID and PID of the application 1 through the binder mechanism.
- SurfaceFlinger manages information related to application 1, which can also be understood as storing mapping information between application 1 and its corresponding package name, UID, and PID in SurfaceFlinger and maintaining the mapping information.
- the electronic device when the display screen displays the window of the application 1, the user can operate the window of the application 1. Accordingly, the electronic device can detect the user operation on the window of the application 1, In response to the user operation, the electronic device may update the user interface in the window of Application 1. It is understood that the present application does not impose any specific restrictions on the user operation on the window of Application 1.
- the user may trigger the electronic device to start application 2.
- the electronic device may create a window of application 2 through the WM startup window creation process.
- the present application does not limit the order in which the electronic device executes step S1 and step S4. That is, the electronic device can first start application 1 in response to the corresponding user operation, or can first start application 2 in response to the corresponding user operation.
- WM can send application connection request 2 to SurfaceFlinger through the surface control interface.
- SurfaceFlinger can receive application connection request 2 sent by WM through the surface control interface.
- application connection request 2 may include the package name (Package Name) of application 2.
- SurfaceFlinger may obtain the UID and PID of application 2 through a Binder mechanism.
- S6 SurfaceFlinger creates a window for application 2, establishes connection channel 2 with application 2, and manages information related to application 2.
- SurfaceFlinger After SurfaceFlinger receives application connection request 2 sent by WM through the surface control interface, it can create a window for application 2 and establish a connection channel with application 2, namely connection channel 2. It can also manage application 2 related information carried in application connection request 2 (for example, the package name of application 2).
- the application 2 related information may further include the UID and PID of the application 2.
- the application connection request 2 sent by WM through the surface control interface it may obtain the UID and PID of the application 2 through the binder mechanism.
- SurfaceFlinger manages information related to application 2, which can also be understood as storing mapping information between application 2 and its corresponding package name, UID, and PID in SurfaceFlinger, and maintaining the mapping information.
- SurfaceFlinger may store mapping information between multiple applications (eg, application 1 and application 2) and their corresponding package names, UIDs, and PIDs.
- SurfaceFlinger may store information related to application 1 (also referred to as mapping information of application 1) and information related to application 2 (also referred to as mapping information of application 2). Specifically, SurfaceFlinger may store the information shown in Table 2. As shown in Table 2, the connection channel corresponding to application 1 is connection channel 1, which may be referred to as con1 for short, and the package name of application 1 is com.example.app1, and the UID and PID of application 1 are 11 and 213 respectively. The connection channel corresponding to application 2 is connection channel 2, which may be referred to as con2 for short, and the package name of application 2 is com.example.app2, and the UID and PID of application 2 are 12 and 862 respectively.
- connection channel corresponding to application 1 is connection channel 1, which may be referred to as con1 for short, and the package name of application 1 is com.example.app1, and the UID and PID of application 1 are 11 and 213 respectively.
- connection channel corresponding to application 2 is connection channel 2, which may be referred to as con
- the input event management module detects a touch operation on the window of application 2.
- the user can touch the window of application 2, and accordingly, the hardware device of the electronic device (for example, a display screen) can generate an original input event.
- the input event management module in the electronic device can collect and obtain the original input events, and process the original input events (for example, preprocessing and classification) to obtain touch events (or touch events). It can also be understood that the input event management module converts the original input events into objects of a more advanced class (that is, events that can be understood by the Android system mentioned above). The above process can be understood as the input event management module detecting a touch operation acting on the window of application 2.
- the touch event obtained by the input event management module based on the touch operation on the window of application 2 may be a drop event (eg, MotionEvent.ACTION_DOWN).
- the window of application 2 may be window w2 as shown in FIG6A .
- the input event management module can detect the touch operation on the window of application 2.
- the input event management module can collect the original input event and process it to obtain MotionEvent.ACTION_DOWN.
- the window of application 2 may be window 2a as shown in FIG7D .
- the input event management module may detect the touch operation on the window of application 2.
- the input event management module may collect the original input event and process it to obtain MotionEvent.ACTION_DOWN.
- the input event management module notifies the WM to process the touch event.
- the input event management module After the input event management module converts the original input event into a touch event, it can notify the WM to process the touch event. In some embodiments of the present application, the input event management module can notify the WM to process the touch event by sending a message to the WM.
- a touch event may carry position information (eg, coordinates of a touch point on a display screen).
- the WM can determine the focus window. Specifically, the WM can determine that the focus window is the window of application 2. In some embodiments of the present application, the WM can determine the focus window based on the position information carried by the touch event. For example, if the coordinates of the touch point carried by the touch event mentioned in step S8 are within the range where the window of application 2 is located, the WM can determine that the window of application 2 is the focus window. In some embodiments of the present application, the WM can specifically determine the focus window based on the position information carried by the touch event, and can also determine that the application corresponding to the focus window is the focus application. In some embodiments of the present application, the WM can determine the focus window by calling the handleTaskFocusChange method.
- WM After WM determines the focus window, it can send the focus window related information to SurfaceFlinger through the surface control interface.
- SurfaceFlinger can receive the focus window related information sent by WM through the surface control interface.
- the focus window related information may include an identifier corresponding to the focus window.
- WM and SurfaceFlinger may add an identifier to the window during the process of creating the application window, and SurfaceFlinger may store the mapping information between the identifier corresponding to the window and the application package name, UID, and PID. It is understood that the identifier corresponding to the window can be represented by numbers, symbols, text, etc., and this application does not limit its specific representation method.
- the focus window related information may further include related information of the application corresponding to the focus application (eg, package name, UID, PID, etc.).
- the focus window related information may include com.example.app2.
- WM can send focus application related information to SurfaceFlinger by calling the setFocusedWindow method.
- S11 SurfaceFlinger updates the focused app and/or focused window.
- SurfaceFlinger After SurfaceFlinger receives the focus window related information sent by WM through the surface control interface, it can update the focus application and/or focus window based on the focus window related information. Specifically, SurfaceFlinger can update the focus application to application 2 and/or update the focus window to the window of application 2.
- SurfaceFlinger after SurfaceFlinger updates the focus application and/or focus window, it can set the screen refresh rate to the highest target refresh rate corresponding to the updated focus application. Specifically, SurfaceFlinger can set the screen refresh rate to the highest target refresh rate corresponding to application 2.
- application 2 corresponds to multiple windows
- SurfaceFlinger can determine that among the multiple windows corresponding to application 2, the window with the same corresponding identifier as the window identifier in the focus application related information is the focus window.
- SurfaceFlinger can record the focus application and/or focus window. In some embodiments of the present application, SurfaceFlinger can record the identifier corresponding to the focus window. In some embodiments of the present application, SurfaceFlinger can record the package name or UID corresponding to the focus application.
- SurfaceFlinger can set the screen refresh rate based on the target refresh rate range corresponding to the focus application. Not only can the screen refresh rate be set to the highest target refresh rate corresponding to the focus application, but the screen refresh rate can also be set to lower than the highest target refresh rate corresponding to the focus application under certain conditions (for example, no user operation).
- the specific method can be referred to above, and this application will not go into details here.
- S12 SurfaceFlinger synchronizes the updated focus application and/or focus window to the input event management module.
- SurfaceFlinger updates the focus application and/or focus window, it can notify the input event management module of the updated focus application and/or focus window, that is, synchronize the updated focus application and/or focus window to the input event management module.
- the input event management module detects a sliding and hand-raising operation on the window of application 2.
- the hardware device of the electronic device for example, a display screen
- the input event management module in the electronic device can collect and obtain the series of original input events, and process them (for example, preprocessing and classification) to obtain a series of touch events.
- the above process can be understood as the input event management module detecting the sliding and raising operation on the window of application 2.
- the touch event obtained by the input event management module based on the sliding operation on the window of application 2 may be a move event (e.g., MotionEvent.ACTION_MOVE).
- the touch event obtained by the input event management module based on the hand-raising operation on the window of application 2 may be a leave event (e.g., MotionEvent.ACTION_UP).
- the input event management module when the input event management module detects a sliding and hand-raising operation on the window of application 2, the input event management module may obtain one or more moving events and one leaving event.
- the window of application 2 may be window w2 as shown in FIG6A .
- the input event management module may detect the sliding operation on the window of application 2.
- the input event management module may collect a series of raw input events and process them to obtain a series of MotionEvent.ACTION_MOVE.
- the window of application 2 may be window 2a as shown in FIG7D .
- the input event management module may detect the sliding operation on the window of application 2.
- the input event management module may collect the original input event and process it to obtain MotionEvent.ACTION_MOVE.
- the window of application 2 may be window w2 as shown in FIG6A .
- the input event management module may detect the hand-raising operation on the window of application 2.
- the input event management module may collect the original input event and process it to obtain MotionEvent.ACTION_UP.
- the window of application 2 may be window 2a as shown in FIG7E .
- the input event management module may detect the hand-lift operation on the window of application 2.
- the input event management module may collect the original input event and process it to obtain MotionEvent.ACTION_UP.
- the input event management module when the input event management module detects the sliding and hand-raising operations acting on the window of application 2, the input event management module can continuously obtain touch events (that is, the series of touch events mentioned above), and the input event management module can continuously notify WM to process touch events.
- a user places their finger on the area of the display screen displaying the window of Application 2 and slides it across the display screen. Then, the user can lift their finger off the display screen. If the sliding speed of the user interface in the window of Application 2 exceeds a speed threshold when the user lifts their finger, the sliding component can detect the fling operation.
- the slider can process the fling operation.
- the slider can determine the status of the fling operation and synchronize the fling operation status to SurfaceFlinger.
- the fling operation status can include start (i.e., START) and end (i.e., END).
- the interaction state related information may include the state information of the fling operation corresponding to the application (also referred to as the state information of the fling operation corresponding to the application window).
- the interaction state related information corresponding to application 2 may include the state of the fling operation corresponding to application 2.
- the sliding component can detect the fling operation. After the sliding component detects the fling operation, the sliding component can determine that the state of the fling operation is START and send the state information to SurfaceFlinger. The sliding component can continue to process the fling operation and when the sliding of the user interface in the window of application 2 stops (that is, the sliding speed is 0), determine that the state of the fling operation is END and send the state information to SurfaceFlinger.
- the sliding component can detect that multiple applications have triggered a fling operation. For example, the user can first slide and lift their hand in the area where the window of application 2 is displayed on the display screen. Accordingly, the sliding component can detect that the state of the fling operation corresponding to application 2 is START and send the status information to SurfaceFlinger. Furthermore, the user can slide and lift their hand in the area where the window of application 1 is displayed on the display screen. Before the sliding component detects that the state of the fling operation corresponding to application 2 has changed to END, it detects that the state of the fling operation corresponding to application 1 is START. The sliding component can still send the status information to SurfaceFlinger. In this case, the user interface in the window of application 1 and the user interface in the window of application 2 are both in the fling state for a period of time.
- the sliding component can monitor the status of the fling operation by adding a stub and promptly synchronize the status of the fling operation to SurfaceFlinger. Specifically, after the sliding component adds the stub, it can monitor the start and end of the fling operation corresponding to the window of application 2, and after monitoring the status of the fling operation as START, send the status information to SurfaceFlinger, and after monitoring the status of the fling operation as END, send the status information to SurfaceFlinger.
- the information related to the interaction state may include not only the status information of the fling operation corresponding to the application, but also the UID and/or package name of the application.
- the information related to the interaction state corresponding to application 2 may include the status of the fling operation corresponding to application 2, the UID of application 2 (e.g., 12), and the package name of application 2 (e.g., com.example.app2).
- S16 SurfaceFlinger updates the interaction state corresponding to application 2 based on the information related to the interaction state corresponding to application 2.
- SurfaceFlinger After SurfaceFlinger receives the information about the interaction state of application 2 sent by the sliding component, it can determine the Does the status information of the fling operation in the interaction state related information include START or END. If the status information of the fling operation in the interaction state related information corresponding to application 2 includes START, SurfaceFlinger can determine that the interaction state corresponding to application 2 is the fling state, that is, application 2 is in the fling state, and SurfaceFlinger can update the interaction state of application 2 to the fling state.
- SurfaceFlinger can determine that the interaction state corresponding to application 2 is the non-fling state, that is, application 2 is not in the fling state, and SurfaceFlinger can update the interaction state of application 2 to the non-fling state.
- SurfaceFlinger can generate VSync signals according to the VSync period (i.e., the inverse of the screen refresh rate). Each time SurfaceFlinger generates a VSync signal, it can determine whether the current screen refresh rate is greater than the first refresh rate threshold. If the current screen refresh rate is greater than the first refresh rate threshold, SurfaceFlinger can continue to execute step S18.
- S18 SurfaceFlinger determines the rendering frame rates of application 1 and application 2 based on the focus application and/or focus window and the interaction states corresponding to application 1 and application 2.
- SurfaceFlinger determines whether the current screen refresh rate is greater than a first refresh rate threshold, SurfaceFlinger can determine the rendering frame rates of application 1 and application 2 based on the focus application and/or focus window, and the interaction state corresponding to application 1 and application 2. Specifically, if application 1 is the focus application or is in the fling state, SurfaceFlinger can determine that the rendering frame rate of application 1 is the current screen refresh rate; if application 1 is a non-focus application that is not in the fling state, SurfaceFlinger can determine that the rendering frame rate of application 1 is less than the current screen refresh rate.
- SurfaceFlinger can determine that the rendering frame rate of application 2 is the current screen refresh rate; if application 2 is a non-focus application that is not in the fling state, SurfaceFlinger can determine that the rendering frame rate of application 2 is less than the current screen refresh rate.
- step S18 can refer to the relevant description of step S101, and this application will not go into details here.
- S19 SurfaceFlinger sends an APP-VSync signal to the rendering orchestrator based on the rendering frame rate of application 1 by connecting to channel 1.
- Step S102 After SurfaceFlinger determines the rendering frame rate of application 1, it can send an APP-VSync signal to the rendering orchestrator based on the rendering frame rate of application 1 through connection channel 1.
- the specific implementation method can refer to the relevant description of step S102 and step S103, which will not be repeated in this application.
- the rendering orchestrator can receive the APP-VSync signal sent by SurfaceFlinger through connection channel 1.
- the rendering orchestrator After the rendering orchestrator receives the APP-VSync signal sent by SurfaceFlinger through connection channel 1, it can initiate the rendering process corresponding to application 1, that is, wake up the UI thread of application 1 for drawing and rendering.
- S21 SurfaceFlinger sends the rendering frame rate of application 2 to the rendering orchestrator through connection channel 2 APP-VSync signal.
- Step S102 After SurfaceFlinger determines the rendering frame rate of application 2, it can send an APP-VSync signal to the rendering orchestrator based on the rendering frame rate of application 2 through connection channel 2.
- the specific implementation method can refer to the relevant description of step S102 and step S103, which will not be repeated in this application.
- the rendering orchestrator can receive the APP-VSync signal sent by SurfaceFlinger through connection channel 2.
- the rendering orchestrator After the rendering orchestrator receives the APP-VSync signal sent by SurfaceFlinger through connection channel 2, it can initiate the rendering process corresponding to application 2, that is, wake up the UI thread of application 2 for drawing and rendering.
- FIG12 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
- the electronic device may include: a processor, an external memory interface, an internal memory, a Universal Serial Bus (USB) interface, a charging management module, a power management module, a battery, antenna 1, antenna 2, a mobile communication module, a wireless communication module, a sensor module, a button, a motor, an indicator, a camera, a display, and a Subscriber Identity Module (SIM) card slot, etc.
- a processor an external memory interface
- an internal memory a Universal Serial Bus (USB) interface
- USB Universal Serial Bus
- the audio module may include a speaker, a receiver, a microphone, an earphone interface, etc.
- the sensor module may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
- the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. It is understandable that the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
- the electronic device may include more components than illustrated.
- the electronic device may include other types of sensors.
- the electronic device may include fewer components than illustrated, or combine certain components, or split certain components, or arrange the components differently.
- the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device.
- a processor may include one or more processing units.
- a processor may include an application processor (AP), a modem (also called a baseband processor), a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), and/or a neural network processing unit (NPU).
- An AP is a processor responsible for running the operating system and applications.
- a modem is a processor responsible for handling various communication protocols.
- the wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, a mobile communication module, a wireless communication module, and a modem.
- the modem can interact with the base station through antennas (e.g., antenna 1, antenna 2, etc.).
- antenna 1 of the electronic device is coupled to the mobile communication module
- antenna 2 is coupled to the wireless communication module, allowing the electronic device to communicate with the network and other devices using wireless communication technologies.
- Electronic devices can achieve display functions through GPU, display, and application processor.
- a GPU is a microprocessor for image processing that connects the display screen and the application processor.
- the GPU is used to perform mathematical and geometric calculations for graphics rendering.
- the processor may include one or more GPUs that execute program instructions to generate or change display information.
- the display screen is used to display images, videos, etc.
- the electronic device may include one or more display screens.
- a camera is used to capture still images or video.
- An ISP processes the data from the camera. Light passes through the lens and is transmitted to the camera's photosensitive element, where it is converted into an electrical signal. The camera's photosensitive element then transmits this electrical signal to the ISP for processing, transforming it into a visible image.
- An electronic device may include one or more cameras.
- Internal memory can include one or more RAMs and one or more non-volatile memories (NVMs).
- RAM can be read and written directly by the processor and can be used to store executable programs (e.g., machine instructions) for the operating system or other running programs, as well as user and application data.
- NVM can also store executable programs and user and application data, and can be pre-loaded into RAM for direct reading and writing by the processor.
- the code for implementing the method described in the embodiment of the present application may be stored in a non-volatile memory.
- the electronic device may load the executable code stored in the non-volatile memory into the random access memory.
- the external memory interface can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device.
- Electronic devices can implement audio functions through audio modules, speakers, receivers, microphones, headphone jacks, and application processors.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Controls And Circuits For Display Device (AREA)
Abstract
本申请实施例提供了一种图像显示方法及相关设备。根据该方法,在电子设备同时显示多个应用的多个窗口的情况下,针对焦点应用和交互状态为fling状态的应用,电子设备可以采用等于当前屏幕刷新率的渲染帧率来进行绘制和渲染,而针对交互状态为非fling状态的非焦点应用,电子设备可以采用低于当前屏幕刷新率的渲染帧率来进行绘制和渲染。这种方法可以避免因非焦点应用采用的渲染帧率较高而导致的无用渲染,从而降低系统负载和功耗。
Description
本申请涉及终端技术领域,尤其涉及一种图像显示方法及相关设备。
随着终端设备(也可称为电子设备)品类的增加及其屏幕尺寸的增大,为提高用户的交互效率,设备厂商提供了诸多复合场景下的显示方案,比如:多窗口、分屏、平行视界、悬浮窗口等。基于这些复合场景下的显示方案,终端设备可以同时将一个应用的多个窗口显示给用户,也可以同时将多个应用的不同窗口显示给用户。与此同时,移动终端设备屏幕刷新率(也可称为系统刷新率,或简称为刷新率)规格也在不断提高。高刷新率可以给用户提供在复合场景下更好的滑动交互体验。在复合场景下,终端设备一般会显示多个应用的多个窗口,但是用户在同一时刻操作的焦点往往只是一个应用的一个窗口。
在复合场景下如何既能保证用户体验,又能降低系统功耗是目前亟待解决的问题。
发明内容
本申请提供了一种图像显示方法及相关设备。根据该方法,在电子设备同时显示多个应用的多个窗口的情况下,针对焦点应用和交互状态为fling状态的应用,电子设备可以采用等于当前屏幕刷新率的渲染帧率来进行绘制、渲染其画面,而针对交互状态为非fling状态的非焦点应用,电子设备可以采用低于当前屏幕刷新率的渲染帧率来进行绘制、渲染其画面。这种方法可以避免因非焦点应用采用较高渲染帧率而导致的无用渲染,从而降低系统负载和功耗。
第一方面,本申请提供了一种图像显示方法。该方法可以应用于包括显示屏的电子设备。根据该方法,电子设备可以以第一帧率渲染第一应用的画面,得到第一画面,以第二帧率渲染第二应用的画面,得到第二画面,并对第一画面和第二画面进行合成处理,得到第一图像,然后以第一刷新率在显示屏上显示第一图像。其中,第一应用是处于fling状态的应用或焦点应用,第二应用是处于非fling状态的非焦点应用(或称不处于fling状态的非焦点应用)。第一刷新率大于第一阈值,第一帧率与第一刷新率相等,第二帧率小于第一刷新率。
在本申请提供的方案中,电子设备可以给不同应用设置不同渲染帧率,并且对以该不同渲染帧率绘制渲染得到应用画面进行合成,再将合成后的画面显示在显示屏上,这样可以实现应用渲染帧率的灵活调节。尤其是在屏幕刷新率较高(例如,大于第一阈值)的情况下,电子设备可以给部分应用设置比屏幕刷新率低的渲染帧率,从而降低实现渲染所导致的系统负载和功耗。
在本申请的一些实施例中,第一应用可以属于下文所提及的A类应用,第二应用可以属于下文所提及的B类应用。在这种情况下,电子设备仅需要显示2个应用的窗口(或称画面),即下文所提及的N等于2,且u=1,s=1。
在本申请的一些实施例中,第一应用可以为如图7A所示的阅读应用,第二应用可以为如图7A所示的视频应用。在这种情况下,第一画面可以为窗口2a的画面,第二画面可
以为窗口1a的画面,第一图像可以为如图7A所示的窗口1a的画面和窗口2a的画面合成的图像。
在本申请的一些实施例中,第一帧率可以为下文所提及的r,第二帧率可以为下文所提及的Ri。在一种可能的实现方式中,i=1,表示电子设备当前需要显示相应窗口的B类应用仅有第二应用。
在本申请的一些实施例中,第一阈值可以为下文所提及的第一刷新率阈值。
可理解,第一刷新率为电子设备在显示屏上显示第一图像的过程中所采用的屏幕刷新率。
可理解,第一应用和第二应用为请求了APP-VSync信号的应用。
可理解,在电子设备以第一刷新率在显示屏上显示第一图像的过程中,第一图像可以发生变化,即第一图像包括的第一应用的画面(即第一画面)可以发生变化,第一图像包括的第二应用的画面(即第二画面)也可以发生变化。
结合第一方面,在一种可能的实现方式中,该方法还可以包括:电子设备可以基于第一定时器每隔第一定时时长生成VSync信号,以及每生成Y个第一VSync信号,就相应生成一个第二VSync信号。其中,第一定时时长为第一刷新率的倒数,Y为大于1的整数。电子设备以第一帧率渲染第一应用的画面,具体可以包括:电子设备可以基于第一VSync信号渲染第一应用的画面。电子设备以第二帧率渲染第二应用的画面,具体可以包括:电子设备基于第二VSync信号渲染第二应用的画面。
在本申请提供的方案中,电子设备可以基于触发生成VSync信号的VSync软件定时器来渲染第一应用的画面和第二应用的画面,即采用电子设备原有的一个定时器负责多个应用的APP-VSync信号的下发,无需再另外添加其他定时器来触发电子设备渲染第一应用的画面和第二应用的画面,自然也就无需对多个定时器同步校准,更方便,功耗也更低。
在本申请的一些实施例中,第一VSync信号可以为下文所提及的VSync信号(硬件VSync信号或软件VSync信号),第二VSync信号可以为下文所提及的APP-VSync信号。
在本申请的一些实施例中,第一定时器可以为下文所提及的VSync软件定时器,第一定时时长可以理解为VSync周期。
在本申请的一些实施例中,第一应用每接收一个第一VSync信号,就渲染一次其画面。类似的,第二应用每接收一个第二VSync信号,就渲染一次其画面。
在本申请的一些实施例中,电子设备可以基于第一定时器每间隔x个VSync周期(或z个VSync周期)生成一次App-VSync信号,并将该App-VSync信号发送给第二应用。
在本申请的一些实施例中,第一刷新率为第二帧率的Y倍。
结合第一方面,在一种可能的实现方式中,该方法还可以包括:电子设备可以基于第一定时器每隔第一定时时长生成第一VSync信号,以及基于第二定时器每隔第二定时时长生成第二VSync信号。其中,第一定时时长为第一刷新率的倒数。电子设备以第一帧率渲染第一应用的画面,具体可以包括:电子设备可以基于第一VSync信号渲染第一应用的画面。电子设备以第二帧率渲染第二应用的画面,具体可以包括:电子设备可以基于第二
VSync信号渲染第二应用的画面。其中,第二定时时长为第二帧率的倒数。
在本申请提供的方案中,电子设备可以基于触发生成VSync信号的VSync软件定时器来渲染第一应用的画面,而新建另一个定时器来渲染第二应用的画面。也就是说,电子设备可以基于两个定时器分别向第一应用和第二应用分发App-VSync信号,无需考虑应用的渲染帧率与第一帧率之间是否存在倍数关系,通过这种方法,电子设备可以更加灵活的调节应用的渲染帧率,不必局限于应用的渲染帧率必须整除屏幕刷新率。
在本申请的一些实施例中,第二定时时长可以理解为下文所提及的第二定时器定义的定时时长。可理解,第二定时时长可以为第一定时时长的整数倍,也可以不为第一定时时长的整数倍,其具体数值可以根据实际需要进行设置,本申请对此不作限制。
结合第一方面,在一种可能的实现方式中,第一刷新率为第二帧率的第一倍数,第一倍数大于1的整数。
在本申请提供的方案中,在第一刷新率为第二帧率的整数倍的情况下,电子设备可以采用原有的定时器(例如,VSync软件定时器)来实现对第一应用和第二应用分发App-VSync信号,相比于采用多个定时器的信号分发方式,这种方式更为方便,无需对多个定时器进行同步校准,功耗也会更低一些。
在本申请的一些实施例中,第一倍数可以等于Y。
结合第一方面,在一种可能的实现方式中,第一刷新率不为第二帧率的整数倍。
在本申请提供的方案中,电子设备设置第二帧率时不必局限于应用的渲染帧率必须整除屏幕刷新率,这种方法可以进一步提高调节渲染帧率的灵活性。例如,在第一刷新率为120Hz的情况下,电子设备可以将第二帧率设置为90Hz,不必局限于20Hz、30Hz、40Hz和60Hz等。
结合第一方面,在一种可能的实现方式中,在以第一帧率渲染第一应用的画面之前,该方法还可以包括:响应于第一VSync信号,电子设备可以获取焦点应用(或称当前焦点应用)、第一应用的交互状态和第二应用的交互状态,并基于焦点应用、第一应用的交互状态和第二应用的交互状态,确定第一帧率和第二帧率。交互状态包括fling状态和非fling状态;
在本申请提供的方案中,电子设备可以实现对不同应用采用不同渲染帧率,尤其针对存在用户交互的应用,电子设备可以采用高渲染帧率,而针对不存在用户交互的应用,电子设备可以采用低渲染帧率,避免不存在用户交互的应用采用高渲染帧率而造成的无用渲染,还可以降低系统负载和功耗。
结合第一方面,在一种可能的实现方式中,第一应用可以为不处于fling状态的焦点应用。电子设备以第一刷新率在显示屏上显示第一图像之后,该方法还可以包括:响应于针对第一图像中的第二应用的画面(例如,第二画面)的用户操作,电子设备可以将焦点应用由第一应用更新为第二应用;电子设备还可以将屏幕刷新率设置为第二刷新率。第二刷
新率可以为第二应用对应的最高刷新率。
在本申请提供的方案中,在用户触发焦点应用发生变化的情况下,电子设备可以重新设置屏幕刷新率,具体可以将屏幕刷新率设置为焦点应用对应的最高目标刷新率,即电子设备可以基于与用户存在交互操作的应用所对应的目标刷新率来设置当前屏幕刷新率,这样可以将渲染资源更好的聚焦在与用户存在交互的应用上,提升了用户体验。
在本申请的一些实施例中,应用对应的最高刷新率可以为下文所提及的目标刷新率区间的上限,即最高目标刷新率,应用对应的最低刷新率可以为下文所提及的目标刷新率区间的下限,即最低目标刷新率。
结合第一方面,在一种可能的实现方式中,电子设备将屏幕刷新率设置为第二刷新率之后,该方法还可以包括:在第二刷新率大于第一阈值的情况下,电子设备可以以第三帧率渲染第一应用的画面,得到第三画面,以及以第四帧率渲染第二应用的画面,得到第四画面,并且对第三画面和第四画面进行合成处理,得到第二图像,然后以第二刷新率在显示屏上显示第二图像。第三帧率小于第二刷新率,第四帧率与第二刷新率相等。
在本申请提供的方案中,在焦点应用发生变化的情况下,电子设备可以基于焦点应用对应的最高目标刷新率来设置当前屏幕刷新率,进一步的,电子设备可以确定当前屏幕刷新率是否处于较高水平(例如,当前屏幕刷新率是否大于第一阈值),在当前屏幕刷新率较高(或称焦点应用对应的最高目标刷新率较高)的情况下,电子设备可以降低部分应用的渲染帧率,以降低无用渲染。
类似的,在第二刷新率大于第一阈值的情况下,在电子设备以第二刷新率在显示屏上显示第二图像的过程中,第二图像可以发生变化,即第二图像包括的第一应用的画面(即第三画面)可以发生变化,第二图像包括的第二应用的画面(即第四画面)也可以发生变化。
在本申请的一些实施例中,在每一次生成VSync信号后,响应于该生成的VSync信号,电子设备可以确定当前屏幕刷新率是否大于第一阈值,在当前屏幕刷新率大于第一阈值的情况下,电子设备可以基于焦点应用、第一应用的交互状态和第二应用的交互状态,来设置第一应用的渲染帧率和第二应用的渲染帧率。
结合第一方面,在一种可能的实现方式中,电子设备将屏幕刷新率设置为第二刷新率之后,该方法还可以包括:在第二刷新率小于或等于第一阈值的情况下,电子设备可以以第四帧率渲染第一应用的画面,得到第五画面,以及以第四帧率渲染第二应用的画面,得到第四画面,并对第五画面和第四画面进行合成处理,得到第三图像。也就是说,在第二刷新率小于或等于第一阈值的情况下,电子设备可以以第四帧率渲染第一应用的画面和第二应用的画面,并对以第四帧率渲染得到的第一应用的画面和第二应用的画面,进行合成处理,得到第三图像。电子设备得到第三图像后,还可以以第二刷新率在显示屏上显示第三图像。
在本申请提供的方案中,在焦点应用发生变化的情况下,电子设备可以基于焦点应用对应的最高目标刷新率来设置当前屏幕刷新率,进一步的,电子设备可以确定当前屏幕刷
新率是否处于较高水平(例如,当前屏幕刷新率是否大于第一阈值),在当前屏幕刷新率不处于较高水平的情况下,电子设备可以直接基于当前屏幕刷新率来渲染第一应用和第二应用,即基于屏幕刷新率来向第一应用和第二应用下发APP-VSync信号。通过这种方法,电子设备并非在任何情况下都会在屏幕刷新率的基础上降低应用的渲染帧率,针对屏幕刷新率不高的场景,电子设备可以不另外调节应用的渲染帧率,从而使得应用的渲染帧率等于屏幕刷新率,在一定程度上可以简化流程和降低功耗。
类似的,在第二刷新率小于或等于第一阈值的情况下,在电子设备以第二刷新率在显示屏上显示第三图像的过程中,第三图像可以发生变化,即第三图像包括的第一应用的画面(即第五画面)可以发生变化,第三图像包括的第二应用的画面(即第六画面)也可以发生变化。
结合第一方面,在一种可能的实现方式中,电子设备将屏幕刷新率设置为第二刷新率之后,该方法还可以包括:若在预设时长内未检测到针对显示屏所显示的画面的用户操作,将屏幕刷新率设置为第三刷新率。第三刷新率小于第二刷新率,且第三刷新率大于或等于第二应用对应的最低刷新率。
在本申请提供的方案中,在焦点应用变化后,若一段时间内未检测到相应的用户操作,则电子设备可以降低屏幕刷新率,不必使其维持在较高水平,从而降低功耗。
可理解,预设时长可以根据实际需要进行设置,本申请对此不作具体限制。
第二方面,本申请提供了一种电子设备,该电子设备包括显示屏、一个或多个存储器,以及一个或多个处理器;该显示屏与一个或多个存储器、该一个或多个处理器耦合,该显示屏用于显示绘制、渲染和合成后的画面,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该电子设备执行如第一方面或第一方面的任意一种实现方式所描述的方法。
第三方面,本申请提供了一种计算机存储介质。该计算机存储介质包括计算机指令,当该计算机指令在电子设备上运行时,使得该电子设备执行如第一方面或第一方面的任意一种实现方式所描述的方法。
第四方面,本申请实施例提供一种芯片。该芯片可以应用于电子设备,该芯片包括一个或多个处理器,该处理器用于调用计算机指令以使得该电子设备执行如第一方面或第一方面的任意一种实现方式所描述的方法。
在本申请的一些实施例中,芯片系统可以为应用处理器(Application Processor,AP),或者包括AP的片上系统(System on Chip,SoC),上述第一方面或第一方面的任意一种实现方式所描述的方法可以由一个AP实施,上述第二方面或第二方面的任意一种实现方式所描述的方法可以由一个AP实施。
在本申请的又一些实施例中,芯片系统可以包括AP和其他模块。该其他模块可以为调制解调处理器(Modem,也可称之为基带处理器)。
第五方面,本申请实施例提供一种包含指令的计算机程序产品。当该计算机程序产品在电子设备上运行时,使得该电子设备执行如第一方面或第一方面的任意一种实现方式所
描述的方法。
可理解,上述第二方面提供的电子设备、第三方面提供的计算机存储介质、第四方面提供的芯片,以及第五方面提供的计算机程序产品均用于执行如第一方面或第一方面的任意一种实现方式所描述的方法。因此,其所能达到的有益效果可参考上述第一方面中任一种可能的实现方式的有益效果,此处不再赘述。
图1为本申请实施例提供的一种用户界面示意图;
图2为本申请实施例提供的又一种用户界面示意图;
图3为本申请实施例提供的一种渲染流程示意图;
图4为本申请实施例提供的一种VSync信号分发示意图;
图5为本申请实施例提供的一种图像显示方法的流程图;
图6A-图6C为本申请实施例提供的一种触发fling状态的示意图;
图7A-图7C为本申请实施例提供的又一组用户界面示意图;
图7D-图7E为本申请实施例提供的一种窗口滑动状态的变化示意图;
图8A为本申请实施例提供的又一种图像显示方法的流程图;
图8B为本申请实施例提供的又一种图像显示方法的流程图;
图9A为本申请实施例提供的又一种VSync信号分发示意图;
图9B为本申请实施例提供的又一种VSync信号分发示意图;
图10为本申请实施例提供的一种电子设备的软件结构示意图;
图11A和图11B为本申请实施例提供的又一种图像显示方法的流程图;
图12为本申请实施例提供的一种电子设备的硬件结构示意图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;文本中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
应当理解,本申请的说明书和权利要求书及附图中的术语“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。
应当理解,本申请的说明书和权利要求书及附图中的术语“用户界面”,是应用程序或操作系统与用户之间进行交互和信息交换的介质接口。用户界面常用的表现形式是图形用户界面(Graphic User Interface,GUI),是指采用图形方式显示的与计算机操作相关的用户界面。它可以是在电子设备的显示屏中显示的一个图标、窗口、控件等界面元素,其中控
件可以包括图标、按钮、菜单、选项卡、文本框、对话框、状态栏、导航栏、小部件(Widget)等可视的界面元素。
在本申请中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本申请所描述的实施例可以与其它实施例相结合。
根据上文,在复合场景下,电子设备可以显示多个应用的多个窗口,还可以显示一个应用的多个窗口。可理解,应用的窗口中显示有该应用的用户界面。基于电子设备的刷新率控制策略,在电子设备上运行的应用可以预设有目标刷新率区间,如:[60,60]、[60,120]等。在电子设备仅显示一个应用的窗口的情况下,电子设备可以基于该应用对应设置的目标刷新率区间(可简称为应用对应的目标刷新率区间)来刷新电子设备显示的画面。在同时运行多个应用的场景下,不同应用的目标刷新率区间可能相同,也可能不同,在这种情况下,电子设备可以基于其中一个应用的目标刷新率区间来刷新电子设备显示的画面。也就是说,电子设备采用的系统整体的刷新率策略(例如,用户交互时采用的刷新率策略)是基于该目标刷新率区间设置屏幕刷新率。
在电子设备显示有多个应用的多个窗口的复合场景下,用户在同一时刻可以与一个应用的一个窗口进行交互,并按照该用户交互的应用对应的目标刷新率区间,来对电子设备显示的多个应用的多个窗口进行刷新。一旦该用户交互的应用对应的目标刷新率区间的上限较高,系统负载和功耗就会大大增加,影响系统长期运行的稳定性。
为了便于描述,本申请将用户交互的应用记为焦点应用,将用户交互的应用窗口记为焦点窗口,将用户未交互的应用记为非焦点应用。
在上述复合场景下,电子设备的屏幕刷新率(即系统刷新率)可以基于焦点应用对应的目标刷新率区间来设置。具体地,在用户针对电子设备有交互操作的情况下,电子设备的屏幕刷新率可以维持在该焦点应用对应的目标刷新率区间上限(例如,90Hz或120Hz),在用户停止交互(例如,用户在电子设备的显示屏上滑动后抬手)的情况下,电子设备的屏幕刷新率可以回落到该焦点应用对应的目标刷新率区间下限(例如,60Hz或更低频率)。可理解,该回落过程中,电子设备的屏幕刷新率可以设置为低于该目标刷新率区间上限且高于该目标刷新率区间下限的值。目标刷新率区间上限也可以被称为最高目标刷新率,目标刷新率区间下限也可以被称为最低目标刷新率。
下面基于表1示例性介绍上述复合场景下的刷新策略。
表1
如表1所示,电子设备可以同时显示应用1的用户界面和应用2的用户界面,并且检测到作用于应用2的用户界面上的用户操作。也就是说,应用2为焦点应用,而应用1为非焦点应用。
在一种可能的实现方式中,如表1所示,电子设备原本给应用1设置的目标刷新率区间上限(即应用1对应的最高目标刷新率)为60Hz,原本给应用2设置的目标刷新率区间上限(即应用2对应的最高目标刷新率)为120Hz。在这种情况下,电子设备检测到作用于应用2的用户界面上的用户操作之后,可以按照焦点应用(即应用2)对应的最高目标刷新率,即120Hz,来刷新其显示的画面(包括应用1的用户界面和应用2的用户界面)。可理解,应用1对应的最高目标刷新率仅为60Hz,若电子设备按照120Hz来刷新应用1的用户界面,其刷新频率会超预期(即实际采用的刷新频率会大于最高目标刷新率),且应用1为非焦点应用,采用高刷新率会造成无用渲染,增加额外的系统负载。可理解,这里所提及的刷新频率以及表1中所提及的渲染刷新频率可以理解为后文所提及的渲染帧率,即应用绘制、渲染画面(或称一帧图像)的频率。
在又一种可能的实现方式中,如表1所示,电子设备原本给应用1和应用2设置的目标刷新率区间上限均为60Hz,即应用1和应用2对应的最高目标刷新率均为60Hz。在这种情况下,电子设备检测到作用于应用2的用户界面上的用户操作之后,可以按照应用2对应的最高目标刷新率,即60Hz,来刷新其显示的画面(包括应用1的用户界面和应用2的用户界面)。可理解,应用1对应的最高目标刷新率为60Hz,电子设备按照60Hz来刷新其用户界面是满足预期的,不会增加额外的系统负载。
在又一种可能的实现方式中,如表1所示,电子设备原本给应用1和应用2设置的目标刷新率区间上限均为120Hz,即应用1和应用2对应的最高目标刷新率均为120Hz。在这种情况下,电子设备检测到作用于应用2的用户界面上的用户操作之后,可以按照焦点应用(即应用2)对应的最高目标刷新率,即120Hz,来刷新其显示的画面(包括应用1的用户界面和应用2的用户界面)。可理解,虽然应用1对应的最高目标刷新率也为120Hz,但是应用1为非焦点应用,采用高刷新率会造成无用渲染,增加额外的系统负载。
在又一种可能的实现方式中,如表1所示,电子设备原本给应用1和应用2设置的目标刷新率区间上限分别为120Hz和60Hz,即应用1对应的最高目标刷新率为120Hz,应用2对应的最高目标刷新率为60Hz。在这种情况下,电子设备检测到作用于应用2的用户
界面上的用户操作之后,可以按照焦点应用(即应用2)对应的最高目标刷新率,即60Hz,来刷新其显示的画面(包括应用1的用户界面和应用2的用户界面)。可理解,应用1对应的最高目标刷新率为120Hz,且应用1为非焦点应用,电子设备采用60Hz来刷新应用1的用户界面不会造成无用渲染,自然也就不会增加额外的系统负载。
可理解,电子设备会按照焦点应用对应的目标刷新率区间,来对焦点应用的用户界面和非焦点应用的用户界面进行刷新。在焦点应用对应的最高目标刷新率较高的情况下,上述刷新方式可能会造成非焦点应用的刷新频率超预期,以及造成无用渲染,使得系统负载增加。
示例性的,如图1所示,电子设备的显示屏上可以显示有窗口1a和窗口2a。其中,窗口1a中显示的是一个视频应用的用户界面,窗口2a中显示的是一个阅读应用的用户界面。该视频应用对应的最高目标刷新率为60Hz,而该阅读应用对应的最高目标刷新率为120Hz。电子设备可以检测到作用于窗口2a上的用户操作(例如,点击操作),响应于该用户操作,电子设备可以确定窗口2a为焦点窗口,该阅读应用为焦点应用,进一步的,电子设备可以采用该阅读应用对应的最高目标刷新率来刷新其在显示屏上显示的整个画面(包括窗口1a中显示的画面和窗口2a中显示的画面)。但是,该视频应用对应的最高目标刷新率仅为60Hz,若电子设备按照120Hz来刷新该视频应用的用户界面,其刷新频率会超预期(即实际采用的刷新频率会大于最高目标刷新率),且该视频应用为非焦点应用,采用高刷新率会造成无用渲染,增加额外的系统负载。
示例性的,如图2所示,电子设备的显示屏上可以显示有窗口3a、窗口3b和窗口2a。其中,窗口3a和窗口3b中显示的是一个购物应用的用户界面,窗口2a中显示的是一个阅读应用的用户界面。该购物应用和该阅读应用对应的最高目标刷新率均为120Hz。电子设备可以检测到作用于窗口2a上的用户操作(例如,点击操作),响应于该用户操作,电子设备可以确定窗口2a为焦点窗口,该阅读应用为焦点应用,进一步的,电子设备可以采用该阅读应用对应的最高目标刷新率来刷新其在显示屏上显示的整个画面(包括窗口3a、窗口3b中显示的画面,以及窗口2a中显示的画面)。但是该购物应用为非焦点应用,采用高刷新率会造成无用渲染,增加额外的系统负载。
基于上述内容,本申请实施例提供了一种图像显示方法及相关设备。根据该方法,在电子设备同时显示多个应用的多个窗口的情况下,针对焦点应用和交互状态为fling状态的应用,电子设备可以采用当前屏幕刷新率作为其渲染帧率来进行绘制和渲染,而针对交互状态为非fling状态的非焦点应用,电子设备可以采用低于当前屏幕刷新率的渲染帧率来进行绘制和渲染。这种方法可以避免因非焦点应用采用的渲染帧率较高而导致的无用渲染,从而降低系统负载和功耗。
本申请涉及渲染机制,为了便于理解,下面首先对渲染机制(也可称为VSync机制)进行简单介绍。
图形渲染管线涉及应用程序(可简称为应用)、图像合成系统(SurfaceFlinger)和显示
屏(也可称为屏幕)。其中,SurfaceFlinger也可以被称为图像合成器。对于一帧画面,首先需要应用对其进行绘制和渲染,再由SurfaceFlinger对其进行合并渲染后放入帧缓冲区(framebuffer),最终送到显示屏进行显示。
图形渲染管线(包括应用的绘制渲染工作、SurfaceFlinger的合成工作和显示屏的显示工作)整体由垂直同步(Vertical Synchronization,VSync)信号驱动。电子设备可以按照固定周期产生VSync信号,该固定周期可以被称为VSync周期。
在本申请的一些实施例中,对于同一帧画面,第一个VSync周期到来(或称第一个VSync信号产生)时,应用开始进行UI渲染,第二个VSync周期到来(或称第二个VSync信号产生)时,SurfaceFlinge可以进行图层的合成,第三个VSync周期到来(或称第三个VSync信号产生)时,显示屏获取合成完成的数据,并将其显示在显示屏上以呈现给用户。示例性的,如图3所示,在第一个VSync周期到来时,应用可以完成第一帧的UI渲染,在第二个VSync周期到来时,SurfaceFlinge可以完成第一帧的图层合成,应用可以完成第二帧的UI渲染,在第三个VSync周期到来时,显示屏可以完成第一帧的显示,SurfaceFlinge可以完成第二帧的图层合成,应用可以完成第三帧的UI渲染,在第四个VSync周期到来时,显示屏可以完成第二帧的显示,SurfaceFlinge可以完成第三帧的图层合成,应用可以完成第四帧的UI渲染,在第五个VSync周期到来时,显示屏可以完成第三帧的显示,SurfaceFlinge可以完成第四帧的图层合成,应用可以完成第五帧的UI渲染。
如图4所示,产生VSync信号的方式有两种:由硬件(例如,硬件合成器相关的硬件模块)产生,以及由软件(例如,VSyncThread)模拟。可理解,硬件或软件可以按照固定周期产生VSync信号,该固定周期可以被称为VSync周期。可理解,由硬件产生的VSync信号可以被称为硬件VSync信号,而由软件产生的VSync信号可以被称为软件VSync信号。在本申请的一些实施例中,VSync周期由屏幕刷新率决定。例如,屏幕刷新率可以为60Hz,VSync周期可以为该屏幕刷新率的倒数,即16.67毫秒(ms)。
在本申请的一些实施例中,由硬件产生的VSync信号(也可称为HW-VSync信号)可以为一个脉冲信号。在本申请的一些实施例中,软件模拟产生VSync信号,具体可以包括:电子设备通过硬件产生的VSync信号进行采样并创建模型,然后输出VSync信号。
在本申请的一些实施例中,由硬件产生的VSync信号可以为硬件合成器(Hardware Composer,HWC)接收到的硬件VSync事件。可理解,HWC中可以注册硬件VSync事件回调,在硬件VSync事件到来时,回调HWC的vsync函数。HWC接收到硬件VSync事件之后,通过SurfaceFlinger将硬件VSync事件添加到DispSync的VSync事件样本中,当DispSync采样完成后,则会停止硬件VSync事件,由软件根据样本的计算结果来产生VSync事件,即产生VSync信号。可理解,在软件产生VSync信号的周期有误差时,电子设备需要重新通过硬件产生VSync事件,并再次采集硬件VSync事件样本。
如图4所示,电子设备可以通过硬件产生或软件模拟VSync信号(如图4所示的硬件VSync信号/软件VSync信号),并通过VSync信号虚拟化线程(例如,DispSyncThread)将VSync信号虚拟化成App-VSync信号(也可称为VSync-app信号)和SF-VSync信号(也可称为VSync-sf信号)。电子设备可以分别通过两个事件线程(EventThread)来接收
APP-VSync信号和SF-VSync信号。为了便于理解和描述,本申请将接收APP-VSync信号的事件线程记为EventThread(APP),将接收SF-VSync信号的事件线程记为EventThread(SF)。如图4所示,EventThread(APP)接收APP-VSync信号之后,可以唤醒相应应用,并驱动该应用进行UI渲染。具体地,应用的UI线程被唤醒后进行UI渲染的工作(包括输入事件处理、动画、绘制等)。EventThread(SF)接收SF-VSync信号之后,可以唤醒SurfaceFlinger,并驱动SurfaceFlinger进行图层合并。
下面介绍本申请实施例提供的一种图像显示方法。
请参阅图5,图5为本申请实施例提供的一种图像显示方法的流程图。该渲染帧率调节方法可以应用于电子设备,其包括但不限于以下步骤:
S101:在当前屏幕刷新率大于第一刷新率阈值的情况下,基于焦点应用和N个应用的交互状态设置该N个应用的渲染帧率。
在当前屏幕刷新率大于第一刷新率阈值的情况下,电子设备可以基于焦点应用和N个应用的交互状态设置该N个应用的渲染帧率,这N个应用为电子设备已启动的N个应用。在本申请的一些实施例中,这N个应用为向电子设备请求APP-VSync信号的应用,具体可以为:向事件线程(如图4所示)请求APP-VSync信号的应用。可理解,本申请对电子设备启动该N个应用的先后顺序不作限制。N为大于1的整数。例如,N可以为2。再例如,N可以为3。
在本申请的一些实施例中,电子设备基于焦点应用和N个应用的交互状态设置该N个应用的渲染帧率,具体可以包括:电子设备针对该N个应用中的焦点应用或处于fling状态的应用,保持其渲染帧率与当前屏幕刷新率相同,针对该N个应用中不处于fling状态的非焦点应用,设置其渲染帧率小于当前屏幕刷新率。
在本申请的一些实施例中,响应于生成的VSync信号,电子设备可以确定当前屏幕刷新率是否大于第一刷新率阈值,在当前屏幕刷新率大于第一刷新率阈值的情况下,基于焦点应用和N个应用的交互状态设置该N个应用的渲染帧率。
在本申请的一些实施例中,电子设备生成VSync信号,具体可以包括:电子设备通过其硬件生成VSync信号,或者电子设备通过其软件模拟生成VSync信号(与硬件生成VSync信号同步)。
在本申请的一些实施例中,电子设备每一次生成VSync信号后,响应于该生成的VSync信号,电子设备可以确定当前屏幕刷新率是否大于第一刷新率阈值,在当前屏幕刷新率大于第一刷新率阈值的情况下,基于焦点应用和N个应用的交互状态设置该N个应用的渲染帧率。
根据上文,每一次生成VSync信号后,具体可以理解为:每一个VSync周期到来时。
在本申请的一些实施例中,VSync周期为屏幕刷新率(或称系统刷新率)的倒数。例如,电子设备的屏幕刷新率可以为120Hz,相应的,VSync周期可以为1/120s,即8.3ms(保留小数点后一位)。
可理解,电子设备可支持的屏幕刷新率的大小主要由电子设备的显示屏自身规格(例如,显示屏的带宽、分辨率、刷新率等)决定。
在本申请的一些实施例中,电子设备的屏幕刷新率是一个固定的值。例如,电子设备的屏幕刷新率固定为60Hz。
在本申请的又一些实施例中,电子设备可以支持多种屏幕刷新率规格,即电子设备的屏幕刷新率可以改变。例如,电子设备支持120Hz的屏幕刷新率(即显示屏每秒钟刷新画面的次数为120次)和60Hz的屏幕刷新率(即显示屏每秒钟刷新画面的次数为60次)。在这种情况下,电子设备可以根据当前使用场景来自动调节屏幕刷新率,或者,用户可以触发电子设备调节屏幕刷新率。例如,电子设备中默认设置的系统刷新率为60Hz,用户可以触发将电子设备的系统刷新率调节为120Hz。
可理解,在电子设备支持多种屏幕刷新率的情况下,电子设备使用的初始屏幕刷新率可以根据实际需要进行设置。例如,电子设备中设置的初始屏幕刷新率可以为60Hz。
可理解,本申请对电子设备支持的一种或多种屏幕刷新率的具体数值不作限制。
在本申请的一些实施例中,电子设备可以设置有VSync软件定时器,并通过该VSync软件定时器来管控VSync信号。可理解,VSync软件定时器定义的定时时长为一个VSync周期。具体地,VSync软件定时器的计时时长每达到其定义的定时时长(即一个VSync周期),电子设备就生成一个VSync信号。进一步的,如图4所示,电子设备可以基于生成的VSync信号生成App-VSync信号和SF-VSync信号,并进行App-VSync信号和SF-VSync信号的分发。
需要说明的是,在电子设备当前使用的屏幕刷新率(即当前屏幕刷新率)发生变化的情况下,VSync周期也会相应发生变化,VSync软件定时器定义的定时时长也会相应发生变化。
在一种可能的实现方式中,VSync软件定时器的计时时长每次达到其定义的定时时长(即一个VSync周期)后,可以停止计时并清零,然后重新开始计时,直到计时时长再次达到其定义的定时时长,再停止计时并清零,然后重新开始计时,循环往复。
在本申请的一些实施例中,电子设备可以记录焦点应用,这样,电子设备可以查看记录来确定当前焦点应用。例如,电子设备可以记录有焦点应用的包名。具体地,电子设备可以检测到作用于显示屏的用户操作,响应于该用户操作,电子设备可以基于用户操作在显示屏上的具体位置来更新并记录焦点应用和/或焦点窗口。在一种可能的实现方式中,响应于用户作用在显示有N个应用的窗口的显示屏上的触摸操作,电子设备可以确定用户触摸位置所在的窗口为焦点窗口,并且,基于各窗口与应用之间存在的对应关系,确定焦点窗口对应的应用即为焦点应用。
示例性的,如图1所示,电子设备在显示屏上显示窗口1a和窗口2a,且窗口1a为一个视频应用对应的窗口,窗口1a中显示有该视频应用的用户界面,窗口2a为一个阅读应用对应的窗口,窗口2a中显示有该阅读应用的用户界面。电子设备可以检测到点击窗口2a的用户操作(或称点击该窗口2a中的用户界面的用户操作),在检测到该点击操作之后,电子设备可以将焦点窗口更新为窗口2a,并且,将焦点应用更新为窗口2a对应的应用,即该阅读应用。
在本申请的一些实施例中,电子设备可以基于焦点应用对应的目标刷新率区间来设置屏幕刷新率。具体地,电子设备检测到用户操作后,可以确定焦点应用是否发生变化。若焦点应用未发生变化,电子设备可以基于焦点应用(即该未发生变化的焦点应用)对应的目标刷新率区间来设置屏幕刷新率,而若焦点应用发生变化,电子设备可以基于变化后的焦点应用对应的目标刷新率区间来设置屏幕刷新率。
在一种可能的实现方式中,在检测到用户操作并确定焦点应用未发生变化的情况下,电子设备可以将屏幕刷新率设置为焦点应用对应的最高目标刷新率,在用户操作停止后,电子设备可以在该焦点应用对应的目标刷新率区间内降低屏幕刷新率,即将屏幕刷新率设置得小于该焦点应用对应的最高目标刷新率,且不小于该焦点应用对应的最低目标刷新率。例如,在用户操作停止后,电子设备可以将屏幕刷新率设置为该焦点应用对应的最低目标刷新率。
在一种可能的实现方式中,在检测到用户操作并确定焦点应用发生变化的情况下,电子设备可以将屏幕刷新率设置为变化后的焦点应用对应的最高目标刷新率,在用户操作停止后,电子设备可以在该变化后的焦点应用对应的目标刷新率区间内降低屏幕刷新率,即将屏幕刷新率设置得小于该变化后的焦点应用对应的最高目标刷新率,且设置的屏幕刷新率不低于该变化后的焦点应用对应的最低目标刷新率。例如,在用户操作停止后,电子设备可以将屏幕刷新率设置为该变化后的焦点应用对应的最低目标刷新率。
在本申请的一些实施例中,电子设备中存储有一个或多个应用与目标刷新率区间之间的对应关系。可理解,电子设备中的多个应用对应的目标刷新率区间可以完全相同,可以部分相同,也可以完全不同,本申请对此不作限制。
可理解,应用对应的目标刷新率区间可以根据实际需要进行设置,本申请对此不作限制。需要说明的是,应用对应的目标刷新率区间中所包含的刷新率是电子设备支持的屏幕刷新率。具体地,电子设备可以在应用对应的目标刷新率区间内选择电子设备支持的刷新率来设置屏幕刷新率,而不是该应用对应的目标刷新率区间中的每一个值都可以被设置为屏幕刷新率。例如,电子设备支持的屏幕刷新率包括144Hz、120Hz、90Hz、60Hz、40Hz和30Hz,在这种情况下,电子设备中的各应用对应的目标刷新率区间的上限和下限可以在上述刷新率中选择,不能为电子设备不支持的其他屏幕刷新率,比如,电子设备中的应用对应的目标刷新率区间可以为[60,90],而不能为[20,110]。
在本申请的一些实施例中,应用对应的目标刷新率区间是出厂前预先设置的,随着应用升级或系统升级,应用对应的目标刷新率区间可以发生变化(例如,目标刷新率区间上限提高),但是变化后的目标刷新率区间的上限和下限也是电子设备支持的屏幕刷新率。例如,电子设备支持的屏幕刷新率包括120Hz和60Hz,应用1升级前对应的最高目标刷新率为60Hz,应用1升级后对应的最高目标刷新率变为120Hz。
在本申请的一些实施例中,对于电子设备出厂后下载的应用,电子设备可以基于应用类型和其自身运行的需求来设置其对应的目标刷新率区间。当然,电子设备需要在其支持的屏幕刷新率的范围内设置应用对应的目标刷新率区间。
在本申请的一些实施例中,一部分应用携带有其对应的目标刷新率区间的相关信息,
电子设备在下载安装及启动这一部分应用的过程中,可以获取其对应的目标刷新率区间的相关信息,并确定其对应的目标刷新率区间。
在本申请的一些实施例中,用户可以自行更改应用对应的目标刷新率区间。当然,用户需要在电子设备支持的屏幕刷新率的范围内设置应用对应的目标刷新率区间。
在本申请的一些实施例中,针对设置有上下滑动界面的应用(例如,阅读应用、社交媒体及购物应用等),电子设备可以将其对应的目标刷新率区间上限(即最高目标刷新率)设置得较高,比如,其对应目标刷新率区间上限可以设置为最高屏幕刷新率(例如,144Hz)。
在本申请的一些实施例中,电子设备可以记录已启动的各应用的交互状态。与上文记录焦点应用类似,电子设备可以基于作用于显示屏的用户操作,来更新并记录各应用的交互状态。在本申请的一些实施例中,应用的交互状态可以包括:非抛滑(或称惯性滑动,英文为fling)状态和fling状态。fling指的是:用户在显示屏上滑动应用的用户界面并抬手后,显示屏所显示的该应用的用户界面自动滑动(此时用户未触摸该应用的用户界面),具体指顺着惯性继续往手指滑动的方向继续滚动直到停止。fling操作从手指离开显示屏瞬间被触发,在滚动停止时结束。非fling状态指的是除fling状态外的其他状态。例如,应用的用户界面未滑动。
下面结合图6A-图6C具体介绍fling状态。
如图6A-图6C所示,电子设备在显示屏上显示2个窗口(即窗口w1和窗口w2),这2个窗口分别对应一个应用。需要说明的是,图6A-图6C仅为本申请提供的一个示例,电子设备还可以在显示屏上显示更多应用的更多窗口,本申请对此不作限制。
图6A-图6C表示的是用户通过手指在显示屏上滑动,并触发fling的过程。具体地,如图6A中的(1)所示,用户手指落在显示屏上(本次滑动过程中针对显示屏的初次触摸),当用户手指落在显示屏上时,窗口w2中的图标1处于位置1。进一步的,如图6B中的(2)所示,用户手指落在显示屏上之后,可以在显示屏上向上滑动(图6A和图6B中已示出手指向上滑动轨迹),并且,在该滑动过程中,窗口w2所显示的用户界面随着手指的滑动而向上滑动,相应的,窗口w2所显示的用户界面中的图标1的位置由位置1变为位置2(图6B中已示出在该滑动过程中,图标1的位置变化)。进一步的,如图6B中的(3)所示,在用户手指在显示屏上向上滑动一段距离后,用户抬手(即用户手指离开显示屏),此时,窗口w2中的图标1处于位置2。进一步的,如图6C中的(4)所示,用户抬手后,在滑动速度大于速度阈值的情况下,触发fling,窗口w2中的用户界面继续向上滑动(自动向上滑动)。在窗口w2中的用户界面自动向上滑动的过程中,图标1的位置由位置2变为位置3。待图标1处于位置3时,窗口w2中的用户界面停止滑动。
示例性的,如图7A所示,电子设备可以在显示屏上显示视频应用对应的窗口1a和阅读应用对应的窗口2a,电子设备可以检测到作用在窗口2a上的向上滑动操作,响应于该向上滑动操作,窗口2a中的用户界面随着用户手指的滑动而向上滑动。可理解,图7A所示的向上滑动操作可以包含图6A所示的手指落在显示屏上的操作,以及图6B所示的手指在显示屏上向上滑动的操作。在电子设备检测到作用在窗口2a上的向上滑动操作之后,电子设备可以检测到作用在窗口2a上的抬手操作。如图7B所示,在电子设备检测到作用在窗
口2a上的抬手操作之后,窗口2a中的用户界面可以继续向上滑动,此时的滑动是窗口2a中的用户界面的自动滑动,而不是用户手指带动的用户界面的滑动。如图7B所示,在窗口2a中的用户界面自动向上滑动的过程中,用户可以点击窗口1a中的视频1控件,响应于该点击操作,电子设备可以在显示屏上显示如图7C所示的内容。如图7C所示,电子设备可以在显示屏上显示窗口1a、窗口1b和窗口2a,与窗口1a一样,窗口1b也是视频应用对应的窗口,此时,窗口2a中的用户界面不同于图7B所示的窗口2a中的用户界面。也就意味着,在焦点应用从该阅读应用变为该视频应用的过程中,窗口2a中的用户界面仍然在向上滑动,并未受到用户点击视频1控件的影响(比如没有因为用户点击视频1控件而停止滑动)。并且,如图7C所示,窗口2a中的用户界面可以继续向上滑动。
示例性的,图7D和图7E示出了用户手指在窗口2a中向上滑动,并触发fling的过程中,窗口2a中的用户界面的具体变化情况。如图7D中的(1)所示,用户手指落在显示屏上并在显示屏上向上滑动,响应于该用户操作,电子设备的窗口2a中的用户界面随着手指的滑动而向上滑动。在该滑动过程中,电子设备的窗口2a中可以显示有如图7D中的(1)和(2)所示的用户界面。可理解,如图7D中的(1)-(3)所示,在用户手指在显示屏上向上滑动的过程中,窗口2a中的用户界面也在相应发生变化。如图7E中的(1)所示,用户手指在显示屏上向上滑动一段距离之后可以抬起,响应于该用户操作,电子设备的窗口2a中的用户界面可以继续向上自动滑动,在该自动滑动过程中,电子设备的窗口2a可以显示有如图7E中的(2)所示的用户界面。如图7E中的(3)所示,电子设备的窗口2a中的用户界面向上滑动一段距离后可以停止滑动。
在本申请的一些实施例中,滑动速度可以为用户手指在显示屏上滑动的速度,具体可以是在某一方向的滑动速度。
可理解,速度阈值可以根据实际需要进行设置,本申请对此不作限制。
可理解,电子设备检测到用户触摸显示屏的操作之后,可以生成相应的触摸事件。触摸事件可以包括以下三种类型的事件:落下事件(例如,MotionEvent.ACTION_DOWN)、移动事件(例如,MotionEvent.ACTION_MOVE),以及离开事件(例如,MotionEvent.ACTION_UP)。可理解,一个完整的触摸显示屏的操作以落下事件开始,中间可以不存在或者存在一个或多个移动事件,最终以离开事件结束。例如,在用户用手指点击显示屏的过程中,用户手指落在显示屏上会触发电子设备生成落下事件,用户手指离开显示屏会触发电子设备生成离开事件。再例如,在用户用手指在显示屏上滑动的过程中,用户手指落在显示屏上会触发电子设备生成落下事件,用户手指落在显示屏后在显示屏上滑动会触发电子设备生成多个移动事件,用户手指离开显示屏会触发电子设备生成离开事件。可理解,fling是在用户手指离开显示屏(即手指完全抬起)后发生的动作。
在本申请的一些实施例中,用户手指落在显示屏上,响应于该用户操作,电子设备生成落下事件,以及更新焦点窗口。
在本申请的一些实施例中,用户手指在显示屏上滑动后抬手,响应于该用户操作,在滑动速度大于速度阈值的情况下,电子设备可以执行fling操作。在一种可能的实现方式中,电子设备可以通过调用computeCurrentVelocity()方法来计算当前滑动速度。在一种可能的
实现方式中,电子设备可以基于落下事件和离开事件的坐标确定滑动距离,以及确定滑动时长(具体可以为生成落下事件和生成离开事件之间的时长),再基于该滑动距离和该滑动时长来计算滑动速度。
可理解,在每一次生成VSync信号后(或称每一个VSync周期到来时),电子设备可以确定当前屏幕刷新率调节是否大于第一刷新率阈值。在当前屏幕刷新率大于第一刷新率阈值的情况下,针对电子设备在显示屏上显示的窗口所对应的N个应用中的每一个应用,电子设备可以确定其是否为焦点应用,以及其交互状态是否为fling状态。具体地,针对该N个应用中的焦点应用或处于fling状态的应用,电子设备可以保持其渲染帧率与当前屏幕刷新率相同。然而,针对该N个应用中处于非fling状态(即不处于fling状态)的非焦点应用,电子设备可以设置(或称调节)其渲染帧率为小于当前屏幕刷新率的渲染帧率。
可理解,第一刷新率阈值可以根据实际需要进行设置,本申请对此不作限制。例如,第一刷新率阈值可以为60Hz。
为了便于理解和描述,本申请将电子设备在显示屏上显示的窗口所对应的N个应用中的焦点应用或处于fling状态的应用记为A类应用,以及将该N个应用中不处于fling状态的非焦点应用记为B类应用。
根据上文,在本申请的一些实施例中,每一次生成VSync信号后,在当前屏幕刷新率大于第一刷新率阈值的情况下,针对该N个应用中的A类应用,电子设备可以确定其渲染帧率为当前屏幕刷新率,针对该N个应用中的B类应用,电子设备可以确定其渲染帧率小于当前屏幕刷新率。
为了便于理解和描述,针对电子设备在显示屏上显示的窗口所对应的N个应用,本申请将其中A类应用的数量记为u,将其中B类应用的数量记为s。也就是说,该N个应用中有u个应用处于fling状态或者为焦点应用,该N个应用中有s个不处于fling状态的非焦点应用。可理解,u+s=N。
为了便于理解和描述,本申请还可以将当前屏幕刷新率记为r,以及将B类应用所对应的设置的渲染帧率记为Ri。可理解,i为不大于s的整数。也就是说,电子设备在显示屏上显示的窗口所对应的N个应用中的B类应用所对应设置的渲染帧率为{R1,…,Ri,…,Rs}。其中,R1到Rs分别为该N个应用中的s个B类应用分别对应设置的渲染帧率。
在本申请的一些实施例中,每一次生成VSync信号后,在当前屏幕刷新率大于第一刷新率阈值的情况下,针对电子设备在显示屏上显示的窗口所对应的N个应用中的A类应用,电子设备可以将其渲染帧率保持为当前屏幕刷新率。也就是说,该N个应用中的u个A类应用对应设置的渲染帧率均为r。
可理解,r的具体值可以根据实际需要进行设置,本申请对此不作限制。例如,r可以为120Hz。在本申请的一些实施例中,r的具体值与应用需求和类型有关。
在本申请的一些实施例中,每一次生成VSync信号后,在当前屏幕刷新率大于第一刷新率阈值的情况下,针对电子设备在显示屏上显示的窗口所对应的N个应用中的B类应用,电子设备可以将其渲染帧率设置为小于当前屏幕刷新率的渲染帧率。也就是说,Ri小于r。
在本申请的一些实施例中,该N个应用中的B类应用对应设置的渲染帧率可以分别为其对应的目标刷新率区间下限,即最低目标刷新率。
在本申请的一些实施例中,该N个应用中的B类应用对应设置的渲染帧率不小于阈值1,即Ri不小于阈值1。可理解,阈值1可以根据实际需要进行设置,本申请对此不作限制。例如,阈值1可以为30Hz。
在本申请的一些实施例中,每一个VSync周期到来时,在当前屏幕刷新率大于第一刷新率阈值的情况下,针对电子设备在显示屏上显示的窗口所对应的N个应用中的B类应用,在r大于阈值2的情况下,电子设备可以将其渲染帧率设置得小于r,即Ri小于r,而在r小于或等于阈值2的情况下,电子设备可以将其渲染帧率设置得小于或者等于r,即Ri小于或等于r。
在本申请的一些实施例中,在s大于1的情况下,该N个应用中的s个B类应用各自对应设置的渲染帧率(即调节后的渲染帧率)可以相同,也可以不同。也就是说,在i为不同值的情况下,Ri可以不变,也可以发生变化。
示例性的,电子设备可以在显示屏上显示应用1、应用2、应用3和应用4的窗口,电子设备的屏幕刷新率为60Hz。其中,应用1为焦点应用,应用2处于fling状态,应用3和应用4既不为焦点应用,又不处于fling状态,且应用1对应的最高目标刷新率为120Hz。在电子设备的VSync周期到来时,电子设备可以将屏幕刷新率设置为120Hz,即屏幕刷新率由60Hz变为120Hz,将应用1和应用2的渲染帧率保持为120Hz,将应用3和应用4的渲染帧率设置为60Hz。
示例性的,电子设备可以在显示屏上显示应用1、应用2、应用3和应用4的窗口,电子设备的屏幕刷新率为60Hz。其中,应用1为焦点应用,应用2处于fling状态,应用3和应用4既不为焦点应用,又不处于fling状态,且应用1对应的最高目标刷新率为120Hz。在电子设备的VSync周期到来时,电子设备可以将屏幕刷新率设置为120Hz,即屏幕刷新率由60Hz变为120Hz,将应用1和应用2的渲染帧率保持为120Hz,将应用3的渲染帧率设置为30Hz,而将应用4的渲染帧率设置为60Hz。
在本申请的一些实施例中,r=k*Ri。也就是说,电子设备在显示屏上显示的窗口所对应的N个应用中的B类应用的渲染帧率可以整除r,且商为k。其中。k为大于1的整数。例如,k可以为1。再例如,k可以为3。可理解,在s大于1的情况下,k可以发生变化,也可以不变。
在一种可能的实现方式中,在s大于1的情况下,i为不同值时,Ri不变,k也不变。示例性的,r=120Hz,s=2,k=2。可理解,该N个应用中存在2个B类应用,其渲染帧率均为:r÷k=60Hz。
在又一种可能的实现方式中,在s大于1的情况下,i为不同值时,Ri发生变化,k也相应变化。示例性的,r=120Hz,s=2。可理解,该N个应用中存在2个B类应用,针对该2个B类应用中的其中一个应用,k=2,该应用的渲染帧率为:r÷k=60Hz,然而,针对该2个B类应用中的另一个应用,k=3,该另一个应用的渲染帧率为r÷k=40Hz。
在本申请的一些实施例中,在s大于1(即电子设备在显示屏上显示的窗口所对应的N个应用中存在多个B类应用)的情况下,该N个应用中的一部分B类应用对应设置的渲染帧率可以整除r(即这一部分B类应用的渲染帧率满足r=k*Ri),该N个应用中的另一部分B类应用对应设置的渲染帧率不能整除r(即该另一部分B类应用的渲染帧率不满足r=k*Ri)。
示例性的,电子设备可以在显示屏上显示应用1、应用2、应用3和应用4的窗口,电子设备的屏幕刷新率为60Hz。其中,应用1为焦点应用,应用2处于fling状态,应用3和应用4既不为焦点应用,又不处于fling状态,且应用1对应的最高目标刷新率为120Hz。在电子设备的VSync周期到来时,电子设备可以将屏幕刷新率设置为120Hz,即屏幕刷新率由60Hz变为120Hz,将应用1和应用2的渲染帧率保持为120Hz,将应用3的渲染帧率设置为30Hz(可以整除120Hz),而将应用4的渲染帧率设置为45Hz(无法整除120Hz)。
S102:分别基于该N个应用的渲染帧率,来渲染该N个应用的画面。
具体地,针对该N个应用中的焦点应用或处于fling状态的应用,在电子设备保持其渲染帧率与当前屏幕刷新率相同的情况下,电子设备可以基于当前屏幕刷新率来渲染其画面(或称其对应的窗口中的画面)。类似的,针对该N个应用中不处于fling状态的非焦点应用,在电子设备设置其渲染帧率小于当前屏幕刷新率的情况下,电子设备可以基于其小于当前屏幕刷新率的渲染帧率,来渲染其画面(或称其对应的窗口中的画面)。
根据上文,VSync周期(可理解为生成相邻两个VSync信号的间隔时长)随着屏幕刷新率的变化而变化,即生成VSync信号的频率随着屏幕刷新率的变化而变化,而APP-VSync信号和SF-VSync信号是基于VSync周期进行分发的,这也就意味着,App-VSync信号和SF-VSync信号的分发频率也会随着VSync周期的变化而变化。
在本申请的一些实施例中,在应用的渲染帧率与当前屏幕刷新率相同的情况下,若应用请求APP-VSync信号,电子设备可以按照生成VSync信号的频率来向应用发送APP-VSync信号,即电子设备每生成一个VSync信号,就可以基于该VSync信号生成App-VSync信号,并将该App-VSync信号发送给应用。相应的,电子设备中的应用接收App-VSync信号后,可以开始绘制并渲染其对应的窗口中的画面。
在本申请的一些实施例中,在应用的渲染帧率小于当前屏幕刷新率的情况下,若应用请求APP-VSync信号,电子设备可以按照当前屏幕刷新率与应用的渲染帧率的倍数关系,来向应用发送APP-VSync信号。
在本申请的一些实施例中,在应用的渲染帧率小于当前屏幕刷新率的情况下,电子设备至少每间隔2个VSync周期就向该应用发送一个App-VSync信号。
为了便于描述,本申请将与当前屏幕刷新率最相近的应用的渲染率的倍数记为z。z为正整数。
在一种可能的实现方式中,在应用的渲染帧率小于当前屏幕刷新率的情况下,若z=1,则电子设备可以每间隔2个VSync周期生成并向该应用发送一次App-VSync信号,若z大
于1,则电子设备可以每间隔z个VSync周期生成并向该应用发送一次App-VSync信号。具体地,在z=1的情况下,电子设备生成VSync信号之后,可以向该应用发送基于该VSync信号生成的APP-VSync信号,然后等到2个VSync周期后再次生成VSync信号的情况下,再向该应用发送基于该再次生成的VSync信号生成的APP-VSync信号,然后重复上述间隔2个VSync周期发送APP-VSync信号的步骤,类似的,在z大于1的情况下,电子设备生成VSync信号之后,可以向该应用发送基于该VSync信号生成的APP-VSync信号,然后等到z个VSync周期后再次生成VSync信号的情况下,再向该应用发送基于该再次生成的VSync信号生成的APP-VSync信号,然后重复上述间隔z个VSync周期发送APP-VSync信号的步骤。需要说明的是,在z大于1的情况下,在该z个VSync周期中,电子设备可以依然按照VSync周期生成VSync信号,只是不向该应用发送APP-VSync信号。相应的,电子设备中的应用接收App-VSync信号后,可以开始绘制并渲染其对应的窗口中的画面。
为了便于描述,本申请将当前屏幕刷新率与应用的渲染帧率的商记为x。x为正整数。可理解,x可以等于z,也可以等于z-1(此时z至少为3)。
在一种可能的实现方式中,在应用的渲染帧率小于当前屏幕刷新率的情况下,若x=1,则电子设备可以每间隔2个VSync周期生成一次App-VSync信号,若x大于1,则电子设备可以每间隔x个VSync周期生成一次App-VSync信号。具体地,在x=1的情况下,电子设备生成VSync信号之后,可以向该应用发送基于该VSync信号生成的APP-VSync信号,然后等到2个VSync周期后再次生成VSync信号的情况下,再向该应用发送基于该再次生成的VSync信号生成的APP-VSync信号,然后重复上述间隔2个VSync周期发送APP-VSync信号的步骤,类似的,在x大于1的情况下,电子设备生成VSync信号之后,可以向该应用发送基于该VSync信号生成的APP-VSync信号,然后等到x个VSync周期后再次生成VSync信号的情况下,再向该应用发送基于该再次生成的VSync信号生成的APP-VSync信号,然后重复上述间隔x个VSync周期发送APP-VSync信号的步骤。需要说明的是,在x大于1的情况下,在该x个VSync周期中,电子设备可以依然按照VSync周期生成VSync信号,只是不向该应用发送APP-VSync信号。相应的,电子设备中的应用接收App-VSync信号后,可以开始绘制并渲染其对应的窗口中的画面。
可理解,在当前屏幕刷新率可以被应用的渲染帧率整除(或称应用的渲染帧率可以整除当前屏幕刷新率)的情况下,x和z可以等于上文所提及的k。
在本申请的一些实施例中,在应用的渲染帧率小于当前屏幕刷新率的情况下,若该应用请求APP-VSync信号,且其渲染帧率可以整除当前屏幕刷新率,电子设备可以基于定义的定时时长为VSync软件定时器来提醒电子设备向该应用发送APP-VSync信号,即电子设备可以基于该VSync软件定时器每间隔x个VSync周期(或z个VSync周期)生成一次App-VSync信号,并将该App-VSync信号发送给应用。然而,在该应用的渲染帧率小于当前屏幕刷新率的情况下,若该应用请求APP-VSync信号,且其渲染帧率不可以整除当前屏幕刷新率,电子设备可以另外设置VSync软件定时器来提醒电子设备向该应用发送App-VSync信号。可理解,该另外设置的VSync软件定时器定义的定时时长不为VSync周
期,而是基于该应用的渲染帧率确定,即该另外设置的VSync软件定时器定义的定时时长为该应用的渲染帧率的倒数。
在本申请的一些实施例中,电子设备每一次生成VSync信号后,可以直接将基于该VSync信号生成的APP-VSync信号发送给该应用,而不会在生成VSync信号的基础上添加一定时间偏移量之后再发送APP-VSync信号。
在本申请的一些实施例中,电子设备每一次生成VSync信号后,可以在添加一定时间偏移量之后,再将基于VSync信号生成的APP-VSync信号发送给该应用。
在本申请的一些实施例中,电子设备执行步骤S101和步骤S102时,针对该N个应用中的每一个应用,电子设备可以执行如图8A所示的步骤,具体可以包括但不限于以下步骤:
S201:确定应用是否为当前焦点应用。
电子设备可以确定应用是否为当前焦点应用。若该应用为当前焦点应用,则电子设备可以继续执行步骤S202,若该应用不为当前焦点应用,则电子设备可以继续执行步骤S203,即确定应用是否处于fling状态。
S202:设置应用的渲染帧率等于当前屏幕刷新率。
在该应用为当前焦点应用的情况下,电子设备可以确定该应用的渲染帧率为当前屏幕刷新率,并保持该渲染帧率。
S203:确定应用是否处于fling状态。
在该应用不为当前焦点应用的情况下,电子设备可以确定该应用是否处于fling状态。若该应用处于fling状态,则电子设备可以继续执行步骤S202,若该应用不处于fling状态,则电子设备可以继续执行步骤S204。
在本申请的一些实施例中,在该应用不为当前焦点应用的情况下,且该应用不处于fling状态的情况下,电子设备可以确定当前屏幕刷新率是否大于阈值2。若当前屏幕刷新率大于阈值2,则电子设备可以继续执行步骤S204,若当前屏幕刷新率小于或等于阈值2,则电子设备可以执行步骤S202或者步骤S204,即电子设备可以确定应用的渲染帧率等于或者小于当前屏幕刷新率。
S204:设置应用的渲染帧率小于当前屏幕刷新率。
在该应用既不为焦点应用,又不处于fling状态的情况下,电子设备可以设置该应用的渲染帧率,使得该应用对应设置的渲染帧率小于当前屏幕刷新率,具体设置方式可以参考步骤S102的相关描述,本申请在此不再赘述。
S205:基于应用的渲染帧率来向应用发送App-VSync信号。
可理解,在应用有更新界面的需求的情况下,应用可以请求App-VSync信号。在确定应用的渲染帧率等于当前屏幕刷新率,或者设置应用的渲染帧率小于当前屏幕刷新率之后,在应用请求App-VSync信号的情况下,电子设备可以基于该应用的渲染帧率来向该应用发送App-VSync信号。
可理解,根据步骤S101,VSync周期也会随着当前屏幕刷新率的变化而变化。
在本申请的一些实施例中,在应用的渲染帧率等于当前屏幕刷新率的情况下,该应用绘制、渲染相邻两帧图像的间隔时长等于一个VSync周期。在这种情况下,电子设备可以直接基于VSync周期来向该应用发送App-VSync信号。具体地,电子设备可以在生成VSync信号之后,直接向该应用发送基于VSync信号得到的APP-VSync信号,然后在下一次生成VSync信号之后,再次向该应用发送基于VSync信号得到的APP-VSync信号,并重复上述在下一次生成VSync信号之后,再次向该应用发送基于VSync信号得到的APP-VSync信号的步骤。
在本申请的一些实施例中,在应用的渲染帧率小于当前屏幕刷新率的情况下,该应用绘制、渲染相邻两帧图像的间隔时长大于一个VSync周期。在这种情况下,电子设备可以基于该间隔时长与VSync周期的倍数关系(即当前屏幕刷新率与该应用的渲染帧率的倍数关系),来向该应用发送APP-VSync信号,具体实现方式可以参考上文,本申请在此不再赘述。
在本申请的一些实施例中,无论应用的渲染帧率是等于当前屏幕刷新率,还是小于当前屏幕刷新率,电子设备都可以通过设置一个定时器(例如,第一定时器)来向该应用发送APP-VSync信号,且该定时器定义的定时时长为一个VSync周期。具体地,电子设备可以基于当前屏幕刷新率与应用的渲染帧率的倍数关系,来确定每间隔多少个VSync周期发送一次APP-VSync信号,并在该VSync软件定时器总的计时时长达到相应VSync周期的情况下,向该应用发送一次APP-VSync信号。
为了便于理解和描述,本申请将该定时器所在线程记为定时器分发线程1。也就是说,无论应用的渲染帧率是等于当前屏幕刷新率,还是小于当前屏幕刷新率,电子设备都可以通过定时器分发线程1来向该应用发送APP-VSync信号。其中,定时器分发线程1中的定时器定义的定时时长为一个VSync周期,或称,定时器分发线程1对应的定时时长为一个VSync周期。这也就意味着,定时器分发线程1对应的定时时长随着VSync周期的变化而变化,即随着当前屏幕刷新率的变化而变化。
示例性的,如图9A所示,电子设备可以在显示屏上显示应用1、应用2、应用3、应用4和应用5对应的窗口,在VSync信号生成后,电子设备可以确定当前焦点应用为焦点1,其对应的最高目标刷新率为120Hz,则电子设备可以将当前屏幕刷新率设置为120Hz,则VSync周期相应变为1/120s,即电子设备每间隔1/120s会生成一个VSync信号。可理解,定时器分发线程1的计时时长每次达到其对应的定时时长时,电子设备可以生成一个VSync信号。由于焦点1为焦点应用,则电子设备可以确定其渲染帧率为120Hz,然而,由于应用2、应用3、应用4和应用5为不处于fling状态的非焦点应用,则电子设备可以将应用2、应用3、应用4和应用5的渲染帧率设置得低于120Hz,具体地,电子设备可以将应用2和应用3的渲染帧率设置为60Hz,将应用4的渲染帧率设置为45Hz,将应用5的渲染帧率设置为90Hz。
可理解,当前屏幕刷新率可以被应用2和应用3对应设置的渲染帧率整除,且当前屏幕刷新率除以应用2/应用3对应设置的渲染帧率的商为2,则电子设备可以每隔2个VSync周期向应用2和应用3发送一个APP-VSync信号,然而,当前屏幕刷新率不可以被应用4对应设置的渲染帧率整除,并且,(120-45*2)>(45*3-120),也就是说,与当前屏幕刷新
率最接近的应用4对应设置的渲染帧率的倍数是3,则电子设备可以每间隔3个VSync周期向应用4发送一个APP-VSync信号,类似的,当前屏幕刷新率不可以被应用4对应设置的渲染帧率整除,并且,(120-90*1)<(90*2-120),也就是说,与当前屏幕刷新率最接近的应用5对应设置的渲染帧率的倍数是1,也就是说,对应用4来说,z=1,根据上文,在这种情况下,电子设备可以每间隔2个VSync周期向应用4发送一个APP-VSync信号。
具体地,如图9A所示,电子设备生成第一个VSync信号之后,可以基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用1、应用2、应用3、应用4和应用5第一次发送APP-VSync信号,以及向SurfaceFlinger第一次发送SF-VSync信号。间隔一个VSync周期(即定时器分发线程1从生成VSync信号后开始计时,一直到其计时时长达到其定义的定时时长)后,电子设备可以生成第二个VSync信号,并基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用1第二次发送APP-VSync信号,以及向SurfaceFlinger第二次发送SF-VSync信号。再次间隔一个VSync周期(即定时器分发线程1从生成第二个VSync信号后重新开始计时,一直到其计时时长达到其定义的定时时长)后,电子设备可以生成第三个VSync信号,并基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用1第三次发送APP-VSync信号,以及向应用2、应用3和应用5第二次发送APP-VSync信号,以及向SurfaceFlinger第三次发送SF-VSync信号。再次间隔一个VSync周期(即定时器分发线程1从生成第三个VSync信号后重新开始计时,一直到其计时时长达到其定义的定时时长)后,电子设备可以生成第四个VSync信号,并基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用1第四次发送APP-VSync信号,向应用4第二次发送APP-VSync信号,以及向SurfaceFlinger第四次发送SF-VSync信号。并且,上述针对应用1、应用2、应用3、应用4和应用5进行的APP-VSync信号的分发均由定时器分发线程1完成,且定时器分发线程1对应的定时时长为1/120s。
在本申请的一些实施例中,电子设备执行步骤S102和步骤S103时,针对电子设备在显示屏上显示的窗口所对应的N个应用中的每一个应用,电子设备可以执行如图8B所示的步骤,具体可以包括但不限于以下步骤:
S301:确定应用是否为当前焦点应用。
电子设备可以确定应用是否为当前焦点应用。若该应用为当前焦点应用,则电子设备可以继续执行步骤S302,若该应用不为当前焦点应用,则电子设备可以继续执行步骤S303,即确定应用是否处于fling状态。
S302:设置应用的渲染帧率等于当前屏幕刷新率。
在该应用为当前焦点应用的情况下,电子设备可以确定该应用的渲染帧率为当前屏幕刷新率,并保持该渲染帧率。在这种情况下,电子设备可以执行步骤S306。
S303:确定应用是否处于fling状态。
在该应用不为当前焦点应用的情况下,电子设备可以确定该应用是否处于fling状态。若该应用处于fling状态,则电子设备可以继续执行步骤S302,若该应用不处于fling状态,则电子设备可以继续执行步骤S304。
与步骤S203类似,在本申请的一些实施例中,在该应用不为当前焦点应用的情况下,且该应用不处于fling状态的情况下,电子设备可以确定当前屏幕刷新率是否大于阈值2。若当前屏幕刷新率大于阈值2,则电子设备可以继续执行步骤S304,若当前屏幕刷新率小于或等于阈值2,则电子设备可以执行步骤S302或者步骤S304,即电子设备可以确定应用的渲染帧率等于或者小于当前屏幕刷新率。
S304:设置应用的渲染帧率小于当前屏幕刷新率。
在该应用既不为焦点应用,又不处于fling状态的情况下,电子设备可以调节该应用的渲染帧率,使得该应用对应设置的渲染帧率小于当前屏幕刷新率,具体调节方式可以参考步骤S102的相关描述,本申请在此不再赘述。在这种情况下,电子设备可以继续执行步骤S305。
S305:确定应用对应设置的渲染帧率是否整除当前屏幕刷新率。
在电子设备设置应用的渲染帧率(即该应用对应的调节后的渲染帧率)小于当前屏幕刷新率的情况下,电子设备可以确定该应用对应设置的渲染帧率是否整除当前屏幕刷新率,即电子设备可以确定当前屏幕刷新率是否被该应用对应设置的渲染帧率整除。若该应用对应设置的渲染帧率整除当前屏幕刷新率(即当前屏幕刷新率被该应用对应设置的渲染帧率整除),则电子设备可以执行步骤S306,若该应用对应设置的渲染帧率不可以整除当前屏幕刷新率(即当前屏幕刷新率不被该应用对应设置的渲染帧率整除),则电子设备可以执行步骤S307。
S306:通过定时器分发线程1向应用发送App-VSync信号。定时器分发线程1对应的定时时长基于当前屏幕刷新率确定。
在该应用的渲染帧率等于当前屏幕刷新率,或者该应用对应设置的渲染帧率小于当前屏幕刷新率且整除当前屏幕刷新率的情况下,电子设备可以通过定时器分发线程1来向该应用发送APP-VSync信号。定时器分发线程1对应的定时时长为一个VSync周期,即当前屏幕刷新率的倒数,定时器分发线程1的相关描述可以参考上文,本申请在此不再赘述。
可理解,在该应用的渲染帧率等于当前屏幕刷新率,或者该应用对应设置的渲染帧率小于当前屏幕刷新率且整除当前屏幕刷新率的情况下,电子设备可以通过定时器分发线程1,每间隔x个VSync周期(或z个VSync周期)就提醒一次向该应用发送APP-VSync信号。具体地,电子设备生成VSync信号之后,可以向该应用发送基于该VSync信号生成的APP-VSync信号,然后等到x个VSync周期后(具体可以通过定时器分发线程1确定距离上一次发送APP-VSync信号已有x个VSync周期)再次生成VSync信号的情况下,再向该应用发送基于该再次生成的VSync信号生成的APP-VSync信号,然后重复上述间隔x个VSync周期发送APP-VSync信号的步骤。
为了便于描述,本申请将定时器分发线程1中设置的定时器记为第一定时器。第一定时器定义的定时时长为一个VSync周期。第一定时器可以理解为上文所提及的VSync软件定时器。
需要说明的是,电子设备可以通过定时器分发线程1来向SurfaceFlinger发送SF-VSync信号。具体地,在第一定时器的计时时长每次达到其定义的定时时长(即一个VSync周期)的情况下,电子设备就可以生成VSync信号,然后基于VSync信号生成SF-VSync信号,
并将SF-VSync信号发送给SurfaceFlinger。也就是说,电子设备每生成一个VSync信号,就可以相应生成一个SF-VSync信号。
然而,根据上文,电子设备每生成x+1个VSync信号(或z+1个VSync信号),就会相应生成一个APP-VSync信号。也就是说,在x=1的情况下,电子设备每生成一个VSync信号,就可以相应生成一个APP-VSync信号,而在x大于1的情况下,电子设备每生成多个VSync信号(至少2个VSync信号),才可以相应生成一个APP-VSync信号。
S307:通过定时器分发线程2向应用发送App-VSync信号。定时器分发线程2对应的定时时长基于应用对应设置的渲染帧率确定。
在该应用对应设置的渲染帧率小于当前屏幕刷新率,且该应用对应设置的渲染帧率不可以整除当前屏幕刷新率的情况下,电子设备可以通过定时器分发线程2来向该应用发送APP-VSync信号。定时器分发线程2是独立于定时器分发线程1的线程,其对应的定时时长为该应用对应设置的渲染帧率的倒数。
示例性的,如图9B所示,电子设备可以在显示屏上显示应用1、应用2、应用3、应用4和应用5对应的窗口,在VSync信号生成后,电子设备可以确定当前焦点应用为焦点1,其对于的目标刷新率为120Hz,则电子设备可以将当前屏幕刷新率设置为120Hz,则VSync周期相应变为1/120s,即电子设备每间隔1/120s会生成一个VSync信号。可理解,定时器分发线程1的计时时长每次达到其对应的定时时长时,电子设备可以生成一个VSync信号。由于焦点1为焦点应用,则电子设备可以确定其渲染帧率为120Hz,然而,由于应用2、应用3、应用4和应用5为不处于fling状态的非焦点应用,则电子设备可以将应用2、应用3、应用4和应用5的渲染帧率设置得低于120Hz,具体地,电子设备可以将应用2和应用3的渲染帧率调节为60Hz,将应用4的渲染帧率设置为45Hz,将应用5的渲染帧率设置为90Hz。可理解,定时器分发线程1对应的定时时长为一个VSync周期,则电子设备可以按照定时器分发线程1对应的定时时长来生成VSync信号,以及向应用1发送APP-VSync信号。
可理解,当前屏幕刷新率可以被应用2和应用3对应设置的渲染帧率整除,电子设备可以通过定时器分发线程1每隔2个VSync周期向应用2和应用3发送一次APP-VSync信号。然而,当前屏幕刷新率不可以被应用4对应设置的渲染帧率整除,也不可以被应用5对应设置的渲染帧率整除,但是应用4对应设置的渲染帧率与应用5对应设置的渲染帧率之间存在2倍的倍数关系,则电子设备可以通过定时器分发线程2来向应用4和应用5发送APP-VSync信号,并且,定时器分发线程2对应的定时时长可以基于应用4和应用5对应设置的渲染帧率中的最高帧率确定,即定时器分发线程2可以为应用5对应设置的渲染帧率的倒数,即1/90s。也就是说,定时器分发线程2对应的定时时长为4/3个VSync周期。
需要说明的是,定时器分发线程1和定时器分发线程2同步开始计时。下面示例性说明定时器分发线程1发送APP-VSync信号的具体过程:
如图9B所示,电子设备生成第一个VSync信号之后,可以基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用1、应用2和应用3第一次发送APP-VSync信号,以及向SurfaceFlinger第一次发送SF-VSync信号。间隔一
个VSync周期(即定时器分发线程1从生成第一个VSync信号后开始计时,一直到其计时时长达到其定义的定时时长)后,电子设备可以生成第二个VSync信号,并基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用1第二次发送APP-VSync信号,以及向SurfaceFlinger第二次发送SF-VSync信号。再次间隔一个VSync周期(即定时器分发线程1从生成第二个VSync信号后重新开始计时,一直到其计时时长达到其定义的定时时长)后,电子设备可以生成第三个VSync信号,并基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用1第三次发送APP-VSync信号,以及向应用2、应用3和应用5第二次发送APP-VSync信号,以及向SurfaceFlinger第三次发送SF-VSync信号。再次间隔一个VSync周期(即定时器分发线程1从生成第三个VSync信号后重新开始计时,一直到其计时时长达到其定义的定时时长)后,电子设备可以生成第四个VSync信号,并基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用1第四次发送APP-VSync信号,向应用4第二次发送APP-VSync信号,以及向SurfaceFlinger第四次发送SF-VSync信号。
还需要说明的是,定时器分发线程2和定时器分发线程1向应用发送APP-VSync信号的过程是独立且同步进行的。下面示例性说明定时器分发线程2发送APP-VSync信号的具体过程:
如图9B所示,电子设备生成第一个VSync信号之后,可以基于该VSync信号生成APP-VSync信号和SF-VSync信号,在这种情况下,电子设备可以向应用4和应用5第一次发送APP-VSync信号。间隔4/3个VSync周期(即定时器分发线程2从生成第一个VSync信号后开始计时,一直到其计时时长达到其定义的定时时长)后,电子设备可以向应用5第二次发送APP-VSync信号。再次间隔4/3个VSync周期(即定时器分发线程2从上一次达到其定义的定时时长后重新开始计时,一直到其计时时长再次达到其定义的定时时长)后,电子设备可以向应用5第三次发送APP-VSync信号,以及向应用4第二次发送APP-VSync信号。再次间隔一个VSync周期(即定时器分发线程2从上一次达到其定义的定时时长后重新开始计时,一直到其计时时长再次达到其定义的定时时长)后,电子设备可以向应用5第四次发送APP-VSync信号。
为了便于描述,本申请将定时器分发线程2中设置的定时器记为第二定时器。第二定时器定义的定时时长为该应用对应设置的渲染帧率(即该应用对应的调节后的渲染帧率)的倒数。第二定时器可以理解为上文所提及的VSync软件定时器。
在本申请的一些实施例中,电子设备在显示屏中显示的窗口对应的N个应用中存在多个应用对应设置的渲染帧率不可以整除当前屏幕刷新率。在这种情况下,电子设备可以确定该多个应用对应设置的渲染帧率之间是否存在倍数关系,若该多个应用对应设置的渲染帧率之间存在倍数关系,则电子设备可以通过定时器分发线程2来向该多个应用发送APP-VSync信号,然而,若该多个应用对应设置的渲染帧率之间完全不存在或者不完全存在倍数关系,则电子设备除了通过定时器分发线程2来向该多个应用中的一个或多个应用发送APP-VSync信号外,还可以另外设置一个或多个定时器分发线程来向该多个应用中的其他应用发送APP-VSync信号。
示例性的,电子设备可以在显示屏上显示应用1、应用2、应用3、应用4、应用5和应用6对应的窗口。应用1为焦点应用,且其对应的目标刷新率为120Hz,则电子设备可以将当前屏幕刷新率调节为120Hz。而应用2、应用3、应用4、应用5和应用6均为不处于fling状态的非焦点应用。应用1-应用5的渲染帧率与图9A和图9B所示的应用1-应用5的渲染帧率相同,而应用6对应设置的渲染帧率为50Hz。具体地,与图9B所示的内容相同,电子设备可以通过定时器分发线程1来向应用1、应用2和应用3发送APP-VSync信号,以及通过定时器分发线程2来向应用4和应用5发送APP-VSync信号。可理解,应用6对应设置的渲染帧率不可以整除当前屏幕刷新率,且应用6对应设置的渲染帧率与应用4对应设置的渲染帧率之间不存在倍数关系,应用6对应设置的渲染帧率与应用5对应设置的渲染帧率之间也不存在倍数关系,则电子设备可以另外通过定时器分发线程3来向应用6发送APP-VSync信号。其中,定时器分发线程3是独立于定时器分发线程1和定时器分发线程2的线程,其对应的定时时长为应用6对应设置的渲染帧率的倒数。与定时器分发线程1和定时器分发线程2类似,定时器分发线程3中也可以设置有定时器,且定时器分发线程3中的定时器定义的定时时长为应用6对应设置的渲染帧率的倒数。
S103:按照当前屏幕刷新率在显示屏上显示该N个应用的画面。
电子设备渲染该N个应用的画面(或称该N个应用的窗口中的画面)之后,可以按照当前屏幕刷新率在显示屏上显示该N个应用的画面。可理解,根据上文,该N个应用中可能存在部分渲染帧率小于当前屏幕刷新率的应用,而SurfaceFlinger按照当前屏幕刷新率合成图层,且显示屏按照当前屏幕刷新率进行显示,那么在SurfaceFlinger准备合成图层时,该部分渲染帧率小于当前屏幕刷新率的应用,可能还没有渲染得到新的图像,在这种情况下,该部分渲染帧率小于当前屏幕刷新率的应用可以将其渲染得到的上一帧图像发送给SurfaceFlinger进行合成。
在本申请的一些实施例中,电子设备在显示屏上显示的N个应用的窗口可以包括M个窗口。其中,M为不小于N的整数。也就是说,一个应用可以对应一个窗口,也可以对应多个窗口,本申请对此不作限制。
示例性的,如图1所示,N可以为2,电子设备可以在显示屏上显示窗口1a和窗口2a。其中,窗口1a为一个视频应用对应的窗口,窗口2a为一个阅读应用对应的窗口。电子设备在启动该视频应用之后创建了窗口1a,类似的,电子设备在启动该阅读应用之后创建了窗口2a。
示例性的,如图2所示,N可以为2,电子设备可以在显示屏上显示窗口3a、窗口3b和窗口2a。其中,窗口3a和窗口3b为一个购物应用对应的窗口,窗口2a为一个阅读应用对应的窗口。电子设备在启动该购物应用之后创建了窗口3a和窗口3b。
可理解,电子设备在显示屏上显示N个应用的窗口时,其已经启动的应用的数量不小于N。在本申请的一些实施例中,电子设备可以启动比N个应用更多的应用,但仅在显示屏上显示该N个应用的窗口,其他已启动的应用可以在后台运行。
下面介绍本申请实施例涉及的电子设备的软件结构。
电子设备的操作系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本申请实施例以分层架构的安卓(Android)操作系统为例,示例性说明电子设备的软件结构。需要说明的是,本申请实施例虽然以Android操作系统(可简称为Android系统)为例进行说明,但是其基本原理同样适用于基于iOS或Windows等操作系统的电子设备。
图10为本申请实施例提供的一种电子设备的软件结构示意图。
电子设备的软件结构采用分层架构,即将软件分成若干个层,其中每一层都有清晰的角色和分工。层与层之间通过软件接口通信。以Android系统运行在AP上为例,在本申请的一些实施例中,Android系统的软件结构分为五层,从上至下分别为应用程序层,应用程序框架层(Framework),安卓运行时(Android runtime)和系统库,硬件抽象层(HAL)以及内核层(Kernel)。
其中,应用程序层可以包括一系列应用程序包。应用程序包可以包括相机,图库,日历,通话,地图,WLAN,蓝牙,音乐,视频,短信息等应用程序。应用程序层还可以包括系统UI(System User Interface,systemUI)。systemUI用于显示电子设备的界面,比如显示SIM卡对应的信号图标、显示通话界面等。应用程序层还可以包括应用1和应用2。可理解,应用1可以为系统应用,也可以为三方应用,类似的,应用2可以为系统应用,也可以为三方应用。
应用程序框架层为应用程序层的应用程序提供应用编程接口(Application Programming Interface,API)和编程框架。应用程序框架层可以包括一些预先定义的函数。例如,应用程序框架层可以包括窗口管理器(Window Manager,WM)、视图系统等。其中,WM可以用于实现系统和应用窗口的管理(例如,添加、移出、更新等)和绘制等,其主要作用包括:窗口创建和管理、窗口层级的管理、窗口事件的分发、外部应用程序的窗口管理,以及窗口样式的控制等。视图系统可用于构建应用程序,具体可以包括绘制、渲染应用程序的显示界面(或称用户界面)。用户界面可以由一个或多个视图组成的。视图系统绘制用户界面的过程中可以调用系统库中的三维图形处理库和二维图形引擎。视图系统可以包括渲染编排器(或称渲染管理器),其英文全称为Choreographer。Choreographer可以配合VSync机制,给上层应用的渲染提供一个稳定的绘制处理的时机。具体地,在VSync周期到来时,电子设备可以唤醒Choreographer来做应用的绘制、渲染操作。Choreographer在Android渲染链路中起到一个承上启下的作用。
应用程序框架层还可以包括输入事件管理模块。输入事件管理模块可以进行各种输入事件(例如,按键事件、触摸事件等)的收集、处理和分发。在本申请的一些实施例中,输入事件管理模块可以为inputflinger。inputflinger是负责处理输入事件的服务,它可以接收来自硬件设备的原始输入事件,并将它们转换为Android系统可以理解的事件,如触摸事件等。
应用程序框架层还可以包括小部件(Widget)。Widget可以包括滑动组件(OverScroller)。OverScroller是一个类,可以对用户界面添加监听,从而确定用户界面当前交互状态是否为fling状态。
应用程序框架层还可以包括表面控制接口。表面控制接口可以用于实现WM与
SurfaceFlinger的交互。在本申请的一些实施例中,表面控制接口可以为surfaceControl。
运行时(Runtime)负责系统的调度和管理。Runtime包括核心库和虚拟机。其中,核心库包含两部分:一部分是编程语言(例如,java语言)需要调用的功能函数,另一部分是系统的核心库。应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的编程文件(例如,java文件)执行为二进制文件。虚拟机用于执行对象生命周期的管理、堆栈管理、线程管理、安全和异常的管理,以及垃圾回收等功能。
系统库可以包括多个功能模块。例如,SurfaceFlinger、媒体库(Media Libraries)、三维图形处理库(例如,OpenGL ES)和二维图形引擎(例如,SGL)等。其中,SurfaceFlinger负责管理所有应用程序的UI显示,通过与硬件抽象层(HAL)和GPU驱动程序交互,还负责将应用程序的UI元素(如文本、图像、视图等)组合成一个完整的屏幕画面。SurfaceFlinger可以包括触控焦点图层管理模块、连接管理模块、滑动状态管理模块、Vsync信号调制模块和图层合成管理模块等。其中,触控焦点图层管理模块可以用于管理和维护焦点窗口,具体可以根据用户操作来更新焦点窗口。连接管理模块可以用于管理和维护SurfaceFlinger与应用程序的连接通道(也可以理解为APP-VSync信号的分发通道)。在本申请的一些实施例中,连接通道可以为socket通道(或称socket连接)。滑动状态管理模块可以用于管理和更新窗口交互状态(例如,上文所提及的应用的交互状态),具体可以包括滑动状态(包括fling状态和非fling状态)。Vsync信号调制模块可以用于按照应用程序的渲染帧率来向其分发APP-VSync信号。图层合成管理模块可以用于将不同应用程序的UI元素,和/或一个应用程序的多个UI元素组合成一个完整的屏幕画面。可理解,系统库中其他功能模块的具体含义和作用可以参考相关技术文档,在此不展开说明。
硬件抽象层(HAL)是位于操作系统内核与上层软件之间的接口层,其目的在于将硬件抽象化。硬件抽象层是设备内核驱动的抽象接口,用于实现向更高级别的Java API框架提供访问底层设备的应用编程接口。HAL可以提供标准界面,向更高级别的Java API框架显示设备硬件功能。HAL包含多个库模块(例如,相机HAL、音频HAL等)。当系统框架层API要求访问便携设备的硬件时,操作系统将为该硬件组件加载库模块。
内核层是Android系统的基础。内核层负责硬件的驱动程序、网络、电源、系统安全以及内存管理等功能。内核层是硬件与软件之间的一个中间层,其作用是将应用程序的请求传递给硬件。内核层可以包括音频驱动、显示驱动、摄像头驱动和传感器驱动。音频驱动为音频软件和音频硬件之间的中间层,用于传递上层软件模块对音频硬件的访问请求。
需要说明的是,本申请提供的图10所示的电子设备的软件结构示意图仅作为一种示例,并不限定Android系统不同分层中的具体模块划分,具体可以参考常规技术中对Android系统软件结构的介绍。另外,本申请提供的方法还可以基于其他操作系统实现,本申请不再一一举例。
下面基于图10所示的电子设备的软件结构,具体介绍上述实施例的一种具体实现方式。
请参阅图11A和图11B,图11A和图11B为本申请实施例提供的又一种图像显示方法的流程图。该方法可以包括但不限于以下步骤:
1、创建窗口、更新焦点应用和/或焦点窗口,以及更新应用的交互状态信息(如图11A所示)。
S1:WM启动窗口创建流程来创建应用1的窗口。
用户可以触发电子设备启动应用1。电子设备接收到触发启动应用1的用户操作之后,可以通过WM启动窗口创建流程来创建应用1的窗口。
S2:WM通过表面控制接口向SurfaceFlinger发送应用连接请求1。
在电子设备接收到触发启动应用1的用户操作之后,并通过WM启动窗口创建流程之后,WM可以通过表面控制接口来向SurfaceFlinger发送应用连接请求1。相应的,SurfaceFlinger可以接收WM通过表面控制接口发送的应用连接请求1。
在本申请的一些实施例中,应用连接请求1可以包括应用1的包名(Package Name)。包名是应用程序的唯一标识字符串,它通常采用反域名(reverse domain name)的命名方式,以确保包名的全局唯一性。
在本申请的一些实施例中,SurfaceFlinger可以通过Binder机制来获取应用1的用户标识(User Identification,UID)和进程标识(Process Identification,PID)。
可理解,Binder机制是一种进程间通信(interprocess communication,IPC)机制。不同操作系统都有各自的IPC机制。传统的进程通信的方式有Socket、管道、内存共享、消息队列等。
可理解,UID可以用来唯一识别应用程序。每个应用程序都会被分配一个独特的UID,该UID决定了应用程序对系统资源的访问权限。可理解,每个进程有唯一的PID。应用程序一运行系统就会给该程序对应的进程自动分配一个PID。PID是进程运行时系统分配的,并不代表专门的进程。进程运行时,其PID不会改变,但是进程终止后,其PID会被系统回收。系统可能将回收的PID重新分配给其他新运行的程序。
S3:SurfaceFlinger创建应用1的窗口,与应用1建立连接通道1,并管理应用1相关信息。
SurfaceFlinger接收WM通过表面控制接口发送的应用连接请求1之后,可以创建应用1的窗口,并且与应用1建立连接通道,即连接通道1,还可以管理应用连接请求1中携带的应用1相关信息(例如,应用1的包名)。
在本申请的一些实施例中,连接通道可以为socket通道。
在本申请的一些实施例中,应用1相关信息还可以包括应用1的UID和PID。在一种可能的实现方式中,SurfaceFlinger接收WM通过表面控制接口发送的应用连接请求1之后,可以通过binder机制来获取应用1的UID和PID。
需要说明的是,SurfaceFlinger管理应用1相关信息,也可以理解为SurfaceFlinger内存储有应用1和其对应的包名、UID、PID之间的映射信息,并维护该映射信息。
可理解,SurfaceFlinger创建应用1的窗口后,应用1可以绘制、渲染其窗口中的显示界面,并在SurfaceFlinger进行图层合成后送至显示屏进行显示,这样,用户就可以在显示屏上看到应用1的窗口以及该窗口中的用户界面(或称窗口中的画面)。
在本申请的一些实施例中,在显示屏显示有该应用1的窗口的情况下,用户可以针对该应用1的窗口进行操作。相应的,电子设备可以检测到针对应用1的窗口的用户操作,
响应于该用户操作,电子设备可以更新应用1的窗口中的用户界面。可理解,本申请对针对应用1的窗口的用户操作不作具体限制。
S4:WM启动窗口创建流程来创建应用2的窗口。
用户可以触发电子设备启动应用2。电子设备接收到触发启动应用2的用户操作之后,可以通过WM启动窗口创建流程来创建应用2的窗口。
可理解,本申请对电子设备执行步骤S1和步骤S4的先后顺序不作限制。也就是说,电子设备可以响应于相应用户操作来首先启动应用1,也可以响应于相应用户操作来首先启动应用2。
S5:WM通过表面控制接口向SurfaceFlinger发送应用连接请求2。
在电子设备接收到触发启动应用2的用户操作之后,并通过WM启动窗口创建流程之后,WM可以通过表面控制接口来向SurfaceFlinger发送应用连接请求2。相应的,SurfaceFlinger可以接收WM通过表面控制接口发送的应用连接请求2。
在本申请的一些实施例中,应用连接请求2可以包括应用2的包名(Package Name)。
在本申请的一些实施例中,SurfaceFlinger可以通过Binder机制来获取应用2的UID和PID。
S6:SurfaceFlinger创建应用2的窗口,与应用2建立连接通道2,并管理应用2相关信息。
SurfaceFlinger接收WM通过表面控制接口发送的应用连接请求2之后,可以创建应用2的窗口,并且与应用2建立连接通道,即连接通道2,还可以管理应用连接请求2中携带的应用2相关信息(例如,应用2的包名)。
在本申请的一些实施例中,应用2相关信息还可以包括应用2的UID和PID。在一种可能的实现方式中,SurfaceFlinger接收WM通过表面控制接口发送的应用连接请求2之后,可以通过binder机制来获取应用2的UID和PID。
需要说明的是,SurfaceFlinger管理应用2相关信息,也可以理解为SurfaceFlinger内存储有应用2和其对应的包名、UID、PID之间的映射信息,并维护该映射信息。
可理解,SurfaceFlinger内可以存储有多个应用(例如,应用1和应用2)和其对应的包名、UID、PID之间的映射信息。
示例性的,SurfaceFlinger内可以存储有应用1相关信息(也可以称为应用1的映射信息)和应用2相关信息(也可以称为应用2的映射信息)。具体地,SurfaceFlinger可以存储有表2所示的信息,如表2所示,应用1对应的连接通道为连接通道1,可简称为con1,且应用1的包名为com.example.app1,应用1的UID和PID分别为11和213,而应用2对应的连接通道为连接通道2,可简称为con2,且应用2的包名为com.example.app2,应用2的UID和PID分别为12和862。
表2
可理解,SurfaceFlinger创建应用2的窗口后,应用2可以绘制、渲染其窗口中的显示界面,并在SurfaceFlinger进行图层合成后送至显示屏进行显示,这样,用户可以在显示屏上看到应用1的窗口和应用2的窗口,以及应用1的窗口所显示的用户界面和应用2的窗口所显示的用户界面。
可理解,在已经触发电子设备启动应用1和应用2的情况下,用户还可以触发电子设备启动其他应用,具体实现方式可参考步骤S1-步骤S6。
S7:输入事件管理模块检测到作用在应用2的窗口上的触摸操作。
用户可以触摸应用2的窗口,相应的,电子设备的硬件设备(例如,显示屏)可以生成原始输入事件。电子设备中的输入事件管理模块可以采集、获取原始输入事件,并对原始输入事件进行处理(例如,预处理和分类),得到触摸事件(或称触控事件)。也可以理解为,输入事件管理模块将原始输入事件转换为更加高级的类的对象(即上文所提及的Android系统可以理解的事件)。上述过程可以理解为输入事件管理模块检测到作用在应用2的窗口上的触摸操作。
在本申请的一些实施例中,输入事件管理模块基于该作用在应用2的窗口上的触摸操作得到的触摸事件可以为落下事件(例如,MotionEvent.ACTION_DOWN)。
示例性的,应用2的窗口可以为如图6A所示的窗口w2。具体地,如图6A中的(1)所示,用户手指落在显示屏上(本次滑动过程中针对显示屏的初次触摸)显示有窗口w2的区域内,相应的,输入事件管理模块可以检测到作用在应用2的窗口上的触摸操作,也就是说,输入事件管理模块可以采集原始输入事件,并处理得到MotionEvent.ACTION_DOWN。
示例性的,应用2的窗口可以为如图7D所示的窗口2a。具体地,如图7D中的(1)所示,用户手指在显示屏上显示有应用2的窗口的区域落下(即用户手指落在显示屏上显示有应用2的窗口的区域),相应的,输入事件管理模块可以检测到作用在应用2的窗口上的触摸操作,也就是说,输入事件管理模块可以采集原始输入事件,并处理得到MotionEvent.ACTION_DOWN。
S8:输入事件管理模块通知WM处理触摸事件。
输入事件管理模块将原始输入事件转换为触摸事件之后,可以通知WM处理该触摸事件。在本申请的一些实施例中,输入事件管理模块可以通过向WM发送消息来通知WM处理该触摸事件。
在本申请的一些实施例中,触摸事件可以携带有位置信息(例如,显示屏上的触摸点的坐标)。
S9:WM确定焦点窗口。
输入事件管理模块通知WM处理触摸事件之后,WM可以确定焦点窗口。具体地,WM可以确定焦点窗口为应用2的窗口。在本申请的一些实施例中,WM可以基于触摸事件携带的位置信息来确定焦点窗口。例如,步骤S8所提及的触摸事件携带的触摸点的坐标位于应用2的窗口所在范围,则WM可以确定应用2的窗口为焦点窗口。在本申请的一些实施例中,WM可以基于触摸事件携带的位置信息具体确定焦点窗口,还可以确定焦点窗口对应的应用为焦点应用。在本申请的一些实施例中,WM可以通过调用handleTaskFocusChange方法来确定焦点窗口。
S10:WM通过表面控制接口向SurfaceFlinger发送焦点窗口相关信息。
WM确定焦点窗口之后,可以通过表面控制接口来将焦点窗口相关信息发送给SurfaceFlinger。相应的,SurfaceFlinger可以接收WM通过表面控制接口发送的焦点窗口相关信息。
在本申请的一些实施例中,焦点窗口相关信息可以包括焦点窗口对应的标识。在本申请的一些实施例中,在应用对应多个窗口的情况下,WM和SurfaceFlinger创建应用窗口的过程中可以给窗口添加标识,且SurfaceFlinger可以存储窗口对应的标识和应用包名、UID、PID之间的映射信息。可理解,窗口对应的标识可以通过数字、符号、文字等来表示,本申请对其具体表示方式不作限制。
在本申请的一些实施例中,焦点窗口相关信息还可以包括焦点应用对应的应用的相关信息(例如,包名、UID、PID等)。例如,焦点窗口相关信息可以包括com.example.app2。
在本申请的一些实施例中,WM可以通过调用setFocusedWindow方法来将焦点应用相关信息发送给SurfaceFlinger。
S11:SurfaceFlinger更新焦点应用和/或焦点窗口。
SurfaceFlinger接收WM通过表面控制接口发送的焦点窗口相关信息之后,可以基于该焦点窗口相关信息来更新焦点应用和/或焦点窗口。具体地,SurfaceFlinger可以将焦点应用更新为应用2,和/或将焦点窗口更新为应用2的窗口。
在本申请的一些实施例中,SurfaceFlinger更新焦点应用和/或焦点窗口之后,可以将屏幕刷新率设置为更新后的焦点应用对应的最高目标刷新率。具体地,SurfaceFlinger可以将屏幕刷新率设置为应用2对应的最高目标刷新率。
在本申请的一些实施例中,应用2对应有多个窗口,SurfaceFlinger可以确定在应用2对应的多个窗口中,对应标识与焦点应用相关信息中的窗口标识相同的窗口为焦点窗口。
需要说明的是,SurfaceFlinger可以记录焦点应用和/或焦点窗口。在本申请的一些实施例中,SurfaceFlinger可以记录焦点窗口对应的标识。在本申请的一些实施例中,SurfaceFlinger可以记录焦点应用对应的包名或UID。
可理解,在本申请的一些实施例中,SurfaceFlinger可以基于焦点应用对应的目标刷新率区间来设置屏幕刷新率,不仅可以将屏幕刷新率设置为焦点应用对应的最高目标刷新率,还可以在一定条件下(例如,无用户操作)将屏幕刷新率设置得低于焦点应用对应的最高目标刷新率,具体方式可以参考上文,本申请在此不再赘述。
还需要说明的是,
S12:SurfaceFlinger向输入事件管理模块同步更新后的焦点应用和/或焦点窗口。
SurfaceFlinger更新焦点应用和/或焦点窗口之后,可以通知输入事件管理模块更新后的焦点应用和/或焦点窗口,即向输入事件管理模块同步更新后的焦点应用和/或焦点窗口。
S13:输入事件管理模块检测到作用在应用2的窗口上的滑动并抬手操作。
用户触摸应用2的窗口之后,可以紧接着滑动并抬手。相应的,在该滑动并抬手的过程中,电子设备的硬件设备(例如,显示屏)可以生成一系列原始输入事件。电子设备中的输入事件管理模块可以采集、获取该一系列的原始输入事件,并对其进行处理(例如,预处理和分类),得到一系列触摸事件。上述过程可以理解为输入事件管理模块检测到作用在应用2的窗口上的滑动并抬手操作。
在本申请的一些实施例中,输入事件管理模块基于该作用在应用2的窗口上的滑动操作得到的触摸事件可以为移动事件(例如,MotionEvent.ACTION_MOVE)。输入事件管理模块基于该作用在应用2的窗口上的抬手操作得到的触摸事件可以为离开事件(例如,MotionEvent.ACTION_UP)。
在本申请的一些实施例中,在输入事件管理模块检测到作用在应用2的窗口上的滑动并抬手操作的过程中,输入事件管理模块可以得到一个或多个移动事件,以及一个离开事件。
示例性的,应用2的窗口可以为如图6A所示的窗口w2。具体地,如图6B中的(2)所示,用户手指落在显示屏上显示有窗口w2的区域内之后,用户手指可以在该显示有窗口w2的区域内向上滑动,相应的,输入事件管理模块可以检测到作用在应用2的窗口上的滑动操作,也就是说,输入事件管理模块可以采集一系列原始输入事件,并处理得到一系列MotionEvent.ACTION_MOVE。
示例性的,应用2的窗口可以为如图7D所示的窗口2a。具体地,如图7D中的(2)和(3)所示,用户手指落在显示屏上显示有应用2的窗口的区域之后,用户手指可以在该显示有应用2的窗口的区域内向上滑动,相应的,输入事件管理模块可以检测到作用在应用2的窗口上的滑动操作,也就是说,输入事件管理模块可以采集原始输入事件,并处理得到MotionEvent.ACTION_MOVE。
示例性的,应用2的窗口可以为如图6A所示的窗口w2。具体地,如图6B中的(3)所示,用户手指在显示屏上该显示有窗口w2的区域内向上滑动之后,可以上抬离开显示屏,相应的,输入事件管理模块可以检测到作用在应用2的窗口上的抬手操作,也就是说,输入事件管理模块可以采集原始输入事件,并处理得到MotionEvent.ACTION_UP。
示例性的,应用2的窗口可以为如图7E所示的窗口2a。具体地,如图7E中的(1)所示,用户手指可以在显示屏上显示有应用2的窗口的区域内向上滑动之后,用户手指可以上抬离开显示屏,相应的,输入事件管理模块可以检测到作用在应用2的窗口上的抬手操作,也就是说,输入事件管理模块可以采集原始输入事件,并处理得到MotionEvent.ACTION_UP。
需要说明的是,在本申请的一些实施例中,在输入事件管理模块检测到作用在应用2的窗口上的滑动并抬手操作的过程中,输入事件管理模块可以不断得到触摸事件(即上文所提及的得到一系列触摸事件),输入事件管理模块可以不断通知WM处理触摸事件。
S14:若用户抬手时,应用2的窗口中的用户界面的滑动速度大于速度阈值,滑动组件检测到fling操作。
根据上文,用户手指落在显示屏上显示有应用2的窗口的区域,并在显示屏上滑动之后,用户可以抬手使得手指离开显示屏。若用户抬手时应用2的窗口中的用户界面的滑动速度大于速度阈值,滑动组件可以检测到fling操作。
S15:在处理该fling操作的过程中,滑动组件向SurfaceFlinger发送应用2对应的交互状态相关信息。
首先,需要说明的是,滑动组件检测到fling操作之后,可以处理该fling操作。在处理fling操作的过程中,滑动组件可以确定fling操作的状态,并将fling操作的状态同步给SurfaceFlinger。其中,fling操作的状态可以包括开始(即START)和结束(即END)。
可理解,交互状态相关信息可以包括应用对应的fling操作的状态信息(也可以称为应用的窗口对应的fling操作的状态信息)。例如,应用2对应的交互状态相关信息可以包括应用2对应的fling操作的状态。
具体地,若用户抬手时,应用2的窗口中的用户界面的滑动速度大于速度阈值,滑动组件可以检测到fling操作,在滑动组件检测到该fling操作之后,滑动组件可以确定该fling操作的状态为START,并将该状态信息发送给SurfaceFlinger。滑动组件后续可以继续处理该fling操作,并在应用2的窗口中的用户界面的滑动停止(即滑动速度为0)时,确定该fling操作的状态为END,并将该状态信息发送给SurfaceFlinger。
在本申请的一些实施例中,滑动组件可以检测到多个应用触发fling操作。例如,用户可以首先在显示屏上显示有应用2的窗口的区域内滑动并抬手,相应的,滑动组件可以检测到应用2对应的fling操作的状态为START,并将该状态信息发送给SurfaceFlinger,进一步的,用户可以再在显示屏上显示有应用1的窗口的区域内滑动并抬手,而滑动组件在检测到应用2对应的fling操作的状态变为END之前,检测到应用1对应的fling操作的状态为START,滑动组件可以仍然将该状态信息发送给SurfaceFlinger。在这种情况下,应用1的窗口中的用户界面和应用2的窗口中的用户界面在一段时间内均处于fling状态。
在本申请的一些实施例中,滑动组件可以通过增加桩点来监听该fling操作的状态,并及时将该fling操作的状态同步给SurfaceFlinger。具体地,滑动组件增加桩点后,可以监听应用2的窗口所对应的fling操作的开始和结束,并在监听到该fling操作的状态为START之后,将该状态信息发送给SurfaceFlinger,以及在监听到该fling操作的状态为END之后,将该状态信息发送给SurfaceFlinger。
在本申请的一些实施例中,交互状态相关信息不仅可以包括应用对应的fling操作的状态信息,还可以包括应用的UID和/或包名。例如,应用2对应的交互状态相关信息可以包括应用2对应的fling操作的状态、应用2的UID(比如12)和应用2的包名(比如com.example.app2)。
S16:SurfaceFlinger基于应用2对应的交互状态相关信息更新应用2对应的交互状态。
SurfaceFlinger接收滑动组件发送的应用2对应的交互状态相关信息之后,可以确定该
交互状态相关信息中的fling操作的状态信息包括的是START,还是END。若应用2对应的交互状态相关信息中的fling操作的状态信息包括START,则SurfaceFlinger可以确定应用2对应的交互状态为fling状态,即应用2处于fling状态,SurfaceFlinger可以将应用2应用的交互状态更新为fling状态。若应用2对应的交互状态相关信息中的fling操作的状态信息包括END,则SurfaceFlinger可以确定应用2对应的交互状态为非fling状态,即应用2不处于fling状态,SurfaceFlinger可以将应用2应用的交互状态更新为非fling状态。
可理解,电子设备执行步骤S1-步骤S15之后,还可以执行下文步骤S17-步骤S22。
2、基于焦点应用和/或焦点窗口,以及应用的交互状态信息,确定需要更新界面的应用的渲染帧率(如图11B所示)。
S17:SurfaceFlinger每一次生成VSync信号,就确定一次当前屏幕刷新率是否大于第一刷新率阈值。
SurfaceFlinger可以按照VSync周期(即屏幕刷新率的倒数)来生成VSync信号。SurfaceFlinger每一次生成VSync信号,就可以确定一次当前屏幕刷新率是否大于第一刷新率阈值。若当前屏幕刷新率大于第一刷新率阈值,则SurfaceFlinger可以继续执行步骤S18。
S18:SurfaceFlinger基于焦点应用和/或焦点窗口,以及应用1和应用2对应的交互状态,确定应用1和应用2的渲染帧率。
在应用当前显示有应用1的窗口和应用2的窗口的情况下,若SurfaceFlinger确定当前屏幕刷新率是否大于第一刷新率阈值,则SurfaceFlinger可以基于焦点应用和/或焦点窗口,以及应用1和应用2对应的交互状态,确定应用1和应用2的渲染帧率。具体地,若应用1为焦点应用或处于fling状态,则SurfaceFlinger可以确定应用1的渲染帧率为当前屏幕刷新率,若应用1为不处于fling状态的非焦点应用,则SurfaceFlinger可以确定应用1的渲染帧率小于当前屏幕刷新率。类似的,若应用2为焦点应用或处于fling状态,则SurfaceFlinger可以确定应用2的渲染帧率为当前屏幕刷新率,若应用2为不处于fling状态的非焦点应用,则SurfaceFlinger可以确定应用2的渲染帧率小于当前屏幕刷新率。
可理解,步骤S18的具体实现方式可以参考步骤S101的相关描述,本申请在此不再赘述。
S19:SurfaceFlinger通过连接通道1来基于应用1的渲染帧率向渲染编排器发送APP-VSync信号。
SurfaceFlinger确定应用1的渲染帧率之后,可以通过连接通道1来基于应用1的渲染帧率向渲染编排器发送APP-VSync信号,具体实现方式可以参考步骤S102和步骤S103的相关描述,本申请在此不再赘述。
相应的,渲染编排器可以接收SurfaceFlinger通过连接通道1发送的APP-VSync信号。
S20:渲染编排器发起应用1对应的渲染流程。
渲染编排器接收SurfaceFlinger通过连接通道1发送的APP-VSync信号之后,可以发起应用1对应的渲染流程,即唤醒应用1的UI线程进行绘制、渲染。
S21:SurfaceFlinger通过连接通道2来基于应用2的渲染帧率向渲染编排器发送
APP-VSync信号。
SurfaceFlinger确定应用2的渲染帧率之后,可以通过连接通道2来基于应用2的渲染帧率向渲染编排器发送APP-VSync信号,具体实现方式可以参考步骤S102和步骤S103的相关描述,本申请在此不再赘述。
相应的,渲染编排器可以接收SurfaceFlinger通过连接通道2发送的APP-VSync信号。
S22:渲染编排器发起应用2对应的渲染流程。
渲染编排器接收SurfaceFlinger通过连接通道2发送的APP-VSync信号之后,可以发起应用2对应的渲染流程,即唤醒应用2的UI线程进行绘制、渲染。
下面介绍本申请实施例涉及的电子设备的硬件结构。
请参阅图12,图12为本申请实施例提供的一种电子设备的硬件结构示意图。
如图12所示,电子设备可以包括:处理器,外部存储器接口,内部存储器,通用串行总线(Universal Serial Bus,USB)接口,充电管理模块,电源管理模块,电池,天线1,天线2,移动通信模块,无线通信模块,传感器模块,按键,马达,指示器,摄像头,显示屏,以及用户识别模块(Subscriber Identity Module,SIM)卡卡槽等。其中,音频模块可以包括扬声器,受话器,麦克风,耳机接口等,传感器模块可以包括压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器,温度传感器,触摸传感器,环境光传感器,骨传导传感器等。
可以理解的是,本申请实施例示意的结构并不构成对电子设备的具体限定。可理解,图示的部件可以以硬件,软件或软件和硬件的组合实现。在本申请的一些实施例中,电子设备可以包括比图示更多的部件。示例性的,电子设备可以包括其他类型的传感器。在本申请的又一些实施例中,电子设备可以包括比图示更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备的结构限定。
处理器可以包括一个或多个处理单元,例如:处理器可以包括应用处理器(Application Processor,AP),调制解调处理器(Modem,也可称之为基带处理器),图形处理器(Graphics Processing Unit,GPU),图像信号处理器(Image Signal Processor,ISP),控制器,视频编解码器,数字信号处理器(Digital Signal Processor,DSP),和/或神经网络处理器(Neural-network Processing Unit,NPU)等。其中,AP是负责运行操作系统和应用程序的处理器。Modem是负责处理各种通信协议的处理器。
电子设备的无线通信功能可以通过天线1、天线2、移动通信模块、无线通信模块,以及Modem等实现。Modem可以通过天线(例如,天线1,天线2等)与基站进行交互。在一些实施例中,电子设备的天线1和移动通信模块耦合,天线2和无线通信模块耦合,使得电子设备可以通过无线通信技术与网络以及其他设备通信。
电子设备可以通过GPU,显示屏,以及应用处理器等实现显示功能。
GPU为图像处理的微处理器,连接显示屏和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器可包括一个或多个GPU,其执行程序指令以生成或改变显示信
息。显示屏用于显示图像,视频等。在一些实施例中,电子设备可以包括一个或多个显示屏。
摄像头用于捕获静态图像或视频。ISP用于处理摄像头反馈的数据。光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。电子设备可以包括一个或多个摄像头。
内部存储器可以包括一个或多个RAM和一个或多个非易失性存储器(Non-Volatile Memory,NVM)。随机存取存储器可以由处理器直接进行读写,可以用于存储操作系统或其他正在运行中的程序的可执行程序(例如,机器指令),还可以用于存储用户及应用程序的数据等。非易失性存储器也可以存储可执行程序和存储用户及应用程序的数据等,可以提前加载到随机存取存储器中,用于处理器直接进行读写。
在本申请实施例中,实现本申请实施例所述的方法的代码可存储在非易失性存储器上。在运行相机应用时,电子设备可将非易失性存储器中存储的可执行代码加载到随机存取存储器。
外部存储器接口可以用于连接外部的非易失性存储器,实现扩展电子设备的存储能力。
电子设备可以通过音频模块,扬声器,受话器,麦克风,耳机接口,以及应用处理器等实现音频功能。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。
Claims (12)
- 一种图像显示方法,其特征在于,所述方法应用于包括显示屏的电子设备;所述方法包括:以第一帧率渲染第一应用的画面,得到第一画面,所述第一应用是处于抛滑fling状态的应用或焦点应用;以第二帧率渲染第二应用的画面,得到第二画面,所述第二应用是处于非fling状态的非焦点应用;对所述第一画面和所述第二画面进行合成处理,得到第一图像;以第一刷新率在所述显示屏上显示所述第一图像;其中,所述第一刷新率大于第一阈值,所述第一帧率与所述第一刷新率相等,所述第二帧率小于所述第一刷新率。
- 如权利要求1所述的方法,其特征在于,所述方法还包括:基于第一定时器每隔第一定时时长生成第一VSync信号;所述第一定时时长为所述第一刷新率的倒数;每生成Y个所述第一VSync信号,相应生成一个第二VSync信号;Y为大于1的整数;所述以第一帧率渲染第一应用的画面,包括:基于所述第一VSync信号渲染所述第一应用的画面;所述以第二帧率渲染第二应用的画面,包括:基于所述第二VSync信号渲染所述第二应用的画面。
- 如权利要求1所述的方法,其特征在于,所述方法还包括:基于第一定时器每隔第一定时时长生成第一VSync信号;所述第一定时时长为所述第一刷新率的倒数;基于第二定时器每隔第二定时时长生成第二VSync信号;所述第二定时时长为所述第二帧率的倒数;所述以第一帧率渲染第一应用的画面,包括:基于所述第一VSync信号渲染所述第一应用的画面;所述以第二帧率渲染第二应用的画面,包括:基于所述第二VSync信号渲染所述第二应用的画面。
- 如权利要求1-3中任一项所述的方法,其特征在于,所述第一刷新率为所述第二帧率的第一倍数,所述第一倍数等于Y。
- 如权利要求1或3所述的方法,其特征在于,所述第一刷新率不为所述第二帧率的整数倍。
- 如权利要求2或3所述的方法,其特征在于,在所述以第一帧率渲染第一应用的画面之前,所述方法还包括:响应于所述第一VSync信号,获取焦点应用、所述第一应用的交互状态和所述第二应用的交互状态;所述交互状态包括所述fling状态和所述非fling状态;基于焦点应用、所述第一应用的交互状态和所述第二应用的交互状态,确定所述第一帧率和所述第二帧率。
- 如权利要求1-6中任一项所述的方法,其特征在于,所述第一应用为处于所述非fling状态的焦点应用;所述以第一刷新率在所述显示屏上显示所述第一图像之后,所述方法还包括:响应于针对所述第一图像中的所述第二画面的用户操作,将焦点应用由所述第一应用更新为所述第二应用;将屏幕刷新率设置为第二刷新率;所述第二刷新率为所述第二应用对应的最高刷新率。
- 如权利要求7所述的方法,其特征在于,所述将屏幕刷新率设置为第二刷新率之后,所述方法还包括:在所述第二刷新率大于所述第一阈值的情况下,以所述第三帧率渲染所述第一应用的画面,得到第三画面,以及以所述第四帧率渲染所述第二应用的画面,得到第四画面;对所述第三画面和所述第四画面进行合成处理,得到第二图像;以所述第二刷新率在所述显示屏上显示所述第二图像;其中,所述第三帧率小于所述第二刷新率,所述第四帧率与所述第二刷新率相等。
- 如权利要求7或8所述的方法,其特征在于,所述将屏幕刷新率设置为第二刷新率之后,所述方法还包括:在所述第二刷新率小于或等于所述第一阈值的情况下,以第四帧率渲染所述第一应用的画面,得到第五画面,以及以所述第四帧率渲染所述第二应用的画面,得到第四画面;所述第四帧率与所述第二刷新率相等;对所述第五画面和所述第四画面进行合成处理,得到第三图像;以所述第二刷新率在所述显示屏上显示所述第三图像。
- 如权利要求7-9任一项所述的方法,其特征在于,所述将屏幕刷新率设置为第二刷新率之后,所述方法还包括:若在预设时长内未检测到针对所述显示屏显示画面的用户操作,将屏幕刷新率设置为第三刷新率;所述第三刷新率小于所述第二刷新率,且所述第三刷新率大于或等于所述第二应用对应的最低刷新率。
- 一种电子设备,其特征在于,所述电子设备包括显示屏、一个或多个存储器、一个或多个处理器;所述显示屏与所述一个或多个存储器,以及所述一个或多个处理器耦合,所述显示屏用于显示画面,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,所述处理器调用所述计算机指令以执行上述权利要求1-10中任一项所述的方法。
- 一种计算机可读存储介质,其特征在于,用于存储计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行上述权利要求1-10中任一项所述的方法。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2024/088577 WO2025217876A1 (zh) | 2024-04-18 | 2024-04-18 | 一种图像显示方法及相关设备 |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2024/088577 WO2025217876A1 (zh) | 2024-04-18 | 2024-04-18 | 一种图像显示方法及相关设备 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2025217876A1 true WO2025217876A1 (zh) | 2025-10-23 |
Family
ID=97402766
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2024/088577 Pending WO2025217876A1 (zh) | 2024-04-18 | 2024-04-18 | 一种图像显示方法及相关设备 |
Country Status (1)
| Country | Link |
|---|---|
| WO (1) | WO2025217876A1 (zh) |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111767013A (zh) * | 2020-06-01 | 2020-10-13 | Oppo(重庆)智能科技有限公司 | 控制方法、控制装置、电子装置、计算机可读存储介质 |
| CN114040238A (zh) * | 2020-07-21 | 2022-02-11 | 华为技术有限公司 | 一种显示多个窗口的方法及电子设备 |
| CN114495864A (zh) * | 2022-04-13 | 2022-05-13 | 荣耀终端有限公司 | 屏幕刷新率的调整方法、电子设备及可读存储介质 |
| CN116196621A (zh) * | 2023-05-05 | 2023-06-02 | 荣耀终端有限公司 | 应用处理方法及相关装置 |
| CN117795478A (zh) * | 2021-08-03 | 2024-03-29 | 维谛信息技术系统有限公司 | 用于管理显示器上呈现的应用刷新率的系统和方法 |
| WO2024066834A1 (zh) * | 2022-09-30 | 2024-04-04 | 荣耀终端有限公司 | Vsync信号的控制方法、电子设备、存储介质及芯片 |
-
2024
- 2024-04-18 WO PCT/CN2024/088577 patent/WO2025217876A1/zh active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111767013A (zh) * | 2020-06-01 | 2020-10-13 | Oppo(重庆)智能科技有限公司 | 控制方法、控制装置、电子装置、计算机可读存储介质 |
| CN114040238A (zh) * | 2020-07-21 | 2022-02-11 | 华为技术有限公司 | 一种显示多个窗口的方法及电子设备 |
| CN117795478A (zh) * | 2021-08-03 | 2024-03-29 | 维谛信息技术系统有限公司 | 用于管理显示器上呈现的应用刷新率的系统和方法 |
| CN114495864A (zh) * | 2022-04-13 | 2022-05-13 | 荣耀终端有限公司 | 屏幕刷新率的调整方法、电子设备及可读存储介质 |
| WO2024066834A1 (zh) * | 2022-09-30 | 2024-04-04 | 荣耀终端有限公司 | Vsync信号的控制方法、电子设备、存储介质及芯片 |
| CN116196621A (zh) * | 2023-05-05 | 2023-06-02 | 荣耀终端有限公司 | 应用处理方法及相关装置 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN102112953B (zh) | 信息处理设备 | |
| EP4411533A1 (en) | Interface generation method and electronic device | |
| US20240312109A1 (en) | Interface generation method and electronic device | |
| CN110881104A (zh) | 拍照方法、装置、存储介质及终端 | |
| CN116166256A (zh) | 界面生成方法及电子设备 | |
| CN117097883A (zh) | 一种丢帧故障原因确定方法、电子设备和存储介质 | |
| WO2022206681A1 (zh) | 一种窗口的显示方法以及相关装置 | |
| CN116347166A (zh) | 显示设备及窗口显示方法 | |
| CN111857480A (zh) | 图标对齐方法、装置、存储介质及电子设备 | |
| CN112612386B (zh) | 移动终端及其应用卡片的显示方法 | |
| CN115639920A (zh) | 绘制方法、电子设备和可读存储介质 | |
| CN118885234B (zh) | 一种播放应用启动动画的方法、电子设备及相关介质 | |
| CN120416559A (zh) | 一种显示设备及序列动画播放方法 | |
| CN103324741A (zh) | 一种电子设备上网页缩放和对齐的方法和装置 | |
| CN116719587A (zh) | 屏幕显示方法、电子设备及计算机可读存储介质 | |
| CN115690269A (zh) | 一种视图对象的处理方法及电子设备 | |
| CN115639936A (zh) | 一种转屏控制方法、装置及电子设备 | |
| CN116166257A (zh) | 界面生成方法及电子设备 | |
| WO2025217822A1 (zh) | 一种动画显示方法及相关设备 | |
| WO2025130055A1 (zh) | 一种图像处理方法及电子设备 | |
| CN121680978A (zh) | 应用切换方法、电子设备和计算机可读存储介质 | |
| WO2026097919A1 (zh) | 数据处理方法、电子设备、可读介质及程序产品 | |
| CN121008728A (zh) | 刷新率调整方法和电子设备 | |
| WO2025152444A1 (zh) | 一种基于web内核的线程调度方法及电子设备 | |
| WO2026085869A1 (zh) | 数据处理方法、电子设备、可读介质及程序产品 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 24935426 Country of ref document: EP Kind code of ref document: A1 |