Refresh rate adjustment method and electronic device
By dynamically adjusting the refresh rate based on view size and speed detection, the problem of inaccurate refresh rate increase during animation execution is solved, achieving better animation display effects and power consumption optimization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-05-17
- Publication Date
- 2026-07-07
AI Technical Summary
Existing technologies cannot accurately increase the refresh rate during animation execution, resulting in poor animation display and affecting user experience, especially in the case of frame-sensitive animations.
By dynamically adjusting the screen refresh rate when the view size exceeds a preset size threshold, identifying frame-sensitive animations and increasing the refresh rate during their execution, and combining the size and speed detection of animation instances, more granular refresh rate control can be achieved.
It improves the display effect of animation, enhances the user experience, saves power consumption, avoids resource waste, and improves the accuracy of refresh rate adjustment and power consumption benefits.
Smart Images

Figure CN121008728B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic technology, specifically to a refresh rate adjustment method and an electronic device. Background Technology
[0002] Dynamic effects, or simply animations, are effects that give interfaces or elements movement and change. Currently, animations have become an indispensable display method for improving user experience during interface display. For example, when displaying the original image corresponding to a thumbnail, a gradually zooming-in animation makes the image more vivid and improves the user's visual experience; another example is the view rotation animation during data loading, which adds interest and reduces the user's waiting time.
[0003] To further improve the display effect of animations, one possible technical solution is to increase the screen refresh rate during the execution of the animation, and then decrease the refresh rate after the animation is completed. Taking view animations as an example, typical view animations are triggered by user clicks. Therefore, in related technologies, if a user touch operation on the corresponding control of a view is detected, it is considered that the animation corresponding to that view has started to execute, and the screen refresh rate is increased.
[0004] However, in practical applications, the effectiveness of this method is closely related to the threshold duration of the screen's idle state, which may lead to issues with the refresh rate not being increased during animation execution. This is because some animations do not execute immediately after a user click, but rather after a certain waiting period. Therefore, although the user's click triggers an increase in the screen refresh rate (e.g., 120Hz), if this waiting period exceeds the threshold for entering the idle state, the screen will enter an idle state, and the refresh rate will be reduced to a lower value (e.g., 60Hz). Afterward, the animation will begin execution, but since user touch input is no longer detected, the refresh rate increase will not be triggered. Thus, during the animation's execution, the screen refresh rate remains at a low 60Hz, failing to achieve the goal of increasing the refresh rate during animation execution, thereby failing to improve the animation's display effect and impacting the user experience. Summary of the Invention
[0005] This application provides a refresh rate adjustment method and an electronic device that can improve the display effect of animation effects and enhance the user experience when the size of the view is greater than a preset size threshold during the execution of animation effects.
[0006] In a first aspect, this application provides a refresh rate adjustment method, which is executed by an electronic device including a screen. The method includes: displaying a first interface on the screen; the first interface including a first control and a second control, wherein the screen refresh rate is a first refresh rate when the first interface is displayed; executing a first animation effect in response to a first operation by a user on the first control, wherein the animation effect object of the first animation effect includes at least one first view, wherein the size of any first view is less than or equal to a preset size threshold; the screen refresh rate is the first refresh rate during the execution of the first animation effect; executing a second animation effect in response to a second operation by a user on the second control, wherein the animation effect object of the second animation effect includes at least one second view, wherein at least one third view exists in the at least one second view, and the third view is a view whose size is greater than the preset size threshold; and at least one first time period exists during the execution of the second animation effect, wherein the screen refresh rate is the second refresh rate during the first time period, and the second refresh rate is greater than the first refresh rate.
[0007] The first motion effect's object includes at least one first view; in other words, the animation effect of at least one first view constitutes the first motion effect. That is, the first motion effect includes the motion effect of at least one first view. The second motion effect is similar.
[0008] The first refresh rate is, for example, 60 Hz, and the second refresh rate can be, for example, 90 Hz or 120 Hz. It can be understood that for electronic devices, different refresh rates correspond to different frame rates. For example, when the refresh rate is the first refresh rate, the frame rate can be the first frame rate. When the refresh rate is the second refresh rate, the frame rate can be the second frame rate, where the second frame rate is greater than the first frame rate. Specifically, after switching from the first refresh rate to the second refresh rate, the electronic device can adjust the generation period of the vertical synchronization signal according to the period length corresponding to the second refresh rate, making them consistent. The change in the generation period of the vertical synchronization signal triggers a change in the frame image rendering period (the period shortens), thereby increasing the frame rate. In other words, increasing the refresh rate will cause an increase in the frame rate, thus improving the animation display effect.
[0009] First, the refresh rate adjustment method provided in the first aspect of this application increases the refresh rate to a second refresh rate during the execution of the second animation effect. This further triggers frame rate adjustment, thereby improving the display effect of the second animation effect and enhancing the user experience. Second, the objects affected by the first animation effect, i.e., the views involved in the first animation effect (first view), are all smaller than or equal to a preset size threshold, indicating that the first animation effect does not involve frame-sensitive animation effects. Therefore, during the execution of the first animation effect, the refresh rate is maintained at a lower first refresh rate. The objects affected by the second animation effect, i.e., the views involved in the second animation effect (second view), have at least one view whose size is larger than the preset size threshold, indicating that the second animation effect may involve frame-sensitive animation effects. Therefore, during the execution of the second animation effect, the refresh rate is increased. In other words, this method increases the refresh rate when frame-sensitive animation effects may be involved, and maintains a low refresh rate when frame-sensitive animation effects are not involved. This not only improves the display effect of frame-sensitive animation effects but also saves power consumption, increasing the power efficiency of electronic devices.
[0010] In one possible implementation, during a first time period, the rate of change of at least one third view is greater than a first speed threshold.
[0011] In this embodiment of the application, the speed of view change is also the speed of the animation effect corresponding to the view (i.e., the view animation effect).
[0012] The third view refers to a second view whose size is larger than a preset size threshold. If the rate of change of at least one third view is greater than a first speed threshold, it indicates that at least one frame-sensitive animation effect exists among the view animation effects involved in the second animation effect. In other words, during the execution of the second animation effect, when a frame-sensitive animation effect is executed, the refresh rate is increased to improve the display effect of the animation, thereby enhancing the user experience.
[0013] In one possible implementation, during a second time period in the execution of the second animation effect, the screen refresh rate is a third refresh rate, which is greater than the second refresh rate; during the second time period, the change speed of at least one third view is greater than a second speed threshold, which is greater than a first speed threshold.
[0014] In this implementation, for frame-sensitive animations, different higher refresh rates can be matched based on the speed of view changes. Specifically, when the animation speeds of all frame-sensitive animations are relatively slow (greater than a first speed threshold but less than a second speed threshold), the refresh rate is set to the second refresh rate; when at least one frame-sensitive animation has a relatively fast animation speed (greater than the second speed threshold), the refresh rate is set to the third refresh rate. This allows for finer-grained refresh rate adjustment during animation execution, thereby achieving finer-grained frame rate control, improving the user's frame rate experience while further saving power consumption of electronic devices.
[0015] In one possible implementation, during the third time period in the process of executing the second animation, the screen refresh rate is the first refresh rate; during the third time period, the change rate of each third view is less than or equal to the first speed threshold.
[0016] In other words, if there are no frame-sensitive animations during the third time period, the screen refresh rate will remain at the first refresh rate. This prevents the need for power saving and improves the power efficiency of electronic devices.
[0017] In one possible implementation, in response to a second user action on a second control, executing a second animation effect includes: in response to the second action, creating at least one animation effect instance, each animation effect instance corresponding to a second view; executing each animation effect instance; before executing each animation effect instance, or during the execution of each animation effect instance, determining a third view in at least one second view; during the execution of the animation effect instances corresponding to each third view, detecting the change speed of each third view; and setting the screen refresh rate based on the change speed of each third view.
[0018] The animation effects of each view are implemented through animation effect instances. In this implementation, animation effects for each view are achieved by creating and executing corresponding animation effect instances, thus realizing the second animation effect. Before or during the execution of each animation effect instance, views larger than a size threshold (i.e., the third view) in the second view are identified, which are likely to be frame-sensitive animation effects. For the third view, the screen refresh rate is adjusted by detecting the view's change speed. In other words, this method can identify frame-sensitive animation effects. When frame-sensitive animation effects are present, the refresh rate is increased to prevent animation stuttering and improve the user's visual experience; when frame-sensitive animation effects are absent, the refresh rate is decreased, effectively saving power consumption of electronic devices, preventing resource waste, and improving power efficiency.
[0019] In one possible implementation, before or during the execution of each motion effect instance, determining at least one third view in the second view includes: during the startup of the fourth motion effect instance, or after the startup of the fourth motion effect instance, if it is determined that the size of the fourth view is greater than a preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth motion effect instance is set to a first value; the fourth motion effect instance can be any motion effect instance, and the fourth view is the view corresponding to the fourth motion effect instance; during the execution of the motion effect instances corresponding to each third view, detecting the change speed of each third view includes: in each frame cycle of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is the first value, then detecting the change speed of the fourth view; based on the change speed of each third view, setting the screen refresh rate includes: in each frame cycle, if the change speed of at least one third view is greater than a first speed threshold, then setting the screen refresh rate to a second refresh rate or a third refresh rate, wherein the third refresh rate is greater than the second refresh rate.
[0020] The first flag is also the speed detection flag.
[0021] In this implementation, the size of the view is determined, motion speed is detected, and the refresh rate is adjusted during or after the animation instance starts. In other words, this method can identify the start of an animation instance and adjust the refresh rate at or during its startup, solving the problem in related technologies where the refresh rate cannot be accurately increased during animation execution. This improves the accuracy of refresh rate adjustment. Furthermore, this method performs motion speed detection on the third view in each frame cycle, identifying frame-sensitive animations in each frame cycle and controlling the refresh rate based on the detection results. This achieves dynamic refresh rate adjustment, rather than being limited to adjusting the refresh rate at the start and end of the animation, improving the fineness and accuracy of refresh rate adjustment during animation execution, further saving power consumption of electronic devices and increasing power efficiency.
[0022] In one possible implementation, the electronic device includes a ValueAnimator, a motion effect manager, and a view drawing module. The fourth motion effect instance is created by the ValueAnimator. During the startup of the fourth motion effect instance, or after the fourth motion effect instance is started, if it is determined that the size of the fourth view is greater than a preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth motion effect instance is set to the first value. This includes: before the ValueAnimator executes the callOnList() function of the fourth motion effect instance for the first time, it sends a first notification to the motion effect manager; after receiving the first notification, the motion effect manager sets the value of the second flag to the third value; during the execution of the setting function of the fourth view, if the value of the second flag is determined to be the third value, the view drawing module determines whether the size of the fourth view is greater than the preset size threshold; if it is determined that the size of the fourth view is greater than the preset size threshold, the view drawing module determines that the fourth view is the third view, and the view drawing module sends the information of the fourth view to the motion effect manager; after receiving the information of the fourth view, the motion effect manager sets the value of the first flag corresponding to the fourth motion effect instance to the first value.
[0023] The first notification is the attribute value update notification. The second flag is the matching flag. The setting function can be the setXXX() function in the specific implementation, including but not limited to at least one of the following functions: setTranslationX(), setTranslationY(), setRotation(), setScaleX(), setScaleY(), setImageMatrix(), or scollTo().
[0024] When implementing view animations, the value-based animation generator cannot directly obtain information about the view corresponding to the animation instance. Therefore, in this embodiment, the value-based animation generator considers the animation instance to be in a pending-matching state when the `callOnList()` function of the animation instance begins execution. On the other hand, when the view drawing module executes the `setXXX()` function for a certain view, it considers that view to be in a pending-matching state as well. Simultaneously, animation instances and views in the pending-matching state are matched, and the animation management module performs size and speed detection on the view based on their correspondence. In this way, the matching of animation instances and views created by the value-based animation generator is achieved simply and accurately, improving the accuracy of the first flag assignment and thus improving the accuracy of the algorithm.
[0025] In one possible implementation, the method further includes: after the value animation generator finishes executing the callOnList() function of the fourth animation instance for the first time, it sends a second notification to the animation manager; after receiving the second notification, the animation manager sets the value of the second flag to the fourth value.
[0026] The second notification is also the notification to end the update process.
[0027] In one possible implementation, the first notification carries information about the fourth motion effect instance; in each frame cycle of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is a first value, the change speed of the fourth view is detected, including: during the execution of the setting function of the fourth view in each frame cycle, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is a first value, the change speed of the fourth view is detected; if the change speed of the fourth view is greater than a first speed threshold, the view drawing module sends a third notification to the motion effect manager; after receiving the third notification, the motion effect manager records the information of the fourth motion effect instance in a first set; if the change speed of the fourth view is less than or equal to the first speed threshold, the view drawing module sends a fourth notification to the motion effect manager; after receiving the fourth notification, if it is determined that the first set contains the information of the fourth motion effect instance, the motion effect manager deletes the information of the fourth motion effect instance.
[0028] The third notification is also known as the speeding notification. The fourth notification is also known as the no-speeding notification. The first set is also known as the speeding set.
[0029] In this implementation, different detection results for the change speed of the fourth view result in different notifications sent to the animation manager. The animation manager manages the first set based on these different notifications. In other words, the animation manager can uniformly manage the animation instances corresponding to each view based on the first set. Subsequently, it can accurately control the refresh rate during animation execution based on the first set, reducing the coupling of methods used by different animation classes, improving management consistency and uniformity, and thus improving algorithm efficiency.
[0030] In the above implementation methods, the sending of the first and second notifications from the value animation device to the animation manager is implemented in the callOnList() function. The detection of the size of the fourth view, the detection and judgment of the change speed of the fourth view, etc. are implemented in the setXXX() function. That is, the method provided by the embodiments of this application can be embedded in the original animation implementation process. In this way, no additional traversal process is added, the load is reduced, and power consumption is saved.
[0031] In one possible implementation, the third notification carries information about the fourth view; after the view drawing module sends the information about the fourth view to the motion effect manager, the method further includes: after receiving the information about the fourth view, the motion effect manager records the information about the fourth view and the information about the fourth motion effect instance, and establishes a mapping relationship between the fourth view and the fourth motion effect instance; after receiving the third notification, the motion effect manager records the information about the fourth motion effect instance to the first set, including: after receiving the third notification, the motion effect manager determines the motion effect instance corresponding to the fourth view as the fourth motion effect instance based on the information about the fourth view and the mapping relationship between the fourth view and the fourth motion effect instance; the motion effect manager records the fourth motion effect instance to the first set.
[0032] In one possible implementation, the method further includes: after the fourth animation instance finishes execution, the animation manager sets the value of the first flag corresponding to the fourth animation instance to the second value, and deletes the information of the fourth view, the information of the fourth animation instance, and the mapping relationship between the fourth view and the fourth animation instance.
[0033] After the fourth animation instance ends, the value of the first flag corresponding to the fourth animation instance is set to the second value. This way, the view rendering module, based on the value of the fourth animation instance flag, no longer detects the speed of change in the fourth view, preventing program errors and wasted power. Furthermore, after the fourth animation instance ends, the animation manager clears the information of that animation instance and no longer manages it. Subsequent detection of the size or speed of that animation instance is also stopped. This prevents wasted power and facilitates accurate refresh rate control based on information from other animation instances, or facilitates subsequent management of other animation instances in the same process for refresh rate adjustment, improving the accuracy of refresh rate adjustments.
[0034] In one possible implementation, the method further includes: after a first preset duration following the creation of the fourth motion effect instance, the motion effect manager sets the value of the first flag corresponding to the fourth motion effect instance to a second value based on the recorded information of the fourth motion effect instance, and deletes the information of the fourth view, the information of the fourth motion effect instance, and the mapping relationship between the fourth view and the fourth motion effect instance.
[0035] In other words, the motion effect manager can set a time limit for clearing motion effect instances and resetting the first flag. This allows for the timely clearing of motion effect instances in cases where abnormalities occur during their operation, preventing the sending of motion effect end notifications and thus improving the accuracy of the algorithm.
[0036] In one possible implementation, the electronic device includes an ObjectAnimator and a motion manager, with the fourth motion instance created by the ObjectAnimator. During the startup of the fourth motion instance, or after the fourth motion instance has started, if it is determined that the size of the fourth view is greater than a preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth motion instance is set to a first value. This includes: during the execution of the `startAnimation()` function on the fourth motion instance, the ObjectAnimator determines whether the size of the fourth view bound to the fourth motion instance is greater than the preset size threshold; if it is determined that the size of the fourth view is greater than the preset size threshold, the ObjectAnimator determines the fourth view to be the third view, and sends the information of the fourth view to the motion manager; after receiving the information of the fourth view, the motion manager sets the value of the first flag corresponding to the fourth motion instance to the first value.
[0037] In one possible implementation, the electronic device further includes a view drawing module; in each frame cycle of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is a first value, the change speed of the fourth view is detected, including: during the execution of the setting function of the fourth view in each frame cycle, if the determined value of the first flag is a first value, the view drawing module detects the change speed of the fourth view; if the change speed of the fourth view is greater than a first speed threshold, the view drawing module sends a third notification to the motion effect manager; after receiving the third notification, the motion effect manager records the information of the fourth motion effect instance in a first set; if the change speed of the fourth view is less than or equal to the first speed threshold, the view drawing module sends a fourth notification to the motion effect manager; after receiving the fourth notification, if it is determined that the first set contains the information of the fourth motion effect instance, the motion effect manager deletes the information of the fourth motion effect instance.
[0038] In the above process, the detection of the fourth view size is implemented in the `startAnimation()` function, and the motion effect speed detection and judgment are implemented in the `setXXX()` function. That is, the method provided in this application embodiment can be embedded in the existing motion effect implementation process of the object motion effector. In this way, no additional traversal process is added, reducing the load and saving power consumption. Moreover, the detection of the view size is implemented in the `startAnimation()` function, so that the process of this solution is triggered when the motion effect starts to execute. Therefore, the screen refresh rate and frame rate can be accurately adjusted, improving the accuracy of refresh rate control and thus improving the user's frame rate experience.
[0039] In one possible implementation, the electronic device includes a view animation generator (View.Animation) and a view drawing module, with the fourth animation instance created by the view animation generator. During the startup of the fourth animation instance, or after the fourth animation instance has started, if it is determined that the size of the fourth view is greater than a preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth animation instance is set to a first value. This includes: the view drawing module executing the applyLegacyAnimation() function of the fourth view to call the view animation generator to execute the fourth animation instance; during the execution of the applyLegacyAnimation() function of the fourth view, the view drawing module determines whether the size of the fourth view is greater than the preset size threshold; if the size of the fourth view is greater than the preset size threshold, then the view drawing module determines the fourth view to be the third view, and the view drawing module sets the value of the first flag corresponding to the fourth animation instance to the first value.
[0040] In one possible implementation, the electronic device further includes a motion effect manager; in each frame cycle of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is a first value, the change speed of the fourth view is detected, including: the view animator responds to the call of the view drawing module by executing the getTransformation() function to execute the fourth motion effect instance, the getTransformation() function including the applyTransformation() function; during the execution of the applyTransformation() function of the fourth motion effect instance in each frame cycle, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is a first value, the change speed of the fourth view is detected; if the change speed of the fourth view is greater than a first speed threshold, the view animator sends a third notification to the motion effect manager, the third notification carrying information about the fourth motion effect instance; after receiving the third notification, the motion effect manager records the information about the fourth motion effect instance in a first set; if the change speed of the fourth view is less than or equal to the first speed threshold, the view animator sends a fourth notification to the motion effect manager, the fourth notification carrying information about the fourth motion effect instance; after receiving the fourth notification, if it is determined that the first set contains information about the fourth motion effect instance, the motion effect manager deletes the information about the fourth motion effect instance.
[0041] In one possible implementation, the applyTransformation() function also includes a startAnimation() function, which further includes: during the execution of the startAnimation() function of the fourth animation instance, the view animator determines whether the value of the first flag corresponding to the fourth animation instance is the first value; if the value of the first flag corresponding to the fourth animation instance is the first value, the view animator sends the information of the fourth animation instance to the animation manager; the animation manager records the information of the fourth animation instance.
[0042] In the above process, the detection of the fourth view size is implemented in the `applyLegacyAnimation()` function, and the detection and judgment of the fourth view's change speed are implemented in the `applyTransformation()` function. That is, the method provided in this embodiment can be embedded into the existing animation implementation process of the view animator, thus avoiding additional traversal processes, reducing load, and saving power. Furthermore, since the view size detection is implemented in the `applyTransformation()` function, which calls the view animator to start the animation, the process of this solution is triggered when the animation begins execution. Therefore, it can accurately adjust the screen refresh rate and frame rate, improve the accuracy of refresh rate control, and thus improve the user's frame rate experience.
[0043] In one possible implementation, the method further includes: after the fourth animation instance finishes execution, the animation manager sets the value of the first flag corresponding to the fourth animation instance to the second value, and deletes the information of the fourth animation instance.
[0044] After the fourth animation instance ends, the value of the first flag corresponding to the fourth animation instance is set to the second value. This way, the view rendering module, based on the value of the fourth animation instance flag, no longer detects the speed of change in the fourth view, preventing program errors and wasted power. Furthermore, after the fourth animation instance ends, the animation manager clears the information of that animation instance and no longer manages it. Subsequent detection of the size or speed of that animation instance is also stopped. This prevents wasted power and facilitates accurate refresh rate control based on information from other animation instances, or facilitates subsequent management of other animation instances in the same process for refresh rate adjustment, improving the accuracy of refresh rate adjustments.
[0045] In one possible implementation, the method further includes: after a second preset duration following the creation of the fourth motion effect instance, the motion effect manager sets the value of the first flag corresponding to the fourth motion effect instance to a second value based on the recorded information of the fourth motion effect instance, and deletes the information of the fourth motion effect instance.
[0046] In other words, the motion effect manager can set a time limit for clearing motion effect instances and resetting the first flag. This allows for the timely clearing of motion effect instances in cases where abnormalities occur during their operation, preventing the sending of motion effect end notifications and thus improving the accuracy of the algorithm.
[0047] In one possible implementation, the electronic device includes a ViewPropertyAnimator, and the fourth animation instance is created by the ViewPropertyAnimator. During the startup of the fourth animation instance, or after the fourth animation instance is started, if it is determined that the size of the fourth view is greater than a preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth animation instance is set to a first value. This includes: during the execution of the start() function of the fourth animation instance, the ViewPropertyAnimator determines whether the size of the fourth view is greater than the preset size threshold; if it is determined that the size of the fourth view is greater than the preset size threshold, then the ViewPropertyAnimator determines the fourth view to be the third view, and the ViewPropertyAnimator sets the value of the first flag corresponding to the fourth animation instance to the first value.
[0048] In one possible implementation, the electronic device further includes a motion effect manager and a view drawing module. The view property animation effecter includes a motion effect event listener, which includes an onAnimationUpdate() function. The onAnimationUpdate() function includes a setValue() function, which is used to set the attribute value of the fourth view. In each frame cycle of the second animation effect, if it is determined that the value of the first flag corresponding to the fourth animation effect instance is the first value, the change speed of the fourth view is detected, including: the view property animation effecter executes onAnimationUpdate() in each frame cycle. During the `setValue()` function of the `()` function, the change rate of the fourth view is detected. If the change rate of the fourth view is greater than the first speed threshold, the view attribute animator sends a third notification to the animation manager, which carries information about the fourth animation instance. After receiving the third notification, the animation manager records the information about the fourth animation instance in the first set. If the change rate of the fourth view is less than or equal to the first speed threshold, the view attribute animator sends a fourth notification to the animation manager, which carries information about the fourth animation instance. After receiving the fourth notification, if the animation manager determines that the first set contains information about the fourth animation instance, it deletes the information about the fourth animation instance.
[0049] In the above process, the detection of the fourth view size is implemented in the `onAnimationStart()` function, and the detection and judgment of the fourth view's change speed are implemented in the `setValue()` function. That is, the method provided in this embodiment can be embedded into the existing animation implementation process of the view attribute animator, thus avoiding additional traversal processes, reducing load, and saving power. Furthermore, the view size detection is implemented in the `onAnimationStart()` function, which signifies the start of the instance created by the view attribute animator. In other words, the process of this solution is triggered when the animation begins to execute, thereby accurately adjusting the screen refresh rate and frame rate, improving the accuracy of refresh rate control, and ultimately enhancing the user's frame rate experience.
[0050] In one possible implementation, the view property animator also includes a value animator. The method further includes: during the execution of the start() function of the fourth animation instance, the view property animator sets the value of the third flag bit of the value animator to the fifth value, whereby the value animator being called by the view property animator indicates that the value animator is called by the view property animator; in response to the call to the start() function, during the execution of the startAnimation() function of the fourth animation instance, if the value animator determines that the value of the third flag bit is the fifth value, then it does not send a first notification to the animation manager before the first execution of the callOnList() function of the fourth animation instance.
[0051] The third flag is the isViewPropertyAnimator (VPA) flag.
[0052] In this implementation, when the view property animation handler calls the value animation handler, the third flag is set to the fifth value. Based on the fifth value of the third flag, the value animation handler skips the step of sending the first notification to the animation manager. Therefore, it does not trigger the animation manager to match the view corresponding to the value animation handler, nor does it trigger the view corresponding to the value animation handler to perform size detection or animation speed detection. This avoids duplication with the subsequent size detection and animation speed detection processes in this embodiment, and also avoids program errors, improving the accuracy of the method.
[0053] In one possible implementation, if the change rate of at least one third view is greater than a first speed threshold in each frame cycle, the screen refresh rate is set to a second refresh rate or a third refresh rate, including: if the motion effect manager determines that the number of elements in the first set is greater than 0 in each frame cycle, the screen refresh rate is set to a second refresh rate; if the number of elements in the first set is equal to 0, the screen refresh rate is set to a first refresh rate.
[0054] In one possible implementation, the third notification also carries the change rate of the fourth view; in each frame period, if the change rate of at least one third view is greater than a first speed threshold, the screen refresh rate is set to a second refresh rate or a third refresh rate, including: if it is determined that the number of elements in the first set is greater than 0, and the change rate of the view corresponding to all elements in the first set is less than or equal to the second speed threshold, then the screen refresh rate is set to the second refresh rate, where the second speed threshold is greater than the first speed threshold; if it is determined that the number of elements in the first set is greater than 0, and the change rate of the view corresponding to at least one element in the first set is greater than the second speed threshold, then the screen refresh rate is set to the third refresh rate.
[0055] Secondly, this application provides an apparatus included in an electronic device, which has the function of implementing the behaviors of the electronic device in the first aspect and possible implementations thereof. The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above-described functions. For example, a receiving module or unit, a processing module or unit, etc.
[0056] Thirdly, this application provides an electronic device, which includes a processor, a memory, and an interface; the processor, memory, and interface cooperate with each other to enable the electronic device to execute any one of the methods in the first aspect of the technical solution.
[0057] Fourthly, this application provides a chip including a processor. The processor is used to read and execute a computer program stored in a memory to perform the methods in the first aspect and any possible implementation thereof.
[0058] Optionally, the chip may also include memory, which is connected to the processor via circuitry or wires.
[0059] Alternatively, the chip may also include a communication interface.
[0060] Fifthly, this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform any one of the methods in the first aspect of the technical solution.
[0061] Sixthly, this application provides a computer program product, which includes computer program code that, when executed on an electronic device, causes the electronic device to perform any one of the methods in the first aspect of the technical solution. Attached Figure Description
[0062] Figure 1 This is a schematic diagram of an example of a motion effect process provided in an embodiment of this application;
[0063] Figure 2 This is another example of a motion effect process diagram provided in the embodiments of this application;
[0064] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0065] Figure 4 This is a software structure block diagram of an electronic device provided in an embodiment of this application;
[0066] Figure 5 This is a flowchart illustrating an example of a motion effect class implementing motion effects provided in an embodiment of this application;
[0067] Figure 6 This is another example of a flowchart illustrating the implementation of motion effects using a motion effect class, provided in an embodiment of this application.
[0068] Figure 7 This is another example of a flowchart illustrating the implementation of motion effects using a motion effect class, provided in an embodiment of this application.
[0069] Figure 8 This is another example of a flowchart illustrating the implementation of motion effects using a motion effect class, provided in an embodiment of this application.
[0070] Figure 9 This is a schematic diagram of an example of interface changes provided in an embodiment of this application;
[0071] Figure 10 This is a flowchart illustrating an example of a refresh rate adjustment method provided in an embodiment of this application;
[0072] Figure 11 This is a schematic diagram of a frame image corresponding to an example refresh rate adjustment method provided in this application embodiment;
[0073] Figure 12 This is a schematic diagram illustrating the main process of implementing motion effects using an example of a motion effect class provided in this application embodiment;
[0074] Figure 13 This is a schematic diagram illustrating the principle of an example refresh rate adjustment method provided in this application embodiment;
[0075] Figure 14 This is a flowchart illustrating another refresh rate adjustment method provided in an embodiment of this application;
[0076] Figure 15 This is a schematic diagram illustrating the principle of another refresh rate adjustment method provided in this application embodiment;
[0077] Figure 16 This is a flowchart illustrating yet another refresh rate adjustment method provided in this application embodiment;
[0078] Figure 17This is a schematic diagram illustrating the principle of another refresh rate adjustment method provided in the embodiments of this application;
[0079] Figure 18 This is a flowchart illustrating yet another refresh rate adjustment method provided in this application embodiment;
[0080] Figure 19 This is a schematic diagram illustrating the inheritance relationship between View.Animation and its subclasses provided in an embodiment of this application;
[0081] Figure 20 This is a schematic diagram illustrating the principle of another refresh rate adjustment method provided in the embodiments of this application;
[0082] Figure 21 This is a flowchart illustrating another refresh rate adjustment method provided in the embodiments of this application. Detailed Implementation
[0083] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0084] Hereinafter, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include one or more of that feature.
[0085] References to "one embodiment" or "some embodiments" as described in this application specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this application specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0086] To better understand the embodiments of this application, the terms or concepts that may be involved in the embodiments are explained below.
[0087] The screen, in this embodiment, can be a touchscreen. The touchscreen may include a display screen and a touch panel. The display screen is used to display images. The touch panel is used to detect touch operations applied to or near it.
[0088] Screen refresh rate refers to the refresh rate of the display screen of an electronic device, also known as hardware refresh rate, or simply refresh rate. It is the number of times the display screen updates per second (s) during the display process, and the unit is Hertz (Hz).
[0089] The screen's idle state occurs when the user does not perform any touch operations on the screen for a preset period of time, and the screen does not detect any touch data within that time. Touch operations can include tapping, swiping, long pressing, etc.
[0090] The screen enters the activity state when the user touches the screen and the screen detects the touch data.
[0091] Frame rate refers to the number of frames of images displayed per second, measured in frames per second (fps). It's important to understand that frame rate is strongly correlated with refresh rate. Generally, the higher the screen's refresh rate, the higher the frame rate can be achieved.
[0092] Vertical synchronization (VSync) is a technology primarily used to coordinate frame rate and refresh rate. Electronic device display interfaces are completed through three pipelines: the rendering pipeline, the compositing pipeline, and the display pipeline. The rendering pipeline draws and renders the elements in each frame of an image. The compositing pipeline combines the elements in each frame of an image to create the final frame. The display pipeline displays each frame of an image on the screen. To coordinate frame rate and refresh rate and prevent screen tearing, vertical synchronization technology synchronizes these three pipelines. Specifically, synchronization is achieved using a vertical synchronization signal (Vsync signal). Generally, the generation period of the Vsync signal corresponds to the refresh rate, i.e., it can be 1 / refresh rate. For example, when the screen refresh rate is 60Hz, the generation period of the Vsync signal can be 1 / 60 = 0.0166 seconds (s) = 16.6 milliseconds (ms). When the screen refresh rate changes, the generation cycle of the Vsync signal changes accordingly. This change in the Vsync signal generation cycle affects the cycles of the three pipelines, including the rendering pipeline, and thus the frame rate. In short, a change in the screen refresh rate will change the frame rate. Optionally, the Vsync signal can be generated by the display screen on the electronic device's screen.
[0093] View animations, also known as view-level animations, refer to the dynamic effects displayed on views in a user interface. View animations can be applied to any UI element that inherits from a view, such as buttons, image views, and text views.
[0094] Window animations, also known as window-level animations, refer to the dynamic effects displayed on windows in a user interface. Window-level animations can be applied to changes in windows or switching between windows. It should be understood that windows contain views; therefore, the implementation of window animations involves view animations.
[0095] Frame-sensitive animation effects: For a view animation effect, if the view size is large and the change speed is fast, then the display effect of the view animation effect is more sensitive to the frame rate. At a higher frame rate, the display effect of the view animation effect is obviously better, and at a lower frame rate, the display effect of the view animation effect is obviously worse. Such view animation effects with large view sizes and fast change speeds can be called frame-sensitive animation effects; otherwise, they are called non-frame-sensitive animation effects.
[0096] Animation classes: In the Android system, depending on the application programming interface (API) for animations and the purpose of different APIs, the animation classes that perform view animations can include: ValueAnimator, ObjectAnimator, View.Animation, and ViewPropertyAnimator, etc.
[0097] First, the scenarios and technical issues involved in this application will be explained.
[0098] When displaying an interface, animations can be used to depict the translation, scaling, and rotation of elements. The presentation of animations is essentially the continuous display of multiple frames of images, in which the position, size, or color of elements differs. It can be understood that the effect of displaying multiple frames is closely related to the screen refresh rate and frame rate; therefore, the display effect of animations is related to these two factors. Higher refresh rates and frame rates result in better animation display and a better user visual experience. As explained in the above explanation, changes in the refresh rate will cause changes in the Vsync signal generation period, which in turn will cause changes in the frame rate. Therefore, to improve the display effect of animations and enhance the user's visual experience (also known as the user's frame rate experience), the screen refresh rate can be controlled during the animation process. Specifically, the screen refresh rate can be increased at the beginning of the animation and decreased after the animation is completed. This way, the screen maintains a high refresh rate during the animation execution, resulting in a better animation display, and maintaining a low refresh rate before and after the animation saves power consumption of electronic devices.
[0099] Regarding the methods for controlling the screen refresh rate during animation effects, the following two solutions exist in relevant technologies:
[0100] 1) The animation effect of pile driving increases and decreases the refresh rate.
[0101] Specifically, for some system applications, the start and end times of animations can be pre-programmed into the system. This allows the system to notify the refresh rate control module when the animation begins and ends. The refresh rate control module can then increase the refresh rate at the start of the animation, for example, from 60Hz to 120Hz, and decrease it again at the end of the animation, for example, back to 60Hz.
[0102] However, this solution is not universal and cannot perform animation staking for non-system applications (i.e., third-party applications), thus failing to achieve refresh rate control during the animation process.
[0103] 2) The "touch to raise frame rate, end to lower frame rate" solution.
[0104] Considering that most animation effects are triggered by user touch operations (such as clicks), related technologies employ a "frame increase upon touch, frame decrease upon completion" approach to improve animation display. Specifically, when the electronic device detects a user touching a control corresponding to a view, it increases the screen refresh rate; after confirming the animation effect has finished executing, it decreases the screen refresh rate.
[0105] While this approach works for both system and third-party applications, it suffers from an inability to accurately increase the refresh rate. Specifically, some animations don't execute immediately after a user touch, but rather after a waiting period of time `t`. Most screens now have intelligent refresh rate adjustment capabilities: if no touch is detected within a preset time `T` (the threshold for entering an idle state), the screen enters an idle state, reducing the refresh rate to a lower value (e.g., 60Hz); if a touch is detected, the screen enters an active state, increasing the refresh rate to a higher value (e.g., 120Hz). Therefore, if the waiting time `t` after a touch is greater than or equal to the preset time `T`, although the touch triggers a refresh rate increase (e.g., to 120Hz), before the animation begins, the screen enters an idle state and reduces the refresh rate to 60Hz. After this, although the animation begins, no further touch triggers a refresh rate increase, and the screen refresh rate remains at 60Hz. Therefore, the screen maintains a low refresh rate during the animation execution.
[0106] In other words, for animations that begin execution some time after a user touch operation, there's an issue of not being able to accurately increase the refresh rate, affecting the animation's performance. This is especially true for frame-sensitive animations, where the performance is even worse, resulting in a poor frame rate experience for the user. Furthermore, the aforementioned "increase frame rate upon touch, decrease frame rate upon completion" solution is rather simplistic, increasing the refresh rate regardless of whether the overall animation includes frame-sensitive elements. Thus, when the overall animation doesn't include non-frame-sensitive elements, increasing the refresh rate means wasted power. Therefore, this solution offers poor power efficiency.
[0107] Below are two examples of frame-sensitive motion effects.
[0108] For example, Figure 1 This is a schematic diagram illustrating an example of a motion effect process provided in an embodiment of this application. For example... Figure 1 As shown in Figure (a), a user opens the interface 101 of a social application. This interface includes a comment. When the user clicks the forwarding control 102 corresponding to the comment, a pop-up window 103 appears, prompting the user to log in to the application. This pop-up window consists of multiple views, and the overall animation effect of the pop-up window 103 is achieved by performing translational animations on each view. This animation effect begins to execute after the user clicks for a period of time. Some views in the pop-up window 103 are relatively large and change rapidly, making it a frame-sensitive animation effect. If the above-mentioned "touch to raise frame rate, end to lower frame rate" solution is followed, the refresh rate cannot be increased during the animation execution, resulting in a poor animation display effect. Figure 1 Figure (b) in the middle Figure 1 Figure (c) in the middle and Figure 1As shown in Figure (d), users will see a stuttering effect in pop-up 103 during the display process.
[0109] For example, Figure 2 This is another example of a motion effect process provided in an embodiment of this application. For example... Figure 2 As shown in Figure (a), a user opens a social content posting interface 201 of another social application. The social content posting 201 includes an image 202. When the user clicks on image 202, a magnified view of the image is displayed on the interface. The image consists of multiple views, each of which can display a zoom-in animation, ultimately achieving an overall animation effect of the image gradually zooming in. This animation effect begins after the user clicks for a period of time. Furthermore, the overall animation effect includes frame-sensitive animation. If the above-mentioned "touch to raise frame rate, end to lower frame rate" solution is followed, the refresh rate cannot be increased during the animation execution, resulting in poor animation display quality. Figure 2 Figure (b) in the middle Figure 2 Figure (c) in the middle and Figure 2 As shown in Figure (d), users will see that the image is not smooth and stutters when zooming in during the display process.
[0110] This application provides a refresh rate adjustment method to solve the above-mentioned problems.
[0111] The refresh rate adjustment method provided in this application can be applied to electronic devices that can install applications (APPs), such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application does not impose any restrictions on the specific type of electronic device.
[0112] For example, Figure 3This is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of this application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0113] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0114] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0115] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0116] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0117] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0118] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0119] Touch sensor 180K, also known as a "touch panel," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touch screen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194.
[0120] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0121] Figure 4 This is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework (FWK) layer, the Android runtime and system libraries, and the kernel layer.
[0122] like Figure 4 As shown, the application layer can include a series of applications. These applications can be system applications such as camera, gallery, calendar, call, WLAN, Bluetooth, and SMS, as well as third-party applications such as navigation, video playback software, and chat software. It can be understood that applications can send motion effect rendering requests to the view system when motion effects are needed.
[0123] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0124] like Figure 4 As shown in this embodiment, the application framework layer may include a view system, a SurfaceFlinger rendering module, and a refresh rate control module. Specifically, the application framework layer may include a Java framework layer and a native framework layer (also known as a C++ framework layer). The view system may reside in the Java framework layer. The SurfaceFlinger and refresh rate control module may reside in the native framework layer.
[0125] The view system manages and presents various views of the user interface. It provides a series of classes and interfaces that enable developers to build rich and diverse display interfaces. A display interface can consist of one or more views. For example, a display interface including a text message notification icon can include views displaying text and views displaying images. Optionally, the view system can have relevant modules perform animation rendering based on animation rendering requests sent by the application in the application layer.
[0126] In this embodiment of the application, the view system may include a view drawing module, an animation execution module, a choreographer, and an animation manager.
[0127] The view drawing module is used to draw and manage views. The view drawing module may include view instances. Optionally, the view instance can be a view root instance (ViewRootImpl), or a child view instance, etc. In this embodiment, the view drawing module can also be used to detect the size of the view, and if the view size is determined to be greater than a preset size threshold, to detect the rate of change of the view. In the following embodiments, the rate of change of the view is also referred to as the animation speed of the view.
[0128] The animation execution module is used to draw animation frames. Optionally, the animation execution module can include various animation classes. These can include value animators, object animators, view animators (View.Animation), and view property animators (ViewPropertyAnimator), etc. Each animation class can draw the animation frame image by creating corresponding instances. In this embodiment, ObjectAnimator can be used to detect the size of the bound view. View.Animation can be used to detect the animation speed of the view. ViewPropertyAnimator can be used to detect the size of the view; if the view size is determined to be greater than a preset size threshold, ViewPropertyAnimator also detects the animation speed of the view.
[0129] The choreographer receives the Vsync signal and provides frame callbacks to the motion effects execution module to control the beat of the image being drawn by the motion effects execution module.
[0130] It is understood that a motion effect can include one or more of the above-mentioned motion effect classes. The motion effect manager is used to manage each motion effect instance in the motion effect, including but not limited to the start and end of the motion effect instance, the mapping relationship between the motion effect instance and the view, and the set of motion effect instances. The motion effect manager is also used to determine the set (referred to as the overspeed set) of motion effect instances whose speed exceeds a preset speed threshold based on the motion effect speed of the view provided by each motion effect class or view drawing module. In addition, multiple motion effects may be involved during the operation of an application. An application runs as a process. Therefore, the motion effect manager can manage the motion effects involved in the operation of each application on a process-by-process basis. Alternatively, in practical applications, a motion effect manager corresponding to each process can be created when each process is created, and the motion effect manager can manage the motion effects involved in that process.
[0131] SurfaceFlinger is responsible for compositing the elements of each frame of the image in the interface.
[0132] The refresh rate control module is used to control the screen's refresh rate, for example, by increasing or decreasing the refresh rate. In this embodiment, the refresh rate control module can control the screen's refresh rate based on the overspeed set provided by the animation manager.
[0133] Of course, in addition to the modules mentioned above, the application framework layer may also include a window manager, content provider, phone manager, notification manager, etc., which are not shown in the diagram. The window manager is used to manage window applications. The window manager can obtain the screen size, determine whether there is a status bar, lock the screen, and capture the screen, etc.
[0134] Content providers store and retrieve data, making that data accessible to applications. This data can include videos, images, audio, phone calls made and received, browsing history and bookmarks, phone books, and more.
[0135] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0136] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0137] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of download completion or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0138] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.
[0139] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0140] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0141] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0142] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0143] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0144] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0145] A 2D graphics engine is a graphics engine for 2D drawing.
[0146] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0147] The display driver is used to display the frames provided by SurfaceFlinger on the screen. Additionally, the display driver is used to adjust the screen refresh rate according to the refresh rate indicated by the refresh rate control module, and to adjust the generation period of the Vsync signal according to the refresh rate indicated by the refresh rate control module. This adjusts the rendering cycle of SurfaceFlinger and the cycle of the screen display interface, thus achieving frame rate adjustment.
[0148] The following embodiments of this application will be used to illustrate having Figure 3 and Figure 4 Taking the electronic device with the structure shown as an example, and in conjunction with the accompanying drawings and application scenarios, the refresh rate adjustment method provided in this application embodiment will be specifically described.
[0149] To facilitate understanding, we will first briefly explain the process of implementing animation effects for the four types of animation effects.
[0150] 1. ValueAnimator
[0151] For example, see Figure 5 Implementing animation effects using ValueAnimator generally involves the following steps:
[0152] 1) Create a ValueAnimator instance.
[0153] Creating a ValueAnimator instance is also called creating a ValueAnimator object, which is essentially instantiating a ValueAnimator object. Specifically, a ValueAnimator instance is created by calling its constructor. Optionally, the start and end values of the ValueAnimator instance can be specified when creating it.
[0154] 2) setDuration: Sets the duration of the animation instance.
[0155] Specifically, ValueAnimator sets the duration of the ValueAnimator instance by calling the setDuration() function.
[0156] 3) addUpdateListener: Add an update listener.
[0157] Specifically, ValueAnimator adds an animation update listener (AnimatorUpdateListener) by calling the addUpdateListener() function. AnimatorUpdateListener can be understood as an interface used to receive events from ValueAnimator that update view property values. AnimatorUpdateListener can include the onAnimationUpdate() function. Subsequently, when addUpdateListener receives an event that updates view property values, it updates the view's property values using the onAnimationUpdate() function. Optionally, there can be one or more AnimatorUpdateListeners; one or more AnimatorUpdateListeners can form an AnimatorUpdateListener list.
[0158] 4) start: Start the process.
[0159] Specifically, ValueAnimator initiates the animation process by calling the start() function.
[0160] 5) addAnimatorCallback: Adds an animation callback.
[0161] Specifically, ValueAnimator adds a Vsync signal callback to AnimationHandler by calling the addAnimatorCallback() function. AnimationHandler is a class or module used to handle animation effects.
[0162] 6) startAnimation: Starts the animation instance.
[0163] Specifically, ValueAnimator starts a ValueAnimator instance by calling the startAnimation() function.
[0164] 7) postCallback: Passes a callback.
[0165] Specifically, AnimationHandler sends a callback to the choreographer by calling the postCallback() function. After the callback is sent to the choreographer, the choreographer sends an event notification to ValueAnimator after the animation has reached a certain stage or completed a certain operation.
[0166] In this embodiment, ValueAnimator can pass Vsync signal callbacks to the choreographer via AnimationHandler. Each time the choreographer receives a Vsync signal, they send a Vsync signal event notification to ValueAnimator by calling the doCallback() function. In other words, the choreographer performs a frame callback upon receiving the Vsync signal (i.e., at the start of each frame).
[0167] 8) doAnimationFrame: Renders animation frames.
[0168] Specifically, each time ValueAnimator receives an event notification from the choreographer, that is, after receiving a frame callback, it calls the doAnimationFrame() function to start drawing the elements of the view corresponding to the animation instance in that frame image.
[0169] 9) animateBasedOnTime: Executes animations based on time.
[0170] Specifically, ValueAnimator can call animateBasedOnTime() to execute the animation instance based on the duration of the animation instance set in step 2) above.
[0171] 10) animateValue: Sets the value of the animation effect.
[0172] Specifically, ValueAnimator can call the animateValue() function to set the value of the animation (i.e., set the property value of the view).
[0173] 11) callOnList: Call list.
[0174] Specifically, after setting the animation value in ValueAnimator, you can call the callOnList() function to access the AnimatorUpdateListener list and send notifications to each AnimatorUpdateListener in the list, informing them that the view's properties have changed.
[0175] 12) onAnimationUpdate: Update event.
[0176] After receiving the callOnList() function, AnimatorUpdateListener updates the view's property values by calling the onAnimationUpdate() function.
[0177] After AnimatorUpdateListener updates the view's property values, the view drawing module can apply the updated view's property values to the view by calling setXXX() functions, thereby changing, but not limited to, the size, position, or color of the element.
[0178] In other words, executing the callOnList() function means that the property values of the view corresponding to the animation instance have been set, and the property values of the view will soon be updated.
[0179] It is understood that in this embodiment, the `setXXX()` function represents one or more of the following: setting the offset using `setTranslation()`, setting the rotation angle using `setRotation()`, or setting the scaling factor using `setScale()`. The `setTranslation()` function enables translation of the view's position, including translation along the X or Y direction. That is, the `setTranslation()` function can include `setTranslationX()` and `setTranslationY()` functions. The `setRotation()` function enables rotation of the view. The `setScale()` function enables scaling of the view, including scaling along the X or Y direction. That is, the `setScale()` function can include `setScaleX()` and `setScaleY()` functions. Of course, the functions used to set view attribute values are not limited to those listed above; for example, they can also include `setImageMatrix()` or `scollTo()` functions, etc., which this application does not limit. Subsequent embodiments will mainly use the `setXXX()` function as an example for explanation and will not be elaborated further.
[0180] It should be understood that step 12) above, which calls the list, is an optional step. In some other embodiments, the list may not be called.
[0181] It should be understood that the choreographer performs a frame callback at the beginning of each frame, triggering the execution of steps 8) to 12) above once to draw a motion effect frame. This process is repeated to draw each motion effect frame, and the attribute values of the view in each frame image are updated, thus realizing changes in the size, position, or color of the view, and achieving the motion effect.
[0182] 13) endAnimation: Ends the animation instance.
[0183] After drawing the last animation frame, ValueAnimator calls endAnimation() to end the animation instance.
[0184] It should be noted that the above process is only an example of how ValueAnimator implements animation. In actual applications, there may be more or fewer steps than the above process, and the order of the steps can also be other than that. No restrictions are placed on this.
[0185] It should be understood that one ValueAnimator instance corresponds to one view. Of course, the correspondence between other types of animation instances and views provided in the embodiments of this application is similar, and will not be described in detail here.
[0186] As can be seen from the above process, when implementing view animation effects, ValueAnimator cannot directly obtain the information of the view corresponding to the ValueAnimator instance.
[0187] 2. ObjectAnimator
[0188] ObjectAnimator inherits from ValueAnimator, meaning that ValueAnimator is the parent class of ObjectAnimator.
[0189] For example, see Figure 6 Implementing animation effects using ObjectAnimator generally involves the following steps:
[0190] 1) Obtain the view object to be manipulated.
[0191] 2) Create an ObjectAnimator instance.
[0192] An ObjectAnimator instance is also called an ObjectAnimator object. An ObjectAnimator instance can be created by calling the ObjectAnimator.ofFloat() function, specifying the name of the view object to be manipulated, the start value of the view object, and the end value.
[0193] 3) setDuration: Sets the duration of the animation instance.
[0194] The ObjectAnimator instance can be set to its duration by calling the setDuration() method.
[0195] 4) startAnimation: Starts the animation instance.
[0196] Specifically, ObjectAnimator is instantiated by calling the startAnimation() function.
[0197] 5) endAnimation: Ends the animation instance.
[0198] Specifically, ValueAnimator calls endAnimation() to terminate the ObjectAnimator instance.
[0199] It should be noted that the above process is only a simplified example of how ObjectAnimator implements animation effects. ObjectAnimator inherits from ValueAnimator, so for the specific process of implementing animation effects, please refer to ValueAnimator, which will not be repeated here.
[0200] As can be seen from the above process, ObjectAnimator specifies a view when it is instantiated. That is to say, the ObjectAnimator instance itself is bound to the corresponding view, and therefore, ObjectAnimator can know the correspondence between ObjectAnimator instances and views.
[0201] 3. View.Animation
[0202] View.Animation, also known as tweening, allows you to perform a series of simple transformations on the content of a View object, such as position, size, selection, and opacity.
[0203] For example, see Figure 7 Implementing animation effects using View.Animation generally involves the following steps:
[0204] 1) Create a LegacyAnimation instance using View.Animation.
[0205] Specifically, View.Animation can call the createAnimation() function to create a LegacyAnimation instance.
[0206] 2) applyLegacyAnimation: Call View.Animation.
[0207] Specifically, the view instance (e.g., ViewRootImpl) in the View.Animation view drawing module traverses each view in the view tree, starting from DecorView. During this traversal, the view's draw() function is called. When the View's draw() function is called, if the view has a bound animation instance, the view instance can call the applyLegacyAnimation() function to invoke View.Animation to execute the bound animation instance.
[0208] 3) getTransformation: Sets the transformation matrix.
[0209] The View.Animation method responds to a call to the applyLegacyAnimation() function of a view instance, calls the getTransformation() function to set the transformation matrix, and then executes the animation instance. Specifically, the getTransformation() function can include functions such as onAnimationStart(), applyTransformation(), and onAnimationEnd().
[0210] The LegacyAnimation instance is started by calling the onAnimationStart() function. The animation is applied by calling the applyTransformation() function and passing in the animation progress. The LegacyAnimation instance is terminated by calling the onAnimationEnd() function.
[0211] As can be seen from the above process, after receiving a call to bind the view, View.Animation calls View.Animation to execute the LegacyAnimation instance. In other words, the LegacyAnimation instance itself is associated with the view; therefore, View.Animation can obtain information about the view corresponding to the LegacyAnimation instance using the getTransformation() function.
[0212] It should be noted that the above process is only a simplified example of how View.Animation implements animation effects. In actual applications, it may include more or fewer steps than described above. For example, the process of View.Animation implementing animation effects may also include adding animation callbacks to the choreographer. For details, please refer to the process of ViewPropertyAnimator implementing animation effects, which will not be elaborated here. Moreover, the order of the steps can also be other than that, and there are no restrictions on it.
[0213] 4. ViewPropertyAnimator
[0214] ViewPropertyAnimator is essentially a wrapper around ValueAnimator, making it easier for developers to write animations. Instances created from ViewPropertyAnimator have a member variable `mView`. The view bound to the ViewPropertyAnimator instance can be directly accessed through the `mView` member variable.
[0215] For example, see Figure 8Implementing animation effects using ViewPropertyAnimator generally involves the following steps:
[0216] 1) Create a ViewPropertyAnimator instance.
[0217] Specifically, ViewPropertyAnimator retrieves the view object to be manipulated, that is, the view to which the animation effect will be applied. It then creates a ViewPropertyAnimator instance by calling the animate() function on the view. The value of the mView member variable in the ViewPropertyAnimator instance is the view corresponding to that ViewPropertyAnimator instance.
[0218] 2) Set the properties and target values of the animation effect.
[0219] Specifically, ViewPropertyAnimator can use various methods to set the properties and target values (i.e., the property values of the view) of the animation to specify the effect of the animation, such as translation, scaling, rotation, etc.
[0220] 3) addUpdateListener: Add an event listener.
[0221] Specifically, ViewPropertyAnimator adds animation event listeners (AnimatorEventListener) by calling the addUpdateListener() function. AnimatorEventListener is a subclass of ViewPropertyAnimator. AnimatorEventListener wraps ValueAnimator.AnimatorUpdateListener and Animator.AnimatorListener, thereby enabling the automatic setting of View property values during the animation process.
[0222] Specifically, the AnimatorEventListener contains functions such as onAnimationStart(), onAnimationUpdate(), and onAnimationEnd(). The onAnimationStart() function starts the ViewPropertyAnimator instance. The onAnimationUpdate() function contains the setValue() function. The setValue() function encapsulates the mRenderNode.setXXX() functions. By calling the setValue() function, the property values of the view corresponding to the ViewPropertyAnimator instance can be set. By calling the onAnimationEnd() function, the ViewPropertyAnimator instance can be terminated.
[0223] 4) start: Start the process.
[0224] Specifically, ViewPropertyAnimator starts the animation process by calling the start() function.
[0225] 5) startAnimation: Starts the animation instance.
[0226] When ValueAnimator receives a frame callback from the choreographer, it starts a ValueAnimator instance by calling the startAnimation() function.
[0227] 6) onAnimationStart: Starts the animation instance.
[0228] ValueAnimator calls the onAnimationStart() function in AnimatorEventListener to start the ViewPropertyAnimator instance.
[0229] 7) onAnimationUpdate: Updates the animation.
[0230] Specifically, during the animation execution, ValueAnimator calls the onAnimationUpdate() function in AnimatorEventListener to update the view's properties according to the progress of the animation.
[0231] 8) onAnimationEnd: End animation.
[0232] Specifically, after the animation is completed, ValueAnimator calls the onAnimationEnd() function in AnimatorEventListener to terminate the ViewPropertyAnimator instance.
[0233] It should be noted that the above process is only an example of how ViewPropertyAnimator implements animation effects. In actual applications, it may include more or fewer steps than described above. For example, the animation effect implementation process of View.Animation also includes steps such as adding animation effect callbacks to the choreographer. For details, please refer to the animation effect implementation process of ValueAnimator described above, which will not be repeated here. Moreover, the order of the steps can also be other than that, and there are no restrictions on it.
[0234] The refresh rate adjustment method provided in this application embodiment will be described in general below with reference to the flowchart and schematic diagram. For ease of explanation, this embodiment uses a translation animation effect as an example. Translation animation effects can be applied to various scenarios, such as the display of pop-ups, the display of navigation menus, the display of view dragging processes, etc. In this embodiment, the display of the Honor share pop-up when sharing photos will be used as an example for explanation. First, combined with... Figure 9 Explain the interface changes in this scenario.
[0235] For example, Figure 9 This is a schematic diagram illustrating an example of interface changes provided in an embodiment of this application. For example... Figure 9 As shown in Figure (a), the mobile phone screen displays the image display interface 901 of the Gallery APP. This interface 901 includes an image 902 and a sharing control 903. When the user clicks the sharing control 903, the mobile phone responds to the user's operation by performing a translation animation on the Honor Share pop-up 904, so that the Honor Share pop-up 904 presents an overall animation effect of gradually translating upwards. Figure 9 Figure (b) in the middle and Figure 9 Figure (c) shows two frames displayed on the screen during the overall animation execution. After the overall animation is completed, the screen displays as follows: Figure 9 The interface shown in Figure (d) is shown in the diagram.
[0236] It should be understood that the Honor Share pop-up 904 includes multiple views, in order to achieve the above... Figure 9 The changes in (a) of the figure are as follows: Figure 9The animation process in diagram (d) is called the overall animation. During the execution of the overall animation, translation animations need to be performed on each view that makes up the pop-up window. That is, the overall animation needs to be achieved by executing multiple view animations. The method provided in this application can detect the size of the object of the view animation (i.e., the view that needs to achieve the animation effect, called the target view) when the animation of each view begins to be executed. If it is determined that the size of at least one target view is greater than a preset size threshold, the animation speed of the target views that are greater than the size threshold is continuously detected. When the animation speed of at least one target view is greater than a first speed threshold, the screen refresh rate is increased, the generation period of the Vsync signal is shortened, and the frame rate is increased; when the animation speed of all target views is less than or equal to the first speed threshold, the screen refresh rate is decreased, the generation period of the Vsync signal is increased, and the frame rate is decreased. In this way, the effect of dynamically adjusting the refresh rate and frame rate according to the animation speed is achieved. The following is combined with Figure 9 and Figure 10 The specific implementation process of the refresh rate adjustment method provided in the embodiments of this application is described.
[0237] Figure 10 This is a flowchart illustrating an example of a refresh rate adjustment method provided in an embodiment of this application, as shown below. Figure 10 As shown, the method includes:
[0238] S101. In response to the user clicking the share control on the interface, the gallery app in the application layer sends an animation drawing request to the animation execution module in the view system of the application framework layer.
[0239] Animation rendering request is used to request the rendering of an interface containing animation effects, such as... Figure 9 The changes in (a) of the figure are as follows: Figure 9 The animation presented in the process of (d) in the figure.
[0240] S102. After receiving the animation rendering request, the animation execution module creates at least one animation instance through the animation class and starts the animation instance.
[0241] As mentioned above, the rendering of an overall animation involves changes to at least one view in the interface, requiring at least one view animation effect. Since the animation effect of a view may involve multiple animation methods (e.g., both translation and rotation), the animation effect of each view can be implemented through one or more animation effect instances. Therefore, to render, for example... Figure 9 Figure (a) in the middle Figure 9The overall animation shown in Figure (d) requires the creation of at least one animation instance. These animation instances may be of the same type created from the same animation class, or they may be of different types created from different animation classes, depending on the type of animation to be implemented, the interface types involved, etc. For example, the execution of an overall animation involves one or more ValueAnimator instances, one or more ObjectAnimator instances, one or more LegacyAnimation instances, and one or more ViewPropertyAnimator instances. These animation instances can be created sequentially. Each animation instance corresponds to one view.
[0242] Optionally, the animation rendering request may include information about the animation class or the type information of the animation instance. The animation execution module can create the corresponding animation instance from the involved animation class based on the animation rendering request.
[0243] For ease of understanding, the following steps will use any one animation instance 1 as an example; the execution process for other animation instances is similar. However, it should be understood that because the animation class used to create the animation instances is different, i.e., the type of animation instance is different, the execution details of each step may differ, and the execution entity may also be different. This embodiment aims to illustrate the logic and general process of implementing refresh rate adjustment under any type of animation instance, and does not impose any limitations.
[0244] In the following description, the animation class that creates animation instance 1 is called animation class 1, and the view corresponding to animation instance 1 is called view. Figure 1 .
[0245] S103. For animation instance 1, during the startup process of animation instance 1, or after starting animation instance 1, the animation class 1 or the view drawing module matches the view corresponding to animation instance 1. Figure 1 And determine the view corresponding to the animation instance 1. Figure 1 If the size is greater than the preset size threshold, then execute step S104 and subsequent steps (i.e., execute steps S104 to S106); if not, then execute step S107 and subsequent steps (i.e., skip steps S104 to S106).
[0246] See Figure 1 If the size is greater than the preset size threshold, it indicates that the view... Figure 1Since the size is relatively large, the view animation implemented in animation example 1 may be a frame-sensitive animation. Therefore, steps S104 and S105 are executed to record the information of animation example 1 to the animation management module for subsequent management. Simultaneously, step S106 is also executed to set the value of the speed detection flag corresponding to animation example 1 to a first value. The value of the speed detection flag corresponding to animation example 1 is the first value, used to indicate the view animation corresponding to animation example 1. Figure 1 Perform motion effect speed detection. It can be understood that one motion effect instance corresponds to one speed detection flag. Furthermore, as mentioned above, one motion effect instance corresponds to one view, therefore one speed detection flag also corresponds to one view. Therefore, in subsequent embodiments, the speed detection flag corresponding to motion effect instance 1 can also be described as a view. Figure 1 The corresponding speed detection flag.
[0247] Optionally, the default value of the speed detection flag is not the first value; for example, it can be the second value. A second value for the speed detection flag indicates no line-of-sight. Figure 1 Perform motion speed testing.
[0248] If the view corresponding to animation instance 1 Figure 1 If the size is less than or equal to the preset size threshold, it indicates that the view... Figure 1 Since the size is relatively small, the view animation implemented in animation example 1 is not a frame-sensitive animation. Therefore, steps S104 to S106 are not executed, and the value of the velocity detection flag corresponding to animation example 1 remains at the default value, i.e., the second value, so that subsequent view animations will not be triggered. Figure 1 Animation speed detection is performed. For ease of description, in subsequent embodiments, views with a size larger than a preset size threshold are referred to as large-size views, and the animation instances corresponding to large-size views are referred to as animation instances to be tested.
[0249] The preset size threshold can be set according to actual needs. In one specific embodiment, the preset size threshold can be, for example, 7% of the screen size.
[0250] In this embodiment, the view is determined. Figure 1 The size is determined after or during the startup of animation instance 1. Different animation classes start their animation instances in different ways and at different times. Therefore, depending on the animation class, different execution entities (animation class or view drawing module) will perform the determination in different functions. Thus, this step is described as "animation class 1 or view drawing module" determining the view corresponding to animation instance 1. Figure 1 Is the size greater than the preset size threshold?
[0251] In this embodiment, depending on the type of animation instance, the size of the view is determined by different modules at different times, which can more accurately locate the start time of the animation instance, thereby more accurately starting the control of the refresh rate and improving the user's frame rate experience.
[0252] S104, Animation class 1 or the view drawing module sends information about animation instance 1 to the animation manager.
[0253] According to steps S103 and S104 above, the animation class 1 or the view drawing module can only be used during the startup process of animation instance 1, or after the startup of animation instance 1, and the view corresponding to animation instance 1... Figure 1 The motion effect manager only sends information about motion effect instance 1 if the size of the animation is larger than a preset size threshold. In other words, if the motion effect manager receives information about motion effect instance 1, it means that motion effect instance 1 is currently starting up or has already started, and the view corresponding to motion effect instance 1 is... Figure 1 This is for a large-scale view. In other words, the motion effect manager only needs to manage the motion effect instance corresponding to the currently executing large-scale view; other motion effect instances do not require management. This reduces the workload of the motion effect manager and improves algorithm efficiency. Furthermore, the motion effect manager only manages motion effect instances after they start running. This reduces management workload and allows the motion effect manager to accurately detect the start of motion effect instances, facilitating precise control of the refresh rate after the motion effect begins execution, improving refresh rate and frame rate control, and ultimately enhancing the motion effect display.
[0254] Optionally, the information for animation instance 1 can be its name, number, identifier, etc.
[0255] Optionally, for different types of animation instances, the animation instance information can be sent to the animation manager through different execution entities. Therefore, this step is described as "animation class 1 or view drawing module" sending the animation instance information to the animation manager.
[0256] S105, The motion effect manager records information about motion effect instance 1.
[0257] Optionally, the animation manager can record animation instances in a preset set based on the type of the animation instance. For example, a LegacyAnimation instance created by View.Animation can be recorded in the LegacyAnimation instance set; a ViewPropertyAnimator instance created by ViewPropertyAnimator can be recorded in the ViewPropertyAnimator instance set.
[0258] Optionally, for some animation classes, such as ValueAnimator and ObjectAnimator, in addition to the information of animation instance 1, the animation manager can also record the view corresponding to animation instance 1. Figure 1 The information, and establish the information and visuals of animation example 1. Figure 1 The mapping relationship between information. The mapping relationship can be stored in the form of a map, for example. For example, the ValueAnimator instance created by ValueAnimator and the ObjectAnimator instance created by ObjectAnimator, and their mapping relationship with the view can be recorded in the Animator instance collection.
[0259] S106. The motion effect class 1, the view drawing module, or the motion effect manager sets the value of the speed detection flag corresponding to motion effect instance 1 to the first value.
[0260] Optionally, the first value can be true, on, or a preset value such as 1; there are no restrictions on this. Furthermore, the speed detection flags for different types of animation instances can be different. For example, the speed detection flag for a ValueAnimator instance (hereinafter referred to as speed detection flag a) can be AnimatingFlag1; the speed detection flag for an ObjectAnimator instance (hereinafter referred to as speed detection flag b) can be AnimatingFlag2; the speed detection flag for a LegacyAnimation instance (hereinafter referred to as speed detection flag c) can be TracingFlag; and the speed detection flag for a ViewPropertyAnimator instance (speed detection flag d) can be AnimatingFlag3.
[0261] Of course, in some other embodiments, the speed detection flag can also be set by assigning a value to a preset variable, setting an attribute to a preset object, or storing the flag data in a preset storage path. This application embodiment does not limit the speed detection flag and its specific setting method, as long as it can indicate the motion speed detection.
[0262] Optionally, the speed detection flag can be set to the first value by the animation class, the view drawing module, or the animation manager based on the relevant parameters reported by the animation class. Specifically, the setting method may differ for different types of animation instances, as detailed in the following embodiments.
[0263] It should be understood that each animation instance is executed according to the above steps S103 to S106 after it is started or during the start-up process. In this way, all the speed animation instances to be tested involved in the overall animation implementation will be recorded in the preset instance set.
[0264] S107. After starting animation instance 1, animation class 1 registers the Vsync signal callback with the choreographer in the view system.
[0265] See above Figure 5 For example, ValueAnimator can add (i.e. register) a Vsync signal callback to AnimationHandler by calling the addAnimatorCallback() function, and then AnimationHandler can pass the Vsync signal callback to the choreographer. Other motion effect classes are similar.
[0266] S108. When the choreographer receives the first Vsync signal sent from the screen, he / she sends a frame callback to motion effects class 1.
[0267] S109. After receiving the frame callback, animation class 1 draws the first animation frame.
[0268] It can be understood that the first motion effect frame includes the view corresponding to motion effect instance 1 in the first frame image of the overall motion effect. Figure 1 Related elements.
[0269] It should be noted that the execution order of steps S107 to S109 and the aforementioned steps S103 to S106 is not limited in this embodiment. For example, steps S107 to S109 may be executed before steps S103 to S106, after steps S103 to S106, or simultaneously with steps S103 to S106. The same applies to other steps in this embodiment; as long as the implementation logic is met, the specific execution order of the steps is not limited.
[0270] The following steps S110 to S117 describe the process of detecting the motion effect speed and controlling the refresh rate during the rendering of the first motion effect frame. It should be understood that the following steps S110 to S117 can be executed during the execution of step S109 above.
[0271] S110. During the process of drawing the first motion effect frame, if the value of the speed detection flag corresponding to motion effect instance 1 is determined to be the first value, motion effect class 1 or the view drawing module determines the view... Figure 1 Is the current motion speed greater than the first speed threshold? If yes, then execute steps S111 and S112; if no, then execute steps S113 and S114.
[0272] Specifically, depending on the type of animation instance, the animation class 1 or the view drawing module can calculate the view... Figure 1 Current motion speed and determine view Figure 1 Is the current motion speed greater than the first speed threshold? If so... Figure 1 The current motion speed is greater than the first speed threshold, indicating that the view... Figure 1 The current animation speed is relatively fast. Additionally, based on previous steps S103 and S106, the view corresponding to animation instance 1... Figure 1 If the size exceeds a preset threshold, the speed detection flag corresponding to animation instance 1 will be set to the first value, triggering step S110. Therefore, if the execution result of step S110 is "yes", it indicates that the view... Figure 1 The size is larger than the preset size threshold, and the view Figure 1 If the current motion effect speed is greater than the first speed threshold, it indicates that the motion effect implemented by motion effect instance 1 is a frame-sensitive motion effect. Therefore, further execute step S111 to notify the motion effect manager to view Figure 1 Overspeed. Otherwise, proceed to step S113 to notify the motion effects manager. Figure 1 No speeding.
[0273] Optionally, the first speed threshold can be, for example, 240 pixels per second (pixel / s).
[0274] S111, Animation class 1 or the view drawing module sends an overspeed notification (also known as a third notification) to the animation manager.
[0275] Overspeed notification is used to notify the view Figure 1 The current motion speed exceeds the first speed threshold, i.e., it is considered... Figure 1 Overspeed (or visual) Figure 1 (For overspeed animation views); or, overspeed notifications are used to notify viewers. Figure 1 The corresponding animation instance 1 is the animation instance corresponding to the super-speed animation view.
[0276] Optionally, the overspeed notification can include information about animation instance 1, or it can include visual information. Figure 1 Information.
[0277] Optionally, the speeding notification can also include a video. Figure 1 Current animation speed.
[0278] S112. After receiving the overspeed notification, the motion effect manager records the information of motion effect instance 1 into the overspeed set.
[0279] Optionally, include a video in the speeding notification. Figure 1 Given the current animation speed, the animation manager can also adjust the view... Figure 1The current motion speed is also recorded in the overspeed set, and a correspondence is established between the motion speed and motion instance 1.
[0280] S113, Animation class 1 or the view drawing module sends a no-speed-overrun notification (also known as the fourth notification) to the animation manager.
[0281] The no-speeding notification is used to notify viewers. Figure 1 The current motion speed exceeds or is less than or equal to the first speed threshold, i.e., it is considered... Figure 1 No speeding (or visual) Figure 1 (For non-overspeed animation views); or, overspeed notifications are used to notify viewers. Figure 1 The corresponding animation instance 1 is an animation instance that does not exceed the speed limit.
[0282] Optionally, the notification of no speeding can include information about animation instance 1, or it can include visual information. Figure 1 The information. Optionally, the no-speeding notification can also include video footage. Figure 1 Current animation speed.
[0283] S114. After receiving the no-speed-over-time notification, the motion effect manager determines whether the speed-over-time set contains information about motion effect instance 1; if so, it deletes the information about motion effect instance 1 from the speed-over-time set.
[0284] It should be understood that within the rendering cycle of one frame (referred to as a frame cycle), each motion effect instance is executed according to the above steps S107 to S114. Thus, all motion effect instances corresponding to overspeeding and large-size views involved in a frame cycle are recorded in the overspeed set. All motion effect instances corresponding to large-size views that were overspeeding in the previous frame cycle but not in the current frame cycle are removed from the overspeed set. This ensures that the overspeed set is updated once per frame cycle, matching the detected motion effect speed in real time.
[0285] S115, the animation manager determines the target refresh rate based on the overspeed set.
[0286] Optionally, the motion manager can determine the target refresh rate at fixed intervals. As one possible implementation, the motion manager can determine the target refresh rate the first time it writes the motion instance information to the overspeed set, and then determine the target refresh rate again at preset intervals based on the overspeed set. Optionally, this preset interval can be approximately equal to the cycle length corresponding to a certain refresh rate supported by the screen, for example, approximately equal to the cycle length corresponding to 60Hz, i.e., 16.67ms. In this way, the motion manager determines the refresh rate at fixed time intervals, making the calculation simple and convenient.
[0287] As another possible implementation, the motion manager can also register a callback for the Vsync signal with the choreographer. Each time the choreographer receives a Vsync signal, they notify the motion manager. Upon receiving the notification, the motion manager determines a refresh rate. This way, the frequency with which the motion manager determines the target refresh rate is consistent with the refresh rate and frame rate, resulting in greater consistency between refresh rate control and motion speed changes, thus improving the refresh rate adjustment effect.
[0288] As another possible implementation, the motion manager can also determine the target refresh rate after completing the overspeed set update in each frame cycle. Specifically, the motion manager can start Timer 1 when it receives information about the first motion effect instance to be tested. Afterward, Timer 1 is reset (i.e., Timer 1 restarts its timing) each time an overspeed notification or a non-overspeed notification is received. When Timer 1 reaches its set duration, the target refresh rate is determined, and Timer 1 is reset. The set duration of Timer 1 is greater than the time difference between the execution times of motion speed detection for any two adjacent motion effect instances to be tested, and the motion duration of Timer 1 is less than the cycle duration corresponding to the minimum refresh rate supported by the screen. Generally, the time difference between the start times of any two motion effect instances is small, and the time difference between the execution times of motion speed detection is also small. Therefore, the set duration of Timer 1 can be pre-set based on prior knowledge to satisfy the above conditions. When the above conditions are met, it indicates that the motion speed detection for all large-size views in the current frame cycle has been completed, and the overspeed set update for the current frame cycle has been completed.
[0289] In this embodiment, the target refresh rate is determined once after the overspeed set is updated in each frame cycle. In this way, the overspeed set contains information on all overspeed animation instances involved in the current frame cycle, the determined target refresh rate is more accurate, and the consistency with the changes in the speed of the view animation is higher, thus improving the accuracy of refresh rate adjustment.
[0290] Regarding methods for determining the target refresh rate, two examples are provided below:
[0291] In one possible implementation, the motion manager can determine the target refresh rate based on the number of elements in the overspeed set. If the number of elements in the overspeed set is greater than 0, it means that at least one large-sized view in the current frame period has a relatively high motion speed, indicating that there is at least one frame-sensitive motion effect in the current frame period. In this case, a higher refresh rate is set, for example, 120Hz. This means the target refresh rate is 120Hz, which improves the motion effect display and enhances the user's frame rate experience. If the number of elements in the overspeed set is equal to 0, it means that the motion speeds of all large-sized views in the current frame period are relatively low, and there are no frame-sensitive motion effects. In this case, a lower refresh rate is set, for example, 60Hz. This means the target refresh rate is 60Hz, which saves power consumption of the electronic device.
[0292] In other words, in the above implementation, the refresh rate will switch between two values (a higher refresh rate value and a lower refresh rate value) during the execution of the animation.
[0293] In another possible implementation, if the screen supports more than two refresh rates, different refresh rates can be matched according to the animation speed of the view corresponding to each frame-sensitive animation effect.
[0294] Specifically, taking a screen that supports refresh rates of at least 60Hz, 90Hz, and 120Hz as an example, if the current animation speed of the view is included in the overspeed set, firstly, it is determined whether the number of elements in the overspeed set is 0. If the number of elements in the overspeed set is 0, it means that there is no frame-sensitive animation in the current frame period, so the target refresh rate is set to 60Hz. If the number of elements in the overspeed set is greater than 0, it is further determined whether at least one animation speed in the overspeed set is greater than the second speed threshold (e.g., 480 pixels / s). If so, the target refresh rate is determined to be 120Hz; if all current animation speeds in the overspeed set are less than or equal to the second speed threshold, the target refresh rate is determined to be 90Hz. The second speed threshold is greater than the first speed threshold.
[0295] In other words, this implementation method can further match different higher refresh rates according to different animation speeds for frame-sensitive animations, enabling finer-grained refresh rate adjustments during animation execution, thereby achieving finer-grained frame rate control. This improves the user's frame rate experience while further saving power consumption of electronic devices.
[0296] S116. If the target refresh rate is determined to be different from the current screen refresh rate, the motion effect manager sends the target refresh rate to the refresh rate control module of the Native framework layer.
[0297] S117 The refresh rate control module adjusts the screen refresh rate according to the target refresh rate and adjusts the generation cycle of the Vsync signal.
[0298] In other words, the motion effect manager only sends the target refresh rate to the refresh rate control module when the refresh rate needs to be adjusted. This reduces the number of communications between the motion effect manager and the refresh rate control module, thus reducing power consumption. Moreover, this eliminates the need for the refresh rate control module to determine whether the refresh rate needs to be adjusted, thereby reducing the power consumption of the refresh rate control module.
[0299] S118, The view drawing module or animation execution module updates the view. Figure 1 The state.
[0300] Specifically, if animation instance 1 is a ValueAnimator instance, ObjectAnimator instance, or ViewPropertyAnimator instance, then the view drawing module can set the view based on the property values updated by the animation drawing module. Figure 1 The attribute value is the updated attribute value, in order to update the view. Figure 1 The state. Specifically, animation type 1 can affect the view. Figure 1 The attribute values are updated, and the view drawing module updates the view accordingly. Figure 1 The attribute values of the view Figure 1 Configure the settings, that is, apply the attribute values provided by animation instance 1 to the view. Figure 1 To define and change vision Figure 1 The appearance, location, size, etc. More specifically, the view drawing module performs the drawing of the view... Figure 1 The `setXXX()` function is used to update the view. Figure 1 The attribute value is applied to the view Figure 1 In this embodiment, all controls in the share pop-up window execute an upward translation animation; therefore, the view drawing module performs a view translation animation. Figure 1 The `setTranslation()` function is used to set the view... Figure 1 The offsets in the X and Y directions are used to achieve the view. Figure 1 The effect of shifting upwards.
[0301] If animation instance 1 is a LegacyAnimation instance, then the transformation matrix can be set by animation class 1 (i.e., View.Animation) to update the view. Figure 1 The state.
[0302] S119, Animation class 1 sends the first animation frame drawn to the SurfaceFlinger of the Native framework layer.
[0303] It is understandable that other animation instances also execute steps S103 to S119 as described above, and send the first animation frame corresponding to the animation instance to SurfaceFlinger. In addition, other modules in the view system draw other related elements and send the drawn elements to SurfaceFlinger.
[0304] S120 and SurfaceFlinger synthesize the first frame image by combining the first animation frame corresponding to each animation instance with the image data drawn by other modules in the view system based on the first Vsync signal sent by the choreographer.
[0305] SurfaceFlinger sends the synthesized first frame image to the display driver, which then sends it to the display for display. The displayed first frame image is as follows: Figure 9 As shown in Figure (a).
[0306] Steps S118 to S120 above provide a general description of the drawing, rendering, and compositing process of the first frame image in the overall motion effect. It should be understood that the drawing, rendering, and compositing of the first frame image may include more steps than those described above, which will not be detailed here.
[0307] It should be noted that steps S118 to S120 can be performed before or after steps S110 to S117 (dynamic speed detection process), or they can be performed simultaneously with steps S110 to S117.
[0308] S121. When the choreographer receives the i-th Vsync signal sent from the screen, he / she returns to step S108.
[0309] i = 2, 3, 4...n, where n is an integer. That is, each time the choreographer receives a Vsync signal, steps S108 to S120 above are executed once in a loop. This completes the rendering of multiple frames. During the rendering of each frame, a motion speed detection is performed on the large-scale view, and the target refresh rate is determined based on the motion speed detection result. If the target refresh rate is inconsistent with the current refresh rate, the refresh rate and frame rate are adjusted. This achieves continuous motion speed detection and dynamic adjustment of the refresh rate and frame rate.
[0310] S122. When animation instance 1 ends, animation instance 1 sends an animation end notification to the animation manager. The animation end notification is used to indicate that animation instance 1 has ended.
[0311] S123. The motion effect manager receives the motion effect end notification, clears the information of motion effect instance 1, and sets the value of the corresponding speed detection flag bit (also known as the first flag bit) of motion effect instance 1 to the second value.
[0312] Optionally, the second value can be, for example, false, off, or 0, etc., and there are no restrictions on it.
[0313] Specifically, after receiving the animation end notification, the animation manager removes the information of animation instance 1 from the corresponding animation instance collection or animation instance mapping table. For example, if animation instance 1 is a LegacyAnimation instance, then the animation manager removes the information of animation instance 1 from the LegacyAnimation instance collection.
[0314] Additionally, if in step S105 the motion effect manager also records the view information corresponding to the motion effect instance, then in this step, the motion effect manager also clears the view corresponding to motion effect instance 1 from the motion effect instance mapping table. Figure 1 Information.
[0315] After an animation instance ends, the animation manager clears the information of that animation instance and no longer manages it. The size or speed of the animation instance will no longer be detected subsequently. This is to prevent power waste and to facilitate accurate control of the refresh rate based on the information of other animation instances. Alternatively, it can facilitate the management of other animation instances in the same process to adjust the refresh rate, thereby improving the accuracy of refresh rate adjustment.
[0316] At the same time, after the animation instance ends, the value of the speed detection flag corresponding to animation instance 1 is set to the second value. In this way, the view drawing module or the animation class will no longer execute the animation overspeed detection process based on the speed detection flag, so as to prevent program errors and power waste.
[0317] As one possible implementation, the motion effect manager can set Timer 2 upon receiving information about the first motion effect instance to be tested, and reset Timer 2 each time it receives information about a motion effect instance to be tested (i.e., when the motion effect instance starts) or each time it receives a termination notification for a motion effect instance to be tested (i.e., when the motion effect instance ends). Then, when Timer 2 reaches its set duration, it clears all recorded information about motion effect instances and sets the speed detection flag for each motion effect instance in both the motion effect instance mapping table and the motion effect instance set to the second value. Specifically, the set duration of Timer 2 is greater than the time difference between the start times of two adjacent motion effect instances to be tested, greater than the time difference between the end times of two adjacent motion effect instances to be tested, and greater than the time difference between the start and end times of each motion effect instance to be tested. In other words, the motion effect manager can set a time limit for clearing motion effect instances and resetting speed detection flags. This allows for timely clearing of instances in cases where anomalies occur during motion effect instance operation, preventing the sending of termination notifications and avoiding impact on the management of other motion effect instances, thus improving algorithm accuracy.
[0318] For example, Figure 11 The image shows the frame corresponding to the main processes described above. For example... Figure 11 As shown, during or after the animation starts (process ① animation start in the diagram), the view corresponding to the animation instance is matched (if necessary), and the size of the corresponding view is detected. Based on the view size, the animation instance to be tested is determined (process ② (matching the view corresponding to the animation instance, detecting the view size)). Generally, process ② is implemented during the rendering of the first to second frames of the overall animation. Then, during the rendering of the third frame and subsequent frames of the animation, the animation speed of each large-scale view is continuously detected, and the refresh rate and frame rate are dynamically adjusted based on the animation speed of each large-scale view (process ③ continuously detecting animation speed, dynamically adjusting refresh rate and frame rate) is shown in the diagram.
[0319] The refresh rate adjustment method provided in this embodiment has at least the following beneficial effects:
[0320] 1) During or after the startup of an animation instance, the method performs steps related to refresh rate adjustment, including matching the view corresponding to the animation instance, determining the size of the view, detecting animation speed, and adjusting the refresh rate. In other words, this method can identify the startup of an animation instance and adjust the refresh rate during or after startup, solving the problem in related technologies that cannot accurately increase the refresh rate during animation execution. That is, this method improves the accuracy of refresh rate adjustment.
[0321] 2) This method identifies large-sized views by performing size detection on the view, detects the motion speed of the large-sized view, and controls the refresh rate based on the motion speed detection results. In other words, this method can identify frame-sensitive motion effects. When frame-sensitive motion effects are present, the refresh rate is increased to prevent stuttering and improve the user's visual experience; when frame-sensitive motion effects are absent, the refresh rate is decreased, effectively saving power consumption of electronic devices, preventing resource waste, and improving power efficiency.
[0322] 3) This method performs motion speed detection on the large-size view in each frame cycle, that is, it identifies frame-sensitive motion effects in each frame cycle and controls the refresh rate and frame rate according to the identification results, realizing dynamic adjustment of refresh rate and frame rate, instead of adjusting the refresh rate at the beginning and end of the motion effect. This improves the fineness and accuracy of refresh rate adjustment during motion effect execution, further saves the power consumption of electronic devices, and increases power consumption benefits.
[0323] 4) This method sends an animation end notification through the animation class, accurately identifying the end of the animation instance. Upon the end of the animation instance, it sets the value of the speed detection flag corresponding to the animation instance to the second value, triggering an adjustment of the refresh rate to a lower value. In other words, this method can accurately set the refresh rate to a lower value after the animation ends, further improving the accuracy of refresh rate adjustment.
[0324] 5) This method uses the animation manager to uniformly manage the start and end of various types of animation instances, as well as information such as the animation speed, to achieve accurate control of the refresh rate during animation execution, reduce the coupling of methods used by different animation classes, improve management consistency and uniformity, and thus improve the efficiency of algorithm operation.
[0325] 6) This method can identify the start and end of animations for different types of animations, as well as detect the view size and animation speed. It is applicable to a variety of view animations and is suitable for both system applications and third-party applications.
[0326] It should be noted that the above embodiment uses the implementation process of translation-based animation as an example. In practical applications, the implementation process of other animation effects such as rotation and scaling can also refer to the above steps to adjust the refresh rate. The difference is that for rotation-based animation effects, the view drawing module calls the setRotation() function to apply the updated attribute values to the view. Figure 1 For scaling animations, the view drawing module calls the setScale() function to apply the updated attribute values to the view. Figure 1 This will not be elaborated upon here.
[0327] In addition, in the above embodiments, if at least one animation instance in the large-size view has a speed greater than a first speed threshold, the screen refresh rate is increased. That is, if at least one animation instance in a frame cycle is a frame-sensitive animation, the screen refresh rate is increased. As another possible implementation, the screen refresh rate can also be increased as soon as a large-size view is determined to exist. Specifically, after the animation instance starts, the animation manager can determine that at least one animation instance exists in the mapping table between the animation instance and the view, the View.Animation collection, and the ViewPropertyAnimator. If so, the refresh rate is increased to a higher value. When all animation instances in the overall animation have finished, the refresh rate is decreased to a lower refresh rate. In this way, the refresh rate only needs to be increased once throughout the entire process, which can conveniently, simply, and accurately improve the screen refresh rate and frame rate during animation execution, thus improving the user's frame rate experience.
[0328] Below, we will further explain the processes of matching views, detecting view size, and detecting animation speed in the implementation of the above process for different types of animation examples.
[0329] First, when implementing motion effects using the methods provided in the embodiments of this application, the main processes and order involved in the four types of motion effects are slightly different. Please refer to the following: Figure 11 and Figure 12 In the process of implementing animation effects using ValueAnimator, the above Figure 11 The three processes shown are in the following order: Process ①: Start the ValueAnimator instance by calling startAnimation(); Process ②: Match the view corresponding to the ValueAnimator instance and detect the size of the view; Process ③: Detect the animation speed of the view during the execution of the setXXX() function.
[0330] See also Figure 12 In the process of implementing animation effects using ObjectAnimator, the above Figure 11 The three processes shown are in the following order: Process ①: Start the ObjectAnimator instance by calling startAnimation(); Process ②: Detect the size of the view; Process ③: Detect the animation speed of the view during the execution of the setXXX() function.
[0331] See also Figure 12 In the process of implementing animation effects using View.Animation, the above Figure 11 The three processes shown are in the following order: Process ②: During the execution of the applyLegacyAnimation() function in the view class, the size of the view is detected; Process ①: The LegacyAnimation instance is started by calling the getTransformation() function; Process ③: During the execution of the applyTransformation() function, the animation speed of the view is detected.
[0332] See also Figure 12 In the process of implementing animation effects using ViewPropertyAnimator, the above Figure 11 The three processes shown are in the following order: Process ①: Start the animation process by calling the start() function; Process ②: Detect the size of the view; Process ③: Detect the animation speed of the view during the execution of the mRenderNode.setXXX() function in the onAnimationStart() function.
[0333] The following sections will elaborate on these four examples of animation effects.
[0334] 1. ValueAnimator instance
[0335] For example, Figure 13 This is a schematic diagram illustrating the principle of a refresh rate adjustment method provided in an embodiment of this application. Figure 14 This is a flowchart illustrating another refresh rate adjustment method provided in an embodiment of this application. Please refer to [the original text here]. Figure 13 and Figure 14 A ValueAnimator instance can be started by calling startAnimation(). After starting the ValueAnimator instance, the following steps can be used to match the view corresponding to the ValueAnimator instance, detect the view's size, and detect the view's animation speed. That is, Figure 10 In the embodiment, the animation class 1 is ValueAnimator. When the animation instance 1 is ValueAnimator instance 1, steps S102 to S114 may include the following steps:
[0336] S201. ValueAnimator creates ValueAnimator instance 1.
[0337] S202. ValueAnimator starts ValueAnimator instance 1 by calling the startAnimation() function.
[0338] S203. When the choreographer receives the first Vsync signal sent from the screen, he / she sends a frame callback to the ValueAnimator.
[0339] S204. After receiving the frame callback, ValueAnimator executes the doAnimationFrame() function to draw the first animation frame.
[0340] S205, ValueAnimator sets the view value by calling the animateValue() function. Figure 1 The attribute value.
[0341] S206. ValueAnimator calls the callOnList() function to call the AnimatorUpdateListener in ValueAnimator to retrieve the view. Figure 1 The attribute value.
[0342] S207. When the callOnList() function of ValueAnimator instance 1 is executed for the first time, ValueAnimator sends information about ValueAnimator instance 1 and property value update notifications (also known as the first notification) to the animation manager.
[0343] Attribute value update notifications are used to inform the animation manager that the first update of view attribute values is about to begin. As described in the example above, executing the `callOnList()` function means that the view's attribute values have been set and are about to be updated. Therefore, the first execution of the `callOnList()` function of a `ValueAnimator` instance also means that the `ValueAnimator` instance has just started. At this time, sending attribute value update notifications to the animation manager allows subsequent view matching, view size detection, speed detection, and refresh rate adjustment to be performed before and after the first view attribute update, further improving the timeliness and accuracy of refresh rate adjustments during animation execution.
[0344] S208. After receiving the attribute value update notification, the motion effect manager sets the value of the match flag (also known as the second flag) to the third value.
[0345] The matching flag value is the third value, indicating that a ValueAnimator instance is about to begin its first update of a view property value; it can also be understood as a ValueAnimator instance currently in a pending matching state. The matching flag can be a general variable for the view, meaning each view can have this variable. Additionally, along with the property value update notification, information about ValueAnimator instance 1 is also sent to the animation manager. Therefore, the animation manager can determine that the animation instance in the pending matching state is ValueAnimator instance 1.
[0346] Optionally, the third value can be a preset value such as on, true, or 1.
[0347] S209. The AnimatorUpdateListener executes the onAnimationUpdate() function to update the view. Figure 1 The attribute value.
[0348] It should be noted that in steps S206 and S209 above, the description attribute value is described as visual. Figure 1 The attribute value is used to indicate which view corresponds to ValueAnimator instance 1. In reality, ValueAnimator cannot know which view corresponds to ValueAnimator instance 1.
[0349] S210, The view drawing module performs view matching. Figure 1 The `setXXX()` function sets the view... Figure 1 The attribute value is the updated attribute value.
[0350] S211, The view drawing module performs view drawing... Figure 1 During the process of the setXXX() function, it is determined whether the value of the matching flag is the third value. If it is, then step S212 and subsequent steps are executed (i.e., steps S212 to S215 need to be executed); if not, then step S216 and subsequent steps are executed (i.e., steps S212 to S215 are skipped).
[0351] As described in the above embodiment, each animation instance is executed serially. Therefore, at any given moment, the view drawing module executes the `setXXX()` function on a view, applying the updated attribute values from the animation instance to that view. Thus, if the current view drawing module is executing the `setXXX()` function on a view, it can be assumed that that view is also in a pending matching state. At this time, since a `ValueAnimator` instance is also in a pending matching state (i.e., the matching flag value is the third value), it indicates that the view matches (i.e., corresponds) the `ValueAnimator` instance, and the two can successfully match (match on). In this embodiment, this means determining the view... Figure 1 This is the view corresponding to ValueAnimator instance 1. If the value of the matching flag is not the third value, it means that there is currently no ValueAnimator instance in the pending matching state, and the matching fails.
[0352] If the match is successful, proceed to the next step S212, which involves viewing... Figure 1 Perform dimensional inspection. Based on the dimensional inspection results, determine whether to perform motion speed inspection; otherwise, do not view it. Figure 1 Perform dimensional inspection but not motion speed inspection, and directly proceed to step S216.
[0353] S212, View drawing module detects view Figure 1 If the size is greater than the preset size threshold, then execute step S213 and subsequent steps (i.e., execute steps S213 to S215); if not, then execute step S216 and subsequent steps (i.e., skip steps S213 to S215).
[0354] S213, The view drawing module will view Figure 1 The information is sent to the motion effects manager.
[0355] S214, The animation manager will combine the information and view of ValueAnimator instance 1. Figure 1The information is recorded in the mapping table between Animator instances and views.
[0356] S215. The motion manager sets the value of the speed detection flag a (e.g., AnimatingFlag1) corresponding to ValueAnimator instance 1 to the first value.
[0357] Optionally, the value of the speed detection flag 'a' can be set to the second value by default. This way, in the view... Figure 1 When the size is less than or equal to the preset size threshold, it is not necessary to set the speed detection flag 'a' corresponding to ValueAnimator instance 1 to the second value, which simplifies the algorithm process and improves the algorithm's running efficiency.
[0358] S216. After the first execution of the callOnList() function of ValueAnimator instance 1, ValueAnimator sends a completion update notification (also known as the second notification) to the animation manager. The completion update notification is used to notify the animation manager that the first update of the property value has ended.
[0359] S217. After receiving the end update notification, the motion effects manager sets the value of the matching flag to the fourth value.
[0360] The value of the matching flag is the fourth value, indicating that the operation of updating the view property value for the first time by the current ValueAnimator instance has ended, or it can be understood that there is currently no ValueAnimator instance in the pending matching state.
[0361] Optionally, the fourth value can be a preset value such as off, false, or 0.
[0362] Because the match flag is set to the third value when the callOnList() function is executed, the view drawing module uses this to detect the view. Figure 1 The size of the view is determined after the `callOnList()` function finishes execution. The view size detection is then complete, and the matching flag is set to the fourth value to facilitate subsequent matching of other views and prevent matching errors.
[0363] In some possible implementations, the view drawing module performs the view drawing... Figure 1The `setxxx()` function may only execute after the `callOnList()` function has completed its first execution. Therefore, in some embodiments of this application, `ValueAnimator` may also send a termination update notification to the animation manager after the `callOnList()` function of `ValueAnimator instance 1` has completed its nth execution (n is an integer greater than or equal to 2). The termination update notification is used to notify the animation manager that the nth update of the attribute value has ended. For example, the termination update notification can be sent to the animation manager after the 6th execution of the `callOnList()` function of `ValueAnimator instance 1`. This ensures that the view drawing module executes the view update at least once. Figure 1 Only after the `setxxx()` function is executed is an end update notification sent to the motion manager, triggering the motion manager to set the matching flag to the fourth value, thereby accurately triggering the view drawing module to adjust the view. Figure 1 Size detection improves the accuracy of the algorithm.
[0364] S218, The view drawing module performs a view... Figure 1 During the `setXXX()` function, after determining that the value of the velocity detection flag 'a' corresponding to ValueAnimator instance 1 is the first value, the view corresponding to ValueAnimator instance 1 is calculated. Figure 1 Current animation speed.
[0365] Optionally, the view drawing module can calculate the view according to the following formula. Figure 1 Animation speed:
[0366]
[0367] Where v represents the current motion speed, and Lv represents the view in the previous frame of the motion effect. Figure 1 The position value (which can be called the last value) is represented by Cv, which represents the position value of the view in the current animation frame (which can be called the current value), and FI represents the frame interval between the previous animation frame and the current animation frame.
[0368] It should be noted that both step S218 and step S213 above occur after the visual image is detected. Figure 1 The execution is triggered when the size is greater than the preset size threshold. Steps S218 and S213 can be executed in a specific order or simultaneously.
[0369] S219, The view drawing module performs view drawing... Figure 1 During the process of the setXXX() function, determine the view Figure 1Is the current motion speed greater than the first speed threshold? If yes, proceed to steps S220 to S221; if no, proceed to steps S222 to S223.
[0370] S220: The view drawing module sends an overspeed notification to the motion effects manager. The overspeed notification can carry the view... Figure 1 Information.
[0371] S221. After receiving the overspeed notification, the animation manager determines the view based on the mapping table between Animator instances and views. Figure 1 The corresponding animation instance is ValueAnimator instance 1, and the information of ValueAnimator instance 1 is recorded in the speed collection.
[0372] S222: The view drawing module sends a "no speed limit" notification to the animation manager. The speed limit notification can include the view drawing module's not-over-speed notification. Figure 1 Information.
[0373] S223. After receiving the "No Overspeed Notification" notification, the Animation Manager determines the view based on the mapping table between Animator instances and views. Figure 1 The corresponding animation instance is ValueAnimator instance 1. Determine whether the overspeed set contains information about ValueAnimator instance 1; if so, delete the information about ValueAnimator 1 from the overspeed set.
[0374] It should be understood that ValueAnimator calls the callOnList() function, which is triggered by the choreographer's frame callback. In other words, ValueAnimator calls the callOnList() function once per frame, updating the view once. Figure 1 The attribute value. Therefore, the view drawing module executes the `setXXX()` function once per frame to set the view's attribute value. Figure 1 The attribute values. The motion speed detection and judgment process (steps S218 to S223 above) are all executed during the execution of the setXXX() function, that is, embedded in the setXXX() function, and therefore are executed once per frame.
[0375] As described in the above embodiments, when implementing view animation effects, ValueAnimator cannot directly obtain the view information corresponding to the ValueAnimator instance. Therefore, in this embodiment, when the callOnList() function of a ValueAnimator instance begins execution, ValueAnimator considers that the ValueAnimator instance is currently in a pending matching state. On the other hand, when the view drawing module executes the setXXX() function for a view, it considers that the view is also in a pending matching state. Simultaneously, ValueAnimator instances and views in the pending matching state are matched, and the animation management module establishes the correspondence between them. In this way, the matching of ValueAnimator instances and views is achieved simply and accurately.
[0376] In the above process, the ValueAnimator can send attribute value update notifications to the animation manager and end update notifications in the callOnList() function. The processes of view size detection, animation speed detection and judgment are implemented in the setXXX() function. That is, the method provided by this application embodiment can be embedded in the original animation implementation process. In this way, no additional traversal process is added, the load is reduced and power consumption is saved.
[0377] 2. ObjectAnimator instance
[0378] As described in the above embodiments, ObjectAnimator inherits from ValueAnimator, and the process of implementing animation effects is similar to that of ValueAnimator. The main difference is that the ObjectAnimator instance itself is bound to the view; therefore, for the ObjectAnimator instance, it is not necessary to match the view according to the above process.
[0379] For example, Figure 15 This is a schematic diagram illustrating the principle of another refresh rate adjustment method provided in this application embodiment. Figure 16 This is a flowchart illustrating yet another refresh rate adjustment method provided in this application embodiment. Please refer to [the flowchart / document] as well. Figure 15 and Figure 16 An ObjectAnimator instance can be started by calling startAnimation(). During the start-up process, the size of the view corresponding to the ObjectAnimator instance can be detected using the following steps. That is, given that animation class 1 is ObjectAnimator and animation instance 1 is ObjectAnimator instance 1, Figure 10Steps S102 to S114 in the embodiments may include the following steps:
[0380] S301, ObjectAnimator obtains view Figure 1 Information, and create with view Figure 1 The bound (i.e., corresponding) ObjectAnimator instance 1.
[0381] S302. ObjectAnimator calls the startAnimation() function to start ObjectAnimator instance 1.
[0382] S303. During the execution of the startAnimation() function, ObjectAnimator detects the view bound (i.e., corresponding to) ObjectAnimator instance 1. Figure 1 If the size is greater than the preset size threshold, then execute step S304 and the subsequent steps (i.e., execute steps S304 to S306); if not, then execute step S307 and the subsequent steps (i.e., skip steps S304 to S306).
[0383] S304, ObjectAnimator will store the information and view of ObjectAnimator instance 1. Figure 1 The information is sent to the motion effects manager.
[0384] S305, The motion manager will store the information and view of ObjectAnimator instance 1. Figure 1 The information is recorded in the mapping table between Animator instances and views.
[0385] S306. The motion manager sets the value of the velocity detection flag b (e.g., AnimatingFlag2) corresponding to ObjectAnimator instance 1 to the first value.
[0386] S307. When the choreographer receives the first Vsync signal sent from the screen, he / she sends a frame callback to the ObjectAnimator.
[0387] S308. After receiving the frame callback, ObjectAnimator executes the doAnimationFrame() function to draw the first animation frame and updates the view. Figure 1 The attribute value.
[0388] Specifically, ObjectAnimator draws the first animation frame and updates the view. Figure 1 The process of determining the attribute value can be found in steps S205, S206, and S209 above, and will not be repeated here.
[0389] S309, The view drawing module performs a view comparison. Figure 1 The `setXXX()` function sets the view... Figure 1 The attribute value is the updated attribute value; execute the view... Figure 1 During the `setXXX()` function, after determining that the velocity detection flag b corresponding to ObjectAnimator instance 1 is the first value, the view is calculated. Figure 1 Current animation speed.
[0390] The process of calculating the motion effect speed can be found in step S218, and will not be repeated here.
[0391] S310, the view drawing module performs view drawing... Figure 1 During the process of the setXXX() function, determine the view Figure 1 Is the current motion speed greater than the first speed threshold? If yes, proceed to steps S311 to S312; if no, proceed to steps S313 to S314.
[0392] S311. The view drawing module sends an overspeed notification to the animation manager. The overspeed notification can carry the view drawing module's overspeed notification. Figure 1 Information.
[0393] S312. After receiving the overspeed notification, the animation manager determines the view based on the mapping table between Animator instances and views. Figure 1 The corresponding animation instance is ObjectAnimator instance 1, and ObjectAnimator instance 1 is recorded in the speed collection.
[0394] S313. The view drawing module sends a "no speed limit" notification to the motion effects manager. The speed limit notification can include the view drawing module's not-over-speed notification. Figure 1 Information.
[0395] S314. After receiving the "No Overspeed Notification" notification, the Animation Manager determines the view based on the mapping table between Animator instances and views. Figure 1 The corresponding animation instance is ObjectAnimator instance 1. Determine whether the overspeed collection contains information about ObjectAnimator instance 1; if so, delete the information about ObjectAnimator 1 from the overspeed collection.
[0396] In the above process, the view size detection is implemented in the `startAnimation()` function, and the motion effect speed detection and judgment are implemented in the `setXXX()` function. That is, the method provided in this application embodiment can be embedded into the existing ObjectAnimator motion effect implementation process. This avoids adding extra traversal processes, reduces load, and saves power. Furthermore, since the view size detection is implemented in the `startAnimation()` function, the process of this solution is triggered as soon as the motion effect starts executing, thus accurately adjusting the screen refresh rate and frame rate, improving the accuracy of refresh rate control, and consequently improving the user's frame rate experience.
[0397] In this embodiment, the ObjectAnimator instance is already bound to the view; therefore, view matching is not required for the ObjectAnimator instance. However, as a possible implementation, after step S302, if the ObjectAnimator determines that ObjectAnimator instance 1 has registered AnimatorUpdateListener, then the ObjectAnimator can also proceed as described above. Figure 13 and Figure 14 The process described in steps S207 to S217 performs view matching. This is because some developers may register an AnimatorUpdateListener in ObjectAnimator instance 1 to achieve view matching other than that bound to the ObjectAnimator instance. Figure 1 Other views (e.g., views) Figure 2 ,See Figure 3 (etc.) animation effects. Therefore, if it is determined that the AnimatorUpdateListener of ObjectAnimator instance1 is registered, further performing view matching can cover the detection of the size and speed of these view animation effects implemented through AnimatorUpdateListener, thus improving the accuracy of the algorithm.
[0398] 3. LegacyAnimation example
[0399] As described in the above embodiments, if a view has a bound animation effect during the view processing process, the view drawing module calls View.Animation to implement the animation effect. Therefore, View.Animation can obtain the view information corresponding to the LegacyAnimation instance without needing to match the view.
[0400] For example, Figure 17 This is a schematic diagram illustrating the principle of another refresh rate adjustment method provided in this application embodiment. Figure 18 This is a flowchart illustrating yet another refresh rate adjustment method provided in this application embodiment. Please refer to [the flowchart / document] as well. Figure 17 and Figure 18 When the animation class 1 is View.Animation and the animation instance 1 is LegacyAnimation instance 1, Figure 10 Steps S102 to S114 in the embodiments may include the following steps:
[0401] S401. View.Animation creates a LegacyAnimation instance 1.
[0402] It is understandable that View.Animation can pre-create the required LegacyAnimation instance, and then call the created LegacyAnimation instance when the animation needs to be executed later.
[0403] S402. When the choreographer receives the first Vsync signal sent from the screen, he / she sends a frame callback to the view drawing module (viewRootlmol).
[0404] S403. After receiving the frame callback, the view drawing module (viewRootimulator) traverses the view tree and executes the applyLegacyAnimation() function to call View.Animation to execute the animation. The applyLegacyAnimation() function carries the view... Figure 1 Information.
[0405] As mentioned above, during the traversal of the view tree, viewRootlmol determines the view... Figure 1 Since the binding has animation effects, the `applyLegacyAnimation()` function is called to invoke `View.Animation` to perform the animation on the view. Figure 1 The animation effects.
[0406] S404. During the execution of the applyLegacyAnimation() function, the view drawing module detects the view... Figure 1 If the size is greater than the preset size threshold, then proceed to step S405 and subsequent steps; otherwise, proceed to step S406 and subsequent steps (i.e., skip step S405).
[0407] S405, The view drawing module sets the value of the velocity detection flag c (e.g., the tracing flag) corresponding to LegacyAnimation instance 1 to the first value.
[0408] S406, View.Animation responds to the view. Figure 1 The `applyLegacyAnimation()` function is called, which in turn calls the `getTransformation()` function to set the transformation matrix.
[0409] S407. View.Animation executes the onAnimationStart() function in the getTransformation() function to start LegacyAnimation instance 1. During the execution of the onAnimationStart() function, if it is determined that the value of the speed detection flag c corresponding to LegacyAnimation instance 1 is the first value, then the information of LegacyAnimation instance 1 is sent to the motion effect manager.
[0410] It should be understood that View.Animation generally only executes the onAnimationStart() function during the first frame callback. Therefore, during the execution of the onAnimationStart() function, it is determined whether the value of the velocity detection flag c is the first value. The value of the velocity detection flag is only determined once, which simplifies the algorithm process.
[0411] If View.Animation determines that the speed detection flag c corresponding to LegacyAnimation instance 1 is the first value, then it will not send information about LegacyAnimation instance 1 to the animation manager.
[0412] S408. After receiving the information from LegacyAnimation instance 1, the animation manager records the information of LegacyAnimation instance 1 into the LegacyAnimation instance collection.
[0413] S409. View.Animation applies animation by calling the applyTransformation() function in the getTransformation() function to draw the first animation frame.
[0414] S410. During the execution of the applyTransformation() function, View.Animation calculates the view corresponding to LegacyAnimation instance 1. Figure 1 Current animation speed.
[0415] The `applyTransformation()` function of `View.Animation` handles animations such as translation, rotation, and scaling of the view. For example, Figure 19 This is a schematic diagram illustrating the inheritance relationship between View.Animation and its subclasses, provided as an example of an embodiment of this application. Figure 19 As shown, the subclasses of View.Animation include translation animation subclasses (TranslateAnimation), rotation animation subclasses (RotateAnimation), and scaling animation subclasses (ScaleAnimation). Among them, the subclasses of TranslateAnimation include the X-direction translation animation subclass (TranslateXAnimation) and the Y-direction translation animation subclass (TranslateYAnimation).
[0416] refer to Figure 19 The inheritance relationship shown can be optionally implemented by using the applyTransformation() function to calculate the motion speed of the view. You can define the motion speed calculation function in the applyTransformation() function of View.Animation (see step S218), and override the motion speed calculation function in the applyTransformation() function of TranslateAnimation, RotateAnimation and ScaleAnimation respectively to complete the speed calculation logic of each motion subclass.
[0417] S411. During the execution of the applyTransformation() function, View.Animation determines the view... Figure 1 Is the current motion speed greater than the first speed threshold? If yes, proceed to steps S412 to S413; if no, proceed to steps S414 to S415.
[0418] S412, View.Animation sends an overspeed notification to the animation manager, which can carry information about LegacyAnimation instance 1.
[0419] S413. After receiving the overspeed notification, the animation manager records the information of LegacyAnimation instance 1 into the overspeed collection.
[0420] S414. View.Animation sends a no-speed-over-limit notification to the animation manager. The speed-over-limit notification can carry information about LegacyAnimation instance 1.
[0421] S415. After receiving the no-speed-over-time notification, the animation manager determines whether the speed-over-time set contains information about LegacyAnimation instance 1; if so, it deletes the information about LegacyAnimation instance 1 from the speed-over-time set.
[0422] In the above process, the view size detection is implemented in the `applyLegacyAnimation()` function, and the motion effect speed detection and judgment are implemented in the `applyTransformation()` function. That is, the method provided in this application embodiment can be embedded into the existing View.Animation motion effect implementation process, thus avoiding additional traversal processes, reducing load, and saving power. Furthermore, since the view size detection is implemented in the `applyTransformation()` function, which calls View.Animation to start the motion effect, the process of this solution is triggered as soon as the motion effect begins execution. Therefore, it can accurately adjust the screen refresh rate and frame rate, improve the accuracy of refresh rate control, and thus improve the user's frame rate experience.
[0423] In this embodiment, the view drawing module calls View.Animation to implement the animation effect. Therefore, View.Animation can obtain the view information corresponding to the LegacyAnimation instance and does not need to perform view matching. However, considering that in some cases, developers may call the view in the applyTransformation() function, Figure 1 The `setxxx()` function is used to implement view... Figure 1 Other animation effects, therefore, as a possible implementation, after step S407 above, may also include: the animation manager connecting LegacyAnimation instance 1 and the view Figure 1 Write the mapping table between Animator instances and views, and set the value of the velocity detection flag bit 'b' corresponding to LegacyAnimation instance 1 to the first value. This will trigger the view drawing module and ObjectAnimator to perform the corresponding view size detection and velocity detection processes (see...). Figure 15 and Figure 16 This allows for more comprehensive management of views and improves the accuracy of the algorithm.
[0424] 4. ViewPropertyAnimator instance
[0425] As described in the above embodiments, the ViewPropertyAnimator instance itself has a member variable mView. The view bound to the ViewPropertyAnimator instance can be directly obtained through the member variable mView, therefore, there is no need to match the view.
[0426] For example, Figure 20 This is a schematic diagram illustrating the principle of another refresh rate adjustment method provided in this application embodiment. Figure 21 This is a flowchart illustrating yet another refresh rate adjustment method provided in this application embodiment. Please refer to [the flowchart / document] as well. Figure 20 and Figure 21 When animation class 1 is ViewPropertyAnimator and animation instance 1 is ViewPropertyAnimator instance 1, Figure 10 Steps S102 to S114 in the embodiments may include the following steps:
[0427] S501. ViewPropertyAnimator creates ViewPropertyAnimator instance 1. The member variable mView of ViewPropertyAnimator instance 1 has the value of view... Figure 1 .
[0428] S502, ViewPropertyAnimator calls ValueAnimator through the start() function to start the animation process.
[0429] S503, during the execution of the start() function, ViewPropertyAnimator sets the value of the IsViewPropertyAnimator (VPA) flag to the fifth value.
[0430] The VPA flag is also known as the third flag.
[0431] As described in the above embodiments, ViewPropertyAnimator is a wrapper around ValueAnimator. Therefore, the execution flow of ValueAnimator may be triggered by a ViewPropertyAnimator call, or it may not be triggered by a ViewPropertyAnimator call, but rather by ValueAnimator itself (see the process of ValueAnimator implementing animations described above). The VPA flag is used to indicate whether the current execution flow of ValueAnimator is triggered by a ViewPropertyAnimator call. A VPA flag value of the fifth value (e.g., true) indicates that the current execution flow of ValueAnimator is triggered by a ViewPropertyAnimator call. A VPA flag value of the sixth value (e.g., false) indicates that the current execution flow of ValueAnimator is not triggered by a ViewPropertyAnimator call.
[0432] S504, ViewPropertyAnimator determines the view during the execution of the start() function. Figure 1 If the size is greater than a preset size threshold, then proceed with step S505 and subsequent steps; otherwise, proceed with step S506 and subsequent steps (i.e., skip step S505).
[0433] S505, ViewPropertyAnimator sets the value of the velocity detection flag d corresponding to ViewPropertyAnimator instance 1 to the first value.
[0434] S506. When the choreographer receives the first Vsync signal sent from the screen, he / she sends a frame callback to the ValueAnimator.
[0435] S507. When ValueAnimator receives a frame callback from the choreographer, it calls the startAnimation() function to start ViewPropertyAnimator instance 1.
[0436] S508, during the execution of the startAnimation() function, ValueAnimator determines whether the VPA flag value is the fifth value; if not, ValueAnimator executes... Figure 13 and Figure 14 Steps S202 to S207 in the embodiment shown in the example are executed if so. Figure 13 and Figure 14In the embodiment shown in the example, steps S202 to S206 are skipped, i.e., step S207 is skipped.
[0437] In other words, if ValueAnimator determines, based on the value of the VPA flag, that the current execution flow was not triggered by a ViewPropertyAnimator call, but rather by ValueAnimator itself, then it will proceed according to... Figure 11 and Figure 12 The process shown is executed as follows. During this process, when the `callOnList()` function begins execution, information about the `ValueAnimator` instance 1 and a property value update notification need to be sent to the animation manager so that the animation manager can subsequently match the `ValueAnimator` instance with the corresponding view.
[0438] If ValueAnimator determines, based on the VPA flag value, that the current execution flow is triggered by a ViewPropertyAnimator call, then ViewPropertyAnimator can directly obtain the view bound to the ViewPropertyAnimator instance through the member variable mView. Therefore, there is no need to match the view, and step S207 is skipped. It can be understood that skipping step S207 prevents the motion manager from matching the view corresponding to ValueAnimator, and also prevents the view corresponding to ValueAnimator from performing size detection and motion speed detection. This avoids duplication with the subsequent size detection and motion speed detection processes in this embodiment, and also avoids program errors, improving the accuracy of the method.
[0439] It should be noted that when ViewPropertyAnimator registers a listener, it registers AnimatorUpdateListener. Therefore, in this embodiment, when executing step S206, AnimatorUpdateListener in step S206 should be replaced with AnimatorEventListener.
[0440] It should be understood that, in one possible implementation, when the animation class of the electronic device includes both ValueAnimator and ViewPropertyAnimator, the above... Figure 13 and Figure 14During the execution of the animation by the ValueAnimator shown, step S202 can be as follows: ValueAnimator starts ValueAnimator instance 1 by calling the startAnimation() function. During the execution of the startAnimation() function, it is determined whether the value of the VPA flag is the fifth value. If not, steps S206 to S208 are executed. If yes, steps S206 to S208 are not executed.
[0441] In another possible implementation, before step S503, ViewPropertyAnimator can first determine whether animation instance 1 has an AnimatorUpdateListener. If it doesn't, then step S503 is executed, that is, during the execution of the start() function, the VPA flag is set to the fifth value. If it does exist, then step S504 is not executed. In other words, for the flow of ViewPropertyAnimator calling ValueAnimator, if it includes AnimatorUpdateListener, view matching, view size determination, and view speed detection can also be performed. This way, for views that implement animations through AnimatorUpdateListener, the corresponding view size detection and speed detection can be covered, improving algorithm accuracy. For animation instances that do not contain AnimatorUpdateListener, setting the VPA flag to the fifth value skips the view matching process, preventing the triggering of view detection and subsequent speed detection processes, saving algorithm steps and improving algorithm efficiency.
[0442] S509. ValueAnimator calls the onAnimationStart() function in AnimatorEventListener to start ViewPropertyAnimator instance 1. During the execution of the onAnimationStart() function, ViewPropertyAnimator determines whether the value of the velocity detection flag d (e.g., AnimatingFlag3) corresponding to ViewPropertyAnimator instance 1 is the first value; if yes, then execute step S509 and subsequent steps; if no, then execute step S511 and subsequent steps (i.e., skip steps S509 and S510).
[0443] It should be understood that, generally, ViewPropertyAnimator only executes the onAnimationStart() function the first time it receives a call from ValueAnimator, i.e., during the first frame callback. Therefore, determining whether the speed detection flag d corresponding to ViewPropertyAnimator instance 1 is the first value is only executed during the first frame callback, i.e., only once. This simplifies the algorithm's execution process and improves its efficiency.
[0444] S510, ViewPropertyAnimator sends information about ViewPropertyAnimator instance 1 to the animation manager.
[0445] S511, The animation manager records the information of ViewPropertyAnimator instance 1 into the ViewPropertyAnimator instance collection.
[0446] S512, ValueAnimator calls the setValue() function in the onAnimationUpdate() function to update the view. Figure 1 The attribute value.
[0447] S513. During the execution of the setValue() function, ViewPropertyAnimator calculates the view value. Figure 1 Current animation speed.
[0448] S514. During the execution of the setValue() function, ViewPropertyAnimator determines the view... Figure 1 Is the current motion speed greater than the first speed threshold? If yes, proceed to steps S515 to S516; if no, proceed to steps S517 to S518.
[0449] S515, ViewPropertyAnimator sends an overspeed notification to the animation manager, and the overspeed notification can carry information about ViewPropertyAnimator instance 1.
[0450] S516. After receiving the overspeed notification, the animation manager records the information of ViewPropertyAnimator instance 1 into the overspeed collection.
[0451] S517, ViewPropertyAnimator sends a no-speed-over-limit notification to the animation manager. The speed-over-limit notification can carry information about ViewPropertyAnimator instance 1.
[0452] S518. After receiving the no-speed-over-time notification, the motion effect manager determines whether the over-speed set contains information about ViewPropertyAnimator instance 1; if so, it deletes the information about ViewPropertyAnimator instance 1 from the over-speed set.
[0453] It should be noted that, for the sake of simplicity, only the steps relevant to the main content of this case are shown; other steps are not shown. In other words, the above steps are merely examples of how this case is executed and are not intended to limit the scope. In practical applications, the method for executing this case may include more or fewer steps than described above.
[0454] In the above process, the view size detection is implemented in the `onAnimationStart()` function, and the motion effect speed detection and judgment are implemented in the `setValue()` function. That is, the method provided in this embodiment can be embedded into the existing motion effect implementation process of `ViewPropertyAnimator`, thus avoiding additional traversal processes, reducing load, and saving power. Furthermore, the view size detection is implemented in the `onAnimationStart()` function, which signifies the startup of the `ViewPropertyAnimator` instance. This means that the process of this solution is triggered when the motion effect begins to execute, thus accurately adjusting the screen refresh rate and frame rate, improving the accuracy of refresh rate control, and consequently improving the user's frame rate experience.
[0455] The foregoing has detailed examples of refresh rate adjustment methods provided in the embodiments of this application. It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0456] This application embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into a separate functional module, such as a detection unit, a processing unit, a display unit, etc., or two or more functions can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0457] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0458] The electronic device provided in this embodiment is used to execute the refresh rate adjustment method described above, and therefore can achieve the same effect as the above implementation method.
[0459] When using integrated units, the electronic device may further include a processing module, a storage module, and a communication module. The processing module is used to control and manage the operation of the electronic device. The storage module supports the execution of stored program code and data. The communication module supports communication between the electronic device and other devices.
[0460] The processing module can be a processor or a controller. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a digital signal processor (DSP), and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, or other devices that interact with other electronic devices.
[0461] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in this embodiment can be a device having... Figure 4 The device with the structure shown.
[0462] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to perform the refresh rate adjustment method of any of the above embodiments.
[0463] This application also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the refresh rate adjustment method described in the above embodiments.
[0464] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component or module. The apparatus may include a connected processor and a memory. The memory is used to store computer execution instructions. When the apparatus is running, the processor can execute the computer execution instructions stored in the memory to cause the chip to execute the refresh rate adjustment method in the above-described method embodiments.
[0465] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0466] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0467] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0468] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0469] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0470] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0471] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A refresh rate adjustment method, the method being performed by an electronic device, the electronic device including a screen, characterized in that, The method includes: A first interface is displayed on the screen; the first interface includes a first control and a second control, and when the first interface is displayed, the refresh rate of the screen is the first refresh rate; In response to a user's first operation on the first control, a first animation effect is executed. The animation effect object of the first animation effect includes at least one first view, wherein the size of any first view is less than or equal to a preset size threshold. During the execution of the first animation effect, the screen refresh rate is the first refresh rate. In response to a second operation by the user on the second control, a second animation effect is executed. The animation effect object of the second animation effect includes at least one second view, wherein at least one third view exists in the at least one second view, and the third view is a view whose size is greater than the preset size threshold. During the execution of the second animation effect, there is at least a first time period, during which the screen refresh rate is a second refresh rate, and the second refresh rate is greater than the first refresh rate. The second animation effect, executed in response to a second user action on the second control, includes: In response to the second operation, at least one motion effect instance is created, each motion effect instance corresponding to one of the second views; each motion effect instance is executed; During the process of starting the fourth animation instance, or after the fourth animation instance is started, if it is determined that the size of the fourth view is greater than the preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth animation instance is set to a first value; the fourth animation instance is any of the animation instances, and the fourth view is the view corresponding to the fourth animation instance. In each frame cycle of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is the first value, then the change speed of the fourth view is detected; in each frame cycle, if the change speed of at least one third view is greater than the first speed threshold, then the refresh rate of the screen is set to the second refresh rate or the third refresh rate, wherein the third refresh rate is greater than the second refresh rate.
2. The method according to claim 1, characterized in that, During the first time period, the rate of change of at least one of the third views is greater than the first speed threshold.
3. The method according to claim 2, characterized in that, During a second time period in the execution of the second animation effect, the screen refresh rate is the third refresh rate; during the second time period, the change rate of at least one of the third views is greater than a second speed threshold, and the second speed threshold is greater than the first speed threshold.
4. The method according to any one of claims 2 or 3, characterized in that, During the third time period of executing the second animation effect, the screen refresh rate is the first refresh rate; during the third time period, the change speed of each of the third views is less than or equal to the first speed threshold.
5. The method according to claim 1, characterized in that, The electronic device includes a value animation generator, an animation manager, and a view drawing module, and the fourth animation instance is created by the value animation generator; During the process of launching the fourth animation instance, or after the fourth animation instance is launched, if it is determined that the size of the fourth view is greater than the preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth animation instance is set to a first value, including: Before the value animation generator executes the callOnList() function of the fourth animation instance for the first time, it sends a first notification to the animation manager. After receiving the first notification, the motion effect manager sets the value of the second flag to the third value; During the execution of the setting function of the fourth view, the view drawing module determines whether the size of the fourth view is greater than the preset size threshold if the value of the second flag bit is the third value. If it is determined that the size of the fourth view is greater than the preset size threshold, then the view drawing module determines that the fourth view is the third view, and the view drawing module sends the information of the fourth view to the motion effect manager; After receiving the information from the fourth view, the motion effect manager sets the value of the first flag corresponding to the fourth motion effect instance to the first value.
6. The method according to claim 5, characterized in that, The method further includes: After the value animation generator finishes executing the callOnList() function of the fourth animation instance for the first time, it sends a second notification to the animation manager. After receiving the second notification, the motion effect manager sets the value of the second flag bit to the fourth value.
7. The method according to claim 5, characterized in that, The first notification carries information about the fourth motion effect instance; In each frame period of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is the first value, then the change speed of the fourth view is detected, including: During the execution of the setting function of the fourth view in each frame cycle, if the view drawing module determines that the value of the first flag corresponding to the fourth animation instance is the first value, then it detects the change speed of the fourth view. If the rate of change of the fourth view is greater than the first speed threshold, the view drawing module sends a third notification to the motion effect manager; After receiving the third notification, the motion effect manager records the information of the fourth motion effect instance into the first set; If the rate of change of the fourth view is less than or equal to the first speed threshold, the view drawing module sends a fourth notification to the motion effect manager. After receiving the fourth notification, if the motion effect manager determines that the first set contains information about the fourth motion effect instance, it deletes the information about the fourth motion effect instance.
8. The method according to claim 7, characterized in that, The third notification carries information about the fourth view; After the view drawing module sends the information of the fourth view to the motion effect manager, the method further includes: After receiving the information from the fourth view, the motion effect manager records the information of the fourth view and the information of the fourth motion effect instance, and establishes a mapping relationship between the fourth view and the fourth motion effect instance. After receiving the third notification, the motion effect manager records the information of the fourth motion effect instance into the first set, including: After receiving the third notification, the motion effect manager determines the motion effect instance corresponding to the fourth view as the fourth motion effect instance based on the information of the fourth view and the mapping relationship between the fourth view and the fourth motion effect instance. The motion effect manager records the fourth motion effect instance into the first set.
9. The method according to claim 8, characterized in that, The method further includes: After the fourth animation instance finishes execution, the animation manager sets the value of the first flag corresponding to the fourth animation instance to the second value, and deletes the information of the fourth view, the information of the fourth animation instance, and the mapping relationship between the fourth view and the fourth animation instance.
10. The method according to claim 8, characterized in that, The method further includes: After the fourth animation instance is created for a first preset duration, the animation manager sets the value of the first flag corresponding to the fourth animation instance to a second value according to the recorded information of the fourth animation instance, and deletes the information of the fourth view, the information of the fourth animation instance, and the mapping relationship between the fourth view and the fourth animation instance.
11. The method according to claim 1, characterized in that, The electronic device includes an object motion effecter and a motion effect manager, and the fourth motion effect instance is created by the object motion effecter; During the process of launching the fourth animation instance, or after the fourth animation instance is launched, if it is determined that the size of the fourth view is greater than the preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth animation instance is set to a first value, including: During the execution of the startAnimation() function on the fourth animation instance, the object animation effecter determines whether the size of the fourth view bound to the fourth animation instance is greater than the preset size threshold. If it is determined that the size of the fourth view is greater than the preset size threshold, then the object motion effector determines that the fourth view is the third view, and the object motion effector sends the information of the fourth view to the motion effect manager; After receiving the information from the fourth view, the motion effect manager sets the value of the first flag corresponding to the fourth motion effect instance to the first value.
12. The method according to claim 11, characterized in that, The electronic device also includes a view drawing module; In each frame period of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is the first value, then the change speed of the fourth view is detected, including: During the execution of the setting function of the fourth view in each frame cycle, if the value of the first flag bit is determined to be the first value, the view drawing module detects the rate of change of the fourth view. If the rate of change of the fourth view is greater than the first speed threshold, the view drawing module sends a third notification to the motion effect manager; After receiving the third notification, the motion effect manager records the information of the fourth motion effect instance into the first set; If the rate of change of the fourth view is less than or equal to the first speed threshold, the view drawing module sends a fourth notification to the motion effect manager. After receiving the fourth notification, if the motion effect manager determines that the first set contains information about the fourth motion effect instance, it deletes the information about the fourth motion effect instance.
13. The method according to claim 1, characterized in that, The electronic device includes a view animation generator and a view drawing module, and the fourth animation instance is created by the view animation generator; During the process of launching the fourth animation instance, or after the fourth animation instance is launched, if it is determined that the size of the fourth view is greater than the preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth animation instance is set to a first value, including: The view drawing module executes the applyLegacyAnimation() function of the fourth view to call the view animation generator to execute the fourth animation instance; During the execution of the applyLegacyAnimation() function of the fourth view, the view drawing module determines whether the size of the fourth view is greater than the preset size threshold. If the size of the fourth view is greater than the preset size threshold, the view drawing module determines the fourth view as the third view, and the view drawing module sets the value of the first flag corresponding to the fourth animation instance to the first value.
14. The method according to claim 13, characterized in that, The electronic device also includes a motion effects manager; In each frame period of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is the first value, then the change speed of the fourth view is detected, including: The view animation generator responds to the call of the view drawing module by executing the getTransformation() function to execute the fourth animation instance, wherein the getTransformation() function includes the applyTransformation() function; During the execution of the applyTransformation() function of the fourth animation instance in each frame cycle, if the value of the first flag corresponding to the fourth animation instance is determined to be the first value, the change speed of the fourth view is detected. If the rate of change of the fourth view is greater than the first speed threshold, the view motion effecter sends a third notification to the motion effect manager, the third notification carrying information about the fourth motion effect instance; After receiving the third notification, the motion effect manager records the information of the fourth motion effect instance into the first set; If the rate of change of the fourth view is less than or equal to the first speed threshold, the view motion effecter sends a fourth notification to the motion effect manager, the fourth notification carrying information about the fourth motion effect instance; After receiving the fourth notification, if the motion effect manager determines that the first set contains information about the fourth motion effect instance, it deletes the information about the fourth motion effect instance.
15. The method according to claim 14, characterized in that, The applyTransformation() function also includes the startAnimation() function, and the method further includes: During the execution of the startAnimation() function of the fourth animation instance, the view animation generator determines whether the value of the first flag corresponding to the fourth animation instance is the first value. If the value of the first flag corresponding to the fourth motion effect instance is the first value, then the view motion effecter sends the information of the fourth motion effect instance to the motion effect manager; The motion effect manager records information about the fourth motion effect instance.
16. The method according to claim 15, characterized in that, The method further includes: After the fourth animation instance finishes execution, the animation manager sets the value of the first flag corresponding to the fourth animation instance to the second value and deletes the information of the fourth animation instance.
17. The method according to claim 15, characterized in that, The method further includes: After the fourth animation instance is created for a second preset duration, the animation manager sets the value of the first flag corresponding to the fourth animation instance to a second value according to the recorded information of the fourth animation instance, and deletes the information of the fourth animation instance.
18. The method according to claim 1, characterized in that, The electronic device includes a view attribute animation effector, and the fourth animation instance is created by the view attribute animation effector. During the process of launching the fourth animation instance, or after the fourth animation instance is launched, if it is determined that the size of the fourth view is greater than the preset size threshold, then the fourth view is determined to be the third view, and the value of the first flag corresponding to the fourth animation instance is set to a first value, including: During the execution of the start() function of the fourth animation instance, the view property animation effecter determines whether the size of the fourth view is greater than the preset size threshold. If it is determined that the size of the fourth view is greater than the preset size threshold, then the view attribute animation effector determines that the fourth view is the third view, and the view attribute animation effector sets the value of the first flag corresponding to the fourth animation instance to the first value.
19. The method according to claim 18, characterized in that, The electronic device also includes a motion effect manager and a view drawing module. The view property motion effectr includes a motion effect event listener. The motion effect event listener includes an onAnimationUpdate() function. The onAnimationUpdate() function includes a setValue() function. The setValue() function is used to set the property value of the fourth view. In each frame period of the second motion effect, if it is determined that the value of the first flag corresponding to the fourth motion effect instance is the first value, then the change speed of the fourth view is detected, including: During the execution of the setValue() function in the onAnimationUpdate() function of each frame cycle, the view property animation effecter detects the rate of change of the fourth view; If the rate of change of the fourth view is greater than the first speed threshold, the view attribute animation effecter sends a third notification to the animation effect manager, the third notification carrying information about the fourth animation effect instance; After receiving the third notification, the motion effect manager records the information of the fourth motion effect instance into the first set; If the rate of change of the fourth view is less than or equal to the first speed threshold, the view attribute animation effecter sends a fourth notification to the animation effect manager, the fourth notification carrying information about the fourth animation effect instance; After receiving the fourth notification, if the motion effect manager determines that the first set contains information about the fourth motion effect instance, it deletes the information about the fourth motion effect instance.
20. The method according to claim 19, characterized in that, The view property animation also includes a value animation, and the method further includes: During the execution of the start() function of the fourth animation instance, the view property animation device sets the value of the third flag bit of the value animation device to the fifth value. The value of the third flag bit to the fifth value indicates that the value animation device is called by the view property animation device. In response to the call to the start() function, if the value of the third flag is determined to be the fifth value during the execution of the startAnimation() function of the fourth animation instance, the value animation generator will not send a first notification to the animation manager before the first execution of the callOnList() function of the fourth animation instance.
21. The method according to any one of claims 7 to 10, 12, 14 to 17, 19, characterized in that, In each frame cycle, if the rate of change of at least one of the third views is greater than a first speed threshold, the screen refresh rate is set to either the second refresh rate or the third refresh rate, including: In each frame cycle, if the motion effect manager determines that the number of elements in the first set is greater than 0, then the screen refresh rate is set to the second refresh rate. If it is determined that the number of elements in the first set is equal to 0, then the refresh rate of the screen is set to the first refresh rate.
22. The method according to any one of claims 7 to 10, 12, 14 to 17, 19, characterized in that, The third notification also carries the rate of change of the fourth view; In each frame cycle, if the rate of change of at least one of the third views is greater than a first speed threshold, the screen refresh rate is set to either the second refresh rate or the third refresh rate, including: If it is determined that the number of elements in the first set is greater than 0, and the change rate of the view corresponding to all elements in the first set is less than or equal to the second speed threshold, then the refresh rate of the screen is set to the second refresh rate, and the second speed threshold is greater than the first speed threshold. If it is determined that the number of elements in the first set is greater than 0, and at least one element in the first set has a view whose change rate is greater than the second speed threshold, then the screen refresh rate is set to the third refresh rate.
23. An electronic device, characterized in that, The electronic device includes: one or more processors, and memory; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 22.
24. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the one or more processors being used to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 22.
25. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1 to 22.