WO2025217822A1 - 一种动画显示方法及相关设备 - Google Patents
一种动画显示方法及相关设备Info
- Publication number
- WO2025217822A1 WO2025217822A1 PCT/CN2024/088136 CN2024088136W WO2025217822A1 WO 2025217822 A1 WO2025217822 A1 WO 2025217822A1 CN 2024088136 W CN2024088136 W CN 2024088136W WO 2025217822 A1 WO2025217822 A1 WO 2025217822A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- animation
- application
- desktop
- image frame
- electronic device
- 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
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Definitions
- the present application relates to the field of terminal technology, and in particular to an animation display method and related equipment.
- the electronic device may play an application startup animation (which may be referred to as a startup animation) to improve the continuity of the electronic device from displaying the desktop interface to displaying the user interface of the launched application, and achieve a smooth transition.
- an application startup animation which may be referred to as a startup animation
- the electronic device displays other interfaces (for example, the user interface of another application)
- the user can swipe up to trigger the electronic device to return to the desktop.
- the electronic device may play a return to desktop animation (which may be referred to as a return animation) to improve the continuity of the electronic device from displaying the user interface of the launched application to displaying the desktop interface, and achieve a smooth transition.
- the present application discloses an animation display method and related equipment. According to this method, when a return animation drawn in a second dynamic effect drawing mode is interrupted, the electronic device can stop drawing the return animation, draw a transition image frame based on the drawing parameters corresponding to the last image frame of the return animation and the drawing parameters corresponding to the image frame where the return animation was interrupted, and then draw the second startup animation in the first dynamic effect drawing mode.
- This method can achieve a smooth connection between the return animation and the startup animation by changing the dynamic effect drawing mode and drawing a transition image frame, avoiding screen flashing or black flashing.
- an embodiment of the present application provides an animation display method.
- the method can be applied to an electronic device.
- the method may include: displaying a first interface, the first interface being an interface of a desktop application, the first interface including a first application icon; displaying a first animation in response to a first operation on the first application icon; the first application icon being an application icon corresponding to a first application, the first animation including an animation of launching the first application; during the display of the first animation, in response to a second operation of returning to the desktop, stopping displaying the first animation and displaying a second animation; the second animation including an animation of returning to the first interface; during the display of the second animation, in response to a third operation on a first image frame in the second animation, stopping displaying the second animation and displaying a third animation; wherein the first animation is drawn by the electronic device through an image synthesizer SurfaceFlinger, the second animation is drawn by the electronic device through the desktop application, and the third animation is drawn by the electronic device through the desktop application.
- the electronic device when the return animation drawn by SurfaceFlinger is interrupted, the electronic device can stop drawing the return animation through SurfaceFlinger and draw the second startup animation through the desktop application. In this way, the electronic device does not need to first display the last image frame of the return animation when the return animation drawn by SurfaceFlinger is interrupted, and then continue the second startup animation through SurfaceFlinger. Instead, it can change the animation drawing method from being drawn by SurfaceFlinger to being drawn by the desktop application to achieve a smooth connection between the return animation and the second startup animation, avoiding screen flashing or black flashing.
- the first animation may be the first startup animation mentioned below
- the second animation may be the return animation mentioned below
- the third animation may be the second startup animation mentioned below.
- the first interface may be a desktop interface.
- the first image frame in the second animation may be the N2th image frame of the return animation mentioned below, or the interrupted image frame of the return animation.
- the first operation and the third operation may be click operations
- the second operation may be an operation of sliding upward from the bottom of the screen.
- Figures 3A-3B, 4A-4B, 10A-10B, and 11A-11B please refer to Figures 3A-3B, 4A-4B, 10A-10B, and 11A-11B.
- the method further includes: in the process of displaying the third animation, in response to a fourth operation of returning to the desktop, displaying a fourth animation; the fourth animation includes an animation of returning to the first interface, and the fourth animation is drawn by the electronic device through the desktop application.
- the electronic device can continue to use the first animation drawing method to draw the return animation.
- the electronic device can select the corresponding animation drawing method based on the drawing state (ended or not yet ended) when the animation is interrupted, thereby achieving a smooth connection between the return animation and the startup animation, avoiding screen flashing or black flashing.
- the fourth animation may be the return animation mentioned below.
- the fourth operation may be an operation of sliding upward from the bottom of the screen.
- the fourth operation may be an operation of sliding upward from the bottom of the screen.
- the method further includes: after displaying the third animation, displaying the interface of the first application; in response to a fourth operation of returning to the desktop, displaying a fourth animation; the fourth animation includes an animation of returning to the first interface, and the fourth animation is drawn by the electronic device through the SurfaceFlinger.
- the electronic device can use the second animation drawing method to draw the return animation.
- the electronic device can select the corresponding animation drawing method based on the drawing state (ended or not yet ended) when the animation is interrupted, thereby achieving a smooth connection between the return animation and the startup animation, avoiding screen flashing or black flashing.
- the method before displaying the first animation, further includes: in response to the first operation, based on the motion effect flag being the first content, drawing the first animation through the SurfaceFlinger.
- stopping displaying the first animation includes: in response to the second operation, based on the first animation not having finished playing, stopping drawing the first animation.
- the method further includes: based on the target interface being the first interface, the third animation is not currently drawn, and the motion effect flag is the first content, drawing the second animation through the SurfaceFlinger; after drawing the second animation through the SurfaceFlinger, the method further includes: in response to the third operation, setting the motion effect flag to the second content.
- the electronic device can determine through a series of judgments whether the electronic device will draw the return animation in the second dynamic effect drawing method or the first dynamic effect drawing method.
- This is a complete set of method logic.
- this shows that the above method can be applied to scenarios where the animation is interrupted multiple times.
- the above method can be applied not only to electronic devices that support the second dynamic effect drawing method, but also to electronic devices that do not support the second dynamic effect drawing method.
- the electronic device can use this method to draw the animation and respond after the animation is interrupted.
- Technicians do not need to formulate corresponding methods for electronic devices that support the second dynamic effect drawing method and electronic devices that do not support the second dynamic effect drawing method. This simplifies the process to a certain extent and improves the applicability of the device.
- the electronic device can determine whether to construct the return animation in the second animation drawing method or the first animation drawing method based on the setting of the flag bit. This is simpler and faster, and there is no need to determine whether the drawing operation involved in the startup animation is performed by SurfaceFlinger or by the desktop application to determine the method of constructing the startup animation.
- stopping displaying the second animation and displaying the third animation includes: stopping displaying the second animation and displaying a second image frame; the content of the second image frame is the same as the content of the first image frame; after displaying the second image frame, displaying the third animation.
- the electronic device when the return animation drawn by SurfaceFlinger is interrupted, the electronic device can stop drawing the return animation through SurfaceFlinger, draw a transition image frame with the same content as the image frame in which the return animation was interrupted, and then draw the second startup animation through the desktop application, thereby achieving a smooth transition from drawing the animation in the second motion effect drawing method to drawing the animation in the first motion effect drawing method, that is, achieving a smooth connection between the return animation and the second startup animation, avoiding phenomena such as screen flashing or black flashing.
- the second image frame is the transition image frame mentioned below.
- the first image frame is synthesized based on the first layer, the second layer and the third layer; the first layer includes the first application icon, the second layer includes other application icons or components except the first application icon, and the third layer is the window layer of the first application; stopping displaying the second animation includes: destroying the first layer; notifying the SurfaceFlinger to stop drawing the second animation; before displaying the second image frame, the method also includes: determining a first drawing parameter based on the playback duration of the second animation; the first drawing parameter is the drawing parameter corresponding to the second layer; drawing the fourth layer based on the second drawing parameter by the SurfaceFlinger, and adjusting the content in the fourth layer based on the first drawing parameter by the desktop application to obtain the drawn fourth layer; the second drawing parameter is the drawing parameter corresponding to the last image frame of the second animation; the second image frame is obtained by synthesizing the drawn fourth layer and the drawn third layer by the SurfaceFlinger.
- the electronic device can destroy the icon layer to avoid the subsequent impact on the image frame drawn in the first animation drawing method, and can also determine the drawing parameters corresponding to the image frame where the return animation is interrupted and the drawing parameters corresponding to the last image frame of the return animation, and still use SurfaceFlinger to draw the transition image frame in the second animation drawing method.
- the electronic device can use SurfaceFlinger to draw the desktop layer based on the drawing parameters corresponding to the last image frame of the return animation, so that the size of the desktop layer in the transition image frame is the same as the size of the desktop layer in the last image frame of the return animation, thereby making the subsequent image frame drawn in the first animation drawing method not affected by the size of the desktop layer.
- the electronic device can also adjust the size of the content of the desktop layer in the transition image frame through the desktop application, so that the size of the content of the desktop layer in the transition image frame is the same as the size of the content of the desktop layer in the image frame where the return animation is interrupted.
- the electronic device can also use SurfaceFlinger to synthesize the adjusted desktop layer with the application layer in the image frame where the return animation is interrupted to obtain a transition image frame, and then display it on the display screen.
- the content and size of the transition image frame are the same as the content and size of the image frame where the return animation was interrupted.
- the transition image frame is the same as the image frame previously displayed on the electronic device, which can achieve a smooth transition between the return animation and the second startup animation, avoiding screen flickering or black screen.
- the first layer is an icon layer
- the second layer and the fourth layer are second desktop layers corresponding to different image frames
- the third layer is an application layer.
- the method before displaying the third animation, further includes: determining a third drawing parameter based on the playback duration of the second animation, where the third drawing parameter is the drawing parameter corresponding to the third layer; determining the drawing parameter corresponding to each image frame in the third animation based on the third drawing parameter, and drawing the third animation based on the drawing parameter corresponding to each image frame in the third animation.
- the electronic device can determine the drawing parameters corresponding to the image frame where the return animation was interrupted, determine the drawing parameters corresponding to each image frame of the second startup animation based on the drawing parameters corresponding to the image frame where the return animation was interrupted, and then construct the second startup animation using the first dynamic drawing method based on the drawing parameters corresponding to each image frame.
- This means that the image frame following the transition image frame is drawn by the electronic device using the image frame where the return animation was interrupted as a reference, and is a continuous image frame, which can further achieve a smooth transition between the return animation and the second startup animation.
- the fourth animation is displayed in response to the fourth operation of returning to the desktop, including: in response to the fourth operation, based on stopping the display of the first animation, the target interface is the first interface, and the third animation has not yet finished playing, stopping drawing the third animation; based on the motion effect flag being the second content, drawing the fourth animation through the desktop application.
- the fourth animation is displayed in response to the fourth operation of returning to the desktop, including: in response to the fourth operation, the display is stopped based on the first animation, the target interface is the first interface, the third animation has ended, and the motion effect flag is the second content, and the fourth animation is drawn through the SurfaceFlinger.
- the electronic device can indicate whether the electronic device supports the first Two animation drawing methods, and whether the specific method of drawing the current animation is the first animation drawing method or the second animation drawing method. In this way, once the user subsequently triggers the electronic device to return to the desktop, the electronic device can determine whether to draw the return animation in the second animation drawing method or the first animation drawing method based on the flag.
- This method is simple and fast, and can save time to a certain extent, and avoid the startup animation being interrupted and the connection with the return animation being not smooth.
- the present application provides an electronic device, comprising one or more memories and one or more processors; the one or more memories are coupled to the one or more processors, the memory being used to store computer program code, the computer program code comprising computer instructions, the one or more processors calling the computer instructions to enable the electronic device to execute 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.
- 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.
- FIG1A is a schematic diagram of a startup animation provided in an embodiment of the present application.
- FIG1B is a schematic diagram of a return animation provided by an embodiment of the present application.
- FIG2A is a schematic diagram of another startup animation provided in an embodiment of the present application.
- FIG2B is a schematic diagram of a return animation provided in an embodiment of the present application.
- 3A and 3B are schematic diagrams of image frame changes caused by interrupting animation playback according to an embodiment of the present application.
- FIGS. 4A and 4B are schematic diagrams of another set of image frame changes caused by interrupting animation playback according to an embodiment of the present application.
- FIG5 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
- FIG6 is a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application.
- FIG7 is a flow chart of an animation display method provided in an embodiment of the present application.
- FIG8 is a flowchart of another animation display method provided in an embodiment of the present application.
- 9A and 9B are comparative schematic diagrams of a set of return animation end image frames and transition image frames provided by an embodiment of the present application.
- 11A-11B are schematic diagrams of image frame changes caused by interrupting animation playback according to another embodiment of the present application.
- GUI graphical user interface
- a control may include visual interface elements such as icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets.
- 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.
- the electronic device in response to a user clicking an application icon, the electronic device can play a startup animation.
- this application will record the application icon clicked by the user (or the clicked application icon) as the first application icon, the application corresponding to the first application icon as the first application, and the window corresponding to the first application as the first application window.
- the first application icon displayed by the electronic device gradually disappears, and The first application window is gradually displayed until the size (or dimension) of the first application window is consistent with the size of the screen (or display screen), that is, the electronic device displays the first application window in full screen.
- the first application icon displayed by the electronic device gradually disappears, which may specifically include: the transparency of the first application icon displayed by the electronic device becomes higher and higher (that is, the first application icon becomes more and more transparent).
- the first application icon displayed by the electronic device in the process of the first application icon displayed by the electronic device gradually disappearing, gradually becomes larger, that is, the size of the first application icon becomes larger and larger.
- the electronic device gradually displays the first application window, which may specifically include: the size of the first application window displayed by the electronic device becomes larger and larger, and the transparency of the first application window displayed by the electronic device becomes lower and lower (that is, the first application window becomes more and more opaque).
- the transparency of the first application icon can be as low as 0, in which case the first application icon is opaque (or completely opaque), and the transparency of the first application icon can be as high as 100%, in which case the first application icon is completely transparent (which can be understood as invisible to the user). It can be understood that the transparency of the first application icon in the desktop interface is 0, and when the electronic device displays the first application window in full screen, the transparency of the first application icon is 100%.
- the first application icon displayed by the electronic device is at least consistent with the first application icon originally included in the desktop interface (that is, the minimum size of the first application icon is consistent with the size of the first application icon originally included in the desktop interface), and the size of the first application icon displayed by the electronic device is smaller than the screen size (that is, the maximum size of the first application icon is smaller than the screen size).
- the specific values can be set according to actual needs, and this application does not display them. For example, the width of the first application icon is at most half of the width of the screen, and the length of the first application icon is at most half of the length of the screen.
- the transparency of the first application window can be as low as 0, in which case the first application window is opaque (or completely opaque), and the transparency of the first application window can be as high as 100%, in which case the first application window is completely transparent (understood as invisible to the user). It can be understood that when the electronic device displays the first application window in full screen, the transparency of the first application window is 0.
- the maximum size of the first application window displayed by the electronic device is consistent with the screen size (that is, the maximum size of the first application window is consistent with the screen size), and the minimum size of the first application window displayed by the electronic device can be set according to actual needs, which is not shown in this application.
- the minimum width of the first application window is half of the width of the screen
- the minimum length of the first application window is half of the length of the screen.
- the first image frame of the complete startup animation is the first image frame displayed by the electronic device after the user clicks the first application icon and raises his hand.
- the first image frame may be the same as the desktop interface or different from the desktop interface.
- the present application uses the example that the first frame of the complete startup animation is the same as the desktop interface.
- the electronic device may continue to play the startup animation (that is, display other image frames of the startup animation in sequence) until the Zth image frame of the startup animation is displayed (specifically, the Zth image frame of the complete startup animation).
- the electronic device may display the M1th image frame of the startup animation (specifically, the M1th image frame of the complete startup animation).
- the first application window/first application in the M1th image frame of the startup animation or the M1th frame image
- the icon is larger. It is understandable that the Zth image frame (or the Zth frame image) of the startup animation is the last image frame of the startup animation.
- the size of the first application window is consistent with the size of the screen (or display screen), that is, the electronic device displays the application window in full screen, that is, the electronic device displays the user interface of the first application in full screen. It is understandable that M1 and Z are both positive integers, and M1 is less than Z.
- the electronic device displays other interfaces (for example, the user interfaces of other applications), the user can swipe up to trigger the electronic device to return to the desktop.
- the electronic device can play a return to desktop animation (which can be simply referred to as the return animation) to improve the continuity of the electronic device from displaying the application user interface to displaying the desktop interface.
- the electronic device when the electronic device displays the first application window in full screen, the user can swipe upward from the bottom of the screen of the electronic device. Accordingly, in response to the user's swiping operation from the bottom of the screen, the electronic device can play a return animation.
- the electronic device when the electronic device displays the first application window in full screen, the electronic device can receive a user operation of swiping upward from the bottom of the screen. After receiving the user operation, the electronic device can play a return animation.
- the first application window displayed by the electronic device gradually becomes smaller, and the first application icon is gradually displayed until the desktop interface is displayed.
- the first application window displayed by the electronic device gradually becomes smaller until it disappears, and the first application icon is gradually displayed until the first application icon is consistent with the first application icon originally included in the desktop interface (for example, the size and transparency of the first application icon are respectively consistent with the size and transparency of the first application icon originally included in the desktop interface).
- the first application window displayed by the electronic device gradually becomes smaller until it disappears, which can specifically include: the size of the first application window displayed by the electronic device becomes smaller and smaller, and the transparency of the first application window displayed by the electronic device becomes higher and higher (that is, the first application window becomes more and more transparent).
- the electronic device gradually displays the first application icon, which can specifically include: the transparency of the first application icon displayed by the electronic device becomes lower and lower (that is, the first application icon becomes more and more opaque).
- the electronic device gradually displays the first application icon, which can specifically also include: the size of the first application icon displayed by the electronic device becomes smaller and smaller.
- the size and transparency range of the first application window can refer to the size and transparency range of the first application window involved in the startup animation described above.
- the size and transparency range of the first application icon can refer to the size and transparency range of the first application icon involved in the startup animation described above. This application will not go into details about this.
- the first image frame of the complete return animation is the first image frame displayed by the electronic device after the user slides up from the bottom of the screen and raises his hand.
- the first image frame can be the user interface of the first application displayed in full screen by the electronic device (or the first image frame is the same as the user interface of the first application displayed in full screen by the electronic device), or it can be different from the user interface of the first application.
- the user interface of the first application displayed in full screen by the electronic device can be understood as: the electronic device displays the first application window in full screen, and the first application window includes the user interface of the first application.
- the first image frame of the complete return animation is the image frame displayed by the electronic device when the user's finger touches the screen but has not yet swiped upward, which can be understood as the first image frame displayed by the electronic device after receiving the press event.
- This first image frame can be the user interface of the first application displayed in full screen by the electronic device, or it can be different from the user interface of the first application.
- this application uses the first image frame of a complete return animation as an example to illustrate the user interface of the first application displayed in full screen on an electronic device.
- the number of frames of the complete return animation and the complete startup animation are the same.
- the number of frames of the complete return animation may be different from the number of frames of the complete startup animation.
- the complete return animation may include a total of Z image frames, that is, the complete return animation is composed of Z image frames (or Z frame images).
- the first frame of the complete return animation may be the Zth frame of the complete startup animation
- the N1th frame of the complete return animation may be the M1th frame of the complete startup animation
- the Zth frame of the complete return animation may be the first frame of the complete startup animation.
- the electronic device when the electronic device displays the first application window in full screen (or the electronic device displays the user interface of the first application in full screen), in response to the user swiping up from the bottom of the screen, the electronic device can display the first image frame of the return animation (specifically, the first image frame of the complete return animation).
- This first image frame is the same as the image frame displayed by the electronic device before the user swiped up. That is, the size and content of the first application window in the first image frame of the return animation have not changed compared to the size and content of the first application window displayed by the electronic device before the user swiped up.
- the electronic device can continue to play the return animation (i.e., display other image frames of the return animation in sequence) until the Zth image frame of the return animation is displayed. While continuing to play the return animation, the electronic device can display the N1th image frame of the return animation (or the N1th frame image). Compared with the first image frame of the return animation, the first application window/first application icon in the N1th image frame of the return animation is larger. It can be understood that the Zth image frame of the return animation is the last image frame of the return animation. The Zth image frame of the return animation can be a desktop interface. It can be understood that N1 and Z are both positive integers, and N1 is smaller than Z.
- users can also trigger the electronic device to return to the desktop (or display the desktop interface) through other operations (for example, sliding down from the top of the screen, double-clicking or long pressing in a specific area of the screen, specific gesture commands, specific voice commands, etc.), and this application does not limit this.
- the size of other application icons or components displayed by the electronic device except the first application icon will also change. It is understandable that the specific change in the size of other application icons or components displayed by the electronic device except the first application icon can be set according to actual needs, and this application does not impose any restrictions on this. For example, with the initial size of the other application icons or components except the first application icon included in the desktop interface as a reference, the maximum size of the other application icons or components except the first application icon can be their initial size, and the minimum size of the other application icons or components except the first application icon can be changed to 80% of their initial size.
- the first application icon displayed by the electronic device gradually disappears, and the other application icons or components displayed by the electronic device except the first application icon gradually become smaller, and the electronic device gradually displays the first application window until the size (or size) of the first application window is consistent with the size of the screen (or display screen), that is, the electronic device displays the first application window in full screen.
- the first image frame of the startup animation is displayed on the screen of the electronic device before the M2 image frame (or M2 frame image)
- the M2 image frame of the startup animation is displayed on the screen of the electronic device before the M1 image frame.
- the size of the other icons or components in the M2 image frame of the startup animation is smaller, and compared with the other icons or components in the M2 image frame of the startup animation, the size of the other icons or components in the M1 image frame of the startup animation is smaller. That is, the size of other icons or components in the M1th image frame of the startup animation is smaller than the size of other icons or components in the M2th image frame of the startup animation, and the size of other icons or components in the M2th image frame of the startup animation is smaller than the size of other icons or components in the 1st image frame of the startup animation.
- M2 is an integer greater than 1
- M2 is smaller than M1.
- the first application window displayed by the electronic device gradually becomes smaller, and the other application icons or components displayed by the electronic device except the first application icon gradually become larger, and the electronic device gradually displays the first application icon until the desktop interface is displayed.
- the 1st image frame of the return animation is displayed on the screen of the electronic device before the N1th image frame
- the N1th image frame of the return animation is displayed on the screen of the electronic device before the N2th image frame (or the N2th frame image).
- the size of the other icons or components in the N1th image frame of the return animation is larger, and compared with the other icons or components in the N1th image frame of the return animation, the size of the other icons or components in the N2th image frame of the return animation is larger. That is to say, the size of other icons or components in the N2th image frame of the return animation is larger than the size of other icons or components in the N1th image frame of the return animation, and the size of other icons or components in the N1th image frame of the return animation is larger than the size of other icons or components in the 1st image frame of the return animation.
- N2 is a positive integer, and N2 is greater than N1, and N2 is less than Z. It is understandable that the changes in the first application icon and the first application window shown in Figure 2B can be referred to Figure 1B, and this application will not go into details here.
- Figures 2A and 2B illustrate a complete startup animation and a complete return animation, respectively.
- the N1th image frame of the complete return animation is the same as the M1th image frame of the complete startup animation
- the N2th image frame of the complete return animation is the same as the M2th image frame of the complete startup animation.
- the Electronic devices can use two dynamic effect drawing methods to draw the above-mentioned startup animation and return animation.
- this application records the first of the two dynamic effect drawing methods as the first dynamic effect drawing method, and the second dynamic effect drawing method as the second dynamic effect drawing method.
- the first dynamic effect drawing method specifically refers to the application layer being responsible for drawing the image frame of the animation. Specifically, after the application layer draws the corresponding layer, the drawing result (which can be understood as the corresponding layer drawn) can be handed over to the module in the lower layer of the application layer in the software framework (which can be simply referred to as the application layer lower layer module) for synthesis to obtain the image frame to be displayed (or the image to be displayed), and finally the image frame to be displayed is sent to the display screen for display.
- the second animation drawing method specifically refers to the drawing of the image frames of the animation by the lower-level module of the application layer (which can be understood as sinking the drawing operation to the lower-level module of the application layer for execution).
- the application layer sends the drawing parameters corresponding to the animation to the lower-level module of the application layer.
- the lower-level module of the application layer draws the corresponding layer based on the drawing parameters corresponding to each image frame of the animation, and synthesizes the corresponding drawn layers to obtain the image frame to be displayed, and then sends the image frame to be displayed to the display screen for display, thereby achieving better animation effects under limited computing resources. Since the lower-level module of the application layer draws through the window, the animation drawn using the second animation drawing method can also be called window animation (or window animation).
- the lower layer of the application layer may include an application framework layer, an Android runtime, a system library, a hardware abstraction layer, and a system kernel layer.
- the first animation effect drawing method may be called non-animation effect sinking
- the second animation effect drawing method may be called animation effect sinking
- the above-mentioned application layer lower layer module may be a module in the application framework layer, for example
- the image synthesizer (SurfaceFlinger), that is, the application of the application layer sends the drawing parameters corresponding to the animation to SurfaceFlinger, and SurfaceFlinger draws the corresponding layer.
- the animation and animation effect (which may be referred to as motion effect) involved in the present application have the same meaning.
- constructing animation (or creating animation) mentioned in this application can refer to the entire process of generating and playing animation (or displaying animation), including steps such as calculating drawing parameters, drawing image frames, synthesizing image frames and displaying image frames.
- the first application icon and other application icons or components can be located in a layer, and this layer is different from the layer where the first application window is located (i.e., the first application layer).
- this application will record the layer where the clicked application icon and other application icons or components involved in the process of drawing the startup animation or return animation using the first motion effect drawing method are located as the first desktop layer, and the application window corresponding to the clicked application icon as the application window (or application layer).
- the window where the first application icon is located is different from the first application window, that is, the electronic device draws the first application icon in a window different from the first application window.
- the window where other application icons or components other than the first application icon are located in the desktop interface is different from the first application window, and also different from the window where the first application icon is located.
- this application will use the second dynamic effect drawing method to draw the window (or layer) where the clicked application icon is located in the process of drawing the startup animation or return animation as the icon window (or icon layer), and the window where other application icons or components other than the clicked application icon are located in the desktop interface is recorded as the desktop window (or second desktop layer), and the application window corresponding to the clicked application icon (that is, the window corresponding to the application started by the electronic device) is recorded as the application window (or application layer).
- the window where the first application icon is located is the icon window
- the window where other application icons or components other than the first application icon are located in the desktop interface is the desktop window
- the first application window is the application window.
- the second desktop layer is located at the bottom layer, that is, the second desktop layer is located below the icon layer and the application layer, the icon layer is located between the second desktop layer and the application layer, that is, the icon layer is located above the second desktop layer and below the application layer, and the application layer is located at the top layer, that is, the application layer is located above the second desktop layer and the icon layer.
- the user can swipe up to trigger the return to the desktop.
- the startup animation is interrupted, and the electronic device can use the second motion effect drawing method to construct the return animation based on this.
- the return animation played on the basis of the interrupted startup animation is not a complete return animation. Its first image frame is the image frame displayed by the electronic device when the startup animation is interrupted, rather than the first image frame of the complete return animation.
- the user can click on the application window/application icon to trigger the continuation of the startup application.
- the return animation is interrupted, and the electronic device needs to first display the last frame of the return animation, and then construct the startup animation (that is, the animation of continuing the startup) based on the second motion effect drawing method, that is, the electronic device displays the return animation.
- the startup animation is constructed after the last image frame is drawn. In this way, the startup animation and the return animation are not smoothly connected, resulting in a flashing screen or a black background.
- the electronic device constructs an animation based on (or adopts) the second motion effect drawing method, which may refer to the entire process of generating and playing the animation, including the steps of calculating drawing parameters, drawing layers (or layers corresponding to image frames) using the second motion effect drawing method, synthesizing image frames of the animation based on layers, and displaying image frames.
- the second motion effect drawing method may refer to the entire process of generating and playing the animation, including the steps of calculating drawing parameters, drawing layers (or layers corresponding to image frames) using the second motion effect drawing method, synthesizing image frames of the animation based on layers, and displaying image frames.
- the electronic device in response to the user clicking on the first application icon, can construct a startup animation in a second dynamic drawing method.
- the electronic device in response to the user sliding up from the bottom of the screen (the first interruption as shown in FIG3A , which can be understood as the first interruption of the animation playback), can start from the M1th image frame of the startup animation (i.e., the N1th image frame of the return animation) and construct the return animation in a second dynamic drawing method.
- the electronic device in response to the user clicking on the first application window/first application icon (the second interruption as shown in FIG3A and FIG3B , which can be understood as the second interruption of the animation playback), the electronic device can display the last image frame of the return animation (or the Zth image frame of the return animation) in the next frame, that is, after the electronic device displays the N2th image frame of the return animation, the next frame can display the Zth image frame of the return animation. Further, after the electronic device displays the last image frame of the return animation, it can construct the startup animation in a second dynamic drawing method.
- the next frame can display the N2th image frame of the return animation (i.e., the M2th image frame of the startup animation), and starting from the N2th image frame of the return animation, the startup animation is constructed using the second motion effect drawing method until the electronic device displays the Zth image frame of the startup animation.
- the N2th image frame of the return animation i.e., the M2th image frame of the startup animation
- the electronic device will display the last image frame of the return animation before playing the startup animation, resulting in an unsmooth connection between the startup animation and the return animation, which in turn causes the screen to flash or the background to flash black.
- the following specifically uses the first application being a camera application and the first application icon being a camera application icon as an example to illustrate this:
- the electronic device may display a desktop interface 1a, and the desktop interface 1a may include a camera application icon 101.
- the electronic device may construct a startup animation in a dynamic sinking manner.
- the camera application icon 101 displayed by the electronic device gradually becomes larger and gradually disappears, and the camera application window displayed by the electronic device gradually appears and gradually becomes larger.
- the electronic device may display an image frame 1b where the startup animation is interrupted.
- the image frame 1b where the startup animation is interrupted is the M1th image frame of the startup animation.
- the image frame 1b where the startup animation is interrupted may include the camera application icon 101 and the camera application window 102.
- the camera application window 102 includes the user interface of the camera application (for example, the shooting interface 1d shown in FIG4B ).
- the size of the camera application icon 101 in the image frame 1b where the startup animation is interrupted is larger than the size of the camera application icon 101 in the desktop interface 1a.
- the electronic device displays the image frame 1b where the startup animation is interrupted, in response to the user sliding upward from the bottom of the electronic device screen (the first interruption as shown in FIG4A , which can be understood as the first time the user interrupts the animation playback), the electronic device can play the return animation.
- the electronic device can construct the startup animation in a dynamic sinking manner starting from the state when the startup animation is interrupted, that is, the return animation is played from the image frame 1b where the startup animation is interrupted. Since the M1th image frame of the startup animation is the same as the N1th image frame of the return animation, it can also be understood that the electronic device can play the return animation from the N1th image frame of the return animation.
- the electronic device may display the return animation interrupted image frame 1c.
- the return animation interrupted image frame 1c may include a camera application icon 101 and a camera application window 102.
- the size of the camera application icon 101 in the return animation interrupted image frame 1c is smaller than the camera application icon 101 in the startup animation interrupted image frame 1b
- the size of the camera application window 102 in the return animation interrupted image frame 1c is smaller than the camera application window in the startup animation interrupted image frame 1b
- the size of other application icons or components in the return animation interrupted image frame 1c is larger than the size of other application icons or components in the startup animation interrupted image frame 1b
- the size of other application icons or components in the return animation interrupted image frame 1c is smaller than the size of other application icons or components in the desktop interface 1a.
- the electronic device In the case where the electronic device displays the image frame 1c where the return animation is interrupted, after the user clicks the camera application icon 101 or the camera application window 102, the electronic device cannot construct the startup animation from the image frame 1c where the return animation is interrupted in the second dynamic effect drawing method, but first needs to restore to the state at the end of the return animation (or the last image frame showing the return animation) and then construct the startup animation in the second dynamic effect drawing method.
- the electronic device in response to the user clicking the camera application icon 101 or the camera application window 102 (the second interruption shown in Figure 4B, which can be understood as the user interrupting the animation playback for the second time), the electronic device can display the desktop interface 1a. That is to say, after the electronic device displays the image frame 1c where the return animation is interrupted, the electronic device displays the desktop interface 1a in the next frame. After the electronic device displays the desktop interface 1a, the startup animation can be constructed in a dynamic effect sinking manner.
- the electronic device displays the image frame 1c where the return animation is interrupted in the next frame, and starts to build the startup animation from the image frame 1c where the return animation is interrupted.
- the electronic device may display the image frame 1b where the startup animation is interrupted, and the electronic device may finally display the shooting interface 1d.
- the shooting interface 1d can be understood as the last image frame of the startup animation (i.e., the Z image frames of the startup animation mentioned above).
- the electronic device can end the first startup animation and determine whether the user's swiping up from the bottom of the screen meets the preset conditions.
- the electronic device draws the first startup animation in the second dynamic effect drawing method
- the electronic device draws the return animation in the second dynamic effect drawing method.
- the electronic device can stop drawing the return animation (or stop building/playing the return animation) and draw the second startup animation in the first dynamic effect drawing method.
- the electronic device can draw a transition image frame that is identical to the image frame in which the return animation was interrupted, and then draw the second startup animation in the first animation drawing method, thereby achieving a smooth connection between the return animation and the second startup animation, avoiding screen flashing or black flashing.
- the electronic devices involved in the embodiments of the present application may be mobile phones, tablet computers, personal computers (PCs), in-vehicle devices, augmented reality (AR)/virtual reality (VR) devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs). It is understood that the present application does not limit the specific types of electronic devices.
- FIG5 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 to the application processor.
- the GPU is used to perform mathematical and geometric calculations for graphics rendering.
- a processor may include one or more GPUs, which execute program instructions to generate or modify display information.
- a display screen is used to display images, videos, and the like.
- an electronic device may include one or more display screens.
- the camera is used to capture still images or videos.
- the ISP is used to process the data fed back by the camera. Light is transmitted through the lens to the camera's photosensitive element, and the light signal is converted into an electrical signal. The camera's photosensitive element transmits the electrical signal to the ISP.
- the 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 embodiments 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 a 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.
- 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.
- FIG6 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 system kernel layer (Kernel).
- the application layer can include a series of application packages.
- Application packages can include applications such as camera, gallery, calendar, call, map, WLAN, Bluetooth, music, video, short message, etc.
- the application layer can also include note applications.
- the application layer can also include desktop applications.
- Desktop applications can provide quick access to various functions and applications on electronic devices.
- Desktop applications in the Android system are implemented by using Android's Launcher.
- Launcher is an application of the Android operating system, which is responsible for managing and presenting the user interface, including the desktop, application drawer and widgets. It allows users to customize the phone's home screen, icons, widget layout, and some basic functions such as sliding effects and screen transitions.
- 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 some predefined functions.
- the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc.
- the phone manager is used to provide call functions for electronic devices, such as managing call status (including answering, hanging up, etc.).
- the application framework layer may also include an input module (input) and SurfaceFlinger.
- the input module can collect, process, and distribute various input events (eg, key events, touch events, etc.)
- the input module can be an Input Manager Service (IMS).
- IMS can monitor device nodes (for example, all device nodes under /dev/input). When a device node has data, it processes the data and finds a suitable window to dispatch the input event to.
- the input event management module can 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.
- 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 combining the application's UI elements (such as text, images, views, etc.) into a complete image frame.
- HAL hardware abstraction layer
- GPU driver By interacting with the hardware abstraction layer (HAL) and GPU driver, it is also responsible for combining the application's UI elements (such as text, images, views, etc.) into a complete image frame.
- 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.
- System libraries can include multiple functional modules. For example, media libraries, 3D graphics libraries (e.g., OpenGL ES), and 2D graphics engines (e.g., SGL) can be found in the relevant technical documentation. The specific meanings and functions of these functional modules are not explained 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, 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 may include audio drivers, display drivers, camera drivers, and sensor drivers.
- the following describes an animation display method provided by an embodiment of the present application based on the software and hardware structure of the electronic device shown in FIG5 and FIG6 .
- FIG. 7 is a flow chart of an animation display method provided in an embodiment of the present application.
- the animation display method may include but is not limited to the following steps:
- the user can trigger the electronic device to start the corresponding application by clicking an application icon.
- the input module can obtain a first input event and send the first input event to the desktop application.
- the desktop application can receive the first input event sent by the input module.
- the first application icon can be an icon corresponding to any application in the application program layer as shown in FIG5 .
- the first application icon may be a camera application icon 101
- the first input event may be an input event generated by the input module in response to a user clicking on the camera application icon 101 .
- a lower-level module in the electronic device may convert a change in screen state caused by the user touching the screen into a raw input event (which may also be understood as encapsulating the change in screen state into an object of a more advanced class), and send the raw input event to the input module.
- the input module may process it to obtain a first input event.
- the input module may send the first input event to the desktop application.
- an input event may refer to an InputEvent object.
- InputEvent is a Java class that may include multiple subclasses, such as motion events (MotionEvent) and key events (KeyEvent).
- MotionEvent may include touch screen events (touch event), that is, input events generated when a user operates on the device screen (i.e., display screen) through skin or stylus.
- Touch screen events may include the following three types of events: press events (e.g., MotionEvent.ACTION_DOWN), move events (e.g., MotionEvent.ACTION_MOVE), and lift events (e.g., MotionEvent.ACTION_UP).
- a complete touch screen (or display screen) operation starts with a press event, there may be no or one or more move events in the middle, and finally ends with a lift event.
- the user's finger falling on the display screen will trigger the electronic device to generate a press event
- the user's finger leaving the display screen will trigger the electronic device to generate a lift event.
- a press event when a user slides his finger on a display screen, when the user's finger lands on the display screen, it will trigger the electronic device to generate a press event. After the user's finger lands on the display screen and then slides on the display screen, it will trigger the electronic device to generate multiple move events. When the user's finger leaves the display screen, it will trigger the electronic device to generate a lift event.
- the first input event may be a touch screen event, which may specifically include a press event (eg, MotionEvent.ACTION_DOWN) and a lift event (eg, MotionEvent.ACTION_UP).
- a press event eg, MotionEvent.ACTION_DOWN
- a lift event eg, MotionEvent.ACTION_UP
- the user can also trigger the electronic device to start the first application through other methods (for example, specific voice commands, specific gesture commands, etc.), and this application does not limit this.
- a flag may be assigned a value, and steps a and b may be performed.
- the animation flag is assigned the animation configuration information; and in step b, when the desktop application is drawing an animation, the animation flag is assigned a value of false.
- the animation effect configuration information if the electronic device supports the second animation effect drawing method, the animation effect configuration information is true, and if the electronic device does not support the second animation effect drawing method, the animation effect configuration information is false.
- the animation effect configuration information includes preset animation effect information, it indicates that the electronic device supports the second animation effect drawing method, and the animation effect flag is true; if the animation effect configuration information does not include preset animation effect information, it indicates that the electronic device does not support the second animation effect drawing method, and the animation effect flag is false.
- the animation flag is equal to the animation configuration information.
- the animation flag is true.
- this application does not limit the specific content of the animation configuration information and flag bits. In addition to true and false mentioned in this application, it can also be represented by 0 and 1, or by other letters, strings, etc.
- the desktop drawing obtains drawing parameters, and draws the first startup animation based on the obtained drawing parameters.
- the animation flag is true, which indicates that the electronic device draws the current animation in the second animation drawing method
- the animation flag is false, which indicates that the electronic device draws the current animation in the first animation drawing method.
- the current animation mentioned here may refer to the first startup animation.
- the first startup animation is the animation played in the process of the desktop application launching the first application, which can be understood as a startup animation involving the change of the life cycle of the activity corresponding to the application (for example, the first application) launched by the electronic device.
- the startup animation please refer to the above, and this application will not go into details.
- the desktop application draws the first startup animation in the first motion effect drawing method, which can be understood as constructing the first startup animation based on the first motion effect drawing method, which can specifically include: the desktop application calculates the drawing parameters, draws the layers corresponding to each image frame of the first startup animation in the first motion effect drawing method, such as the desktop layer (the first desktop layer or the second desktop layer), the icon layer and the application layer, synthesizes the drawn layers, and sends the synthesized image frames to be displayed to the display screen for display.
- the desktop application calculates the drawing parameters, draws the layers corresponding to each image frame of the first startup animation in the first motion effect drawing method, such as the desktop layer (the first desktop layer or the second desktop layer), the icon layer and the application layer, synthesizes the drawn layers, and sends the synthesized image frames to be displayed to the display screen for display.
- the motion effect flag indicates the situation where the desktop application is responsible for drawing the animation image frames. That is to say, when the desktop application determines that the electronic device does not support the second motion effect drawing method, the desktop application can draw the first startup animation in the first motion effect drawing method, that is, the desktop application is responsible for drawing the animation image frame, and then sending the drawn image frame to SurfaceFlinger for synthesis, and finally sending it to the display for display. In this case, the desktop application can set the motion effect flag, and specifically set the motion effect flag to false.
- the desktop application can draw the first startup animation in the second motion effect drawing method, that is, the desktop application is not responsible for drawing the animation image frame, but SurfaceFlinger is responsible for drawing and synthesizing the animation image frame, and finally sending it to the display for display.
- the desktop application can set the motion effect flag, and specifically set the motion effect flag to true.
- the desktop application may assign a value to the animation flag after the first startup animation starts (start).
- the start of the first startup animation mentioned in this application may refer to the state of the first startup animation becoming start, or it may refer to the desktop application running the start() method corresponding to the first startup animation.
- the desktop application draws the first startup animation in the second animation drawing method. In this case, after the desktop application sends the drawing parameters corresponding to each image frame of the first startup animation to SurfaceFlinger, the state of the first startup animation becomes start. In some embodiments of the present application, the desktop application draws the first startup animation in the first animation drawing method.
- the desktop application determines the drawing parameters corresponding to the first image frame of the first startup animation
- the state of the first startup animation becomes start.
- the desktop application draws the first startup animation in the first animation drawing method.
- the desktop application can determine the drawing parameters corresponding to the first image frame of the first startup animation, and draw the layer corresponding to the first image frame of the first startup animation based on the drawing parameters.
- the desktop application sends the drawn first image frame of the first startup animation (or the first image frame of the drawn first startup animation) to SurfaceFlinger, the state of the first startup animation becomes start.
- the desktop application when the desktop application determines that the electronic device supports dynamic effect sinking, the desktop application can determine that the content of the dynamic effect flag corresponding to the assigned value is true, specifically, the dynamic effect flag can be assigned to true during the process of drawing the first startup animation in the second dynamic effect drawing method.
- the desktop application can After sending the drawing parameters corresponding to each image frame of the first startup animation to SurfaceFlinger, the animation flag is assigned to true.
- the desktop application when the desktop application determines that the electronic device does not support dynamic effect sinking, the desktop application can determine that the content of the dynamic effect flag corresponding to the assignment is false. Specifically, the dynamic effect flag can be assigned to false during the process of drawing the first startup animation in the first dynamic effect drawing method. In one possible implementation, the desktop application can assign the dynamic effect flag to false after determining the drawing parameters corresponding to the first image frame of the first startup animation. In one possible implementation, the desktop application can assign the dynamic effect flag to false after sending the first image frame of the drawn first startup animation to SurfaceFlinger.
- the desktop application can also assign the animation flag in other specific time periods during the construction of the first startup animation, and this application does not impose any restrictions on this.
- the desktop application may assign a value to the dynamic effect flag after determining that the electronic device supports dynamic effect sinking and before constructing the startup animation.
- the desktop application can clear the animation flag.
- the desktop application can receive a corresponding callback, indicating that the first startup animation has finished playing (or ended playing). After receiving the corresponding callback, the desktop application can clear the animation flag.
- the motion effect configuration information may be pre-set in the electronic device.
- the motion effect configuration information may include various configuration information corresponding to the motion effect (for example, number of animation frames, animation duration, motion effect setting method, etc.).
- the motion effect configuration information may be understood as configuration information corresponding to the motion effect setting method, which is only used to indicate whether the electronic device supports motion effect sinking. It is understandable that the motion effect setting method includes a motion effect sinking method and a non-motion effect sinking method.
- the preset motion effect information can be understood as configuration information corresponding to the motion effect sinking mode, that is, configuration information corresponding to the window motion effect.
- This application does not limit its specific form.
- the presence of preset motion effect information in an electronic device may indicate that the electronic device supports motion effect sinking, and the absence of preset motion effect information in the electronic device may indicate that the electronic device does not support motion effect sinking.
- the specific content of the animation effect flag can also be in other forms (e.g., numbers, strings, etc.), and this application does not limit this. For example, by assigning a flag bit to 1, it can be indicated that the electronic device draws the animation in the second animation effect drawing method, and by assigning a flag bit to 0, it can be indicated that the electronic device draws the animation in the first animation effect drawing method.
- the meanings of the two animation drawing methods have been briefly mentioned above.
- the following takes the first startup animation as an example to briefly introduce the process of building animation based on the first animation drawing method and the second animation drawing method.
- the desktop application draws the first startup animation (the first animation drawing method).
- Step 1 The desktop application determines the total number of image frames (Z) of the first startup animation that the first application needs to play during startup, and obtains Z sets of rendering parameters corresponding to the Z frames of the first startup animation. It is understood that the Z sets of rendering parameters correspond to the Z frames of the first startup animation.
- the image frame in the first startup animation drawn by the desktop application may include the first desktop layer and the application layer.
- the drawing parameters corresponding to each image frame of the first startup animation may be The drawing parameters corresponding to the first desktop layer and the drawing parameters corresponding to the application layer may be included.
- each of the Z sets of drawing parameters corresponding to the Z image frames of the first startup animation may include the drawing parameters corresponding to the first desktop layer and the drawing parameters corresponding to the application layer.
- Step 2 The desktop application draws the first desktop layer and application layer in each image frame of the first startup animation (or the first desktop layer and application layer corresponding to each image frame) based on each set of drawing parameters in the Z set of drawing parameters, and sends the drawn (or drawn) first desktop layer and application layer to SurfaceFlinger.
- the desktop application draws the first desktop layer and application layer based on a set of drawing parameters, it can send the drawn first desktop layer and application layer to SurfaceFlinger.
- SurfaceFlinger can receive the drawn first desktop layer and application layer sent by the desktop application.
- the desktop application can draw the first desktop layer and application layer corresponding to an image frame of the first startup animation based on the set of drawing parameters after obtaining the set of drawing parameters corresponding to the image frame, and send the drawn first desktop layer and application layer to SurfaceFlinger, and then obtain a set of drawing parameters corresponding to the next image frame of the first startup animation. Similarly, draw the first desktop layer and application layer corresponding to the next image frame based on the set of drawing parameters, and send the drawn first desktop layer and application layer corresponding to the next image frame to SurfaceFlinger.
- the Z groups of drawing parameters corresponding to the Z image frames of the first startup animation have a preset order
- the desktop application can directly draw the first desktop layer and application layer corresponding to each image frame based on each group of drawing parameters in the Z groups of drawing parameters based on the preset order.
- Step 3 Every time SurfaceFlinger receives the first desktop layer and application layer drawn corresponding to an image frame of the first startup animation (or each time it receives the first desktop layer and application layer), it synthesizes the drawn first desktop layer and application layer to obtain an image frame to be displayed (or a frame of image to be displayed), and sends the image frame to be displayed to the display driver.
- Step 4 The display driver sends each image frame to be displayed to the display screen for display after receiving an image frame to be displayed from SurfaceFlinger. In this way, the display screen can display the image frame 1 to the Zth image frame of the first startup animation.
- Step 1 The desktop application determines the total number of image frames (Z) of the first startup animation that the first application needs to play during startup, and obtains Z sets of rendering parameters corresponding to the Z frames of the first startup animation. It is understood that the Z sets of rendering parameters correspond to the Z frames of the first startup animation.
- each set of drawing parameters may include drawing parameters corresponding to one or more windows (or layers). That is, when an image frame includes multiple layers, the drawing parameters corresponding to the image frame may include the drawing parameters corresponding to the multiple layers respectively.
- the image frames in the first startup animation drawn by SurfaceFlinger may include an icon layer, a second desktop layer, and an application layer.
- the drawing parameters corresponding to each image frame of the first startup animation may include the drawing parameters corresponding to the icon layer, the drawing parameters corresponding to the second desktop layer, and the drawing parameters corresponding to the application layer.
- each set of drawing parameters in the Z groups of drawing parameters corresponding to the Z image frames of the first startup animation may include the drawing parameters corresponding to the icon layer, the drawing parameters corresponding to the second desktop layer, and the drawing parameters corresponding to the application layer.
- the drawing parameters corresponding to the layer may include the drawing parameters corresponding to the icon layer, the drawing parameters corresponding to the second desktop layer, and the drawing parameters corresponding to the application layer.
- the image frames in the first startup animation drawn by SurfaceFlinger may include the second desktop layer and the application layer.
- the drawing parameters corresponding to each image frame of the first startup animation may include the drawing parameters corresponding to the second desktop layer and the drawing parameters corresponding to the application layer.
- each set of drawing parameters in the Z sets of drawing parameters corresponding to the Z image frames of the first startup animation may include the drawing parameters corresponding to the second desktop layer and the drawing parameters corresponding to the application layer.
- drawing parameters may include any one or more of parameters such as transparency (alpha), scaling (scale), displacement (translation) and rotation (rotate), and this application does not limit the specific content thereof.
- Step 2 The desktop application sends the obtained Z group drawing parameters to SurfaceFlinger.
- SurfaceFlinger can receive the Z group drawing parameters sent by the desktop application.
- Step 3 SurfaceFlinger draws the second desktop layer and the application layer (or the icon layer, the second desktop layer, and the application layer) based on each set of drawing parameters of the Z set of drawing parameters.
- Step 4 SurfaceFlinger draws the second desktop layer and application layer (or icon layer, second desktop layer, and application layer) based on a set of drawing parameters, and then synthesizes the drawn layers into an image frame, i.e., the image frame to be displayed, and sends this image frame to the display driver.
- the display driver can receive the image frame to be displayed sent by SurfaceFlinger.
- the Z group of drawing parameters sent by the desktop application to SurfaceFlinger has a preset order, and SurfaceFlinger can directly draw each image frame based on each group of drawing parameters in the Z group of drawing parameters based on the preset order.
- Step 5 The display driver sends each image frame to be displayed (or a drawn and synthesized image frame) sent by SurfaceFlinger to the display screen for display. In this way, the display screen can display the first image frame to the Zth image frame of the first startup animation.
- the user can swipe up from the bottom of the screen to trigger the electronic device to return to the desktop (which can also be understood as displaying the desktop interface).
- the input module can receive a second input event and send the second input event to the desktop application.
- the desktop application can receive the second input event sent by the input module.
- step S101 the specific implementation method of the input module obtaining the second input event can refer to the relevant description of step S101, and this application will not elaborate on it again.
- the second input event may be a touch screen event, which may specifically include a drop event (e.g., MotionEvent.ACTION_DOWN), multiple move events (e.g., MotionEvent.ACTION_MOVE) and a lift event (e.g., MotionEvent.ACTION_UP).
- a drop event e.g., MotionEvent.ACTION_DOWN
- multiple move events e.g., MotionEvent.ACTION_MOVE
- a lift event e.g., MotionEvent.ACTION_UP
- the user can also trigger the electronic device to return to the desktop in other ways, and this application does not limit this.
- S105 The desktop application determines whether the first startup animation exists.
- the desktop application After the desktop application receives the second input event sent by the input module, it can determine whether the first startup animation exists. In some embodiments of the present application, the desktop application can determine whether there is an animation object corresponding to the first startup animation in the electronic device. If the animation object corresponding to the first startup animation exists in the electronic device, the desktop application can determine whether the first startup animation exists. The animation exists. In this case, the desktop application can execute step S106. If the animation object corresponding to the first startup animation does not exist in the electronic device, the desktop application can determine that the first startup animation does not exist. In this case, the desktop application can execute step S108.
- step S105 after the desktop application receives the second input event sent by the input module, it may not execute step S105 but directly execute step S106. In other words, after the desktop application receives the second input event sent by the input module, it may determine whether the first startup animation has ended.
- the desktop application may determine whether the first startup animation is finished.
- the desktop application can determine whether the first startup animation has ended. If the first startup animation has ended, the desktop application can continue to execute step S108. If the first startup animation has not ended, the desktop application can execute step S107 and then execute step S108 after executing step S107. That is, the desktop application can first end the first startup animation and then execute step S108.
- the desktop application determines whether the first startup animation has ended, which may specifically include: the desktop application may determine whether the state of the first startup animation is end. If the state of the first startup animation is end, the first startup animation has ended. In this case, the desktop application may execute step S108. If the state of the first startup animation is not end, the first startup animation has not ended. In this case, the desktop application may execute step S107, i.e., end the first startup animation.
- the end of the first startup animation mentioned in this application can be understood as the completion of the drawing, synthesis, and display of all image frames of the first startup animation (such as the Z image frames of the first startup animation mentioned above).
- the desktop application can set the state of the first startup animation from start to end.
- the desktop application may end the first startup animation first and then execute step S108.
- the desktop application draws the first startup animation in a second motion effect drawing method.
- the desktop application ends the first startup animation, which can specifically include: the desktop application notifies SurfaceFlinger to stop drawing the image frames that synthesize the first startup animation based on the drawing parameters. It can also be understood that the desktop application notifies SurfaceFlinger to stop drawing the layer corresponding to the image frame of the first startup animation based on the drawing parameters.
- the desktop application can call the setAnimState() method to notify SurfaceFlinger to stop drawing the image frames of the synthesized first startup animation based on the drawing parameters.
- the setAnimState() method can represent the animation state. When its parameter value is 1, it indicates start; when its parameter value is 2, it indicates cancellation; when its parameter value is 3, it indicates end.
- the first startup animation may include one or more layers (or windows), and the desktop application can specifically notify SurfaceFlinger to stop drawing the one or more layers by calling the setAnimState() method.
- the first startup animation may include a desktop layer and an application layer.
- the desktop application can set setAnimState(2) for the desktop layer to cancel the drawing of the desktop layer, and call setAnimState(2) for the application layer to cancel the drawing of the application layer.
- the desktop application draws the first startup animation in the first dynamic drawing mode.
- the desktop application ends the first startup animation, which may specifically include: the desktop application stops drawing based on the drawing parameters.
- the first image frame that starts the animation corresponds to the layer.
- the desktop application executes steps S106-S108, which may specifically include: when the first startup animation has not ended, the desktop application may first end the first startup animation, and then execute steps S107-S108; when the first startup animation has ended, the desktop application may execute step S108.
- the desktop application determines whether the target interface is a desktop interface.
- the desktop application can determine whether the target interface is the desktop interface. If the target interface is a desktop interface, the desktop application can execute step S109. In some embodiments of the present application, if the target interface is not a desktop interface, the desktop application can determine the specific response method based on the target interface. For example, if the target interface is a multi-tasking interface, the desktop application can draw a task card and send it to SurfaceFlinger, which synthesizes it to obtain an image frame to be displayed, and then sends the image frame to be displayed to the display screen for display. Among them, the target interface refers to the interface to be switched (or the interface to be displayed). In other words, the desktop application actually determines whether the electronic device switches from displaying other interfaces to displaying the desktop interface.
- the desktop application determines whether the target interface is a desktop interface, which may specifically include: the desktop application determines whether the sliding distance and sliding speed meet preset conditions based on the received input event (for example, the second input event, the fourth input event, etc.).
- the desktop application may execute steps S105-S107, and then determine whether the sliding distance and sliding speed meet the preset conditions based on the second input event. If the sliding distance and sliding speed meet the preset conditions, the desktop application may proceed to step S109.
- the second input event can include the position information (for example, X/Y coordinates) corresponding to the user's operation of sliding upward from the bottom of the screen, and can also be understood as the position information of the user's contact point (or touch point) with the screen.
- position information for example, X/Y coordinates
- the second input event may be a MotionEvent.
- the action that generates this event is called a motion
- the subject that generates this action for example, a finger, a mouse, a stylus, etc.
- a MotionEvent object may contain one or more pointers, each of which contains attributes such as an identifier (id), an index (index), a position, a size, and a direction.
- the desktop application can determine the sliding distance and sliding speed based on the position and direction contained in the pointer in the second input event.
- the second input event may include a drop event (for example, MotionEvent.ACTION_DOWN), multiple move events (for example, MotionEvent.ACTION_MOVE) and a lift event (for example, MotionEvent.ACTION_UP).
- a drop event for example, MotionEvent.ACTION_DOWN
- multiple move events for example, MotionEvent.ACTION_MOVE
- a lift event for example, MotionEvent.ACTION_UP.
- the sliding distance mentioned above may specifically refer to the moving distance of the coordinates of the touch point
- the sliding speed mentioned above may specifically refer to the moving speed of the touch point.
- the sliding distance determined by the desktop application based on the second input event can be understood as the distance between the touch point corresponding to the drop event and the touch point corresponding to the lift event in the second input event.
- the desktop application can not only determine the sliding distance based on the coordinates of the press event and the lift event included in the second input event, but also determine the sliding duration (specifically, the duration between generating the press event and generating the lift event), and then calculate the sliding speed based on the sliding distance and the sliding duration.
- the desktop application may calculate the sliding velocity by calling the computeCurrentVelocity() method.
- the desktop application after the desktop application receives the lift event included in the second input event (which can be understood as the user sliding upward from the bottom of the screen and raising the hand), the desktop application can determine the sliding distance and the sliding speed of the screen (i.e., the sliding speed after raising the hand), and determine whether the sliding distance and the sliding speed meet the preset conditions.
- whether the sliding distance and sliding speed meet the preset conditions may specifically include: the sliding distance is greater than the preset sliding distance, and the sliding speed is greater than the preset sliding speed. It is understood that the preset sliding distance and preset sliding speed can be set according to actual needs, and this application does not impose any restrictions on this.
- the desktop application can determine whether to respond to the user's swipe up from the bottom of the screen, and the specific response method based on the swipe distance and swipe speed. For example, if the screen swipe distance and swipe speed do not meet the preset conditions, but they meet the swipe conditions that trigger the display of a task card list, the desktop application can draw the task card list and send it to the display screen for display.
- the desktop application After the desktop application determines that the target interface is the desktop interface, it can determine whether the second startup animation exists. Similar to step S105, in some embodiments of the present application, the desktop application can determine whether there is an animation object corresponding to the second startup animation in the electronic device. If there is an animation object corresponding to the second startup animation in the electronic device, the desktop application can determine that the second startup animation exists. In this case, the desktop application can execute steps S110-step S111, and then execute steps S112-step S118. If there is no animation object corresponding to the second startup animation in the electronic device, the desktop application can determine that the second startup animation does not exist. In this case, the desktop application can execute steps S112-step S118.
- the desktop application may not execute step S109 but directly execute step S110. In other words, after the desktop application receives the confirmation that the target interface is the desktop interface, it may determine whether the second startup animation ends.
- S110 The desktop application determines whether the second startup animation is finished.
- the desktop application can determine whether the second startup animation has ended. If the second startup animation has ended, the desktop application can continue to execute step S111. If the second startup animation has not ended, the desktop application can execute step S111 and then execute step S112 after executing step S111. In other words, the desktop application can first end the second startup animation and then execute step S112.
- the desktop application determines whether the second startup animation has ended. Specifically, the desktop application may determine whether the status of the second startup animation is end. If the status of the second startup animation is end, the second startup animation has ended. In this case, the desktop application may execute step S112. If the status of the first startup animation is not end, the first startup animation has not ended. In this case, the desktop application may execute step S111, i.e., end the second startup animation, and then execute step S112.
- the desktop application may determine whether the second startup animation exists and the second startup animation has not ended (or has not stopped playing). If the second startup animation exists and the second startup animation has not ended, the desktop application may execute step S111, and then execute step S112 after executing step S111. If the second startup animation does not exist and the second startup animation has not ended, the desktop application may execute step S112. Step S112.
- the desktop application can stop drawing the second startup animation, which can also be understood as canceling the drawing of the second startup animation.
- a listener can be set for the second startup animation.
- the desktop application can use the listener to listen for the interruption event of the second startup animation (or the input event that interrupts the second startup animation), such as the fourth input event.
- the desktop application listens to the interruption event of the second startup animation through the listener, it can stop drawing the second startup animation. It can be understood that the desktop application receives the input event and can execute steps S105-step S110. After determining that the second startup animation has not ended, the desktop application can determine that the interruption event of the second startup animation has been listened to through the listener.
- the desktop application determines whether the electronic device supports the second animation drawing method by judging whether the animation flag is true. If the animation flag is true, it indicates that the electronic device supports the second animation drawing method. If the animation flag is false, it indicates that the electronic device does not support the second animation drawing method.
- a flag bit may be assigned a value, and steps a and b may be performed.
- the animation flag bit is assigned the animation configuration information; and in step b, when the desktop application is drawing an animation, the flag bit is assigned a value of false.
- the animation effect configuration information if the electronic device supports the second animation effect drawing method, the animation effect configuration information is true, and if the electronic device does not support the second animation effect drawing method, the animation effect configuration information is false.
- the animation effect configuration information includes preset animation effect information, it indicates that the electronic device supports the second animation effect drawing method, and the animation effect flag is true; if the animation effect configuration information does not include preset animation effect information, it indicates that the electronic device does not support the second animation effect drawing method, and the animation effect flag is false.
- the desktop application can determine whether the motion effect flag is true. If the motion effect flag is true, it means that the electronic device draws the current animation in the second motion effect drawing method, and the desktop application can execute step S116, that is, the electronic device can draw the return animation in the second motion effect drawing method, that is, the desktop application can determine the drawing parameters and send the drawing parameters to SurfaceFlinger, SurfaceFlinger can draw the return animation based on the drawing parameters, and, after executing step S116, the desktop application can also execute steps S114 and S117.
- the motion effect flag is not true, it means that the electronic device draws the current animation in the first motion effect drawing method, and the desktop application can execute step S113, that is, the desktop application can draw the return animation in the first motion effect drawing method.
- the current animation mentioned here can be understood as an interrupted startup animation, or a finished startup animation (or a startup animation that has finished playing).
- the current animation can be understood as the first startup animation.
- the current animation can be understood as the second startup animation.
- the desktop application determines that the startup animation has ended during the execution of step S106, it means that the startup animation has ended playing on its own and has not been interrupted. In this case, the desktop application can clear the animation flag it set. In this way, the desktop application can set the animation flag to the animation flag before executing step S112. Configuration information. In this way, the desktop application can then execute step S112 based on the assigned animation flag.
- the desktop application determines that the startup animation has not ended during the execution of step S106, it means that the startup animation has been interrupted. In this case, the desktop application does not clear the animation flag it has set. In this way, the desktop application can directly determine whether the animation flag is true during the execution of step S112. If the animation flag is true, the electronic device can execute S116, step S114 and step S117. If the animation flag is not true but false, the electronic device can execute steps S113-S115.
- S113 The desktop application draws a return animation in the first animation effect drawing mode, and sets a listener for the return animation object.
- the animation flag is not true, it means that the electronic device draws the current animation in the first animation drawing method, and the desktop application can continue to draw the return animation in the first animation drawing method.
- the specific implementation method of the desktop application drawing the return animation in the first animation drawing method can refer to the specific implementation method of constructing the first startup animation in the first animation drawing method mentioned above (as shown in step S102), and this application will not repeat it here.
- the desktop application can call the buildReverseAnimator() method to implement the construction of an animation based on the first animation drawing method. For example, if the animation flag is not true, the desktop application can call the buildReverseAnimator() method to build a return animation.
- the buildReverseAnimator() method may specifically involve setTranslationX(), setTranslationY(), setScaleX(), setScaleY(), and setRadius().
- setTranslationX() and setTranslationY() respectively represent the offset (or displacement/translation) in the X direction and Y direction
- setScaleX() and setScaleY() respectively represent the scale (or scaling) in the X direction and Y direction
- setRadius() represents the radius of the rounded corners.
- the desktop application can call the anmiator.addListener() method to set a listener for the animation object corresponding to the return animation (which may be simply referred to as the return animation object).
- the desktop application can use the listener to listen for input events received by the desktop application during the construction of the return animation, that is, the interruption event of the return animation (or the input event that interrupts the return animation).
- the desktop application listens to the interruption event of the return animation through the listener, the desktop application can stop drawing (or constructing) the return animation.
- the user can trigger the electronic device to continue to start the first application by clicking the first application window or the first application icon.
- the input module sends a third input event to the desktop application.
- the desktop application can receive the third input event sent by the input module.
- the third input event can be understood as the input event that the desktop application listens to through the listener set for the return animation object during the return animation construction process.
- the desktop application can listen to the input event sent by the input module to the desktop application through the listener.
- the desktop application listens to the input module sending the third input event to the desktop application through the listener.
- the third input event can be understood as an interrupt event of the return animation.
- the specific implementation method in which the input module obtains the third input event can refer to the specific implementation method in which it obtains the first input event (as shown in step S101), and this application will not elaborate on this.
- the third input event may be a touch screen event.
- a motion event can include a press event (e.g., MotionEvent.ACTION_DOWN) and a lift event (e.g., MotionEvent.ACTION_UP).
- the desktop application can listen to the input events sent by the input module based on the listener.
- the desktop application can stop drawing the return animation, which can also be understood as canceling the drawing of the return animation, and draw the second startup animation in the first animation drawing method.
- the desktop application can receive a third input event sent by the input module, and based on the third input event, stop drawing the return animation and draw the second startup animation in the first animation drawing method.
- the second startup animation refers to the reverse animation of the return animation, which is different from the first startup animation mentioned above.
- the first startup animation mentioned above involves the change of the life cycle of the activity corresponding to the application launched by the electronic device (for example, the first application), and during the change of the life cycle of the activity corresponding to the application, the size of the corresponding application window also changes.
- the second startup animation does not involve the change of the life cycle of the activity corresponding to the application launched by the electronic device, but involves the change of the corresponding application window.
- the second startup animation can be understood as a startup animation that does not involve the change of the life cycle of the activity corresponding to the application.
- the first startup animation can be the complete startup animation mentioned above (as shown in Figure 2A), that is, an animation consisting of the 1st image frame to the Zth image frame of the startup animation
- the second startup animation can be an animation consisting of the M1th image frame to the Zth image frame of the complete startup animation mentioned above (as shown in Figure 2A).
- the desktop application can set a listener for the second startup animation and use the listener to listen for input events received during the drawing of the second startup animation, i.e., interruption events of the second startup animation (or input events that interrupt the second startup animation). If the desktop application listens to the interruption event of the second startup animation through the listener, the desktop application can stop drawing the second startup animation, which can also be understood as canceling the second startup animation. For details, please refer to step S111. In some embodiments of the present application, the desktop application monitors the interruption event of the second startup animation through the listener, which specifically involves step S118, step S105-step S110.
- the desktop application can determine that the first startup animation does not exist, and then determine whether the target interface is the desktop interface. If the target interface is the desktop interface, the desktop application can determine that the second startup animation exists and has not yet ended. In this case, it can be understood that the fourth input event monitored by the desktop application through the listener is an interruption event of the second startup animation. Further, the desktop application can stop drawing the second startup animation (or cancel drawing the second startup animation), and then execute steps S111-step S117.
- the desktop application executes step S115, the entire return animation drawing process ends.
- the desktop application can then receive an input event sent by the input module.
- the desktop application can then execute steps S105-S115.
- steps S105-S115 For example, according to the above, after the desktop application executes step S115, it can receive a fourth input event sent by the input module (such as step S118) and then execute steps S105-S115.
- S116 The desktop application sends drawing parameters to SurfaceFlinger, SurfaceFlinger draws the return animation, and the desktop application sets a listener for the return animation object.
- the animation flag is true, it means that the electronic device draws the current animation in the second animation drawing method, and the electronic device can continue to draw the return animation in the second animation drawing method, that is, the desktop application can determine the drawing parameters and send the drawing parameters to SurfaceFlinger, and SurfaceFlinger can draw the return animation based on the drawing parameters.
- the desktop application can set a listener for the animation object corresponding to the return animation (i.e., the return animation object). For the relevant description of the listener, please refer to step S113, and this application will not go into details about it.
- the desktop application may receive a third input event sent by the input module (such as step S114), and then execute step S117.
- the desktop application may monitor the third input event sent by the input module through a listener set for the return animation object.
- the specific implementation method can refer to the relevant description of steps S113 and S115, and will not be repeated in this application.
- the desktop application draws the return animation in the second dynamic drawing method, which can specifically include: the desktop application calculates the drawing parameters corresponding to the return animation and sends the drawing parameters to SurfaceFlinger, and then SurfaceFlinger draws frame by frame, and after drawing each layer corresponding to an image frame, the layer is synthesized to obtain the image frame to be displayed, and then sent for display.
- the specific implementation method of the desktop application drawing the return animation in the second dynamic drawing method can refer to the specific implementation method of drawing the first startup animation in the second dynamic drawing method mentioned above (as shown in step S102), and this application will not go into details.
- the image frame of the startup animation drawn in the second dynamic drawing method can be obtained by synthesizing the second desktop layer and the application layer, and the image frame of the return animation in the second dynamic drawing method can be synthesized by the icon layer, the second desktop layer and the application layer.
- the process of drawing the return animation involves more layers and corresponding drawing parameters.
- the return animation drawn by the desktop application in the second dynamic drawing method is a complete return animation, such as a return animation including a total of Z image frames (as shown in Figures 1B and 2B). That is, the desktop application can determine the total number of frames of the return animation, that is, Z, and obtain Z sets of drawing parameters corresponding to the Z image frames of the return animation, and then send the Z sets of drawing parameters to SurfaceFlinger.
- the return animation drawn by the desktop application in the second dynamic drawing method is not a complete return animation.
- the desktop application can calculate the drawing parameters corresponding to the starting image frame of the return animation (for example, the N1th image frame of the complete return animation shown in Figure 3A) and the drawing parameters corresponding to the last image frame of the return animation based on the drawing parameters corresponding to the image frame displayed by the electronic device when the first startup animation is interrupted (for example, the M1th image frame of the startup animation shown in Figure 3A, or the M1th image frame of the complete startup animation).
- the desktop application can calculate the image frame number of the first startup animation (or the serial number of the frames of the first startup animation) displayed by the electronic device when the desktop application ends the first startup animation, and determine the image frame number of the return animation (or the serial number of the frames of the return animation) corresponding to this image frame.
- the desktop application can calculate the serial number of the frames of the return animation corresponding to the serial number of the frames of the first startup animation displayed by the electronic device when the first startup animation ends.
- the desktop application can obtain the drawing parameters corresponding to other image frames included in the return animation that appear after this image frame, and send the drawing parameters corresponding to the other image frames to SurfaceFlinger.
- the first startup animation may be the startup animation shown in FIG3A .
- the desktop application may determine that when the desktop application ends the first startup animation, the electronic device displays the M1th image frame of the first startup animation. And determine that the M1th image frame of the startup animation corresponds to the N1th image frame of the return animation. In this way, the desktop application can determine the drawing parameters corresponding to the N1th image frame of the return animation based on the drawing parameters corresponding to the M1th image frame of the first startup animation.
- the drawing parameters corresponding to the N1th image frame of the return animation obtain the drawing parameters corresponding to the N1+1th image frame to the Zth image frame (that is, the last image frame of the return animation) of the return animation, and send the drawing parameters to SurfaceFlinger.
- the desktop application can call the compareBuildReverseForSink() method to implement the construction of animation based on the second dynamic effect drawing method, which may specifically involve setAnimState(), scheduleApply(), setTranslationX(), setTranslationY(), setScaleX(), setScaleY(), and setRadius().
- scheduleApply() can realize the conversion from drawing animation in the second dynamic effect drawing method to drawing animation in the first dynamic effect drawing method.
- the desktop application can call the compareBuildReverseForSink() method to draw the return animation in the second dynamic effect drawing method.
- the desktop application can call the scheduleApply() method to realize the transition between the second dynamic effect drawing method and the first dynamic effect drawing method, and continue to call the buildReverseAnimator() method after calling the scheduleApply() method to draw the return animation in the first dynamic effect drawing method.
- the scheduleApply() method to realize the transition between the second dynamic effect drawing method and the first dynamic effect drawing method
- the buildReverseAnimator() method after calling the scheduleApply() method to draw the return animation in the first dynamic effect drawing method.
- the desktop application can monitor the input event sent by the input module based on the listener.
- the desktop application can stop drawing the return animation, which can also be understood as canceling the drawing of the return animation, prepare to draw the transition image frame, and draw the second startup animation in the first dynamic drawing mode.
- the second startup animation please refer to step S115, and this application will not go into details about it.
- the desktop application can receive a third input event sent by the input module, and based on the third input event, stop drawing the return animation, prepare to draw the transition image frame, and draw the second startup animation in the first animation drawing method.
- the desktop application when the electronic device receives an operation in which the user clicks on the first application window or the first application icon before the return animation is completed (or the input module obtains a third input event before the return animation is completed), the desktop application can determine that the third input event is an input event that interrupts the return animation. In this case, the desktop application can listen to the third input event through a listener set for the return animation object.
- the desktop application draws the return animation in the second animation drawing method, then the desktop application stops drawing the return animation, which can specifically include: the desktop application notifies SurfaceFlinger to stop drawing the image frame of the synthetic return animation based on the drawing parameters, which can also be understood as the desktop application notifying SurfaceFlinger to stop drawing the layer corresponding to the image frame of the return animation based on the drawing parameters.
- the return animation may include an icon layer, a desktop layer (e.g., a second desktop layer), and an application layer.
- the desktop application stops drawing the return animation, or notifies SurfaceFlinger to stop drawing the image frames of the synthesized return animation based on the drawing parameters.
- the desktop application may set setAnimState(2) for the application layer, indicating that the drawing of the application layer is canceled, without setting setAnimState(2) for the desktop layer.
- step S117 A specific implementation of step S117 is described below in conjunction with FIG8. It is understood that based on the third input event monitored by the desktop application through the listener, the specific implementation of the desktop application stopping drawing the return animation may include steps S201- Step S203 , the specific implementation method of the desktop application preparing to draw the transition image frame may include steps S204 to S210 , and the specific implementation method of the desktop application drawing the second startup animation in the first animation drawing method may include steps S211 to S212 .
- the desktop layer e.g., the second desktop layer
- the icon layer e.g., the second desktop layer
- the application layer are drawn, synthesized, and displayed on the display screen of the electronic device. It is understood that during the process of the desktop application drawing the return animation using the second animation effect drawing method, the desktop application can create an icon layer.
- the desktop application can send multiple sets of drawing parameters corresponding to the multiple image frames included in the return animation to SurfaceFlinger.
- SurfaceFlinger can draw the desktop layer, icon layer, and application layer based on the multiple sets of drawing parameters, and synthesize them to obtain the image frame to be displayed, and then send it to the display screen for display.
- Each set of drawing parameters can include drawing parameters corresponding to the desktop layer (for example, the second desktop layer), drawing parameters corresponding to the icon layer, and drawing parameters corresponding to the application layer.
- the desktop application After receiving the third input event sent by the input module, or based on the third input event monitored by the listener, the desktop application can destroy the icon layer. It is understandable that after destroying the icon layer, the desktop application does not need to obtain its corresponding drawing parameters, and SurfaceFlinger does not need to draw the icon layer.
- the desktop application After the desktop application destroys the icon layer, it can notify SurfaceFlinger to stop drawing the layer corresponding to the image frame of the return animation based on the drawing parameters, and stop synthesizing the image frame of the return animation based on the layer obtained by drawing.
- SurfaceFlinger after the desktop application notifies SurfaceFlinger to stop drawing the return animation, SurfaceFlinger can receive a notification sent by the desktop application to stop drawing the return animation, and stop drawing the return animation based on the notification.
- the desktop application can directly notify SurfaceFlinger to stop drawing the return animation by calling the corresponding function. In this case, the desktop application will not receive the corresponding notification.
- the desktop application after the desktop application destroys the icon layer, it can call setAnimState(2) on the application layer to cancel the drawing of the application layer, while not calling setAnimState(2) on the desktop layer to not cancel the drawing of the desktop layer. It is understood that after the desktop calls setAnimState(2) on the application layer, SurfaceFlinger can stop drawing the application layer.
- SurfaceFlinger can stop drawing the layers corresponding to the image frames of the return animation based on the drawing parameters, and stop synthesizing the image frames of the return animation based on the drawn layers. Specifically, SurfaceFlinger can stop drawing the application layer, but still draw the desktop layer (see below for details).
- the desktop application determines the drawing parameters corresponding to the desktop layer in the Zth image frame of the return animation, and calculates the drawing parameters corresponding to the application layer in the N2th image frame of the return animation and the drawing parameters corresponding to the desktop layer in the N2th image frame of the return animation based on the playback duration of the return animation.
- the N2th image frame of the return animation is the last image frame of the return animation displayed by the electronic device before stopping the construction of the return animation.
- this application records the last image frame of the return animation (or the image of the last frame of the return animation) displayed before the electronic device stops drawing the return animation (or stops playing/constructing the return animation) as the N2th image frame of the return animation (as shown in Figures 3A and 3B).
- the desktop application After the desktop application notifies SurfaceFlinger to stop drawing the return animation, it can determine the drawing parameters corresponding to the desktop layer in the last image frame of the return animation (or the Zth image frame of the return animation), and calculate the drawing parameters corresponding to the application layer in the N2th image frame of the return animation and the drawing parameters corresponding to the desktop layer (for example, the second desktop layer) based on the playback duration of the return animation.
- the desktop application can combine the playback duration of the return animation, the total number of frames of the return animation (that is, the Z mentioned above), and the screen refresh rate (indicating the frequency of refreshing the displayed image frames per second) to determine the frame number corresponding to the last image frame of the return animation displayed before the electronic device stops constructing the return animation (or stops playing the return animation), that is, N2, and determine the drawing parameters corresponding to the N2th image frame of the return animation (which can be called the N2th group of drawing parameters).
- the N2th group of drawing parameters may include the drawing parameters corresponding to the application layer in the N2th image frame of the return animation, and the drawing parameters corresponding to the desktop layer in the N2th image frame of the return animation.
- the desktop application sends the drawing parameters corresponding to the desktop layer in the Zth image frame of the return animation to SurfaceFlinger.
- the desktop application After the desktop application determines the drawing parameters corresponding to the desktop layer in the Zth image frame of the return animation, it can send them to SurfaceFlinger.
- SurfaceFlinger can receive the drawing parameters corresponding to the desktop layer in the Zth image frame of the return animation sent by the desktop application.
- S206 SurfaceFlinger draws the desktop layer based on the drawing parameters corresponding to the desktop layer in the Zth image frame of the returned animation.
- the desktop application sends multiple sets of drawing parameters corresponding to multiple image frames in the return animation to SurfaceFlinger.
- SurfaceFlinger can search for the drawing parameters corresponding to the last image frame of the return animation (or the Zth image frame of the return animation) from the multiple sets of drawing parameters sent by the desktop application.
- the drawing parameters corresponding to the Zth image frame of the return animation may include the drawing parameters corresponding to the desktop layer in the Zth image frame.
- the desktop application can determine the drawing parameters corresponding to the desktop layer in the Zth image frame of the return animation and send them to SurfaceFlinger. For details, please refer to steps S204-S205.
- SurfaceFlinger After SurfaceFlinger receives the drawing parameters corresponding to the desktop layer in the Zth image frame of the return animation sent by the desktop application, it can draw the desktop layer based on the drawing parameters corresponding to the desktop layer in the Zth image frame of the return animation.
- the drawn desktop layer is consistent with the desktop layer in the Zth image frame of the return animation, including the size and content of the desktop layer.
- the desktop layer is adjusted (or adjusted) to the state where the return animation is completely completed, that is, adjusted to the desktop layer in the image frame displayed by the electronic device when the return animation is completely completed (or the Zth image frame of the electronic device).
- the desktop application adjusts the size of the content in the desktop layer drawn by SurfaceFlinger based on the drawing parameters corresponding to the desktop layer in the N2th image frame of the return animation.
- the desktop application can adjust the size of the content in the drawn desktop layer (for example, other application icons or components other than the first application icon) based on the drawing parameters corresponding to the desktop layer in the N2th image frame of the return animation to obtain the desktop layer after drawing.
- the size of the content in the drawn desktop layer is adjusted to the size of the corresponding content in the image frame of the last frame of the return animation displayed before the electronic device stops playing the return animation.
- the size of the desktop layer in the animation image frame and the size of the content therein are adjusted as a whole.
- the animation for example, startup animation, return animation, etc.
- SurfaceFlinger draws the desktop layer in a certain image frame of the animation, specifically, the desktop layer and the content therein can be reduced to 80% based on the above reference size, and draws the desktop layer in the next image frame of the animation, specifically, the desktop layer and the content therein can be reduced to 60% based on the above reference size.
- the scaling ratio of the desktop layer in the first image frame of the startup animation is 1, the scaling ratio of the desktop layer in the last image frame of the startup animation is 0.9, the scaling ratio of the desktop layer in the first image frame of the return animation is 0.9, and the scaling ratio of the desktop layer in the last image frame of the return animation is 1. It can be understood that the scaling ratio of the desktop layer in the image frames between the first image frame and the last image frame can be adjusted based on the number of image frames of the animation.
- SurfaceFlinger can first draw the size of the desktop layer and the content therein as a whole, specifically, it can be drawn to be consistent with the desktop layer in the Zth image frame of the return animation, and the desktop application then adjusts the size of the content in the desktop layer drawn by SurfaceFlinger, and the size of the content can be adjusted to be consistent with the size of the corresponding content in the N2th image frame of the return animation.
- the size of the desktop layer after the drawing adjustment obtained by SurfaceFlinger is consistent with the desktop layer in the Zth image frame of the return animation, and the size of its content is consistent with the size of the corresponding content in the N2th image frame of the return animation.
- the size of the desktop layer after the drawing adjustment and the degree of scaling of its content are not completely consistent. For example, taking the size of the desktop layer in the desktop interface as a reference, in the process of constructing the return animation using the second motion effect drawing method, the return animation is interrupted, and when the return animation is interrupted, the desktop layer in the N2th image frame of the return animation displayed by the electronic device has been reduced to 80% of the above reference size.
- SurfaceFlinger can restore the desktop layer to the above reference size, and the desktop application can reduce the content in the restored desktop layer to 80% of the above reference size. That is to say, the size of the desktop layer finally drawn by SurfaceFlinger (i.e., the desktop layer in the transition image frame) is consistent with the above reference size, and the content in the desktop layer is still 80% of the above reference size.
- the scaling ratio of the desktop layer in the first image frame of the complete startup animation (for example, the first startup animation) is 1, and the scaling ratio of the desktop layer in its last image frame is 0.9.
- the scaling ratio of the desktop layer in the first image frame of the complete return animation is 0.9, and the scaling ratio of the desktop layer in its last image frame is 1.
- SurfaceFlinger restores the scaling ratio of the desktop layer from the scaling ratio when the return animation is interrupted (for example, 0.95) to 1, and then adjusts the scaling ratio of the content in the desktop layer from 1 to the scaling ratio when the return animation is interrupted (for example, 0.95).
- the content in the desktop layer is visible, but its size is invisible. It can also be understood as a transparent layer with visible content drawn on it.
- the desktop application can implement the drawing of the transition image frame by calling the scheduleApply() method.
- the scheduleApply() method may include a scaling ratio setting method for the desktop layer, such as scaleX() and scaleY() set for the desktop layer, and may also include a scaling ratio setting method for the content in the desktop layer, such as scaleX() and scaleY() set for the content in the desktop layer, which may be specifically given to workSpace and hotSeat. Set scaleX() and scaleY() respectively.
- the scheduleApply() method may include setting scaleX(1.0f) and scaleY(1.0f) for the desktop layer, and setting scaleX(0.95f) and scaleY(0.95f) for workSpace and hotSeat respectively.
- scaleX(1.0f) means that the scaling ratio in the X direction is adjusted to 1
- scaleY(1.0f) means that the scaling ratio in the Y direction is adjusted to 1.
- scaleX(0.95f) means that the scaling ratio in the X direction is adjusted to 0.95
- scaleY(0.95f) means that the scaling ratio in the Y direction is adjusted to 0.95.
- workSpace and hotSeat represent the desktop part (or desktop area), which can be understood as view. WorkSpace can include icons loaded by system default, manually dragged in by users, and automatically generated by applications. HotSeat can include a shortcut launch bar.
- S208 SurfaceFlinger synthesizes the desktop layer after drawing the adjustment and the application layer in the N2-th image frame of the drawn return animation to obtain a transition image frame.
- SurfaceFlinger After SurfaceFlinger completes drawing the desktop layer and the desktop application adjusts the size of the content in the drawn desktop layer, SurfaceFlinger can synthesize the adjusted desktop layer with the application layer in the N2th image frame of the drawn return animation to obtain a drawn synthesized image frame.
- this application refers to this image frame as a transition image frame.
- the application layer in the N2th image frame of the drawn return animation can be the application layer drawn by SurfaceFlinger before the electronic device displays the N2th image frame of the return animation, or it can be the application layer redrawn based on the drawing parameters after SurfaceFlinger receives the drawing parameters corresponding to the application layer in the N2th image frame of the return animation.
- Figure 9A shows the desktop layer in the N2th image frame of the return animation and the desktop layer in the transition image frame.
- the dotted box in Figure 9A represents the desktop layer (which can be understood as a transparent layer).
- the size of the dotted box represents the size of the desktop layer, that is, the size of the desktop layer itself (excluding the content in the desktop layer).
- the small box in Figure 9A represents the content in the desktop layer (for example, other application icons or components besides the first application icon).
- the size of the desktop layer in the transition image frame is equal to the size of the desktop layer in the Zth image frame of the return animation, and the size of the desktop layer in the transition image frame is larger than the size of the desktop layer in the N2th image frame of the return animation.
- the dotted box is invisible to the user, that is, the size of the desktop layer itself mentioned above is invisible to the user.
- the content of the desktop layer in the transition image frame is consistent with the content of the desktop layer in the N2th image frame of the return animation, and the two are also the same size. It is worth noting that the content of the desktop layer is visible to the user, which means that the content of the desktop layer visible to the user in the transition image frame and the N2th image frame of the return animation is exactly the same.
- the application layer in the transition image frame is completely consistent with the application layer in the N2 th image frame of the return animation.
- the user triggers the electronic device to return to the desktop and interrupts the animation played during the process of returning to the desktop (i.e., the return animation).
- the image frame of the last return animation displayed before the electronic device stops playing the return animation is the image frame 1c where the return animation is interrupted.
- the size of the desktop layer in the transition image frame is equal to the size of the desktop layer in the Zth image frame of the return animation, and the size of the desktop layer in the transition image frame is larger than
- the size of the desktop layer in the N2th image frame of the return animation is the same as that of the desktop layer.
- the size and position of other application icons (except the camera application icon 101) in the transition image frame are exactly the same as the size and position of other application icons in the image frame 1c where the return animation was interrupted. It can be understood that these other application icons are the content in the desktop layer, which is visible to the user.
- the size, position, and content of the camera application window 102 in the transition image frame are exactly the same as those in the image frame 1c where the return animation was interrupted.
- S209 SurfaceFlinger sends a transition image frame to the display driver.
- SurfaceFlinger draws the composite transition image frame, it can send the transition image frame to the display driver.
- the display driver can receive the transition image frame sent by SurfaceFlinger.
- S210 The display driver controls the display screen to display a transition image frame.
- the display driver After the display driver receives the transition image frame sent by SurfaceFlinger, it can control the display screen to display the transition image frame.
- the desktop application After the desktop application calculates the drawing parameters corresponding to the application layer in the N2th image frame of the return animation and the drawing parameters corresponding to the desktop layer in the N2th image frame of the return animation, it can set the animation effect flag to false, indicating that the electronic device draws the current animation using the first animation effect drawing method. It is understood that the current animation mentioned here refers to the second startup animation.
- the desktop application may execute step S211 after executing step S204, or after executing step S205, or after executing step S207, or after SurfaceFlinger executes step S206, or after SurfaceFlinger executes step S208, or after the display screen executes step S210.
- This application does not impose any specific restrictions on this.
- the desktop application draws the second startup animation in the first animation effect drawing manner based on the drawing parameters corresponding to the application layer in the N2th image frame of the return animation.
- the desktop application can determine the drawing parameters corresponding to the image frame of the second startup animation based on the drawing parameters corresponding to the application layer in the N2th image frame of the return animation, and construct the second startup animation using the first animation drawing method based on the drawing parameters corresponding to the second startup animation.
- the specific implementation method of constructing the animation using the first animation drawing method can be found above and will not be further described in this application.
- the desktop application can determine the drawing parameters corresponding to the image frame of the second startup animation (for example, the scaling ratio mentioned above) based on the drawing parameters corresponding to the application layer in the N2th image frame of the return animation and the drawing parameters corresponding to the first image frame of the return animation.
- the input module can receive a fourth input event and send the fourth input event to the desktop application. After the desktop application receives the fourth input event sent by the input module, it can execute steps S105 to S117.
- the input module may send a fourth input event to the desktop application.
- the fourth input event can be understood as an input event that interrupts the second startup animation and is detected by the desktop application through the listener set for the second startup animation.
- the input module may send a fourth input event to the desktop application. Enter the event.
- the electronic device in response to the user clicking on the first application icon, can start the first application and, when the dynamic effect flag is true, draw the first startup animation in the second dynamic effect drawing mode (such as steps S101-S103).
- the electronic device can play the first startup animation drawn in the second dynamic effect drawing mode during the process of starting the first application.
- the user can slide up from the bottom of the screen to trigger the electronic device to return to the desktop (such as step S104), thereby interrupting the playing of the first startup animation (the first interruption shown in FIG10A).
- the electronic device In response to the upward sliding operation, the electronic device can determine that the first startup animation exists and the first startup animation has not yet ended.
- the electronic device first ends the first startup animation (such as steps S105-S107).
- the electronic device stops drawing the first startup animation. That is, after the electronic device displays the image frame where the first startup animation is interrupted (the M1th image frame of the first startup animation as shown in FIG10A), it no longer performs the relevant drawing operation of the next image frame of the first startup animation.
- the electronic device stops drawing the first startup animation it can determine that the target interface is the desktop interface (such as step S108) and determine that the second startup animation does not exist (such as step S109). Further, based on the fact that the desktop application is not currently drawing an animation, the electronic device can determine that the dynamic effect flag is true (such as step S112).
- the electronic device can draw the return animation in the second dynamic effect drawing method (such as step S116).
- the user can click on the first application window or the first application icon to interrupt the playback of the return animation (the second interruption shown in Figure 10A).
- the electronic device can stop drawing the return animation, draw the transition image frame, and draw the second startup animation in the first dynamic effect drawing method (such as steps S114 and S117).
- the last image frame displayed by the electronic device is the N2th image frame of the return animation.
- the electronic device in response to the user clicking on the first application window or the first application icon, can calculate corresponding drawing parameters to draw a layer corresponding to a transition image frame whose visible content (e.g., the first application icon, other application icons or components, etc.) is completely consistent with the N2-th image frame, and after synthesizing the transition image frame based on the layer, it is displayed on the display screen, and then the second startup animation is drawn in the first dynamic effect drawing method. Since the content in the transition image frame and the N2-th image frame of the return animation is consistent, the connection between the return animation and the second startup animation is natural and does not change significantly.
- visible content e.g., the first application icon, other application icons or components, etc.
- the electronic device is triggered to return to the desktop and the animation played during the process of returning to the desktop (i.e., the return animation) is interrupted.
- the image frame of the last return animation displayed before the electronic device stops playing the return animation is the return animation interrupted image frame 1c.
- the electronic device can calculate the corresponding drawing parameters to draw a transition image frame whose visible content is completely consistent with the return animation interrupted image frame 1c.
- the camera application window 102 in the transition image frame and the camera application window 102 in the return animation interrupted image frame 1c include completely consistent contents.
- the electronic device can subsequently draw the second startup animation in the first animation drawing method. Since the return animation drawn in the second animation drawing method and the return animation drawn in the first animation drawing method are played in the same manner, the content of the camera application window 102 in the transition image frame is completely consistent. Between the startup animations drawn in the first and second ways, the electronic device will display a transition image frame, and the content of the transition image frame is consistent with the N2th image frame of the return animation, so the return animation and the second startup animation are naturally connected, and there will be no screen flashing or black flashing.
- the electronic device in response to the user clicking the first application icon, can start the first application and, when the animation flag is true, draw the first startup animation in the second animation drawing method (such as steps S101-S103).
- the electronic device can play the first startup animation drawn in the second animation drawing method during the process of starting the first application.
- the user can slide upward from the bottom of the screen to trigger the electronic device to return to the desktop (such as step S104), thereby interrupting the playing of the first startup animation (the first interruption as shown in Figure 11A).
- the electronic device can determine that the first startup animation exists and the first startup animation has not yet ended. In this case, the electronic device first ends the first startup animation (such as steps S105-S107). As shown in (1) in Figure 11A, the electronic device stops drawing the first startup animation. That is, after the electronic device displays the image frame in which the first startup animation is interrupted (the M1th image frame of the first startup animation as shown in Figure 11A), it no longer performs the related drawing operations for the next image frame of the first startup animation. After the electronic device stops drawing the first startup animation, it can determine that the target interface is the desktop interface (such as step S108), and determine that the second startup animation does not exist (such as step S109).
- the electronic device can determine that the dynamic effect flag is true (such as step S112). In this case, as shown in (1) in Figure 11A, the electronic device can draw the return animation in the second dynamic effect drawing method (such as step S116). As shown in (1) in Figure 11A, during the playback of the return animation, the user can click on the first application window or the first application icon to interrupt the playback of the return animation (the second interruption shown in Figure 11A). In response to the click operation, the electronic device can stop drawing the return animation, draw the transition image frame, and draw the second startup animation in the first dynamic effect drawing method (such as steps S114 and S117).
- the electronic device sets the dynamic effect flag to false during the process of drawing the second startup animation in the first dynamic effect drawing method.
- the relevant description of the transition image frame shown in FIG. 11A may refer to the relevant description of the transition image frame involved in FIG. 10A above, and this application will not elaborate on this.
- the user can slide up from the bottom of the screen to trigger the electronic device to return to the desktop (such as step S118), thereby interrupting the playing of the second startup animation (the third interruption as shown in Figure 11A).
- the electronic device can determine that the first startup animation does not exist and determine that the target interface is the desktop interface (such as steps S105 and S108), and then determine that the second startup animation exists and the second startup animation has not yet ended. In this case, the electronic device first ends the second startup animation (such as steps S109-step S111). As shown in (2) in Figure 11A, the electronic device stops drawing the second startup animation.
- the electronic device displays the image frame where the second startup animation is interrupted (the M1th image frame of the second startup animation as shown in Figure 11A), it no longer performs the related drawing operations for the next image frame of the second startup animation.
- the electronic device stops drawing the second startup animation, because it is the second startup animation drawn by the desktop application, it can be determined that the animation flag is false (such as step S112).
- the electronic device can draw the return animation in the first animation drawing method (such as step S113).
- the user interrupts the electronic device to start the camera application and plays After the animation (i.e., the first startup animation drawn in the second dynamic effect drawing method), the electronic device is triggered to return to the desktop and the animation played by the electronic device in the process of returning to the desktop is interrupted (i.e., the return animation drawn in the second dynamic effect drawing method), i.e., the first interruption and the second interruption shown in (1) in Figure 11B.
- the animation i.e., the first startup animation drawn in the second dynamic effect drawing method
- the animation played by the electronic device in the process of returning to the desktop is interrupted (i.e., the return animation drawn in the second dynamic effect drawing method), i.e., the first interruption and the second interruption shown in (1) in Figure 11B.
- the electronic device can stop playing the return animation and draw a transition image frame (the camera application window 102 in the transition image frame and the camera application window 102 in the image frame 1c where the return animation is interrupted are completely consistent), and then draw the second startup animation in the first dynamic effect drawing method to achieve a smooth transition between the return animation and the second startup animation.
- the user can slide up from the bottom of the screen to trigger the electronic device to return to the desktop, thereby interrupting the playback of the second startup animation (the third interruption shown in Figure 11B).
- the electronic device can stop drawing the second startup animation and draw the return animation in the first dynamic effect drawing method.
- the electronic device can respond in a timely manner and select the corresponding motion effect drawing method to draw the animation, thereby achieving a smooth transition between the startup animation and the return animation, thereby avoiding the occurrence of screen flashing or black flashing.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
本申请公开了一种动画显示方法及相关设备。根据该方法,在以第二动效绘制方式绘制的返回动画被打断的情况下,电子设备可停止绘制返回动画,基于返回动画最后一个图像帧对应的绘制参数和返回动画被打断图像帧对应的绘制参数来绘制过渡图像帧,然后以第一动效绘制方式绘制第二启动动画。通过这种方法,在用户打断电子设备播放以第二动效绘制方式绘制的返回动画的情况下,电子设备可以绘制与返回动画被打断图像帧相同的一帧过渡图像帧,并以第一动效绘制方式来绘制接下来播放的第二启动动画,从而实现返回动画和第二启动动画的流畅衔接,避免出现闪屏或闪黑等现象。
Description
本申请涉及终端技术领域,尤其涉及一种动画显示方法及相关设备。
在应用程序(可简称为应用)的启动过程中,电子设备可以播放应用启动动画(可简称为启动动画),以提高电子设备从显示桌面界面到显示被启动应用的用户界面的连续性,实现平滑过渡。在电子设备显示其他界面(例如,其他应用的用户界面)的情况下,用户可以上滑触发电子设备返回桌面,在这种情况下,电子设备可以播放返回桌面动画(可简称为返回动画),以提高电子设备从显示被启动应用的用户界面到显示桌面界面的连续性,实现平滑过渡。
若用户在电子设备启动应用的过程中打断启动动画,触发电子设备返回桌面,并且在返回动画未结束的情况下打断返回动画,触发电子设备继续启动应用,则启动动画和返回动画之间未衔接,会导致闪屏或背景闪黑。
发明内容
本申请公开了一种动画显示方法及相关设备。根据该方法,在以第二动效绘制方式绘制的返回动画被打断的情况下,电子设备可停止绘制返回动画,基于返回动画最后一个图像帧对应的绘制参数和返回动画被打断图像帧对应的绘制参数来绘制一帧过渡图像帧,然后以第一动效绘制方式绘制第二启动动画。这种方法可以通过变换动效绘制方式,并绘制一帧过渡图像帧,来实现返回动画和启动动画之间的流畅衔接,避免出现闪屏或闪黑等现象。
第一方面,本申请实施例提供了一种动画显示方法。该方法可以应用于电子设备。该方法可以包括:显示第一界面,所述第一界面为桌面应用的界面,所述第一界面包括第一应用图标;响应于对所述第一应用图标的第一操作,显示第一动画;所述第一应用图标为第一应用对应的应用图标,所述第一动画包括在启动第一应用的动画;在显示所述第一动画的过程中,响应于返回桌面的第二操作,停止显示所述第一动画,并显示第二动画;所述第二动画包括返回所述第一界面的动画;在显示所述第二动画的过程中,响应于对所述第二动画中的第一图像帧的第三操作,停止显示所述第二动画,并显示第三动画;其中,所述第一动画是被所述电子设备通过图像合成器SurfaceFlinger绘制的,所述第二动画是被所述电子设备通过所述桌面应用绘制的,所述第三动画是被所述电子设备通过所述桌面应用绘制的。
在本申请提供的方案中,在SurfaceFlinger绘制的返回动画被打断的情况下,电子设备可以停止通过SurfaceFlinger绘制返回动画,并通过桌面应用来绘制第二启动动画。通过这种方法,电子设备无需在SurfaceFlinger绘制的返回动画被打断的情况下首先显示返回动画最后一个图像帧,然后再继续通过SurfaceFlinger第二启动动画,而是可以通过将动效绘制方式从由SurfaceFlinger绘制变为由桌面应用绘制,来实现返回动画和第二启动动画的流畅衔接,避免出现闪屏或闪黑等现象。
在本申请的一些实施例中,第一动画可以为下文所提及的第一启动动画,第二动画可以为下文所提及的返回动画,第三动画可以为下文所提及的第二启动动画。
在本申请的一些实施例中,第一界面可以为桌面界面。
在本申请的一些实施例中,第二动画中的第一图像帧可以为下文所提及的返回动画的第N2个图像帧,或称返回动画被打断图像帧。
在本申请的一些实施例中,第一操作和第三操作可以为点击操作,第二操作可以为从屏幕底部向上滑动的操作,具体可以参考图3A-图3B、图4A-图4B、图10A-图10B、图11A-图11B。
结合第一方面,在一种可能的实现方式中,所述显示第三动画之后,所述方法还包括:在显示所述第三动画的过程中,响应于返回桌面的第四操作,显示第四动画;所述第四动画包括返回所述第一界面的动画,所述第四动画是被所述电子设备通过所述桌面应用绘制的。
在本申请提供的方案中,在以第二动效绘制方式绘制的返回动画被打断,且以第一动效绘制方式绘制第二启动动画的情况下,若在该以第一动效绘制方式绘制的第二启动动画还未结束的情况下,该第二启动动画被打断,则电子设备可以继续采取第一动效绘制方式来绘制返回动画。通过这种方式,在多次打断动画场景下,电子设备可以基于动画被打断时的绘制状态(已结束或者还未结束),来选择相应的动效绘制方式,从而实现返回动画和启动动画的流畅衔接,避免出现闪屏或闪黑等现象。
在本申请的一些实施例中,第四动画可以为下文所提及的返回动画。
在本申请的一些实施例中,第四操作可以为从屏幕底部向上滑动的操作,具体可以参考图11A-图11B。
结合第一方面,在一种可能的实现方式中,显示第三动画之后,所述方法还包括:在显示所述第三动画之后,显示所述第一应用的界面;响应于返回桌面的第四操作,显示第四动画;所述第四动画包括返回所述第一界面的动画,所述第四动画是被所述电子设备通过所述SurfaceFlinger绘制的。
在本申请提供的方案中,在以第二动效绘制方式绘制的返回动画被打断,且以第一动效绘制方式绘制第二启动动画的情况下,若在该以第一动效绘制方式绘制的第二启动动画已结束的情况下,该第二启动动画被打断,则电子设备可以采取第二动效绘制方式来绘制返回动画。通过这种方式,在多次打断动画场景下,电子设备可以基于动画被打断时的绘制状态(已结束或者还未结束),来选择相应的动效绘制方式,从而实现返回动画和启动动画的流畅衔接,避免出现闪屏或闪黑等现象。
结合第一方面,在一种可能的实现方式中,显示第一动画之前,所述方法还包括:响应于所述第一操作,基于动效标志位为第一内容,通过所述SurfaceFlinger绘制所述第一动画。所述响应于对返回桌面的第二操作,停止显示所述第一动画,包括:响应于所述第二操作,基于所述第一动画还未结束播放,停止绘制所述第一动画。所述停止显示所述第一
动画之后,所述方法还包括:基于目标界面为所述第一界面,当前未绘制所述第三动画,以及所述动效标志位为所述第一内容,通过所述SurfaceFlinger绘制所述第二动画;所述通过所述SurfaceFlinger绘制所述第二动画之后,所述方法还包括:响应于所述第三操作,将所述动效标志位设置为第二内容。
在本申请提供的方案中,电子设备接收到触发返回桌面的操作(比如第二操作)之后,电子设备可以通过一系列判断来确定电子设备接下来是以第二动效绘制方式来绘制返回动画,还是以第一动效绘制方式来绘制返回动画。这是一套完整的方法逻辑,第一方面,这表明上述方法可以适用于多次打断动画的场景,第二方面,还表明上述方法不仅可以应用于支持第二动效绘制方式的电子设备,还可以应用于不支持第二动效绘制方式的电子设备。也就是说,无论电子设备是否支持第二动效绘制方式,电子设备都可以使用该方法来绘制动画以及在动画被打断之后做出响应,技术人员无需针对支持第二动效绘制方式的电子设备和不支持第二动效绘制方式的电子设备来分别制定相应方法,在一定程度上简化了流程,提升了设备的适用性。
可理解,电子设备接收到触发返回桌面的操作(比如第二操作)之后,电子设备可以基于标志位的设置情况来确定是以第二动效绘制方式构建返回动画,还是以第一动效绘制方式构建返回动画,更为简单快捷,无需通过确定启动动画涉及的绘制操作是由SurfaceFlinger执行,还是由桌面应用执行来确定构建启动动画的方式。
结合第一方面,在一种可能的实现方式中,所述停止显示所述第二动画,并显示第三动画,包括:停止显示所述第二动画,并显示第二图像帧;所述第二图像帧的内容与所述第一图像帧的内容相同;在显示所述第二图像帧之后,显示所述第三动画。
在本申请提供的方案中,在SurfaceFlinger绘制的返回动画被打断的情况下,电子设备可以停止通过SurfaceFlinger绘制返回动画,绘制一帧与返回动画被打断图像帧内容相同的过渡图像帧,然后通过桌面应用来绘制第二启动动画,从而实现从以第二动效绘制方式绘制动画到以第一动效绘制方式绘制动画的流畅过渡,即实现返回动画和第二启动动画的流畅衔接,避免出现闪屏或闪黑等现象。
在本申请的一些实施例中,第二图像帧为下文所提及的过渡图像帧。
结合第一方面,在一种可能的实现方式中,所述第一图像帧基于第一图层、第二图层和第三图层合成;所述第一图层包括所述第一应用图标,所述第二图层包括除所述第一应用图标外的其他应用图标或组件,所述第三图层为所述第一应用的窗口图层;所述停止显示所述第二动画,包括:销毁所述第一图层;通知所述SurfaceFlinger停止绘制所述第二动画;所述显示第二图像帧之前,所述方法还包括:根据所述第二动画的已播放时长,确定第一绘制参数;所述第一绘制参数为所述第二图层对应的绘制参数;通过所述SurfaceFlinger基于第二绘制参数绘制第四图层,以及通过所述桌面应用基于所述第一绘制参数调整所述第四图层中的内容,得到已绘制的所述第四图层;所述第二绘制参数为所述第二动画的最后一个图像帧对应的绘制参数;通过所述SurfaceFlinger基于已绘制的所述第四图层和已绘制的所述第三图层合成得到所述第二图像帧。
在本申请提供的方案中,在以第二动效绘制方式构建返回动画被打断之后,电子设备可以销毁图标图层以避免后续对以第一动效绘制方式绘制图像帧的影响,还可以确定返回动画被打断图像帧对应的绘制参数和返回动画最后一个图像帧对应的绘制参数,并仍然通过SurfaceFlinger以第二动效绘制方式来绘制过渡图像帧。在绘制过渡图像帧的过程中,电子设备可以通过SurfaceFlinger基于返回动画最后一个图像帧对应的绘制参数绘制桌面图层,使得过渡图像帧中桌面图层的尺寸与返回动画最后一个图像帧中桌面图层的尺寸相同,进而使得后续以第一动效绘制方式绘制图像帧不会被桌面图层的尺寸所影响。在绘制过渡图像帧的过程中,电子设备还可以通过桌面应用来调整过渡图像帧中桌面图层的内容的尺寸,使得过渡图像帧中桌面图层的内容的尺寸与返回动画被打断图像帧中桌面图层的内容的尺寸相同,电子设备还可以通过SurfaceFlinger对绘制调整后的桌面图层与返回动画被打断图像帧中的应用图层进行合成,得到过渡图像帧,然后再将其显示在显示屏上。可理解,过渡图像帧中的内容和内容的尺寸与返回动画被打断图像帧中的内容和内容的尺寸相同。也就是说,过渡图像帧与电子设备上一帧显示的图像帧相同,可以实现返回动画和第二启动动画的流畅衔接,避免出现闪屏或闪黑等现象。
在本申请的一些实施例中,第一图层为图标图层,第二图层和第四图层为不同图像帧对应的第二桌面图层,第三图层为应用图层。
结合第一方面,在一种可能的实现方式中,所述显示所述第三动画之前,所述方法还包括:根据所述第二动画的已播放时长,确定第三绘制参数,所述第三绘制参数为所述第三图层对应的绘制参数;基于所述第三绘制参数确定所述第三动画中每一个图像帧对应的绘制参数,基于所述第三动画中每一个图像帧对应的绘制参数,绘制所述第三动画。
在本申请提供的方案中,在以第二动效绘制方式构建返回动画被打断之后,电子设备可以确定返回动画被打断图像帧对应的绘制参数,基于返回动画被打断图像帧对应的绘制参数来确定第二启动动画每一个图像帧对应的绘制参数,并基于该每一个图像帧对应的绘制参数来以第一动效绘制方式构建第二启动动画。也就意味着,过渡图像帧的下一个图像帧是电子设备以返回动画被打断图像帧为参照来绘制的,属于连续图像帧,可以进一步实现返回动画和第二启动动画的流畅衔接。
结合第一方面,在一种可能的实现方式中,所述响应于返回桌面的第四操作,显示第四动画,包括:响应于所述第四操作,基于所述第一动画停止显示,目标界面为所述第一界面,且所述第三动画还未结束播放,停止绘制所述第三动画;基于动效标志位为第二内容,通过所述桌面应用绘制所述第四动画。
结合第一方面,在一种可能的实现方式中,所述响应于返回桌面的第四操作,显示第四动画,包括:响应于所述第四操作,基于所述第一动画停止显示,目标界面为所述第一界面,所述第三动画已结束播放,且动效标志位为第二内容,通过所述SurfaceFlinger绘制所述第四动画。
在本申请提供的方案中,电子设备可以基于相应的标志位来表示电子设备是否支持第
二动效绘制方式,以及表示绘制当前动画的具体方式是第一动效绘制方式还是第二动效绘制方式,这样,一旦用户后续触发电子设备返回桌面,电子设备可以基于标志位来确定是以第二动效绘制方式绘制返回动画,还是以第一动效绘制方式绘制返回动画,这种方法简单快捷,可以在一定程度上节约时长,避免启动动画被打断之后与返回动画的衔接不流畅。
第二方面,本申请提供了一种电子设备,该电子设备包括一个或多个存储器,以及一个或多个处理器;该一个或多个存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该电子设备执行如第一方面或第一方面的任意一种实现方式所描述的方法。
第三方面,本申请提供了一种计算机存储介质。该计算机存储介质包括计算机指令,当该计算机指令在电子设备上运行时,使得该电子设备执行如第一方面或第一方面的任意一种实现方式所描述的方法。
第四方面,本申请实施例提供一种芯片。该芯片可以应用于电子设备,该芯片包括一个或多个处理器,该处理器用于调用计算机指令以使得该电子设备执行如第一方面或第一方面的任意一种实现方式所描述的方法。
在本申请的一些实施例中,芯片系统可以为应用处理器(Application Processor,AP),或者包括AP的片上系统(System on Chip,SoC),上述第一方面或第一方面的任意一种实现方式所描述的方法可以由一个AP实施,上述第二方面或第二方面的任意一种实现方式所描述的方法可以由一个AP实施。
在本申请的又一些实施例中,芯片系统可以包括AP和其他模块。该其他模块可以为调制解调处理器(Modem,也可称之为基带处理器)。
第五方面,本申请实施例提供一种包含指令的计算机程序产品。当该计算机程序产品在电子设备上运行时,使得该电子设备执行如第一方面或第一方面的任意一种实现方式所描述的方法。
可理解,上述第二方面提供的电子设备、第三方面提供的计算机存储介质、第四方面提供的芯片,以及第五方面提供的计算机程序产品均用于执行如第一方面或第一方面的任意一种实现方式所描述的方法。因此,其所能达到的有益效果可参考上述第一方面中任一种可能的实现方式的有益效果,此处不再赘述。
图1A为本申请实施例提供的一种启动动画的示意图;
图1B为本申请实施例提供的一种返回动画的示意图;
图2A为本申请实施例提供的又一种启动动画的示意图;
图2B为本申请实施例提供的一种返回动画的示意图;
图3A和图3B为本申请实施例提供的一组打断动画播放所导致的图像帧变化示意图;
图4A和图4B为本申请实施例提供的又一组打断动画播放所导致的图像帧变化示意图;
图5为本申请实施例提供的一种电子设备的硬件结构示意图;
图6为本申请实施例提供的一种电子设备的软件结构示意图;
图7为本申请实施例提供的一种动画显示方法的流程图;
图8为本申请实施例提供的又一种动画显示方法的流程图;
图9A和图9B是本申请实施例提供的一组返回动画结束图像帧和过渡图像帧的对比示意图;
图10A-图10B为本申请实施例提供的一种打断动画播放所导致的图像帧变化示意图;
图11A-图11B为本申请实施例提供的又一种打断动画播放所导致的图像帧变化示意图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;文本中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
应当理解,本申请的说明书和权利要求书及附图中的术语“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。
应当理解,本申请的说明书和权利要求书及附图中的术语“用户界面”,是应用程序或操作系统与用户之间进行交互和信息交换的介质接口。用户界面常用的表现形式是图形用户界面(Graphic User Interface,GUI),是指采用图形方式显示的与计算机操作相关的用户界面。它可以是在电子设备的显示屏中显示的一个图标、窗口、控件等界面元素,其中控件可以包括图标、按钮、菜单、选项卡、文本框、对话框、状态栏、导航栏、小部件(Widget)等可视的界面元素。
在本申请中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本申请所描述的实施例可以与其它实施例相结合。
在应用程序(可简称为应用)的启动过程中,电子设备可以播放应用启动动画(可简称为启动动画),以提高电子设备从显示桌面界面到显示被启动应用的用户界面的连续性。
如图1A所示,响应于用户点击应用图标的操作,电子设备可以播放启动动画。为了便于理解和描述,本申请将用户点击的应用图标(或称被点击的应用图标)记为第一应用图标,将第一应用图标对应的应用记为第一应用,将第一应用对应的窗口记为第一应用窗口。
示例性的,在播放启动动画的过程中,电子设备显示的第一应用图标逐渐消失,并且
逐渐显示第一应用窗口,直到第一应用窗口的大小(或称尺寸)与屏幕(或称显示屏)大小一致,即电子设备全屏显示第一应用窗口。可理解,电子设备显示的第一应用图标逐渐消失,具体可以包括:电子设备显示的第一应用图标的透明度越来越高(即第一应用图标越来越透明)。在本申请的一些实施例中,在电子设备显示的第一应用图标逐渐消失的过程中,电子设备显示的第一应用图标逐渐变大,即第一应用图标的尺寸越来越大。类似的,电子设备逐渐显示第一应用窗口,具体可以包括:电子设备显示的第一应用窗口的大小越来越大,且电子设备显示的第一应用窗口的透明度越来越低(即第一应用窗口越来越不透明)。
其中,第一应用图标的透明度最低可以为0,在这种情况下,第一应用图标不透明(或称完全不透明),第一应用图标的透明度最高可以为100%,在这种情况下,第一应用图标完全透明(可理解为用户不可见)。可理解,桌面界面中的第一应用图标的透明度为0,而在电子设备全屏显示第一应用窗口的情况下,第一应用图标的透明度为100%。在播放启动动画的过程中,电子设备显示的第一应用图标最小与桌面界面原本包括的第一应用图标一致(即第一应用图标的最小尺寸与桌面界面原本包括的第一应用图标的尺寸一致),且电子设备显示的第一应用图标的大小小于屏幕大小(即第一应用图标的最大尺寸小于屏幕尺寸),其具体值可以根据实际需要进行设置,本申请对此不作显示。例如,第一应用图标的宽最大为屏幕的宽的一半,且第一应用图标的长最大为屏幕的长的一半。类似的,第一应用窗口的透明度最低可以为0,在这种情况下,第一应用窗口不透明(或称完全不透明),第一应用窗口的透明度最高可以为100%,在这种情况下,第一应用窗口完全透明(可理解为用户不可见)。可理解,在电子设备全屏显示第一应用窗口的情况下,第一应用窗口的透明度为0。在播放启动动画的过程中,电子设备显示的第一应用窗口最大与屏幕大小一致(即第一应用窗口的最大尺寸与屏幕尺寸一致),且电子设备显示的第一应用窗口的最小尺寸可以根据实际需要进行设置,本申请对此不作显示。例如,第一应用窗口的宽最小为屏幕的宽的一半,且第一应用窗口的长最小为屏幕的长的一半。
在本申请的一些实施例中,完整的启动动画的第1个图像帧为用户点击第一应用图标并抬手后电子设备显示的第1个图像帧,该第1个图像帧可以与桌面界面相同,也可以不同于桌面界面。为了便于理解和描述,本申请中以完整的启动动画的第1帧与桌面界面相同来举例说明。
示例性地,如图1A所示,完整的启动动画可以总共包括Z个图像帧,即完整的启动动画由Z个图像帧(或称Z帧图像)组成。响应于用户点击桌面界面中的第一应用图标的操作,电子设备可以显示启动动画的第1个图像帧(具体指完整的启动动画的第1个图像帧)。该第1个图像帧(或称第1帧图像)与桌面界面相同,也就是说,相较于在用户点击第一应用图标前电子设备显示的桌面界面中的第一应用图标的大小,启动动画的第1个图像帧中的第一应用图标的大小未发生变化。在后续过程中,电子设备可以继续播放启动动画(即按顺序显示启动动画的其他图像帧)直到显示启动动画的第Z个图像帧(具体指完整的启动动画的第Z个图像帧)。在继续播放启动动画的过程中,电子设备可以显示启动动画的第M1个图像帧(具体指完整的启动动画的第M1个图像帧),相较于启动动画的第1个图像帧,启动动画的第M1个图像帧(或称第M1帧图像)中的第一应用窗口/第一应用
图标更大一些。可理解,启动动画的第Z个图像帧(或称第Z帧图像)为启动动画的最后一个图像帧。在启动动画的第Z个图像帧中,第一应用窗口的大小与屏幕(或称显示屏)大小一致,即电子设备全屏显示该应用窗口,也就是说,电子设备全屏显示第一应用的用户界面。可理解,M1和Z均为正整数,且M1小于Z。
类似的,在电子设备显示其他界面(例如,其他应用的用户界面)的情况下,用户可以上滑触发电子设备返回桌面,在这种情况下,电子设备可以播放返回桌面动画(可简称为返回动画),以提高电子设备从显示应用用户界面到显示桌面界面的连续性。
如图1B所示,在电子设备全屏显示第一应用窗口的情况下,用户可以从电子设备的屏幕底部向上滑动,相应的,响应于用户从屏幕底部向上滑动的操作,电子设备可以播放返回动画。可选的,在电子设备全屏显示第一应用窗口的情况下,电子设备可以接收到从屏幕底部向上滑动的用户操作,在接收到该用户操作之后,电子设备可以播放返回动画。
示例性的,在播放返回动画的过程中,电子设备显示的第一应用窗口逐渐变小,并且逐渐显示第一应用图标,直到显示桌面界面。也就意味着,在播放返回动画的过程中,电子设备显示的第一应用窗口逐渐变小直到消失,并且逐渐显示第一应用图标,直到第一应用图标与桌面界面原本包括的第一应用图标一致(例如,第一应用图标的尺寸和透明度分别与桌面界面原本包括的第一应用图标的尺寸和透明度一致)。可理解,电子设备显示的第一应用窗口逐渐变小直到消失,具体可以包括:电子设备显示的第一应用窗口的大小越来越小,且电子设备显示的第一应用窗口的透明度越来越高(即第一应用窗口越来越透明)。类似的,电子设备逐渐显示第一应用图标,具体可以包括:电子设备显示的第一应用图标的透明度越来越低(即第一应用图标越来越不透明)。在本申请的一些实施例中,电子设备逐渐显示第一应用图标,具体还可以包括:电子设备显示的第一应用图标的大小越来越小。
其中,第一应用窗口的尺寸和透明度的范围可以分别参考上文所描述的启动动画涉及的第一应用窗口的尺寸和透明度的范围,类似的,第一应用图标的尺寸和透明度的范围可以分别参考上文所描述的启动动画涉及的第一应用图标的尺寸和透明度的范围,本申请对此不再赘述。
在本申请的一些实施例中,完整的返回动画的第1个图像帧为用户从屏幕底部向上滑动并抬手后电子设备显示的第1个图像帧,该第1个图像帧可以为电子设备全屏显示的第一应用的用户界面(或称该第1个图像帧与电子设备全屏显示的第一应用的用户界面相同),也可以不同于第一应用的用户界面。其中,电子设备全屏显示的第一应用的用户界面可以理解为:电子设备全屏显示第一应用窗口,且第一应用窗口包括第一应用的用户界面。
在本申请的一些实施例中,完整的返回动画的第1个图像帧为用户手指落到屏幕上但还未向上滑动时电子设备显示的图像帧,可以理解为电子设备接收到按下事件后所显示的第1个图像帧。该第1个图像帧可以为电子设备全屏显示的第一应用的用户界面,也可以不同于第一应用的用户界面。
为了便于理解和描述,本申请中以完整的返回动画的第1个图像帧为电子设备全屏显示的第一应用的用户界面来举例说明。
可理解,下面以完整的返回动画和完整的启动动画的帧数相同为例进行说明,在本申请的其他实施例中,完整的返回动画的帧数可以不同于完整的启动动画的帧数。
示例性地,如图1B所示,与启动动画相同,完整的返回动画可以总共包括Z个图像帧,即完整的返回动画由Z个图像帧(或称Z帧图像)组成。在本申请的一些实施例中,完整的返回动画的第1帧可以为完整的启动动画的第Z帧,完整的返回动画的第N1帧可以为完整的启动动画的第M1帧,完整的返回动画的第Z帧可以为完整的启动动画的第1帧。
如图1B所示,在电子设备全屏显示第一应用窗口(或称电子设备全屏显示第一应用的用户界面)的情况下,响应于用户从屏幕底部向上滑动的操作,电子设备可以显示返回动画的第1个图像帧(具体指完整的返回动画的第1个图像帧)。该第1个图像帧与用户向上滑动前电子设备所显示的图像帧相同,也就是说,相较于在用户向上滑动前电子设备显示的第一应用窗口的大小和内容,返回动画的第1个图像帧中的第一应用窗口的大小和内容未发生变化。在后续过程中,电子设备可以继续播放返回动画(即按顺序显示返回动画的其他图像帧)直到显示返回动画的第Z个图像帧。在继续播放返回动画的过程中,电子设备可以显示返回动画的第N1个图像帧(或称第N1帧图像),相较于返回动画的第1个图像帧,返回动画的第N1个图像帧中的第一应用窗口/第一应用图标更大一些。可理解,返回动画的第Z个图像帧为返回动画的最后一个图像帧。返回动画的第Z个图像帧可以为桌面界面。可理解,N1和Z均为正整数,且N1小于Z。
需要说明的是,用户还可以通过其他操作(例如,从屏幕顶部下滑,在屏幕特定区域双击或长按,特定手势指令,特定语音指令等)触发电子设备返回桌面(或称显示桌面界面),本申请对此不作限制。
在本申请的一些实施例中,在播放启动动画和返回动画的过程中,电子设备显示的除第一应用图标外的其他应用图标或组件的大小也会发生变化。可理解,电子设备显示的除第一应用图标外的其他应用图标或组件的大小具体变化情况可以根据实际需要进行设置,本申请对此不作限制。例如,以桌面界面包括的该除第一应用图标外的其他应用图标或组件的初始大小为参照,该除第一应用图标外的其他应用图标或组件最大可以为其初始大小,该除第一应用图标外的其他应用图标或组件最小可以变化为其初始大小的80%。
示例性的,在播放启动动画的过程中,电子设备显示的第一应用图标逐渐消失,且电子设备显示的除第一应用图标外的其他应用图标或组件逐渐变小,且电子设备逐渐显示第一应用窗口,直到第一应用窗口的大小(或称尺寸)与屏幕(或称显示屏)大小一致,即电子设备全屏显示第一应用窗口。具体地,如图2A所示,启动动画的第1个图像帧先于第M2个图像帧(或称第M2帧图像)被显示在电子设备的屏幕上,而启动动画的第M2个图像帧先于第M1个图像帧被显示在电子设备的屏幕上。相比于启动动画的第1个图像帧中的其他图标或组件(即除第一应用图标外的其他应用图标或组件),启动动画的第M2个图像帧中的该其他图标或组件的大小更小一些,而相比于启动动画的第M2个图像帧中的其他图标或组件,启动动画的第M1个图像帧中的其他图标或组件的大小又更小一些。也就是说,启动动画的第M1个图像帧中的其他图标或组件的尺寸小于启动动画的第M2个图像帧中的其他图标或组件的尺寸,而启动动画的第M2个图像帧中的其他图标或组件的尺寸小于启动动画的第1个图像帧中的其他图标或组件的尺寸。可理解,M2为大于1的整数,且M2小于M1。可理解,图2A所示的第一应用图标和第一应用窗口的变化情况
可以参考图1A,本申请在此不再赘述。
类似的,在播放返回动画的过程中,电子设备显示的第一应用窗口逐渐变小,且电子设备显示的除第一应用图标外的其他应用图标或组件逐渐变大,且电子设备逐渐显示第一应用图标,直到显示桌面界面。示例性的,如图2B所示,返回动画的第1个图像帧先于第N1个图像帧被显示在电子设备的屏幕上,而返回动画的第N1个图像帧先于第N2个图像帧(或称第N2帧图像)被显示在电子设备的屏幕上。相比于返回动画的第1个图像帧中的其他图标或组件(即除第一应用图标外的其他应用图标或组件),返回动画的第N1个图像帧中的该其他图标或组件的大小更大一些,而相比于返回动画的第N1个图像帧中的其他图标或组件,返回动画的第N2个图像帧中的其他图标或组件的大小又更大一些。也就是说,返回动画的第N2个图像帧中的其他图标或组件的尺寸大于返回动画的第N1个图像帧中的其他图标或组件的尺寸,而返回动画的第N1个图像帧中的其他图标或组件的尺寸大于返回动画的第1个图像帧中的其他图标或组件的尺寸。可理解,在返回动画的Z个图像帧中,返回动画的第Z个图像帧所包括的该其他图标或组件最大。可理解,N2为正整数,且N2大于N1,N2小于Z。可理解,图2B所示的第一应用图标和第一应用窗口的变化情况可以参考图1B,本申请在此不再赘述。
可理解,与图1A和图1B类似,图2A和图2B所示的分别是完整的启动动画和完整的返回动画。如图2B所示,完整的返回动画的第N1个图像帧与完整的启动动画的第M1个图像帧相同,完整的返回动画的第N2个图像帧与完整的启动动画的第M2个图像帧相同。
电子设备可以采用两种动效绘制方式来绘制上述启动动画和返回动画。为了便于理解和描述,本申请将这两种动效绘制方式中的第一种动效绘制方式记为第一动效绘制方式,将其中第二种动效绘制方式记为第二动效绘制方式。第一动效绘制方式具体指由应用层负责绘制动画的图像帧,具体地,应用层绘制得到相应图层之后,可以将绘制结果(可以理解为绘制的相应图层)交给软件框架中应用层的下层中的模块(可简称为应用层下层模块)进行合成,得到待显示图像帧(或称待显示图像),最终将待显示图像帧送到显示屏显示。由于应用层的应用可以通过绘制视图(view)来绘制动画,所以采用第一动效绘制方式绘制的动画可以被称为view动画(或称view动效)。第二动效绘制方式具体指的是由应用层下层模块绘制动画的图像帧(可以理解为将绘制操作下沉到应用层下层模块来执行),具体地,应用层将动画对应的绘制参数下发给应用层下层模块,应用层下层模块基于动画的每一个图像帧对应的绘制参数来绘制相应图层,并对绘制的相应图层进行合成,得到待显示图像帧,再将待显示图像帧送到显示屏显示,从而在有限的计算资源下能实现更好的动画效果。由于应用层下层模块通过窗口来进行绘制,所以采用第二动效绘制方式绘制的动画也可以被称为窗口动画(或称窗口动效)。
可选地,结合图6,应用层的下层可以包含应用程序框架层、安卓运行时、系统库、硬件抽象层和系统内核层。
示例性的,第一动效绘制方式可以称为非动效下沉,第二动效绘制方式可以称为动效下沉。
在本申请的一些实施例中,上述应用层下层模块可以为应用程序框架层中的模块,例
如,图像合成器(SurfaceFlinger),即应用层的应用将动画对应的绘制参数下发给SurfaceFlinger,由SurfaceFlinger绘制相应图层。
在本申请的一些实施例中,本申请所涉及的动画与动画效果(可简称为动效)含义相同。
可理解,本申请所提及的构建动画(或称创建动画)可以指包括计算绘制参数、绘制图像帧、合成图像帧和显示图像帧等步骤在内的生成并播放动画(或称显示动画)的整个过程。
需要说明的是,在本申请的一些实施例中,在电子设备采用第一动效绘制方式来绘制启动动画或返回动画的情况下,第一应用图标和其他应用图标或组件可以位于一个图层,且该图层不同于第一应用窗口所在图层(即第一应用图层)。为了便于描述和区分,本申请将采用第一动效绘制方式来绘制启动动画或返回动画的过程中所涉及的被点击应用图标和其他应用图标或组件所在图层记为第一桌面图层,将被点击应用图标对应的应用窗口记为应用窗口(或称应用图层)。
还需要说明的是,在本申请的一些实施例中,在电子设备采用第二动效绘制方式来构建启动动画或返回动画的情况下,第一应用图标所在的窗口不同于第一应用窗口,即电子设备在不同于第一应用窗口的窗口中绘制第一应用图标。类似的,桌面界面中除第一应用图标外的其他应用图标或组件所在的窗口不同于第一应用窗口,也不同于第一应用图标所在的窗口。为了便于描述,本申请将采用第二动效绘制方式来绘制启动动画或返回动画的过程中所涉及的被点击应用图标所在的窗口(或称图层)记为图标窗口(或称图标图层),将桌面界面中除被点击应用图标外的其他应用图标或组件所在的窗口记为桌面窗口(或称第二桌面图层),将被点击应用图标对应的应用窗口(即电子设备启动的应用所对应的窗口)记为应用窗口(或称应用图层)。可理解,第一应用图标所在的窗口为图标窗口,桌面界面中除第一应用图标外的其他应用图标或组件所在的窗口为桌面窗口,第一应用窗口为应用窗口。
在本申请的一些实施例中,在采用第二动效绘制方式来绘制启动动画或返回动画的情况下,在第二桌面图层、图标图层和应用图层中,第二桌面图层位于最下层,即第二桌面图层位于图标图层和应用图层的下层,图标图层位于第二桌面图层和应用图层之间,即图标图层位于第二桌面图层的上层,且位于应用图层的下层,应用图层位于最上层,即应用图层位于第二桌面图层和图标图层的上层。
在电子设备基于第二动效绘制方式构建启动动画的过程中,用户可以上滑触发返回桌面,在这种情况下,启动动画被打断,电子设备可以在此基础上采用第二动效绘制方式构建返回动画。可理解,在被打断的启动动画的基础上播放的返回动画并不是完整的返回动画,其第1个图像帧为启动动画被打断时电子设备显示的图像帧,而不是完整的返回动画的第1个图像帧。而在播放该返回动画的过程中,用户可以点击应用窗口/应用图标触发继续启动应用,在这种情况下,返回动画被打断,电子设备需要首先显示返回动画的最后一帧,再基于第二动效绘制方式构建启动动画(即继续启动的动画),即电子设备显示返回动
画的最后一个图像帧后再构建启动动画,这样,启动动画和返回动画衔接不流畅,造成闪屏或背景闪黑。
可理解,根据上文,电子设备基于(或称采用)第二动效绘制方式构建动画,可以指包括计算绘制参数、采用第二动效绘制方式绘制图层(或称图像帧对应的图层)、基于图层合成动画的图像帧和显示图像帧等步骤在内的生成并播放动画的整个过程。
示例性的,如图3A所示,响应于用户点击第一应用图标的操作,电子设备可以以第二动效绘制方式构建启动动画。在显示启动动画的第M1个图像帧的情况下,响应于用户从屏幕底部向上滑动的操作(如图3A所示的第1次打断,可理解为第1次打断动画播放),电子设备可以从启动动画的第M1个图像帧(即返回动画的第N1个图像帧)开始,以第二动效绘制方式构建返回动画。在电子设备显示返回动画的第N2个图像帧的情况下,响应于用户点击第一应用窗口/第一应用图标的操作(如图3A和图3B所示的第2次打断,可理解为第2次打断动画播放),电子设备下一帧可以显示返回动画的最后一个图像帧(或称返回动画的第Z个图像帧),也就是说,电子设备显示返回动画的第N2个图像帧后,下一帧可以显示返回动画的第Z个图像帧。进一步的,电子设备显示返回动画的最后一个图像帧后,可以以第二动效绘制方式构建启动动画。具体地,电子设备显示返回动画的最后一个图像帧后,下一帧可以显示返回动画的第N2个图像帧(即启动动画的第M2个图像帧),并且从返回动画的第N2个图像帧开始,以第二动效绘制方式构建启动动画,直到电子设备显示启动动画的第Z个图像帧。
根据上文,如果在打断启动动画并播放返回动画的过程中,用户可以点击应用窗口/应用图标触发返回应用界面(或称触发全屏显示应用窗口),则电子设备显示返回动画的最后一个图像帧后再播放启动动画,从而导致启动动画和返回动画衔接不流畅,进而导致闪屏或背景闪黑。下面具体以第一应用为相机应用,第一应用图标为相机应用图标为例来对此进行说明:
示例性的,如图4A所示,电子设备可以显示桌面界面1a,桌面界面1a可以包括相机应用图标101。响应于用户点击相机应用图标101的操作,电子设备可以以动效下沉方式构建启动动画。在电子设备播放启动动画的过程中,电子设备显示的相机应用图标101逐渐变大且逐渐消失,电子设备显示的相机应用窗口逐渐出现且逐渐变大。具体地,如图4A所示,在电子设备播放启动动画的过程中,电子设备可以显示启动动画被打断图像帧1b。启动动画被打断图像帧1b为启动动画的第M1个图像帧。启动动画被打断图像帧1b可以包括相机应用图标101和相机应用窗口102。相机应用窗口102包括相机应用的用户界面(例如,如图4B所示的拍摄界面1d)。启动动画被打断图像帧1b中的相机应用图标101的尺寸大于桌面界面1a中的相机应用图标101的尺寸。在电子设备显示启动动画被打断图像帧1b的情况下,响应于用户从电子设备屏幕底部向上滑动的操作(如图4A所示的第1次打断,可理解为用户第1次打断动画播放),电子设备可以播放返回动画。可理解,电子设备可以从启动动画被打断时的状态开始以动效下沉方式构建启动动画,即从启动动画被打断图像帧1b开始播放返回动画,由于启动动画的第M1个图像帧与返回动画的第N1个图像帧相同,也可以理解为,电子设备可以从返回动画的第N1个图像帧开始播放返回动
画。在播放返回动画的过程中,电子设备可以显示返回动画被打断图像帧1c。返回动画被打断图像帧1c可以包括相机应用图标101和相机应用窗口102。返回动画被打断图像帧1c中的相机应用图标101的尺寸小于启动动画被打断图像帧1b中的相机应用图标101,返回动画被打断图像帧1c中的相机应用窗口102的尺寸小于启动动画被打断图像帧1b中的相机应用窗口,返回动画被打断图像帧1c中的其他应用图标或组件的尺寸大于启动动画被打断图像帧1b中的其他应用图标或组件的尺寸,且返回动画被打断图像帧1c中的其他应用图标或组件的尺寸小于桌面界面1a中的其他应用图标或组件的尺寸。
在电子设备显示返回动画被打断图像帧1c的情况下,用户点击相机应用图标101或相机应用窗口102后,电子设备无法以第二动效绘制方式从该返回动画被打断图像帧1c开始构建启动动画,而是首先需要恢复至返回动画结束时的状态(或称显示返回动画的最后一个图像帧)后再以第二动效绘制方式来构建启动动画。具体地,如图4B所示,在电子设备显示返回动画被打断图像帧1c的情况下,响应于用户点击相机应用图标101或相机应用窗口102的操作(如图4B所示的第2次打断,可理解为用户第2次打断动画播放),电子设备可以显示桌面界面1a。也就是说,在电子设备显示返回动画被打断图像帧1c后,电子设备下一帧显示桌面界面1a。电子设备显示桌面界面1a后,可以以动效下沉方式构建启动动画。具体地,在电子设备显示桌面界面1a后,电子设备下一帧显示返回动画被打断图像帧1c,并从返回动画被打断图像帧1c开始构建启动动画,如图4B所示,在播放启动动画的过程中,电子设备可以显示启动动画被打断图像帧1b,并且电子设备最终可以显示拍摄界面1d。拍摄界面1d可以理解为启动动画的最后一个图像帧(即上文所提及的启动动画的Z个图像帧)。
需要说明的是,无论用户是在启动动画结束之后触发电子设备返回桌面,还是在启动动画还未结束的情况下触发电子设备返回桌面,后续用户打断返回动画都会造成电子设备闪屏或闪黑的现象。
基于上述内容,本申请实施例提供了一种动画显示方法及相关设备。根据该方法,响应于用户点击第一应用图标的操作,电子设备可以启动第一应用,并确定电子设备是否支持动效下沉。在电子设备支持动效下沉的情况下,以第二动效绘制方式绘制第一启动动画,在电子设备不支持动效下沉的情况下,以第一动效绘制方式绘制第一启动动画。响应于用户从屏幕底部上滑的操作,电子设备可以确定第一启动动画是否结束。在第一启动动画结束的情况下,电子设备可以确定用户从屏幕底部上滑的操作是否满足预设条件,而在第一启动动画未结束的情况下,电子设备可以结束第一启动动画,并确定用户从屏幕底部上滑的操作是否满足预设条件。在用户从屏幕底部上滑的操作满足预设条件,且电子设备以第二动效绘制方式绘制第一启动动画的情况下,电子设备以第二动效绘制方式绘制返回动画。响应于用户点击第一应用窗口或第一应用图标的操作,电子设备可以停止绘制返回动画(或称停止构建/播放返回动画),以第一动效绘制方式绘制第二启动动画。通过这种方法,在用户打断电子设备播放以第二动效绘制方式绘制的返回动画的情况下,电子设备可以绘制与返回动画被打断图像帧相同的一帧过渡图像帧,接下来再以第一动效绘制方式来绘制第二启动动画,从而实现返回动画和第二启动动画的流畅衔接,避免出现闪屏或闪黑等现象。
下面介绍本申请实施例涉及的装置。
本申请实施例所涉及的电子设备可以为手机、平板电脑、个人计算机(Personal Computer,PC)、车载设备、增强现实(Augmented Reality,AR)/虚拟现实(Virtual Reality,VR)设备、超级移动个人计算机(Ultra-Mobile Personal Computer,UMPC)、上网本、或个人数字助理(Personal Digital Assistant,PDA)等设备。可理解,本申请对电子设备的具体类型不作限制。
请参阅图5,图5为本申请实施例提供的一种电子设备的硬件结构示意图。
如图5所示,电子设备可以包括:处理器,外部存储器接口,内部存储器,通用串行总线(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)。随机存取存储器可以由处理器直接进行读写,可以用于存储操作系统或其他正在运行中的程序的可执行程序(例如,机器指令),还可以用于存储用户及应用程序的数据等。非易失性存储器也可以存储可执行程序和存储用户及应用程序的数据等,可以提前加载到随机存取存储器中,用于处理器直接进行读写。
在本申请的一些实施例中,实现本申请实施例所述的方法的代码可存储在非易失性存储器上。在运行桌面应用时,电子设备可将非易失性存储器中存储的可执行代码加载到随机存取存储器。
外部存储器接口可以用于连接外部的非易失性存储器,实现扩展电子设备的存储能力。
电子设备可以通过音频模块,扬声器,受话器,麦克风,耳机接口,以及应用处理器等实现音频功能。
电子设备的操作系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本申请实施例以分层架构的安卓(Android)操作系统为例,示例性说明电子设备的软件结构。需要说明的是,本申请实施例虽然以Android操作系统(可简称为Android系统)为例进行说明,但是其基本原理同样适用于基于iOS或Windows等操作系统的电子设备。
图6为本申请实施例提供的一种电子设备的软件结构示意图。
电子设备的软件结构采用分层架构,即将软件分成若干个层,其中每一层都有清晰的角色和分工。层与层之间通过软件接口通信。以Android系统运行在AP上为例,在本申请的一些实施例中,Android系统的软件结构分为五层,从上至下分别为应用程序层,应用程序框架层(Framework),安卓运行时(Android runtime)和系统库,硬件抽象层(HAL)以及系统内核层(Kernel)。
其中,应用程序层可以包括一系列应用程序包。应用程序包可以包括相机,图库,日历,通话,地图,WLAN,蓝牙,音乐,视频,短信息等应用程序。应用程序层还可以包括笔记应用。应用程序层还可以包括桌面应用。桌面应用可以提供快速访问电子设备上的各种功能和应用程序。Android系统中的桌面应用是通过使用Android的Launcher实现的。Launcher是Android操作系统的应用程序,它负责管理和呈现用户界面,包括桌面、应用程序抽屉和部件。它允许用户自定义手机的主屏幕、图标、小部件布局以及一些基本功能,如滑动效果和屏幕转换。
应用程序框架层为应用程序层的应用程序提供应用编程接口(Application Programming Interface,API)和编程框架。应用程序框架层可以包括一些预先定义的函数。例如,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。电话管理器用于提供电子设备的通话功能,例如通话状态的管理(包括接通,挂断等)。应用程序框架层还可以包括输入模块(input)和SurfaceFlinger。
输入模块可以进行各种输入事件(例如,按键事件、触摸事件等)的收集、处理和分发。在本申请的一些实施例中,输入模块可以为输入管理服务(Input Manager Service,IMS)。
IMS可以监听设备节点(例如,/dev/input下的所有的设备节点),当设备节点有数据时会将数据进行加工处理并找到合适的窗口,将输入事件派发给它。在本申请的一些实施例中,输入事件管理模块可以为inputflinger。inputflinger是负责处理输入事件的服务,它可以接收来自硬件设备的原始输入事件,并将它们转换为Android系统可以理解的事件,如触摸事件等。
SurfaceFlinger负责管理所有应用程序的UI显示,通过与硬件抽象层(HAL)和GPU驱动程序交互,还负责将应用程序的UI元素(如文本、图像、视图等)组合成一个完整的图像帧。
运行时(Runtime)负责系统的调度和管理。Runtime包括核心库和虚拟机。其中,核心库包含两部分:一部分是编程语言(例如,java语言)需要调用的功能函数,另一部分是系统的核心库。应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的编程文件(例如,java文件)执行为二进制文件。虚拟机用于执行对象生命周期的管理、堆栈管理、线程管理、安全和异常的管理,以及垃圾回收等功能。
系统库可以包括多个功能模块。例如,媒体库(Media Libraries)、三维图形处理库(例如,OpenGL ES)和二维图形引擎(例如,SGL)等。这些功能模块的具体含义和作用可以参考相关技术文档,在此不展开说明。
硬件抽象层(HAL)是位于操作系统内核与上层软件之间的接口层,其目的在于将硬件抽象化。硬件抽象层是设备内核驱动的抽象接口,用于实现向更高级别的Java API框架提供访问底层设备的应用编程接口。HAL可以提供标准界面,向更高级别的Java API框架显示设备硬件功能。HAL包含多个库模块(例如,相机HAL、音频HAL等)。当系统框架层API要求访问便携设备的硬件时,操作系统将为该硬件组件加载库模块。
内核层是Android系统的基础。内核层负责硬件的驱动程序、网络、电源、系统安全以及内存管理等功能。内核层是硬件与软件之间的一个中间层,其作用是将应用程序的请求传递给硬件。内核层可以包括音频驱动、显示驱动、摄像头驱动和传感器驱动。
需要说明的是,本申请提供的图6所示的电子设备的软件结构示意图仅作为一种示例,并不限定Android系统不同分层中的具体模块划分,具体可以参考常规技术中对Android系统软件结构的介绍。另外,本申请提供的方法还可以基于其他操作系统实现,本申请不再一一举例。
下面基于图5和图6所示的电子设备的软硬件结构,介绍本申请实施例提供的一种动画显示方法。
请参阅图7,图7为本申请实施例提供的一种动画显示方法的流程图。该动画显示方法可以包括但不限于以下步骤:
S101:响应于用户点击第一应用图标的操作,输入模块向桌面应用发送第一输入事件。
用户可以通过点击应用图标来触发电子设备启动相应的应用。响应于用户点击第一应用图标的操作,输入模块可以得到第一输入事件,并向桌面应用发送第一输入事件。相应的,桌面应用可以接收输入模块发送的第一输入事件。
可理解,第一应用图标可以为如图5所示的应用程序层中的任一应用对应的图标,本
申请对此不作具体限制。示例性的,如图4A所示,第一应用图标可以为相机应用图标101,第一输入事件可以为输入模块响应于用户点击相机应用图标101的操作而生成的输入事件。
在本申请的一些实施例中,响应于用户点击第一应用图标的操作,电子设备中的下层模块可以将用户接触屏幕所导致的屏幕状态的变化转化为原始输入事件(也可以理解为将屏幕状态的变化封装为更加高级的类的对象),并将原始输入事件发送给输入模块。输入模块接收原始输入事件后,可以对其进行处理,得到第一输入事件。输入模块得到第一输入事件之后,可以将第一输入事件发送给桌面应用。
在本申请的一些实施例中,输入事件可以指InputEvent对象。InputEvent是一个Java类,可以包括多个子类,比如动作事件(MotionEvent)和按键事件(KeyEvent)。其中,MotionEvent可以包括触屏事件(touch event),即用户通过皮肤或手写笔在设备屏幕(即显示屏)上操作时生成的输入事件。触屏事件可以包括以下三种类型的事件:按下事件(例如,MotionEvent.ACTION_DOWN)、移动事件(例如,MotionEvent.ACTION_MOVE),以及抬起事件(例如,MotionEvent.ACTION_UP)。可理解,一个完整的触摸屏幕(或称显示屏)的操作以按下事件开始,中间可以不存在或者存在一个或多个移动事件,最终以抬起事件结束。例如,在用户用手指点击显示屏的过程中,用户手指落在显示屏上会触发电子设备生成按下事件,用户手指离开显示屏会触发电子设备生成抬起事件。再例如,在用户用手指在显示屏上滑动的过程中,用户手指落在显示屏上会触发电子设备生成按下事件,用户手指落在显示屏后在显示屏上滑动会触发电子设备生成多个移动事件,用户手指离开显示屏会触发电子设备生成抬起事件。
在本申请的一些实施例中,第一输入事件可以为触屏事件,具体可以包括一个按下事件(例如,MotionEvent.ACTION_DOWN)和一个抬起事件(例如,MotionEvent.ACTION_UP)。
可理解,用户还可以通过其他方式(例如,特定语音指令,特定手势指令等)来触发电子设备启动第一应用,本申请对此不作限制。
S102:桌面应用启动第一应用,判断动效标志位是否为true。
可选地,S102之前可以对标志位赋值,执行步骤a和步骤b。其中,步骤a,将动效标志位赋值为动效配置信息;步骤b,当桌面应用正在绘制动画时,将动效标志位赋值为false。
在一种可能的实现方式中,在电子设备支持第二动效绘制方式的情况下,动效配置信息为true,而在电子设备不支持第二动效绘制方式的情况下,动效配置信息为false。在又一种可能的实现方式中,在动效配置信息包括预设动效信息的情况下,表示电子设备支持第二动效绘制方式,动效标志位为true;在动效配置信息不包括预设动效信息的情况下,表示电子设备不支持第二动效绘制方式,动效标志位为false。
因为桌面应用执行步骤S102时,桌面应用没有绘制动画,所以,动效标志位就等于动效配置信息,当动效配置信息为true时,动效标志位为true。
可理解,本申请对动效配置信息和标志位的具体内容不作限制,除了本申请所提及的true和false,还可以用0和1表示,或者用其他字母、字符串来表示等。
S103:在动效标志位为true的情况下,桌面应用向SurfaceFlinger发送绘制参数,SurfaceFlinger绘制第一启动动画。
可选地,在动效标志位为false的情况下,桌面绘制获取绘制参数,并基于获取的绘制参数来绘制第一启动动画。
可理解,动效标志位为true表示电子设备以第二动效绘制方式绘制当前动画,而动效标志位为false表示电子设备以第一动效绘制方式绘制当前动画。可理解,这里所提及的当前动画可以指第一启动动画。可理解,第一启动动画是桌面应用启动第一应用的过程中播放的动画,可以理解为涉及电子设备所启动的应用(例如,第一应用)对应的activity的生命周期的变化的启动动画。启动动画的相关描述具体可以参考上文,本申请对此不再赘述。
在本申请的一些实施例中,桌面应用以第一动效绘制方式绘制第一启动动画可以理解为基于第一动效绘制方式构建第一启动动画,具体可以包括:桌面应用计算绘制参数,以第一动效绘制方式绘制第一启动动画的每一个图像帧对应的图层,比如桌面图层(第一桌面图层或第二桌面图层)、图标图层和应用图层,对绘制得到的图层进行合成,将合成的待显示图像帧送到显示屏进行显示。
可理解,动效标志位表示的是桌面应用负责绘制动画图像帧的情况。也就是说,在桌面应用确定电子设备不支持第二动效绘制方式的情况下,桌面应用可以第一动效绘制方式绘制第一启动动画,即由桌面应用负责绘制动画图像帧,再将已绘制图像帧发送给SurfaceFlinger进行合成,最终送至显示屏进行显示,在这种情况下,桌面应用可以设置动效标志位,并将动效标志位具体设置为false。而在桌面应用确定电子设备支持第二动效绘制方式的情况下,桌面应用可以以第二动效绘制方式绘制第一启动动画,即不由桌面应用负责绘制动画图像帧,而是由SurfaceFlinger负责绘制和合成动画图像帧,最终送至显示屏进行显示,在这种情况下,桌面应用可以设置动效标志位,并将动效标志位具体设置为true。
在本申请的一些实施例中,桌面应用可以在第一启动动画开始(start)之后为动效标志位赋值。本申请所提及的第一启动动画开始可以指第一启动动画的状态变为start,也可以指桌面应用运行第一启动动画对应的start()方法。在本申请的一些实施例中,桌面应用以第二动效绘制方式绘制第一启动动画,在这种情况下,在桌面应用将第一启动动画的各个图像帧对应的绘制参数发送给SurfaceFlinger之后,第一启动动画的状态变为start。在本申请的一些实施例中,桌面应用以第一动效绘制方式绘制第一启动动画,在这种情况下,桌面应用确定第一启动动画的第一个图像帧对应的绘制参数之后,第一启动动画的状态变为start。在本申请的一些实施例中,桌面应用以第一动效绘制方式绘制第一启动动画,在这种情况下,桌面应用可以确定第一启动动画的第一个图像帧对应的绘制参数,基于该绘制参数绘制得到第一启动动画的第一个图像帧对应的图层,在桌面应用将该绘制得到的第一启动动画的第一个图像帧(或称已绘制的第一启动动画的第一个图像帧)发送给SurfaceFlinger之后,第一启动动画的状态变为start。
在本申请的一些实施例中,在桌面应用确定电子设备支持动效下沉的情况下,桌面应用可以确定动效标志位对应赋值的内容为true,具体可以在以第二动效绘制方式绘制第一启动动画的过程中将动效标志位赋值为true。在一种可能的实现方式中,桌面应用可以在
将第一启动动画的各个图像帧对应的绘制参数发送给SurfaceFlinger之后,将动效标志位赋值为true。
类似的,在本申请的一些实施例中,在桌面应用确定电子设备不支持动效下沉的情况下,桌面应用可以确定动效标志位对应赋值的内容为false,具体可以在以第一动效绘制方式绘制第一启动动画的过程中将动效标志位赋值为false。在一种可能的实现方式中,桌面应用可以在确定第一启动动画的第一个图像帧对应的绘制参数之后,将动效标志位赋值为false。在一种可能的实现方式中,桌面应用可以在将绘制得到的第一启动动画的第一个图像帧发送给SurfaceFlinger之后,将动效标志位赋值为false。
可理解,桌面应用还可以具体在构建第一启动动画过程中的其他具体时间段内赋值动效标志位,本申请对此不作限制。
在本申请的一些实施例中,桌面应用可以在确定电子设备支持动效下沉之后,且构建启动动画之前,为动效标志位赋值。
需要说明的是,在第一启动动画结束播放后,桌面应用可以清除动效标志位。在本申请的一些实施例中,第一启动动画的最后一个图像帧显示在显示屏上之后,桌面应用可以收到相应回调,表示第一启动动画已播放完成(或称结束播放)。桌面应用收到该相应回调之后,可以清除动效标志位。
在本申请的一些实施例中,动效配置信息可以预先设置在电子设备中。在本申请的一些实施例中,动效配置信息可以包括动效对应的各个配置信息(例如,动画帧数、动画时长、动效设置方式等)。在本申请的又一些实施例中,动效配置信息可以理解为动效设置方式对应的配置信息,仅用于表示电子设备是否支持动效下沉。可理解,动效设置方式包括动效下沉方式和非动效下沉方式。
在本申请的一些实施例中,预设动效信息可以理解为动效下沉方式对应的配置信息,即窗口动效对应的配置信息,本申请对其具体表现形式不作限制。电子设备中存在预设动效信息可以表示该电子设备支持动效下沉,电子设备中不存在预设动效信息可以表示该电子设备不支持动效下沉。
需要说明的是,动效标志位的具体内容还可以为其他表现形式(例如,数字、字符串等),本申请对此不作限制。例如,可以通过将标志位赋值为1表示电子设备以第二动效绘制方式绘制动画,而通过将标志位赋值为0表示电子设备以第一动效绘制方式绘制动画。
上文已简单提及两种动效绘制方式(第一动效绘制方式和第二动效绘制方式)的含义,下面以第一启动动画为例来简要介绍基于第一动效绘制方式和第二动效绘制方式构建动画的流程。
1、桌面应用绘制第一启动动画(第一动效绘制方式)。
第一步:桌面应用确定第一应用在启动过程需要播放的第一启动动画总共的图像帧帧数,即Z,并获取第一启动动画的Z个图像帧对应的Z组绘制参数。可理解,Z组绘制参数分别对应第一启动动画的Z个图像帧。
在本申请的一些实施例中,由桌面应用绘制的第一启动动画中的图像帧可以包括第一桌面图层和应用图层。在这种情况下,第一启动动画的每一个图像帧对应的绘制参数都可
以包括第一桌面图层对应的绘制参数和应用图层对应的绘制参数。也就意味着,第一启动动画的Z个图像帧对应的Z组绘制参数中的每一组绘制参数都可以包括第一桌面图层对应的绘制参数和应用图层对应的绘制参数。
第二步:桌面应用基于Z组绘制参数中的每一组绘制参数来绘制第一启动动画的每一个图像帧中的第一桌面图层和应用图层(或称每一个图像帧对应的第一桌面图层和应用图层),并将绘制得到(或称已绘制)的第一桌面图层和应用图层发送给SurfaceFlinger。也就是说,桌面应用每基于一组绘制参数绘制第一桌面图层和应用图层,就可以将该绘制得到的第一桌面图层和应用图层发送给SurfaceFlinger。相应的,SurfaceFlinger可以接收桌面应用发送的绘制得到的第一桌面图层和应用图层。
在本申请的一些实施例中,桌面应用可以每获取第一启动动画的一个图像帧对应的一组绘制参数之后,就基于这一组绘制参数绘制该图像帧对应的第一桌面图层和应用图层,并将该绘制得到的第一桌面图层和应用图层发送给SurfaceFlinger,然后再获取第一启动动画的下一个图像帧对应的一组绘制参数,类似的,再基于这一组绘制参数绘制该下一个图像帧对应的第一桌面图层和应用图层,并将该绘制得到的下一个图像帧对应的第一桌面图层和应用图层发送给SurfaceFlinger。
在本申请的一些实施例中,第一启动动画的Z个图像帧对应的Z组绘制参数有预设先后顺序,桌面应用可以直接基于该预设先后顺序来基于Z组绘制参数中的每一组绘制参数绘制每一个图像帧对应的第一桌面图层和应用图层。
第三步:SurfaceFlinger每接收第一启动动画的一个图像帧对应的绘制得到的第一桌面图层和应用图层(或称每接收一次第一桌面图层和应用图层),就对该绘制得到的第一桌面图层和应用图层进行合成,得到一个待显示图像帧(或称一帧待显示图像),并将该待显示图像帧发送给显示屏驱动。
第四步:显示屏驱动每接收SurfaceFlinger发送的一个待显示图像帧,就将该待显示图像帧送至显示屏进行显示。这样,显示屏可以显示第一启动动画的第1个图像帧到第Z个图像帧。
2、SurfaceFlinger绘制第一启动动画(第二动效绘制方式)。
第一步:桌面应用确定第一应用在启动过程需要播放的第一启动动画总共的图像帧帧数,即Z,并获取第一启动动画的Z个图像帧对应的Z组绘制参数。可理解,Z组绘制参数分别对应第一启动动画的Z个图像帧。
可理解,每一组绘制参数可以包括一个或多个窗口(或称图层)对应的绘制参数。也就是说,在一个图像帧包括多个图层的情况下,这一个图像帧对应的绘制参数可以包括该多个图层分别对应的绘制参数。
在本申请的一些实施例中,由SurfaceFlinger绘制的第一启动动画中的图像帧可以包括图标图层、第二桌面图层和应用图层。在这种情况下,第一启动动画的每一个图像帧对应的绘制参数都可以包括图标图层对应的绘制参数、第二桌面图层对应的绘制参数和应用图层对应的绘制参数。也就意味着,第一启动动画的Z个图像帧对应的Z组绘制参数中的每一组绘制参数都可以包括图标图层对应的绘制参数、第二桌面图层对应的绘制参数和应用
图层对应的绘制参数。
在本申请的一些实施例中,由SurfaceFlinger绘制的第一启动动画中的图像帧可以包括第二桌面图层和应用图层。在这种情况下,第一启动动画的每一个图像帧对应的绘制参数都可以包括第二桌面图层对应的绘制参数和应用图层对应的绘制参数。也就意味着,第一启动动画的Z个图像帧对应的Z组绘制参数中的每一组绘制参数都可以包括第二桌面图层对应的绘制参数和应用图层对应的绘制参数。
可理解,绘制参数可以包括透明度(alpha)、缩放(scale)、位移(translate)和旋转(rotate)等参数中的任意一项或多项,本申请对其具体包含内容不作限制。
第二步:桌面应用将获取的Z组绘制参数发送给SurfaceFlinger。相应的,SurfaceFlinger可以接收桌面应用发送的Z组绘制参数。
第三步:SurfaceFlinger基于Z组绘制参数的每一组绘制参数来绘制第二桌面图层和应用图层(或者图标图层、第二桌面图层和应用图层)。
第四步:SurfaceFlinger每基于一组绘制参数绘制得到第二桌面图层和应用图层(或者图标图层、第二桌面图层和应用图层),就将该绘制得到的图层合成为一个图像帧,即待显示图像帧,并将这一个待显示图像帧发送给显示屏驱动。相应的,显示屏驱动可以接收SurfaceFlinger发送的待显示图像帧。
在本申请的一些实施例中,桌面应用发送给SurfaceFlinger的Z组绘制参数有预设先后顺序,SurfaceFlinger可以直接基于该预设先后顺序来基于Z组绘制参数中的每一组绘制参数绘制每一个图像帧。
第五步:显示屏驱动每接收SurfaceFlinger发送的一个待显示图像帧(或称一个已绘制合成的图像帧),就将这一个待显示图像帧送至显示屏进行显示。这样,显示屏可以显示第一启动动画的第1个图像帧到第Z个图像帧。
S104:响应于用户从屏幕底部向上滑动的操作,输入模块向桌面应用发送第二输入事件。
用户可以从屏幕底部向上滑动来触发电子设备返回桌面(也可以理解为显示桌面界面),响应于该从底部向上滑动的操作,输入模块可以得到第二输入事件,并向桌面应用发送第二输入事件。相应的,桌面应用可以接收输入模块发送的第二输入事件。
可理解,输入模块得到第二输入事件的具体实现方式可以参考步骤S101的相关描述,本申请对此不再赘述。
在本申请的一些实施例中,第二输入事件可以为触屏事件,具体可以包括一个落下事件(例如,MotionEvent.ACTION_DOWN)、多个移动事件(例如,MotionEvent.ACTION_MOVE)和一个抬起事件(例如,MotionEvent.ACTION_UP)。
根据上文,用户还可以通过其他方式来触发电子设备返回桌面,本申请对此不作限制。
S105:桌面应用确定第一启动动画是否存在。
桌面应用接收输入模块发送的第二输入事件之后,可以判断第一启动动画是否存在。在本申请的一些实施例中,桌面应用可以判断电子设备中是否存在第一启动动画对应的动画对象。若电子设备中存在第一启动动画对应的动画对象,则桌面应用可以确定第一启动
动画存在,在这种情况下,桌面应用可以执行步骤S106,若电子设备中不存在第一启动动画对应的动画对象,则桌面应用可以确定第一启动动画不存在,在这种情况下,桌面应用可以执行步骤S108。
在本申请的一些实施例中,桌面应用接收输入模块发送的第二输入事件之后,可以不执行步骤S105,而直接执行步骤S106。也就是说,桌面应用接收输入模块发送的第二输入事件之后,可以判断第一启动动画是否结束。
S106:桌面应用可以判断第一启动动画是否结束。
若桌面应用确定第一启动动画存在,则桌面应用可以判断第一启动动画是否结束。若第一启动动画结束,则桌面应用可以继续执行步骤S108,若第一启动动画还未结束,则桌面应用可以执行步骤S107,并在执行步骤S107之后再执行步骤S108,即桌面应用可以先结束第一启动动画后再执行步骤S108。
在本申请的一些实施例中,桌面应用判断第一启动动画是否结束,具体可以包括:桌面应用可以判断第一启动动画的状态是否为结束(end)。若第一启动动画的状态为end,则第一启动动画已结束,在这种情况下,桌面应用可以执行步骤S108,而若第一启动动画的状态不为end,则第一启动动画还未结束,在这种情况下,桌面应用可以执行步骤S107,即结束第一启动动画。
需要说明的是,本申请所提及的第一启动动画结束可以理解为完成第一启动动画所有图像帧(比如上文所提及的第一启动动画的Z个图像帧)的绘制、合成和显示。在本申请的一些实施例中,电子设备通过显示屏显示第一启动动画的最后一个图像帧之后,桌面应用可以将第一启动动画的状态由start设置为end。
S107:桌面应用结束第一启动动画。
若在桌面应用接收输入模块发送的第二输入事件之后,第一启动动画还未结束(或称结束播放/停止构建),则桌面应用可以先结束第一启动动画,再执行步骤S108。
在本申请的一些实施例中,桌面应用以第二动效绘制方式绘制第一启动动画,在这种情况下,桌面应用结束第一启动动画,具体可以包括:桌面应用通知SurfaceFlinger停止基于绘制参数来绘制合成第一启动动画的图像帧,也可以理解为桌面应用通知SurfaceFlinger停止基于绘制参数来绘制第一启动动画的图像帧所对应的图层。
在本申请的一些实施例中,桌面应用可以调用setAnimState()方法来通知SurfaceFlinger停止基于绘制参数来绘制合成第一启动动画的图像帧。setAnimState()方法可以表示动画状态,其参数值为1时,表示开始,其参数值为2时,表示取消,其参数值为3时,表示结束。根据上文,第一启动动画可以包括一个或多个图层(或称窗口),桌面应用具体可以通过调用setAnimState()方法来通知SurfaceFlinger停止绘制该一个或多个图层。例如,第一启动动画可以包括桌面图层和应用图层,在这种情况下,桌面应用可以针对桌面图层设置setAnimState(2),表示取消对桌面图层的绘制,以及针对应用图层调用设置setAnimState(2),表示取消对应用图层的绘制。
在本申请的一些实施例中,桌面应用以第一动效绘制方式绘制第一启动动画,在这种情况下,桌面应用结束第一启动动画,具体可以包括:桌面应用停止基于绘制参数来绘制
第一启动动画的图像帧对应的图层。
可选的,桌面应用执行步骤S106-步骤S108,具体可以包括:当第一启动动画未结束时,桌面应用可以首先结束第一启动动画,然后再执行步骤S107-步骤S108,而当第一启动动画已结束时,桌面应用可以执行步骤S108。
S108:桌面应用判断目标界面是否为桌面界面。
在第一启动动画存在且已结束(包括第一启动动画播放完成,以及第一启动动画还未播放完成的情况下由桌面应用结束第一启动动画)的情况下,桌面应用可以判断目标界面是否为桌面界面。若目标界面为桌面界面,则桌面应用可以执行步骤S109。在本申请的一些实施例中,若目标界面不为桌面界面,桌面应用可以再基于目标界面确定具体响应方式。例如,若目标界面为多任务界面,桌面应用可以绘制任务卡片并将其发送给SurfaceFlinger,SurfaceFlinger将其合成得到待显示图像帧,然后将该待显示图像帧送至显示屏进行显示。其中,目标界面指的是待切换界面(或称待显示界面)。也就是说,桌面应用实际就是判断电子设备是否从显示其他界面切换为显示桌面界面。
在本申请的一些实施例中,桌面应用判断目标界面是否为桌面界面,具体可以包括:桌面应用基于接收到的输入事件(例如,第二输入事件,第四输入事件等)判断滑动距离和滑动速度是否满足预设条件。
以第二输入事件为例,桌面应用接收输入模块发送的第二输入事件之后,可以执行步骤S105-步骤S107,然后基于第二输入事件判断滑动距离和滑动速度是否满足预设条件。若滑动距离和滑动速度满足预设条件,则桌面应用可以继续执行步骤S109。
可理解,第二输入事件可以包括用户从屏幕底部向上滑动的操作对应的位置信息(例如,X/Y坐标),也可以理解为用户与屏幕的接触点(或称触摸点)的位置信息。
根据上文,在本申请的一些实施例中,第二输入事件可以为MotionEvent。可理解,在MotionEvent类中,将产生此次事件的动作称为motion,将产生此动作的主体(例如,手指、鼠标、手写笔等)称为pointer。一个MotionEvent对象中可以包含一个或多个pointer,每个pointer都包含标识(id),索引(index),位置,大小,方向等属性。在这种情况下,桌面应用可以基于第二输入事件中的pointer所包含的位置和方向来确定滑动距离和滑动速度。
根据上文,在本申请的一些实施例中,第二输入事件可以包括一个落下事件(例如,MotionEvent.ACTION_DOWN)、多个移动事件(例如,MotionEvent.ACTION_MOVE)和一个抬起事件(例如,MotionEvent.ACTION_UP)。上文所提及的滑动距离具体可以指触摸点的坐标的移动距离,上文所提及的滑动速度具体可以指触摸点的移动速度。桌面应用基于第二输入事件确定的滑动距离可以理解为第二输入事件中落下事件对应的触摸点与抬起事件对应的触摸点之间的距离。在本申请的一些实施例中,桌面应用不仅可以基于第二输入事件所包括的按下事件和抬起事件的坐标确定滑动距离,还可以确定滑动时长(具体可以为生成该按下事件和生成该抬起事件之间的时长),再基于该滑动距离和该滑动时长来计算滑动速度。
在本申请的又一些实施例中,桌面应用可以通过调用computeCurrentVelocity()方法来计算滑动速度。
在本申请的一些实施例中,在桌面应用接收到第二输入事件所包括的抬起事件(可以理解为用户从屏幕底部向上滑动并抬手)之后,桌面应用可以确定滑动距离和屏幕的滑动速度(即抬手后的滑动速度),并确定滑动距离和滑动速度是否满足预设条件。
在本申请的一些实施例中,滑动距离和滑动速度是否满足预设条件,具体可以包括:滑动距离大于预设滑动距离,且滑动速度大于预设滑动速度。可理解,预设滑动距离和预设滑动速度可以根据实际需要进行设置,本申请对此不作限制。
在本申请的一些实施例中,若滑动距离和滑动速度不满足预设条件,桌面应用可以再基于滑动距离和滑动速度确定是否需要响应用户从屏幕底部向上滑动的操作,以及具体响应方式。例如,若屏滑动距离和滑动速度不满足预设条件,但是其满足触发显示任务卡片列表的滑动条件,则桌面应用可以绘制任务卡片列表并送至显示屏进行显示。
S109:桌面应用判断第二启动动画是否存在。
桌面应用确定目标界面为桌面界面之后,可以判断第二启动动画是否存在。与步骤S105类似,在本申请的一些实施例中,桌面应用可以判断电子设备中是否存在第二启动动画对应的动画对象。若电子设备中存在第二启动动画对应的动画对象,则桌面应用可以确定第二启动动画存在,在这种情况下,桌面应用可以执行步骤S110-步骤S111,之后可以再执行步骤S112-步骤S118,若电子设备中不存在第二启动动画对应的动画对象,则桌面应用可以确定第二启动动画不存在,在这种情况下,桌面应用可以执行步骤S112-步骤S118。
在本申请的一些实施例中,桌面应用确定目标界面为桌面界面之后,可以不执行步骤S109,而直接执行步骤S110。也就是说,桌面应用接收确定目标界面为桌面界面之后,可以判断第二启动动画是否结束。
S110:桌面应用判断第二启动动画是否结束。
若桌面应用确定第二启动动画存在,则桌面应用可以判断第二启动动画是否结束。若第二启动动画结束,则桌面应用可以继续执行步骤S111,若第二启动动画还未结束,则桌面应用可以执行步骤S111,并在执行步骤S111之后再执行步骤S112,即桌面应用可以先结束第二启动动画后再执行步骤S112。
与步骤S106类似,在本申请的一些实施例中,桌面应用判断第二启动动画是否结束,具体可以包括:桌面应用可以判断第二启动动画的状态是否为end。若第二启动动画的状态为end,则第二启动动画已结束,在这种情况下,桌面应用可以执行步骤S112,而若第一启动动画的状态不为end,则第一启动动画还未结束,在这种情况下,桌面应用可以执行步骤S111,即结束第二启动动画,之后再执行步骤S112。
可理解,第二启动动画结束的含义可以参考步骤S106中对第一启动动画结束的含义的描述,本申请对此不再赘述。
可选地,结合步骤S109和步骤S110,在另一种可能的实现方式中,桌面应用可以判断是否满足第二启动动画存在且第二启动动画未结束(或称未停止播放)。若满足第二启动动画存在且第二启动动画未结束,桌面应用可以执行步骤S111,并在执行步骤S111之后再执行步骤S112。若不满足第二启动动画存在且第二启动动画未结束,桌面应用可以执行步
骤S112。
S111:桌面应用停止绘制第二启动动画。
若桌面应用确定第二启动动画还未结束,桌面应用可以停止绘制第二启动动画,也可以理解为取消(cancel)绘制第二启动动画。在本申请的一些实施例中,桌面应用构建(或称创建)第二启动动画的过程中,可以给第二启动动画设置监听器。桌面应用可以通过该监听器来监听第二启动动画的中断事件(或称中断第二启动动画的输入事件),比如第四输入事件。在桌面应用通过该监听器监听到第二启动动画的中断事件之后,可以停止绘制第二启动动画。可理解,桌面应用接收输入事件,可以执行步骤S105-步骤S110,在确定第二启动动画还未结束之后,桌面应用可以确定通过该监听器监听到第二启动动画的中断事件。
S112:桌面应用判断动效标志位是否为true。
可选地,结合步骤S102,桌面应用通过判断动效标志位是否为true来确定电子设备是否支持第二动效绘制方式,若动效标志位为true,表示电子设备支持第二动效绘制方式,若动效标志位为false,表示电子设备不支持第二动效绘制方式。
可选地,S112之前可以对标志位赋值,执行步骤a和步骤b。其中,步骤a,将动效标志位赋值为动效配置信息;步骤b,当桌面应用正在绘制动画时,将标志位赋值为false。
在一种可能的实现方式中,在电子设备支持第二动效绘制方式的情况下,动效配置信息为true,而在电子设备不支持第二动效绘制方式的情况下,动效配置信息为false。在又一种可能的实现方式中,在动效配置信息包括预设动效信息的情况下,表示电子设备支持第二动效绘制方式,动效标志位为true;在动效配置信息不包括预设动效信息的情况下,表示电子设备不支持第二动效绘制方式,动效标志位为false。
若第二启动动画不存在,或者第二启动动画存在且第二启动动画已结束,或者,第二启动动画存在且桌面应用停止绘制第二启动动画,则桌面应用可以判断动效标志位是否为true。若动效标志位为true,则表示电子设备以第二动效绘制方式绘制当前动画,桌面应用可以执行步骤S116,即电子设备可以以第二动效绘制方式绘制返回动画,也就是说,桌面应用可以确定绘制参数,将绘制参数发送给SurfaceFlinger,SurfaceFlinger可以基于该绘制参数来绘制返回动画,并且,在执行步骤S116之后,桌面应用还可以执行步骤S114和步骤S117。若动效标志位不为true,则表示电子设备以第一动效绘制方式绘制当前动画,桌面应用可以执行步骤S113,即桌面应用可以以第一动效绘制方式绘制返回动画。可理解,这里所提及的当前动画可以理解为被打断的启动动画,或者已结束的启动动画(或称已结束播放的启动动画)。在第二启动动画不存在的情况下,当前动画可以理解为第一启动动画,在第二启动动画存在的情况下,当前动画可以理解为第二启动动画。
在本申请的一些实施例中,若桌面应用执行步骤S106的过程中确定启动动画已经结束,则表示启动动画自行播放结束,未被打断播放,在这种情况下,桌面应用可以清除其设置的动效标志位。这样,桌面应用执行步骤S112之前可以再次将动效标志位赋值为动效
配置信息。这样,桌面应用可以再基于该赋值后的动效标志位来执行步骤S112。
在本申请的一些实施例中,若桌面应用执行步骤S106的过程中确定启动动画未结束,则表示启动动画被打断播放,在这种情况下,桌面应用不清除其设置的动效标志位。这样,桌面应用执行步骤S112的过程中可以直接确定动效标志位是否为true。若动效标志位为true,则电子设备可以执行S116、步骤S114和步骤S117,若动效标志位不为true,而是为false,则电子设备可以执行步骤S113-步骤S115。
S113:桌面应用以第一动效绘制方式绘制返回动画,为返回动画对象设置监听器。
若动效标志位不为true,则表示电子设备以第一动效绘制方式绘制当前动画,桌面应用可以继续以第一动效绘制方式绘制返回动画。可理解,桌面应用以第一动效绘制方式绘制返回动画的具体实现方式可以参考上文所提及的以第一动效绘制方式构建第一启动动画的具体实现方式(如步骤S102所示),本申请对此不再赘述。
在本申请的一些实施例中,桌面应用可以调用buildReverseAnimator()方法来实现基于第一动效绘制方式构建动画。例如,若动效标志位不为true,则桌面应用可以调用buildReverseAnimator()方法来构建返回动画。buildReverseAnimator()方法具体可以涉及setTranslationX()、setTranslationY()、setScaleX()、setScaleY()和setRadius()。其中,setTranslationX()和setTranslationY()分别表示在X方向和Y方向上的偏移(或称位移/平移),setScaleX()和setScaleY()分别表示在X方向和Y方向上的尺度(或称缩放),setRadius()表示圆角弧度。
在本申请的一些实施例中,桌面应用可以调用anmiator.addListener()方法来给返回动画对应的动画对象(可简称为返回动画对象)设置监听器。桌面应用可以通过该监听器来监听桌面应用在返回动画构建过程中接收到的输入事件,即返回动画的中断事件(或称中断返回动画的输入事件)。在桌面应用通过监听器监听到返回动画的中断事件的情况下,桌面应用可以停止绘制(或称构建)返回动画。
S114:响应于用户点击第一应用窗口或第一应用图标的操作,输入模块向桌面应用发送第三输入事件。
在绘制(或称构建/播放)返回动画(例如,以第一动效绘制方式绘制返回动画,或者以第二动效绘制方式绘制返回动画)的过程中,用户可以通过点击第一应用窗口或第一应用图标触发电子设备继续启动第一应用。响应于用户点击第一应用窗口或第一应用图标的操作,输入模块向桌面应用发送第三输入事件。相应的,桌面应用可以接收输入模块发送的第三输入事件。其中,第三输入事件可以理解为桌面应用在返回动画构建过程中通过给返回动画对象设置的监听器监听到的输入事件。也就是说,在绘制(或称构建/播放)返回动画的过程中,桌面应用可以通过监听器监听输入模块向桌面应用发送的输入事件,例如,在绘制返回动画的过程中,桌面应用通过监听器监听到输入模块向桌面应用发送第三输入事件,在这种情况下,第三输入事件可以理解为返回动画的中断事件。
可理解,输入模块得到第三输入事件的具体实现方式可以参考其得到第一输入事件的具体实现方式(如步骤S101所示),本申请对此不再赘述。
在本申请的一些实施例中,与第一输入事件类似,第三输入事件可以为触屏事件,具
体可以包括一个按下事件(例如,MotionEvent.ACTION_DOWN)和一个抬起事件(例如,MotionEvent.ACTION_UP)。
S115:通过监听器监听到第三输入事件时,桌面应用停止绘制返回动画,绘制第二启动动画。
在桌面应用以第一动效绘制方式绘制返回动画的过程中,桌面应用可以基于监听器监听输入模块发送的输入事件,在通过监听器监听到输入模块向桌面应用发送第三输入事件的情况下,桌面应用可以停止绘制返回动画,也可以理解为cancel绘制返回动画,并且以第一动效绘制方式绘制第二启动动画。
也可以理解为,当返回动画还未结束播放时,桌面应用可以接收输入模块发送的第三输入事件,并基于该第三输入事件,停止绘制返回动画,以第一动效绘制方式绘制第二启动动画。
可理解,第二启动动画指的是返回动画的逆向动画,其与上文所提及的第一启动动画不同,上文所提及的第一启动动画涉及电子设备所启动的应用(例如,第一应用)对应的activity的生命周期的变化,且在应用对应的activity的生命周期的变化过程中,相应的应用窗口的大小也发生了变化,然而,第二启动动画不涉及电子设备所启动的应用对应的activity的生命周期的变化,但涉及相应应用窗口的变化。也就是说,第二启动动画可以理解为不涉及应用对应的activity的生命周期的变化的启动动画。
在本申请的一些实施例中,第一启动动画可以为上文所提及的完整的启动动画(如图2A所示),即由启动动画的第1个图像帧到第Z个图像帧组成的动画,第二启动动画可以为由上文所提及的完整的启动动画(如图2A所示)的第M1个图像帧到第Z个图像帧组成的动画。
在本申请的一些实施例中,桌面应用可以给第二启动动画设置监听器,并通过该监听器来监听在绘制第二启动动画的过程中接收到的输入事件,即第二启动动画的中断事件(或称中断第二启动动画的输入事件)。若桌面应用通过该监听器监听到第二启动动画的中断事件,则桌面应用可以停止绘制第二启动动画,也可以理解为cancel第二启动动画,具体可以参考步骤S111。在本申请的一些实施例中,桌面应用通过该监听器监听到第二启动动画的中断事件具体可以涉及步骤S118、步骤S105-步骤S110,具体地,桌面应用通过监听器监听到输入模块向桌面应用发送第四输入事件之后,桌面应用可以确定第一启动动画不存在,然后再判断目标界面是否为桌面界面,若目标界面为桌面界面,桌面应用可以确定第二启动动画存在且还未结束,在这种情况下,可理解为桌面应用通过该监听器监听到的第四输入事件为第二启动动画的中断事件,进一步的,桌面应用可以停止绘制第二启动动画(或称取消绘制第二启动动画),然后再执行步骤S111-步骤S117。
需要说明的是,桌面应用执行步骤S115之后,整个返回动画绘制流程结束,后续桌面应用可以接收输入模块发送的输入事件,响应于该输入事件,桌面应用可以再执行步骤S105-步骤S115。例如,根据上文,桌面应用执行步骤S115之后,可以接收输入模块发送的第四输入事件(如步骤S118),然后执行步骤S105-步骤S115。
S116:桌面应用向SurfaceFlinger发送绘制参数,SurfaceFlinger绘制返回动画,桌面应用为返回动画对象设置监听器。
若动效标志位为true,则表示电子设备以第二动效绘制方式绘制当前动画,电子设备可以继续以第二动效绘制方式绘制返回动画,也就是说,桌面应用可以确定绘制参数,将绘制参数发送给SurfaceFlinger,SurfaceFlinger可以基于该绘制参数来绘制返回动画。桌面应用可以给返回动画对应的动画对象(即返回动画对象)设置监听器。该监听器的相关描述可以参考步骤S113,本申请对此不再赘述。
进一步的,桌面应用绘制返回动画之后,可以接收输入模块发送的第三输入事件(如步骤S114),然后执行步骤S117。在本申请的一些实施例中,桌面应用可以通过给返回动画对象设置的监听器监听到输入模块发送的第三输入事件,其具体实现方式可以参考步骤S113和步骤S115的相关描述,本申请对此不再赘述。
可理解,桌面应用以第二动效绘制方式绘制返回动画,具体可以包括:桌面应用计算返回动画对应的绘制参数并将该绘制参数发送给SurfaceFlinger,然后SurfaceFlinger一帧一帧进行绘制,每绘制一个图像帧对应的图层之后,对该图层进行合成,得到待显示图像帧,然后送显。桌面应用以第二动效绘制方式绘制返回动画的具体实现方式可以参考上文所提及的以第二动效绘制方式绘制第一启动动画的具体实现方式(如步骤S102所示),本申请对此不再赘述。需要说明的是,在本申请的一些实施例中,以第二动效绘制方式绘制启动动画的图像帧可以由第二桌面图层和应用图层合成后得到,以第二动效绘制方式返回动画的图像帧可以由图标图层、第二桌面图层和应用图层合成得到,在这种情况下,相较于绘制启动动画,绘制返回动画的过程中涉及的图层更多,相应的绘制参数也会更多。
值得注意的是,若桌面应用接收第二输入事件后确定第一启动动画已结束,则桌面应用以第二动效绘制方式绘制的返回动画是完整的返回动画,比如总共包括Z个图像帧的返回动画(如图1B和图2B所示)。也就是说,桌面应用可以确定返回动画的总帧数,即Z,并获取返回动画的Z个图像帧对应的Z组绘制参数,然后将该Z组绘制参数发送给SurfaceFlinger。然而,若桌面应用接收第二输入事件后确定第一启动动画未结束,则桌面应用以第二动效绘制方式绘制的返回动画不是完整的返回动画。在这种情况下,桌面应用可以基于第一启动动画被打断时电子设备显示的图像帧(例如,图3A所示的启动动画的第M1个图像帧,或称完整的启动动画的第M1个图像帧)对应的绘制参数,来计算返回动画的起始图像帧(例如,图3A所示的完整的返回动画的第N1个图像帧)对应的绘制参数,以及返回动画的最后一个图像帧对应的绘制参数。在本申请的一些实施例中,桌面应用可以计算桌面应用结束第一启动动画时电子设备显示的是第一启动动画的第几个图像帧(或称第一启动动画的帧数的序号),并确定这一个图像帧对应的是返回动画的第几个图像帧(或称返回动画的帧数的序号)。也就是说,桌面应用可以计算结束第一启动动画时电子设备显示的第一启动动画的帧数的序号所对应的返回动画的帧数的序号。进一步的,桌面应用可以获取返回动画所包括的在这一个图像帧之后出现的其他图像帧对应的绘制参数,并将该其他图像帧对应的绘制参数发送给SurfaceFlinger。
示例性的,第一启动动画可以为如图3A所示的启动动画,在这种情况下,桌面应用可以确定桌面应用结束第一启动动画时电子设备显示的是第一启动动画的第M1个图像帧,
并确定启动动画的第M1个图像帧对应的是返回动画的第N1个图像帧,这样,桌面应用可以基于第一启动动画的第M1个图像帧对应的绘制参数确定返回动画的第N1个图像帧对应的绘制参数,然后,基于返回动画的第N1个图像帧对应的绘制参数,获取返回动画的第N1+1个图像帧到第Z个图像帧(即返回动画的最后一个图像帧)所对应的绘制参数,并将该绘制参数发送给SurfaceFlinger。
在本申请的一些实施例中,桌面应用可以调用compareBuildReverseForSink()方法来实现基于第二动效绘制方式构建动画,具体可以涉及setAnimState()、scheduleApply()、setTranslationX()、setTranslationY()、setScaleX()、setScaleY()和setRadius()。其中,scheduleApply()可以实现从以第二动效绘制方式绘制动画转换为以第一动效绘制方式绘制动画,具体地,桌面应用可以调用compareBuildReverseForSink()方法来以第二动效绘制方式绘制返回动画,若返回动画被打断,桌面应用可以调用scheduleApply()方法来实现第二动效绘制方式和第一动效绘制方式的过渡,并且在调用scheduleApply()方法后继续调用buildReverseAnimator()方法来以第一动效绘制方式绘制返回动画。其他涉及的函数具体可以参考上文的相关描述,本申请在此不再赘述。
S117:通过监听器监听到第三输入事件时,桌面应用通知SurfaceFlinger停止绘制返回动画,准备绘制过渡图像帧,并绘制第二启动动画。
在电子设备以第二动效绘制方式绘制返回动画(可以理解为SurfaceFlinger绘制返回动画)的过程中,桌面应用可以基于监听器监听输入模块发送的输入事件,在通过监听器监听到输入模块向桌面应用发送第三输入事件的情况下,桌面应用可以停止绘制返回动画,也可以理解为cancel绘制返回动画,准备绘制过渡图像帧,并且以第一动效绘制方式绘制第二启动动画。第二启动动画的相关描述可以参考步骤S115,本申请对此不再赘述。
根据上文,也可以理解为,当返回动画还未结束播放时,桌面应用可以接收输入模块发送的第三输入事件,并基于该第三输入事件,停止绘制返回动画,准备绘制过渡图像帧,以第一动效绘制方式绘制第二启动动画。
在本申请的一些实施例中,电子设备在返回动画未结束的情况下接收到用户点击第一应用窗口或第一应用图标的操作(或称输入模块在返回动画未结束的情况下得到第三输入事件),则桌面应用可以确定第三输入事件为中断返回动画的输入事件,在这种情况下,桌面应用可以通过给返回动画对象设置的监听器监听到该第三输入事件。
可理解,根据步骤S116,桌面应用以第二动效绘制方式绘制返回动画,则桌面应用停止绘制返回动画,具体可以包括:桌面应用通知SurfaceFlinger停止基于绘制参数来绘制合成返回动画的图像帧,也可以理解为桌面应用通知SurfaceFlinger停止基于绘制参数来绘制返回动画的图像帧所对应的图层。
在本申请的一些实施例中,返回动画可以包括图标图层、桌面图层(例如,第二桌面图层)和应用图层。桌面应用停止绘制返回动画,或称通知SurfaceFlinger停止基于绘制参数来绘制合成返回动画的图像帧,具体可以包括:桌面应用可以针对应用图层设置setAnimState(2),表示取消对应用图层的绘制,而不针对桌面图层设置setAnimState(2)。
下面结合图8介绍步骤S117的一种具体实现方式。可理解,基于桌面应用通过监听器监听到的第三输入事件,桌面应用停止绘制返回动画的具体实现方式可以包括步骤S201-
步骤S203,桌面应用准备绘制过渡图像帧的具体实现方式可以包括步骤S204-步骤S210,桌面应用以第一动效绘制方式绘制第二启动动画的具体实现方式可以包括步骤S211-步骤S212。
S201:桌面应用销毁图标图层。
根据上文,在以第二动效绘制方式绘制动画的过程中,桌面图层(例如,第二桌面图层)、图标图层和应用图层被绘制、合成后显示在电子设备的显示屏上。可理解,在桌面应用以第二动效绘制方式绘制返回动画的过程中,桌面应用可以创建图标图层。
具体地,在以第二动效绘制方式绘制返回动画的过程中,桌面应用可以将返回动画包括的多个图像帧对应的多组绘制参数发送给SurfaceFlinger,SurfaceFlinger可以基于该多组绘制参数绘制桌面图层、图标图层和应用图层,并对其进行合成,得到待显示图像帧,然后送至显示屏进行显示。其中,每一组绘制参数可以包括桌面图层(例如,第二桌面图层)对应的绘制参数、图标图层对应的绘制参数和应用图层对应的绘制参数。
桌面应用接收输入模块发送的第三输入事件之后,或称基于通过监听器监听到的第三输入事件,可以销毁图标图层。可理解,销毁图标图层后,桌面应用无需获取其对应的绘制参数,SurfaceFlinger也无需绘制图标图层。
S202:桌面应用通知SurfaceFlinger停止绘制返回动画。
桌面应用销毁图标图层之后,可以通知SurfaceFlinger停止基于绘制参数来绘制返回动画的图像帧对应的图层,以及停止基于绘制得到的图层合成返回动画的图像帧。在本申请的一些实施例中,桌面应用通知SurfaceFlinger停止绘制返回动画之后,SurfaceFlinger可以接收桌面应用发送的停止绘制返回动画的通知,并基于该通知停止绘制返回动画。在本申请的一些实施例中,桌面应用可以直接通过调用相应函数来通知SurfaceFlinger停止绘制返回动画,在这种情况下,桌面应用不会接收到相应通知。
在本申请的一些实施例中,桌面应用销毁图标图层之后,可以针对应用图层调用设置setAnimState(2),表示取消对应用图层的绘制,而不针对桌面图层设置setAnimState(2),表示不取消对桌面图层的绘制。可理解,桌面针对应用图层调用设置setAnimState(2)之后,SurfaceFlinger可以停止绘制应用图层。
S203:SurfaceFlinger停止绘制返回动画。
桌面应用通知SurfaceFlinger停止绘制返回动画之后,SurfaceFlinger可以停止基于绘制参数来绘制返回动画的图像帧对应的图层,以及停止基于绘制得到的图层合成返回动画的图像帧。具体地,SurfaceFlinger可以停止绘制应用图层,但是仍然绘制桌面图层(具体可以参考下文)。
S204:桌面应用确定返回动画的第Z个图像帧中的桌面图层所对应的绘制参数,以及根据返回动画的播放时长,计算返回动画的第N2个图像帧中的应用图层所对应的绘制参数和返回动画的第N2个图像帧中的桌面图层所对应的绘制参数。返回动画的第N2个图像帧为停止构建返回动画前电子设备显示的最后一个返回动画的图像帧。
为了便于理解和描述,本申请将电子设备停止绘制返回动画(或称停止播放/构建返回动画)前显示的最后一个返回动画的图像帧(或称最后一帧返回动画的图像)记为返回动画的第N2个图像帧(如图3A和图3B所示)。
桌面应用通知SurfaceFlinger停止绘制返回动画之后,可以确定返回动画的最后一个图像帧(或称返回动画的第Z个图像帧)中的桌面图层所对应的绘制参数,以及根据返回动画的播放时长,来计算返回动画的第N2个图像帧中的应用图层所对应的绘制参数和桌面图层(例如,第二桌面图层)所对应的绘制参数。具体地,桌面应用可以结合返回动画的播放时长、返回动画的总帧数(即上文所提及的Z),以及屏幕刷新率(表示每秒钟刷新显示图像帧的频率),来确定电子设备停止构建返回动画(或称停止播放返回动画)前显示的最后一个返回动画的图像帧所对应的帧数序号,即N2,并确定返回动画的第N2个图像帧对应的绘制参数(可称为第N2组绘制参数)。可理解,该第N2组绘制参数可以包括返回动画的第N2个图像帧中的应用图层对应的绘制参数,以及返回动画的第N2个图像帧中的桌面图层对应的绘制参数。
S205:桌面应用向SurfaceFlinger发送返回动画的第Z个图像帧中的桌面图层所对应的绘制参数。
桌面应用确定返回动画的第Z个图像帧中的桌面图层所对应的绘制参数之后,可以将其发送给SurfaceFlinger。相应的,SurfaceFlinger可以接收桌面应用发送的返回动画的第Z个图像帧中的桌面图层所对应的绘制参数。
S206:SurfaceFlinger基于返回动画的第Z个图像帧中的桌面图层所对应的绘制参数,绘制桌面图层。
可理解,在以第二动效绘制方式绘制返回动画的过程中,桌面应用将返回动画中的多个图像帧对应的多组绘制参数发送给SurfaceFlinger,在本申请的一些实施例中,SurfaceFlinger可以从桌面应用发送的该多组绘制参数中查找返回动画的最后一个图像帧(或称返回动画的第Z个图像帧)对应的绘制参数。返回动画的第Z个图像帧对应的绘制参数可以包括该第Z个图像帧中的桌面图层对应的绘制参数。
在本申请的又一些实施例中,桌面应用可以确定返回动画的第Z个图像帧中的桌面图层对应的绘制参数,并将其发送给SurfaceFlinger,具体可以参考步骤S204-步骤S205。
SurfaceFlinger接收桌面应用发送的返回动画的第Z个图像帧中的桌面图层所对应的绘制参数之后,可以基于返回动画的第Z个图像帧中的桌面图层所对应的绘制参数,来绘制桌面图层,绘制得到的桌面图层与返回动画的第Z个图像帧中的桌面图层一致,包括桌面图层的尺寸和内容都一致。也就是说,将桌面图层调整(或称调节)为返回动画完全结束的状态,即调整为返回动画完全结束时电子设备所显示的图像帧(或称电子设备的第Z个图像帧)中的桌面图层。
S207:桌面应用基于返回动画的第N2个图像帧中的桌面图层所对应的绘制参数,调整SurfaceFlinger绘制得到的桌面图层中的内容的尺寸。
在SurfaceFlinger基于返回动画的第Z个图像帧中的桌面图层所对应的绘制参数,来绘制桌面图层之后,桌面应用可以基于返回动画的第N2个图像帧中的桌面图层所对应的绘制参数,来调整该绘制得到的桌面图层中的内容(例如,除第一应用图标外的其他应用图标或组件)的尺寸,得到绘制调整后的桌面图层。也就是说,将该绘制得到的桌面图层中的内容的尺寸调整为电子设备停止播放返回动画前显示的最后一帧返回动画的图像帧中的相应内容的尺寸。
需要说明的是,在以第二动效绘制方式绘制动画的过程中,动画图像帧中的桌面图层的尺寸和其中内容的尺寸是作为一个整体来进行调节的。例如,以桌面界面中的桌面图层的尺寸为参考,在以第二动效绘制方式绘制动画(例如,启动动画、返回动画等)的过程中,SurfaceFlinger绘制动画的某一个图像帧中的桌面图层,具体可以在上述参考尺寸的基础上将桌面图层和其中内容缩小至其80%,而绘制该动画的下一个图像帧中的桌面图层,具体可以在上述参考尺寸的基础上将桌面图层和其中内容缩小至其60%。在本申请的一些实施例中,启动动画的第一个图像帧中的桌面图层的缩放比例为1,启动动画的最后一个图像帧中的桌面图层的缩放比例为0.9,返回动画的第一个图像帧中的桌面图层的缩放比例为0.9,返回动画的最后一个图像帧中的桌面图层的缩放比例为1,可理解,介于第一个图像帧和最后一个图像帧之间的图像帧中的桌面图层的缩放比例可以基于动画的图像帧数量调整。
然而,根据步骤S206和步骤S207的相关描述,在SurfaceFlinger停止绘制返回动画(具体可以指停止绘制应用图层)之后,SurfaceFlinger可以首先将桌面图层的尺寸和其中内容作为一个整体来绘制,具体可以绘制得与返回动画的第Z个图像帧中的桌面图层一致,桌面应用再对该SurfaceFlinger绘制的桌面图层中的内容的尺寸进行调整,该内容的尺寸具体可以调整得与返回动画的第N2个图像帧中的相应内容的尺寸一致,最终,SurfaceFlinger得到的绘制调整后的桌面图层的尺寸与返回动画的第Z个图像帧中的桌面图层一致,而其内容的尺寸与返回动画的第N2个图像帧中的相应内容的尺寸一致。也就是说,该绘制调整后的桌面图层的尺寸和其内容的缩放程度不是完全一致的。例如,以桌面界面中的桌面图层的尺寸为参考,在以第二动效绘制方式构建返回动画的过程中,该返回动画被打断,且该返回动画被打断时电子设备显示的返回动画的第N2个图像帧中的桌面图层已缩小至上述参考尺寸的80%,在该返回动画被打断后,SurfaceFlinger可以将桌面图层恢复为上述参考尺寸,桌面应用可以将该恢复尺寸后的桌面图层中的内容缩小至上述参考尺寸的80%,也就是说,SurfaceFlinger最终绘制得到的桌面图层(即过渡图像帧中的桌面图层)的尺寸与上述参考尺寸一致,并且该桌面图层中的内容仍为上述参考尺寸的80%。
在本申请的一些实施例中,完整的启动动画(例如,第一启动动画)的第一个图像帧中的桌面图层的缩放比例为1,其最后一个图像帧中的桌面图层的缩放比例为0.9,类似的,完整的返回动画的第一个图像帧中的桌面图层的缩放比例为0.9,其最后一个图像帧中的桌面图层的缩放比例为1,若返回动画被打断,则SurfaceFlinger将桌面图层从返回动画被打断时的缩放比例(例如,0.95)恢复至1,再将桌面图层中的内容的缩放比例由1调整为返回动画被打断时的缩放比例(例如,0.95)。
还需要说明的是,对于用户来说,桌面图层中的内容是可见的,但是其大小是不可见的,也可以将其理解为绘制有可见内容的透明图层。
在本申请的一些实施例中,桌面应用可以通过调用scheduleApply()方法来实现过渡图像帧的绘制。scheduleApply()方法可以包括针对桌面图层的缩放比例设置方法,比如针对桌面图层设置的scaleX()和scaleY(),还可以包括针对桌面图层中的内容的缩放比例设置方法,比如针对桌面图层中的内容设置的scaleX()和scaleY(),具体可以给workSpace和hotSeat
分别设置scaleX(),scaleY()。示例性的,scheduleApply()方法可以包括给桌面图层设置scaleX(1.0f)和scaleY(1.0f),以及给workSpace和hotSeat分别设置scaleX(0.95f)和scaleY(0.95f)。其中,scaleX(1.0f)表示在X方向上的缩放比例调整为1,scaleY(1.0f)表示在Y方向上的缩放比例调整为1,类似的,scaleX(0.95f)表示在X方向上的缩放比例调整为0.95,scaleY(0.95f)表示在Y方向上的缩放比例调整为0.95。workSpace和hotSeat表示的是桌面部分(或称桌面区域),可理解为view,workSpace可以包括系统默认加载、用户手动拖入和应用自动生成的图标,hotSeat可以包括快捷启动栏。
S208:SurfaceFlinger对绘制调整后的桌面图层与已绘制的返回动画的第N2个图像帧中的应用图层进行合成,得到过渡图像帧。
在SurfaceFlinger完成针对桌面图层的绘制,以及桌面应用对该绘制得到的桌面图层中的内容尺寸进行调整之后,SurfaceFlinger可以对绘制调整后的桌面图层和已绘制的返回动画的第N2个图像帧中的应用图层进行合成,得到已绘制合成的图像帧。为了便于理解和描述,本申请将该图像帧记为过渡图像帧。
可理解,已绘制的返回动画的第N2个图像帧中的应用图层可以是在电子设备显示返回动画的第N2个图像帧前SurfaceFlinger已绘制得到的应用图层,也可以是SurfaceFlinger接收返回动画的第N2个图像帧中的应用图层所对应的绘制参数之后,基于该绘制参数重新绘制得到的应用图层。
为了更直观的表现返回动画的第N2个图像帧和过渡图像帧的区别,下面结合图9A和图9B进行示例性说明。
图9A示出了返回动画的第N2个图像帧中的桌面图层和过渡图像帧中的桌面图层。图9A所示的虚线框表示的是桌面图层(可以理解为透明图层),该虚线框尺寸表示的是桌面图层的尺寸,即桌面图层自身(不包括桌面图层中的内容)的尺寸,图9A所示的小方框表示的是桌面图层中的内容(例如,除第一应用图标外的其他应用图标或组件)。
如图9A所示,过渡图像帧中的桌面图层的尺寸等于返回动画的第Z个图像帧中的桌面图层的尺寸,且过渡图像帧中的桌面图层的尺寸大于返回动画的第N2个图像帧中的桌面图层的尺寸。需要说明的是,该虚线框对于用户来说是不可见的,即上文所提及的桌面图层自身的尺寸对于用户来说是不可见的。
如图9A所示,过渡图像帧中的桌面图层所包括的内容与返回动画的第N2个图像帧中的桌面图层所包括的内容一致,且二者尺寸也一致。值得注意的是,桌面图层所包括的内容对于用户来说是可见的,这也就意味着,在过渡图像帧和返回动画的第N2个图像帧中,用户可见的桌面图层的内容是完全一样的。
如图9A所示,过渡图像帧中的应用图层与返回动画的第N2个图像帧中的应用图层完全一致。
示例性的,如图4A所示,用户打断电子设备启动相机应用的过程中所播放的动画(即启动动画)之后,再触发电子设备返回桌面,并打断返回桌面的过程中电子设备所播放的动画(即返回动画)。如图4A所示,电子设备停止播放返回动画前显示的最后一帧返回动画的图像帧为返回动画被打断图像帧1c。如图9B所示,过渡图像帧中的桌面图层的尺寸等于返回动画的第Z个图像帧中的桌面图层的尺寸,且过渡图像帧中的桌面图层的尺寸大
于返回动画的第N2个图像帧中的桌面图层的尺寸,并且,过渡图像帧中其他应用图标(除相机应用图标101外的图标)的尺寸和位置分别与返回动画被打断图像帧1c中其他应用图标的尺寸和位置完全一致。可理解,该其他应用图标即为桌面图层中的内容,其为用户可见的内容。过渡图像帧中的相机应用窗口102和返回动画被打断图像帧1c的尺寸、位置和内容完全一致。
S209:SurfaceFlinger向显示驱动发送过渡图像帧。
SurfaceFlinger绘制合成过渡图像帧之后,可以将过渡图像帧发送给显示驱动。相应的,显示驱动可以接收SurfaceFlinger发送的过渡图像帧。
S210:显示驱动控制显示屏显示过渡图像帧。
显示驱动接收SurfaceFlinger发送的过渡图像帧之后,可以控制显示屏显示该过渡图像帧。
S211:桌面应用将动效标志位设置为false。
桌面应用计算得到返回动画的第N2个图像帧中的应用图层所对应的绘制参数和返回动画的第N2个图像帧中的桌面图层所对应的绘制参数之后,可以将动效标志位设置为false,表示电子设备以第一动效绘制方式绘制当前动画。可理解,这里所提及的当前动画指的是第二启动动画。
可理解,桌面应用可以在执行步骤S204之后执行步骤S211,还可以在执行步骤S205之后执行步骤S211,还可以在执行步骤S207之后执行步骤S211,还可以在SurfaceFlinger执行步骤S206之后执行步骤S211,还可以在SurfaceFlinger执行步骤S208之后执行步骤S211,还可以在显示屏执行步骤S210之后执行步骤S211,本申请对此不作具体限制。
S212:桌面应用基于返回动画的第N2个图像帧中的应用图层所对应的绘制参数,以第一动效绘制方式绘制第二启动动画。
桌面应用可以基于返回动画的第N2个图像帧中的应用图层所对应的绘制参数,来确定第二启动动画的图像帧对应的绘制参数,并基于该第二启动动画对应的绘制参数来以第一动效绘制方式构建第二启动动画。以第一动效绘制方式构建动画的具体实现方式可以参考上文,本申请对此不再赘述。
在本申请的一些实施例中,桌面应用可以基于返回动画的第N2个图像帧中的应用图层所对应的绘制参数和返回动画的第一个图像帧对应的绘制参数,来确定第二启动动画的图像帧对应的绘制参数(例如,上文所提及的缩放比例)。
S118:响应于用户从屏幕底部向上滑动的操作,输入模块向桌面应用发送第四输入事件。
在桌面应用停止绘制返回动画之后,用户可以从屏幕底部向上滑动来触发电子设备返回桌面,相应的,输入模块可以得到第四输入事件,并将第四输入事件发送给桌面应用。桌面应用接收输入模块发送的第四输入事件之后,可以执行步骤S105-步骤S117。
在本申请的一些实施例中,在桌面应用绘制第二启动动画的过程中,输入模块可以向桌面应用发送第四输入事件。在这种情况下,第四输入事件可以理解为桌面应用通过给第二启动动画设置的监听器监听到的中断第二启动动画的输入事件。在本申请的又一些实施例中,在第二启动动画结束(或称完成播放)之后,输入模块可以向桌面应用发送第四输
入事件。
下面结合不同动画显示场景来进一步说明上述动画显示方法。
1、两次打断动画的动画显示场景
示例性的,响应于用户点击第一应用图标的操作,电子设备可以启动第一应用,并在动效标志位为true的情况下,以第二动效绘制方式绘制第一启动动画(如步骤S101-步骤S103),如图10A中的(1)所示,电子设备启动第一应用的过程中可以播放以第二动效绘制方式绘制的第一启动动画。如图10A中的(1)所示,在播放第一启动动画的过程中,用户可以从屏幕底部向上滑动触发电子设备返回桌面(如步骤S104),从而打断第一启动动画的播放(如图10A所示的第1次打断),响应于该向上滑动的操作,电子设备可以确定第一启动动画存在,且第一启动动画还未结束,在这种情况下,电子设备先结束第一启动动画(如步骤S105-步骤S107),如图10A中的(1)所示,电子设备停止绘制第一启动动画,也就是说,电子设备显示第一启动动画被打断图像帧(如图10A所示的第一启动动画的第M1个图像帧)之后,不再进行第一启动动画的下一个图像帧的相关绘制操作。电子设备停止绘制第一启动动画之后,可以确定目标界面为桌面界面(如步骤S108),并确定第二启动动画不存在(如步骤S109),进一步的,基于桌面应用当前并没有绘制动画,电子设备可以确定动效标志位为true(如步骤S112),在这种情况下,如图10A中的(1)所示,电子设备可以以第二动效绘制方式绘制返回动画(如步骤S116)。如图10A中的(1)所示,在播放返回动画的过程中,用户可以点击第一应用窗口或第一应用图标,从而打断返回动画的播放(如图10A所示的第2次打断),响应于该点击操作,电子设备可以停止绘制返回动画,绘制过渡图像帧,并且以第一种动效绘制方式绘制第二启动动画(如步骤S114和步骤S117)。具体地,如图10A中的(1)和(2)所示,在停止播放返回动画前,电子设备显示的最后一个图像帧是返回动画的第N2个图像帧。如图10A中的(2)所示,响应于用户点击第一应用窗口或第一应用图标的操作,电子设备可以计算相应绘制参数来绘制可见内容(例如,第一应用图标,其他应用图标或组件等)与该第N2个图像帧完全一致的一帧过渡图像帧对应的图层,并在基于该图层合成该过渡图像帧之后将其显示在显示屏上,然后以第一动效绘制方式绘制第二启动动画。由于过渡图像帧和返回动画的第N2个图像帧中的内容一致,所以返回动画和该第二启动动画的衔接自然,不会出现较大程度的变化。
下面具体以第一应用为相机应用,第一应用图标为相机应用图标为例来对上述动画显示场景进行说明:
示例性的,如图10B中的(1)所示,用户打断电子设备启动相机应用的过程中所播放的动画(即第一启动动画)之后,再触发电子设备返回桌面,并打断返回桌面的过程中电子设备所播放的动画(即返回动画)。如图10B中的(1)和(2)所示,电子设备停止播放返回动画前显示的最后一帧返回动画的图像帧为返回动画被打断图像帧1c。电子设备可以计算相应绘制参数来绘制可见内容与该返回动画被打断图像帧1c完全一致的一帧过渡图像帧,如图10B中的(2)所示,过渡图像帧中的相机应用窗口102和返回动画被打断图像帧1c中的相机应用窗口102所包括的内容完全一致。电子设备后续可以以第一动效绘制方式绘制第二启动动画。由于在播放以第二动效绘制方式绘制的返回动画和以第一动效绘制方
式绘制的启动动画之间,电子设备会显示过渡图像帧,且过渡图像帧和返回动画的第N2个图像帧中的内容一致,所以该返回动画和该第二启动动画衔接自然,不会出现闪屏或者闪黑的现象。
2、多次打断动画的动画显示场景
示例性的,与上述两次打断动画的动画显示场景类似,响应于用户点击第一应用图标的操作,电子设备可以启动第一应用,并在动效标志位为true的情况下,以第二动效绘制方式绘制第一启动动画(如步骤S101-步骤S103),如图11A中的(1)所示,电子设备启动第一应用的过程中可以播放以第二动效绘制方式绘制的第一启动动画。如图11A中的(1)所示,在播放第一启动动画的过程中,用户可以从屏幕底部向上滑动触发电子设备返回桌面(如步骤S104),从而打断第一启动动画的播放(如图11A所示的第1次打断),响应于该向上滑动的操作,电子设备可以确定第一启动动画存在,且第一启动动画还未结束,在这种情况下,电子设备先结束第一启动动画(如步骤S105-步骤S107),如图11A中的(1)所示,电子设备停止绘制第一启动动画,也就是说,电子设备显示第一启动动画被打断图像帧(如图11A所示的第一启动动画的第M1个图像帧)之后,不再进行第一启动动画的下一个图像帧的相关绘制操作。电子设备停止绘制第一启动动画之后,可以确定目标界面为桌面界面(如步骤S108),并确定第二启动动画不存在(如步骤S109),进一步的,基于桌面应用当前并没有绘制动画,电子设备可以确定动效标志位为true(如步骤S112),在这种情况下,如图11A中的(1)所示,电子设备可以以第二动效绘制方式绘制返回动画(如步骤S116)。如图11A中的(1)所示,在播放返回动画的过程中,用户可以点击第一应用窗口或第一应用图标,从而打断返回动画的播放(如图11A所示的第2次打断),响应于该点击操作,电子设备可以停止绘制返回动画,绘制过渡图像帧,并且以第一种动效绘制方式绘制第二启动动画(如步骤S114和步骤S117)。可理解,电子设备以第一种动效绘制方式绘制第二启动动画的过程中将动效标志位设置为false。具体地,图11A所示的过渡图像帧的相关描述可以参考上文图10A所涉及的过渡图像帧的相关描述,本申请对此不再赘述。
与上述两次打断动画的动画显示场景相区别的是,如图11A中的(2)所示,在播放第二启动动画的过程中,用户可以从屏幕底部向上滑动触发电子设备返回桌面(如步骤S118),从而打断第二启动动画的播放(如图11A所示的第3次打断),响应于该向上滑动的操作,电子设备可以确定第一启动动画不存在且确定目标界面为桌面界面(如步骤S105和步骤S108),然后再确定第二启动动画存在,且第二启动动画还未结束,在这种情况下,电子设备先结束第二启动动画(如步骤S109-步骤S111),如图11A中的(2)所示,电子设备停止绘制第二启动动画,也就是说,电子设备显示第二启动动画被打断图像帧(如图11A所示的第二启动动画的第M1个图像帧)之后,不再进行第二启动动画的下一个图像帧的相关绘制操作。电子设备停止绘制第二启动动画之后,因为是桌面应用绘制的第二启动动画,可以确定动效标志位为false(如步骤S112),在这种情况下,如图11A中的(2)所示,电子设备可以以第一动效绘制方式绘制返回动画(如步骤S113)。
下面具体以第一应用为相机应用,第一应用图标为相机应用图标为例来对上述动画显示场景进行说明:
示例性的,如图11B中的(1)所示,用户打断电子设备启动相机应用的过程中所播放
的动画(即以第二动效绘制方式绘制的第一启动动画)之后,再触发电子设备返回桌面,并打断返回桌面的过程中电子设备所播放的动画(即以第二动效绘制方式绘制的返回动画),即图11B中的(1)所示的第1次打断和第2次打断。如图11B中的(1)和(2)所示,电子设备可以停止播放返回动画,并绘制一帧过渡图像帧(过渡图像帧中的相机应用窗口102和返回动画被打断图像帧1c中的相机应用窗口102所包括的内容完全一致),然后再以第一动效绘制方式来绘制第二启动动画,以实现返回动画和第二启动动画的平滑过渡。在电子设备播放第二启动动画的过程中,用户可以从屏幕底部向上滑动触发电子设备返回桌面,从而打断第二启动动画的播放(如图11B所示的第3次打断),响应于该向上滑动的操作,电子设备可以停止绘制第二启动动画,并以第一动效绘制方式绘制返回动画。
基于本申请实施例提供的上述动画显示方法,在用户多次打断启动动画和返回动画的场景下,电子设备可以及时响应并选择相应的动效绘制方式绘制动画,实现启动动画和返回动画的流畅过渡,从而避免出现闪屏或者闪黑现象。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。
Claims (11)
- 一种动画显示方法,其特征在于,所述方法应用于电子设备,所述方法包括:显示第一界面,所述第一界面为桌面应用的界面,所述第一界面包括第一应用图标;响应于对所述第一应用图标的第一操作,显示第一动画;所述第一应用图标为第一应用对应的应用图标,所述第一动画包括启动所述第一应用的动画;在显示所述第一动画的过程中,响应于返回桌面的第二操作,停止显示所述第一动画,并显示第二动画;所述第二动画包括返回所述第一界面的动画;在显示所述第二动画的过程中,响应于对所述第二动画中的第一图像帧的第三操作,停止显示所述第二动画,并显示第三动画;其中,所述第一动画是被所述电子设备通过图像合成器SurfaceFlinger绘制的,所述第二动画是被所述电子设备通过所述桌面应用绘制的,所述第三动画是被所述电子设备通过所述桌面应用绘制的。
- 如权利要求1所述的方法,其特征在于,所述显示第三动画之后,所述方法还包括:在显示所述第三动画的过程中,响应于返回桌面的第四操作,显示第四动画;所述第四动画包括返回所述第一界面的动画,所述第四动画是被所述电子设备通过所述桌面应用绘制的。
- 如权利要求1所述的方法,其特征在于,所述显示第三动画之后,所述方法还包括:在显示所述第三动画之后,显示所述第一应用的界面;响应于返回桌面的第四操作,显示第四动画;所述第四动画包括返回所述第一界面的动画,所述第四动画是被所述电子设备通过所述SurfaceFlinger绘制的。
- 如权利要求1-3中任一项所述的方法,其特征在于,所述显示第一动画之前,所述方法还包括:响应于所述第一操作,基于动效标志位为第一内容,通过所述SurfaceFlinger绘制所述第一动画;所述响应于返回桌面的第二操作,停止显示所述第一动画,包括:响应于所述第二操作,基于所述第一动画还未结束播放,停止绘制所述第一动画;所述停止显示所述第一动画之后,所述方法还包括:基于目标界面为所述第一界面,当前未绘制所述第三动画,以及所述动效标志位为所述第一内容,通过所述SurfaceFlinger绘制所述第二动画;所述通过所述SurfaceFlinger绘制所述第二动画之后,所述方法还包括:响应于所述第三操作,将所述动效标志位设置为第二内容。
- 如权利要求1-4中任一项所述的方法,其特征在于,所述停止显示所述第二动画,并显示第三动画,包括:停止显示所述第二动画,并显示第二图像帧;所述第二图像帧的内容与所述第一图像 帧的内容相同;在显示所述第二图像帧之后,显示所述第三动画。
- 如权利要求5所述的方法,其特征在于,所述第一图像帧基于第一图层、第二图层和第三图层合成;所述第一图层包括所述第一应用图标,所述第二图层包括除所述第一应用图标外的其他应用图标或组件,所述第三图层为所述第一应用的窗口图层;所述停止显示所述第二动画,包括:销毁所述第一图层;通知所述SurfaceFlinger停止绘制所述第二动画;所述显示第二图像帧之前,所述方法还包括:根据所述第二动画的已播放时长,确定第一绘制参数;所述第一绘制参数为所述第二图层对应的绘制参数;通过所述SurfaceFlinger基于第二绘制参数绘制第四图层,以及通过所述桌面应用基于所述第一绘制参数调整所述第四图层中的内容,得到已绘制的所述第四图层;所述第二绘制参数为所述第二动画的最后一个图像帧对应的绘制参数;通过所述SurfaceFlinger基于已绘制的所述第四图层和已绘制的所述第三图层合成得到所述第二图像帧。
- 如权利要求5或6所述的方法,其特征在于,所述显示所述第三动画之前,所述方法还包括:根据所述第二动画的已播放时长,确定第三绘制参数,所述第三绘制参数为所述第三图层对应的绘制参数;基于所述第三绘制参数确定所述第三动画中每一个图像帧对应的绘制参数,基于所述第三动画中每一个图像帧对应的绘制参数,绘制所述第三动画。
- 如权利要求2所述的方法,其特征在于,所述响应于返回桌面的第四操作,显示第四动画,包括:响应于所述第四操作,基于所述第一动画停止显示,目标界面为所述第一界面,且所述第三动画还未结束播放,停止绘制所述第三动画;基于动效标志位为第二内容,通过所述桌面应用绘制所述第四动画。
- 如权利要求3所述的方法,其特征在于,所述响应于返回桌面的第四操作,显示第四动画,包括:响应于所述第四操作,基于所述第一动画停止显示,目标界面为所述第一界面,所述第三动画已结束播放,且动效标志位为第一内容,通过所述SurfaceFlinger绘制所述第四动画。
- 一种电子设备,其特征在于,所述电子设备包括一个或多个存储器、一个或多个处理器;所述一个或多个存储器与所述一个或多个处理器耦合,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,所述处理器调用所述计算机指令以执行上述权利要求1-9中任一项所述的方法。
- 一种计算机可读存储介质,其特征在于,用于存储计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行上述权利要求1-9中任一项所述的方法。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2024/088136 WO2025217822A1 (zh) | 2024-04-16 | 2024-04-16 | 一种动画显示方法及相关设备 |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2024/088136 WO2025217822A1 (zh) | 2024-04-16 | 2024-04-16 | 一种动画显示方法及相关设备 |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| WO2025217822A1 true WO2025217822A1 (zh) | 2025-10-23 |
| WO2025217822A9 WO2025217822A9 (zh) | 2026-01-08 |
Family
ID=97402801
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2024/088136 Pending WO2025217822A1 (zh) | 2024-04-16 | 2024-04-16 | 一种动画显示方法及相关设备 |
Country Status (1)
| Country | Link |
|---|---|
| WO (1) | WO2025217822A1 (zh) |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090007017A1 (en) * | 2007-06-29 | 2009-01-01 | Freddy Allen Anzures | Portable multifunction device with animated user interface transitions |
| CN108304237A (zh) * | 2017-12-29 | 2018-07-20 | 维沃移动通信有限公司 | 一种移动终端的图像处理方法及装置、移动终端 |
| CN115344178A (zh) * | 2021-05-12 | 2022-11-15 | 荣耀终端有限公司 | 显示方法及电子设备 |
| CN117724781A (zh) * | 2023-07-04 | 2024-03-19 | 荣耀终端有限公司 | 一种应用程序启动动画的播放方法和电子设备 |
| CN117827300A (zh) * | 2023-07-07 | 2024-04-05 | 华为技术有限公司 | 显示方法、图形界面及相关装置 |
-
2024
- 2024-04-16 WO PCT/CN2024/088136 patent/WO2025217822A1/zh active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090007017A1 (en) * | 2007-06-29 | 2009-01-01 | Freddy Allen Anzures | Portable multifunction device with animated user interface transitions |
| CN108304237A (zh) * | 2017-12-29 | 2018-07-20 | 维沃移动通信有限公司 | 一种移动终端的图像处理方法及装置、移动终端 |
| CN115344178A (zh) * | 2021-05-12 | 2022-11-15 | 荣耀终端有限公司 | 显示方法及电子设备 |
| CN117724781A (zh) * | 2023-07-04 | 2024-03-19 | 荣耀终端有限公司 | 一种应用程序启动动画的播放方法和电子设备 |
| CN117827300A (zh) * | 2023-07-07 | 2024-04-05 | 华为技术有限公司 | 显示方法、图形界面及相关装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| WO2025217822A9 (zh) | 2026-01-08 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN109062475B (zh) | 图标显示方法、装置、终端及存储介质 | |
| EP3779684B1 (en) | Icon display method, device and terminal | |
| CN108089786B (zh) | 用户界面显示方法、装置、设备及存储介质 | |
| KR101296052B1 (ko) | 애니메이션 | |
| US8477143B2 (en) | Buffers for display acceleration | |
| EP2245589B1 (en) | Multi-context graphics processing | |
| US10394441B2 (en) | Device, method, and graphical user interface for controlling display of application windows | |
| CN111752666B (zh) | 窗口显示方法、装置和终端 | |
| US20150113455A1 (en) | Operating method for multiple windows and electronic device supporting the same | |
| CN103853424A (zh) | 显示装置和控制显示装置的方法 | |
| CN102112953B (zh) | 信息处理设备 | |
| CN111597000A (zh) | 一种小窗口管理方法及终端 | |
| CN107562323A (zh) | 图标移动方法、装置及终端 | |
| CN108845855A (zh) | 用户界面显示方法、装置、终端及存储介质 | |
| CN108762881A (zh) | 界面绘制方法、装置、终端及存储介质 | |
| CN108170361A (zh) | 一种应用运行状态控制方法及移动终端 | |
| CN105204751A (zh) | 一种触屏设备背景图变换的方法及终端 | |
| WO2022242628A1 (zh) | 投屏方法、装置、设备及存储介质 | |
| WO2025152449A1 (zh) | 一种控制中心的编辑方法以及电子设备 | |
| CN111857480A (zh) | 图标对齐方法、装置、存储介质及电子设备 | |
| CN113419650B (zh) | 一种数据移动方法、装置、存储介质及电子设备 | |
| WO2025217822A9 (zh) | 一种动画显示方法及相关设备 | |
| CN108170362A (zh) | 一种应用运行状态控制方法及移动终端 | |
| US20250264976A1 (en) | Display method, display apparatus, and electronic device | |
| CN119493672B (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: 24935375 Country of ref document: EP Kind code of ref document: A1 |