Dynamic effect identification method and related equipment
By obtaining the screen refresh rate and transformation matrix to determine the view position change value, and combining the animation speed to adjust the display refresh rate and frame rate, the problem of low recognition rate of user-defined animations is solved, and the animation recognition rate and display effect are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-10-08
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies cannot accurately identify user-defined view animation classes, resulting in low animation recognition rates and affecting display quality.
By acquiring the screen refresh rate and determining the position change value of the view based on the transformation matrix, and combining the position change value and screen refresh rate to determine the motion effect speed, the screen refresh rate and frame rate are dynamically adjusted to improve the motion effect recognition rate.
It achieves accurate recognition of user-defined animation effects, improves the recognition rate and display smoothness of animation effects, and avoids additional traversal processes and increased power consumption.
Smart Images

Figure CN121879702A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of display technology, and in particular to motion effect recognition methods and related equipment. Background Technology
[0002] Dynamic effects (or animations) are effects that give an interface or element movement and change. Currently, animations have become a way to improve user experience during interface display. Taking view animations as an example, to further improve the display effect, the screen refresh rate can be increased during the execution of the animation, and then decreased after the animation is completed.
[0003] However, when identifying view animations, it is impossible to accurately identify the view animations corresponding to user-defined animation classes, resulting in a low animation recognition rate and thus affecting the display effect. Summary of the Invention
[0004] In view of the above, it is necessary to provide a motion effect recognition method, electronic device, and computer storage medium to improve the recognition rate of motion effects.
[0005] In a first aspect, embodiments of this application provide a motion effect recognition method applied to an electronic device, the electronic device including a display screen, the method comprising: displaying a first interface on the display screen, the first interface including a first control; responding to a user's operation on the first control, executing a motion effect, the motion effect including at least one view; obtaining a first screen refresh rate of the display screen; determining a position change value of at least one view based on a transformation matrix of the motion effect; and determining the motion effect speed based on the position change value and the first screen refresh rate.
[0006] The above technical solution can be embedded into the original animation implementation process, so there is no need to add an extra traversal process, reducing the load and saving power. In addition, the above technical solution in this case determines the position change value of at least one view based on the transformation matrix, and determines the animation speed of the animation based on the position change value and the first screen refresh rate, which solves the technical problem of not being able to accurately identify the view animation corresponding to the user-defined animation class and improves the recognition rate of the animation.
[0007] In some embodiments of this application, determining the position change value of at least one view based on the transformation matrix of the animation effect includes: determining the first positions of multiple corner points of at least one view; transforming the multiple corner points according to the transformation matrix to obtain the second positions of the multiple corner points; calculating the difference between the second position and the first position of each corner point to obtain multiple differences, and taking the maximum value among the multiple differences as the position change value of at least one view. The above technical solution uses the maximum corner point movement distance of multiple corner points in the view as the position change value of the view, thereby using the corner point movement distance of the fastest moving corner as the position change value of the view, which can accurately identify the view change situation.
[0008] In some embodiments of this application, determining the motion speed of an animation based on the position change value and the first screen refresh rate includes: determining the motion speed of the animation based on the product of the position change value and the first screen refresh rate. The above technical solution uses the product of the view's position change value and the first screen refresh rate as the total distance or displacement of the view within one second, thereby accurately identifying the motion speed of the animation corresponding to the view.
[0009] In some embodiments of this application, the method further includes: determining the refresh rate of the second screen based on the animation speed, and adjusting the refresh rate of the display screen based on the second screen refresh rate. The above technical solution can dynamically adjust the refresh rate according to the animation speed, thereby improving the smoothness of the animation display.
[0010] In some embodiments of this application, determining the second screen refresh rate based on the motion effect speed includes: if the motion effect speed is less than a first speed threshold, determining the second screen refresh rate as a first preset value; if the motion effect speed is greater than or equal to the first speed threshold and less than a second speed threshold, determining the second screen refresh rate as a second preset value; if the motion effect speed is greater than or equal to the second speed threshold, determining the second screen refresh rate as a third preset value, wherein the first speed threshold is less than the second speed threshold, the first preset value is less than the second preset value, and the second preset value is less than the third preset value. The above technical solution, by comparing the motion effect speed with two speed thresholds (the first speed threshold and the second speed threshold) to determine the second screen refresh rate, can avoid the problem of incorrect recognition of the second screen refresh rate caused by motion effect speed fluctuations.
[0011] In some embodiments of this application, the method further includes adjusting the frame rate of the animation based on the second screen refresh rate. The above technical solution can dynamically adjust the frame rate according to the animation speed, thereby improving the smoothness of the animation display.
[0012] In some embodiments of this application, the method for determining the transformation matrix of the animation includes: calling the applyLegacyAnimation() function to execute the animation; and obtaining the output of the applyLegacyAnimation() function.
[0013] In existing methods, third-party developers can define custom classes that inherit from Animation and override the applyTransformation() function. Therefore, it is impossible to instrument the animation effects in the custom functions defined by the third-party developers. However, the technical solution of this application can directly obtain the transformation matrix output by the applyLegacyAnimation() function, so there is no need to instrument the applicationTransformation() function. This solves the technical problem of not being able to use the applyTransformation() function in View.Animation for motion effect recognition.
[0014] In some embodiments of this application, the method further includes: drawing at least one motion effect frame of a view; synthesizing image data from the motion effect frame to obtain an image frame; and sending the image frame to a display screen for display. The above technical solution can synthesize motion effect frames and display them on a display screen.
[0015] In some embodiments of this application, the motion effect is one or more of translational motion effects, scaling motion effects, and rotational motion effects.
[0016] Secondly, embodiments of this application provide an electronic device, which includes a memory and a processor: the memory is used to store program instructions; the processor is used to read and execute the program instructions stored in the memory, and when the program instructions are executed by the processor, the electronic device performs the above-mentioned motion effect recognition method.
[0017] Thirdly, some embodiments of this application provide a computer storage medium storing program instructions that, when executed on a terminal device, cause the terminal device to perform the aforementioned motion effect recognition method.
[0018] Fourthly, some embodiments of this application provide a computer program product, including computer program instructions, which, when executed by a processor, implement the above-described motion effect recognition method.
[0019] Furthermore, the technical effects brought about by the second to fourth aspects can be found in the descriptions of the methods in the above-mentioned method section, and will not be repeated here. Attached Figure Description
[0020] Figure 1 This is a schematic diagram illustrating the inheritance relationship between View.Animation and its subclasses, provided for embodiments of this application.
[0021] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0022] Figure 3A software structure block diagram of an electronic device provided in an embodiment of this application.
[0023] Figure 4 This is a schematic diagram of interface changes provided for an embodiment of this application.
[0024] Figure 5 This is a flowchart illustrating a motion effect recognition method provided in an embodiment of this application.
[0025] Figure 6 This is a flowchart illustrating a motion effect recognition method provided in another embodiment of this application. Detailed Implementation
[0026] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of some embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in some embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this application's specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. It should be understood that, unless otherwise stated, " / " in this application means "or". For example, A / B can mean A or B. In some embodiments of this application, "and / or" 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 alone, A and B simultaneously, and B alone. "At least one" refers to one or more. "More than one" refers to two or more. For example, at least one of a, b, or c can represent: a, b, c, a and b, a and c, b and c, and a, b, and c (seven cases).
[0028] To better understand the embodiments of this application, the terms or concepts that may be involved in the embodiments are explained below.
[0029] 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).
[0030] Frame rate refers to the number of image frames 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 refresh rate, the higher the frame rate.
[0031] 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.
[0032] Animation classes: In the Android system, based on the application programming interface (API) for animations and the purpose of different APIs, the animation classes that execute view animations include View.Animation, which can be used to detect the speed of view animations.
[0033] Dynamic effects (or animations) are effects that give an interface or element movement and change. Currently, animations have become a way to improve user experience during interface display. Taking view animations as an example, to further improve the display effect, the screen refresh rate can be increased during the execution of the animation, and then decreased after the animation is completed.
[0034] However, while it can identify three animation categories—translation, scaling, and rotation—it cannot accurately identify view animations corresponding to user-defined animation categories, resulting in a low animation recognition rate and thus affecting the display effect.
[0035] The `applyTransformation()` function of `View.Animation` handles animations such as translation, rotation, and scaling of the view. For example, Figure 1 This diagram illustrates the inheritance relationship between View.Animation and its subclasses, as provided in an embodiment of this application. Figure 1 As shown, subclasses of View.Animation include translation animation (TranslateAnimation), rotation animation (RotateAnimation), and scaling animation (ScaleAnimation). Among them, subclasses of TranslateAnimation include X-direction translation animation (TranslateXAnimation) and Y-direction translation animation (TranslateYAnimation).
[0036] refer to Figure 1As shown in the inheritance relationship, optionally, to implement the motion speed calculation of the view through the applyTransformation() function, you can define the motion speed calculation function in the applyTransformation() function of View.Animation, and override the motion speed calculation function in the applyTransformation() function of TranslateAnimation, RotateAnimation and ScaleAnimation respectively, so as to complete the speed calculation logic of each motion effect subclass.
[0037] If a user develops an animation effect that inherits from a class in View.Animation, they cannot instrument the code in the applyTransformation() function of View.Animation. This prevents them from calculating the animation speed and thus from using View.Animation's applyTransformation() function for animation recognition. Instrumenting code in View.Animation's applyTransformation() function involves inserting additional code into the applyTransformation() function to recognize the animation effect.
[0038] This application provides a motion effect recognition method to solve the problem of motion effect recognition failure.
[0039] The motion recognition 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.
[0040] refer to Figure 2The diagram shown is a structural schematic of the electronic device 100 provided in this application embodiment. 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.
[0041] 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.
[0042] 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.
[0043] 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 instruction fetching and execution.
[0044] 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.
[0045] 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.
[0046] 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.
[0047] 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.
[0048] 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.
[0049] refer to Figure 3 The diagram shown is a software structure block diagram of the electronic device 100 provided in 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.
[0050] like Figure 3 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.
[0051] 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.
[0052] like Figure 3 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.
[0053] 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.
[0054] 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.
[0055] 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 detect the animation speed of the view.
[0056] The animation execution module is used to draw animation frames. Optionally, the animation execution module may include animation classes, such as a view animator (View.Animation). In other embodiments, the animation execution module may also include animation classes such as value animator (ValueAnimator), object animator (ObjectAnimator), and view property animator (ViewPropertyAnimator). Each animation class can draw the image frame of the animation by creating corresponding instances. In this embodiment, View.Animation can be used to detect the animation speed of the view.
[0057] The choreographer receives the vertical synchronization (Vsync) signal and provides frame callbacks to the motion effects execution module to control the beat of the image rendering. The generation period of the Vsync signal is consistent with the period corresponding to the refresh rate, that is, it can be expressed as "Vsync signal generation period = 1 / refresh rate". For example, when the screen refresh rate is 60Hz, the Vsync signal generation period can be 1 / 60 = 0.0166 seconds (s) = 16.6 milliseconds (ms). When the screen refresh rate changes, the Vsync signal generation period changes accordingly.
[0058] SurfaceFlinger is responsible for compositing the elements of each frame of the image in the interface.
[0059] The refresh rate control module is used to control the screen refresh rate, such as increasing or decreasing the refresh rate.
[0060] 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.
[0061] Content providers are used to 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.
[0062] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0063] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0064] The notification manager allows applications to display notifications in the status bar. These can be used to convey 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.
[0065] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.
[0066] 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.
[0067] 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.
[0068] 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.
[0069] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0070] 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.
[0071] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0072] A 2D graphics engine is a graphics engine for 2D drawing.
[0073] 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.
[0074] The display driver is used to display the image frames provided by SurfaceFlinger on the display screen. In addition, the display driver is also 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, thereby adjusting the rendering period of SurfaceFlinger and the display screen's display period, that is, to adjust the frame rate.
[0075] The animation recognition 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 4 Explain the interface changes in this scenario.
[0076] refer to Figure 4 The diagram shown is a schematic representation of interface changes provided in an embodiment of this application. Figure 4 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 4 Figure (b) in the middle and Figure 4 Figure (c) shows two image frames displayed on the screen during the overall animation execution. After the overall animation is completed, the screen displays as follows: Figure 4 The interface shown in Figure (d) is shown in the diagram.
[0077] In some embodiments of this application, the Honor Share pop-up 904 includes multiple views, in order to achieve the above-mentioned... Figure 4 The changes in (a) of the figure are as follows: Figure 4The animation process in diagram (d) is called the overall animation. During the execution of the overall animation, translation animations need to be applied to each view that makes up the pop-up window. That is, the overall animation needs to be achieved by executing the animations of multiple views. The method provided in this application can detect the animation speed of the target object (i.e., the view that needs to achieve the animation effect) when executing the animation of each view, thus realizing the identification of the animation. When the animation speed of at least one view is greater than a preset speed threshold, the screen refresh rate is increased and the generation cycle of the Vsync signal is shortened; when the animation speed of all target views is less than or equal to the preset speed threshold, the screen refresh rate is decreased and the generation cycle of the Vsync signal is increased. In this way, the refresh rate can be dynamically adjusted according to the animation speed, thereby improving the smoothness of the animation display.
[0078] refer to Figure 5 The diagram shown is a flowchart illustrating a motion effect recognition method provided in an embodiment of this application. The following is a detailed explanation... Figure 4 and Figure 5 The specific implementation process of the motion effect recognition method provided in the embodiments of this application will be described. Figure 5 The example method includes one or more steps, but does not constitute a limitation of this application. Furthermore, the order of the steps in the method is merely illustrative and may be changed. Additional steps may be added or steps may be removed without departing from the disclosure of this application. The method includes the following steps.
[0079] In step S501, in response to the user clicking the share control in 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.
[0080] In some embodiments of this application, the animation rendering request is used to request the rendering of an interface containing animation effects, such as... Figure 4 The changes in (a) of the figure are as follows: Figure 4 The animation presented in the process of (d) diagram.
[0081] In step S502, after receiving the animation rendering request, the animation execution module creates at least one animation instance and starts the animation instance.
[0082] In some embodiments of this application, the rendering of an overall animation involves changes to at least one view in the interface, which needs to be achieved through the animation of at least one view. Since the animation of a view may involve multiple animation methods (e.g., both translation and rotation), the animation of each view can be implemented through one or more animation instances. For example, to render... Figure 4 Figure (a) in the middle Figure 4 The overall animation shown in Figure (d) requires the creation of at least one animation instance.
[0083] In some embodiments of this application, the animation execution module includes View.Animation. View.Animation creates Animation animation instances, which can be called when animation needs to be executed later.
[0084] Step S503: After starting the motion effect instance, the motion effect execution module view registers the Vsync signal callback with the choreographer in the view system.
[0085] In some embodiments of this application, View.Animation can add (e.g., register) a callback for the Vsync signal to AnimationHandler by calling the addAnimatorCallback() function, and then AnimationHandler can pass the Vsync signal callback to the choreographer.
[0086] In step S504, when the choreographer receives the first Vsync signal sent by SurfaceFlinger, he sends a frame callback to the view drawing module.
[0087] In an operating system, the choreographer (or scheduler) is responsible for managing and scheduling the execution of tasks, processes, or threads within the computer system. The choreographer can optimize the use of system resources, improving overall system performance and responsiveness. Frame callbacks are typically used to handle updates to each frame in graphics rendering, animation, or games. This process usually involves time management between frames to ensure smooth visual effects. When controlling frame callbacks, the choreographer can manage timers, event loops, frame rates, and task scheduling to ensure that applications can execute and render animations smoothly, thereby achieving efficient graphics rendering and providing a good user experience.
[0088] In some embodiments of this application, the choreographer is used to receive Vsync signals and provide frame callbacks to the view drawing module to control the beat of View.Animation drawing images (such as motion frames of the view).
[0089] In step S505, after receiving the frame callback, the view drawing module determines the first screen refresh rate of the display screen based on the frame callback, and executes the applyLegacyAnimation() function to call the View.Animation of the animation execution module to execute the animation instance and send the first screen refresh rate to the animation execution module.
[0090] In some embodiments of this application, the frame callback includes the first screen refresh rate of the current display screen. After receiving the frame callback, the view drawing module obtains the first screen refresh rate of the display screen from the frame callback.
[0091] In some embodiments of this application, after receiving a frame callback, the view drawing module traverses the views in the view tree and calls the view's draw() function during the traversal of the view tree. When the view's draw() function is called, if the view is bound to an Animation instance, the Animation instance calls the applyLegacyAnimation() function to call View.Animation to execute the view's animation.
[0092] S506, in response to the call to the view's applyLegacyAnimation() function, the animation execution module calls the getTransformation() function to set the transformation matrix.
[0093] In some embodiments of this application, View.Animation, in response to a call to the applyLegacyAnimation() function of a view instance, calls the getTransformation() function to set the transformation matrix and execute the animation instance. In some embodiments of this application, the getTransformation() function includes onAnimationStart(), applyTransformation(), and onAnimationEnd() functions. The getTransformation() function starts the animation instance by calling onAnimationStart() and ends the animation instance by calling onAnimationEnd().
[0094] Step S507: The animation execution module obtains the transformation matrix output by the applyLegacyAnimation() function.
[0095] In some embodiments of this application, the animation execution module obtains the transformation matrix output by the applyLegacyAnimation() function through the parent.getChildTransformation() function.
[0096] In some embodiments of this application, the transformation matrix is used to perform transformation operations such as scaling, rotation, and translation on the view corresponding to the animation. The transformation matrix can be a 3x3 matrix that defines how the view should be mapped from its original position and orientation to a new position and orientation on the screen. In some embodiments of this application, the transformation matrix includes, but is not limited to, translation matrices, scaling matrices, and rotation matrices.
[0097] In some embodiments of this application, the translation matrix Where tx represents the translation along the x-axis and ty represents the translation along the y-axis. In some embodiments of this application, the x-axis and y-axis are two perpendicular coordinate axes in the pixel coordinate system. For example, the pixel coordinate system can use the upper left corner of the view as the origin, the direction to the right of the origin as the positive direction of the x-axis, and the direction downward from the origin as the positive direction of the y-axis.
[0098] In some embodiments of this application, the scaling matrix Here, sx and sy are the scaling factors along the x-axis and y-axis, respectively. For example, if the scaling factor is greater than 1, it indicates that the image is enlarged; if the scaling factor is less than 1, it indicates that the image is reduced.
[0099] In some embodiments of this application, the rotation matrix Where θ is the rotation angle.
[0100] In some embodiments of this application, the transformation matrix may also include a combination of two or more matrices. For example, the translation matrix and the scaling matrix M = R*T.
[0101] In step S508, the animation execution module executes the onAnimationStart() function in the getTransformation() function to start the animation instance and sends the animation instance information to the animation manager.
[0102] In some embodiments of this application, View.Animation executes the onAnimationStart() function in the getTransformation() function to start the Animation instance and send the Animation instance information to the animation manager.
[0103] In step S509, the animation execution module calls the applyTransformation() function in the getTransformation() function to draw the animation frame of the animation instance of the view.
[0104] In some embodiments of this application, the motion effect frame includes elements of the view corresponding to the motion effect instance in the first image frame.
[0105] Step S510: Determine the position change value of the view corresponding to the animation frame based on the transformation matrix of the animation instance.
[0106] In some embodiments of this application, based on the transformation matrix, View.Animation determines the first position of the view before the transformation and the second position after the transformation, and determines the position change value of the view based on the difference between the first position and the second position.
[0107] In some embodiments of this application, the first position includes the first coordinates of multiple corner points of the view, and the second position includes the second coordinates of multiple corner points of the view. For ease of description, four corner points are used as an example below. In actual applications, no limitation is made on the number of corner points, as long as the method of each embodiment of this application can be clearly implemented. In some embodiments of this application, based on the transformation matrix, View.Animation determines the first position of the view before transformation and the second position after transformation, and obtains the position change value of the view based on the difference between the first position and the second position, including: determining the first coordinates of each of the four corner points of the view before transformation by the transformation matrix; transforming the four corner points respectively through the transformation matrix to obtain the second coordinates of each of the four corner points; determining the position change value of each corner point based on the second coordinates of each corner point and the corresponding first coordinates; and taking the maximum value among all the position change values of the corner points as the position change value of the view.
[0108] In some embodiments of this application, based on the second coordinates and the corresponding first coordinates of each corner point, the distance is calculated according to the formula. Determine the position change value of each corner point, where x1 and y1 are the coordinates of any one of the four corner points before the transformation, and x2 and y2 are the coordinates of that corner point after the transformation matrix.
[0109] The following example uses the four corner points of the view (A, B, C, D). The coordinates of the four corner points are: top left A(x1, y1), top right B(x2, y1), bottom right C(x2, y2), and bottom left D(x1, y2). x1 and y1 are the coordinates of the top left corner of the layer, and x2 and y2 are the coordinates of the bottom right corner of the layer. The transformation matrix is used as the translation matrix. Let's take an example to illustrate the positional changes of the four corner points. The coordinates of the four corner points (A, B, C, D) of the view after transformation using the translation matrix are as follows:
[0110] Top left corner
[0111] Top right corner
[0112] bottom right corner
[0113] bottom left corner
[0114] The coordinates of the top left corner A1 become (x1+tx1,y1+ty1), the coordinates of the top right corner B1 become (x2+tx1,y1+ty1), the coordinates of the bottom right corner C1 become (x2+tx1,y2+ty1), and the coordinates of the bottom left corner D1 become (x1+tx1,y2+ty1).
[0115] For each corner point, calculate the distance after translation according to the distance calculation formula:
[0116] The distance the top left corner point moves
[0117] The distance the top right corner point moves
[0118] The distance the bottom right corner point moves
[0119] The distance the bottom left corner point moves
[0120] The maximum value among the corner point movement distances DA1, DB1, DC1, and DD1 is used as the position change value, and the coordinates of the four corner points (A1, B1, C1, D1) are saved.
[0121] In this embodiment of the application, the maximum value of the corner movement distance of the four corner points in the view is taken as the position change value of the view, that is, the corner movement distance of the corner point that moves the fastest is taken as the position change value of the view, which can accurately identify whether there is a change in the view.
[0122] In step S511, the motion effect execution module determines the motion effect speed based on the position change value of the view and the first screen refresh rate, and sends the motion effect speed to the motion effect manager.
[0123] In some embodiments of this application, the View.Animation of the animation execution module obtains the animation speed of the animation based on the product of the view's position change value and the first screen refresh rate. The product of the view's position change value and the first screen refresh rate represents the total distance or displacement of the view within one second, and the total distance or displacement of the view within one second is used as the animation speed of the animation corresponding to the view.
[0124] In some embodiments of this application, the start frame and end frame of the motion effect can be determined based on the motion effect speed. In some embodiments of this application, if the motion effect speed of the current view increases relative to the motion effect speed of the previous frame view, the frame of the current view can be determined as the start frame; if the motion effect speed of several consecutive frames decreases sequentially, the frame of the current view can be determined as the end frame.
[0125] In step S512, the motion effect manager determines the second screen refresh rate of the motion effect based on the motion effect speed.
[0126] In some embodiments of this application, if the motion effect speed is less than a first speed threshold, the motion effect manager determines the second screen refresh rate of the motion effect to be a first preset value; if the motion effect speed is greater than or equal to the first speed threshold and less than the second speed threshold, the second screen refresh rate is determined to be a second preset value; if the motion effect speed is greater than the second speed threshold, the second screen refresh rate is determined to be a third preset value, wherein the first speed threshold is less than the second speed threshold, the first preset value is less than the second preset value, and the second preset value is less than the third preset value. In some embodiments of this application, the first preset value is 60Hz, the second preset value is 90Hz, the third preset value is 120Hz, the first speed threshold is 240 pixels / s, and the second speed threshold is 480 pixels / s.
[0127] In some embodiments of this application, the motion effect manager can determine the second screen refresh rate at fixed preset intervals. In some embodiments of this application, the preset interval can be 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 effect manager determines the refresh rate according to fixed time intervals, which is simple and convenient to calculate.
[0128] In some other embodiments of this application, the motion manager can 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 from the choreographer, the motion manager determines a refresh rate. In this way, the motion manager determines the frequency and refresh rate of the second screen refresh rate, resulting in greater consistency between refresh rate control and motion speed changes, thus improving the refresh rate adjustment effect.
[0129] The above-described embodiments of this application can match different refresh rates according to different animation speeds, achieving finer-grained refresh rate adjustment during animation execution, and further saving power consumption of electronic devices.
[0130] In step S513, if it is determined that the refresh rate of the second screen is different from that of the first screen, the motion effect manager sends the refresh rate of the second screen to the refresh rate control module of the Native framework layer.
[0131] In step S514, the refresh rate control module adjusts the refresh rate of the display screen according to the refresh rate of the second screen, and adjusts the generation cycle of the Vsync signal.
[0132] In the above embodiments of this application, the motion effect manager sends the second screen refresh rate to the refresh rate control module only 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, reduces power consumption, and eliminates the need for the refresh rate control module to determine whether the refresh rate needs to be adjusted, thus reducing the power consumption of the refresh rate control module.
[0133] In step S515, the animation execution module sends the drawn animation frame to the SurfaceFlinger of the Native framework layer.
[0134] In step S516, SurfaceFlinger synthesizes image data from the motion effect frame based on the Vsync signal to obtain the first image frame.
[0135] In some embodiments of this application, SurfaceFlinger can receive a Vsync signal sent by the display screen, and based on the Vsync signal r, send a synthesized first image frame to the display driver, which then sends it to the screen for display. The displayed first image frame is as follows: Figure 4 As shown in Figure (a).
[0136] In step S517, when the choreographer receives the i-th Vsync signal, he returns to step S504.
[0137] Where i = 2, 3, 4...n, and n is an integer. In some embodiments of this application, each time the choreographer receives a Vsync signal, steps S504 to S516 above are executed cyclically once. This completes the drawing of multiple image frames, and during the drawing of each image frame, the motion effect view is subjected to motion effect speed detection, and the second screen refresh rate is determined based on the motion effect speed detection result. If the second screen refresh rate is inconsistent with the current refresh rate (first screen refresh rate), the refresh rate and frame rate are adjusted. Thus, continuous motion effect speed detection and dynamic adjustment of the refresh rate and frame rate are achieved.
[0138] Step S518: When the animation instance ends, the animation execution module sends an animation end notification to the animation manager. The animation end notification is used to indicate that the animation instance has ended.
[0139] In some embodiments of this application, if the termination frame of the animation is detected, View.Animation determines that the Animation animation instance has ended. For example, if the animation speed of several consecutive frames of the view decreases sequentially, View.Animation can determine that the current view's frame is the termination frame, and thus determine that the Animation animation instance has ended. When the Animation animation instance ends, View.Animation sends an animation end notification to the animation manager, which indicates that the Animation animation instance has ended.
[0140] In step S519, the animation manager receives the animation end notification and clears the information of the animation instance.
[0141] In some embodiments of this application, after receiving a notification that the animation has ended, the animation manager clears the information of the Animation instance.
[0142] The method provided in this application can be embedded into the existing animation implementation process of View.Animation, thus eliminating the need for additional traversal processes, reducing load, and saving power. Furthermore, this application identifies the animation speed by using the transformation matrix set by the getTransformation() function, solving the technical problem of not being able to use the applyTransformation() function in View.Animation for animation recognition.
[0143] refer to Figure 6 The diagram shown is a flowchart illustrating a motion effect recognition method provided in another embodiment of this application. The motion effect recognition method is applied in electronic devices. Figure 6 The example method includes one or more steps, but does not constitute a limitation of this application. Furthermore, the order of the steps in the method is merely illustrative and may be changed. Additional steps may be added or steps may be removed without departing from the disclosure of this application. The method includes the following steps.
[0144] Step S601: Display a first interface on the screen. The first interface includes a first control.
[0145] In one embodiment of this application, the first interface includes an interface with animation effects, and a first control is used to control the display of the animation effects. For example, see reference... Figure 4 As shown in Figure (a), the first interface can be the image display interface 901 of the gallery app, and the first control can be the sharing control 903. The sharing control 903 can control the sharing pop-up 904 to perform a translational animation effect, so that the sharing pop-up 904 presents an overall animation effect of gradually translating upwards. In step S602, in response to the user's operation on the first control, the animation effect is executed, and the animation effect includes at least one view.
[0146] In some embodiments of this application, if a user clicks the share control 903, the electronic device responds to the user's operation by performing a translational animation on the share pop-up 904. Figure 4 Figure (b) in the middle and Figure 4 Figure (c) shows two image frames displayed on the screen during the overall animation execution. After the overall animation is completed, the screen displays as follows: Figure 4 The interface shown in Figure (d) is shown in the diagram.
[0147] Step S603: Obtain the first screen refresh rate of the display.
[0148] In one embodiment of this application, the first screen refresh rate of the display screen is obtained from the choreographer. For details on step 603, please refer to [link / reference needed]. Figure 5 The descriptions of steps S503-S505 will not be repeated here.
[0149] Step S604: Determine the position change value of at least one view based on the transformation matrix of the motion effect.
[0150] In some embodiments of this application, the electronic device determines the first positions of multiple corner points of at least one view; transforms the multiple corner points according to a transformation matrix to obtain the second positions of the multiple corner points; calculates the difference between the second position and the first position of each corner point to obtain multiple differences, and uses the maximum value of the multiple differences as the position change value of at least one view. For details of step 604, please refer to [link / reference needed]. Figure 5 The description of steps S506-S510.
[0151] Step S605: Determine the motion speed of the animation based on the position change value and the first screen refresh rate.
[0152] In some embodiments of this application, the electronic device determines the motion speed of the animation based on the product of the position change value and the first screen refresh rate. For details of step S605, please refer to [link / reference needed]. Figure 5 The description of step S511 will not be repeated here.
[0153] The method provided in this application can be embedded into the existing animation implementation process of View.Animation, thus avoiding additional traversal processes, reducing load, and saving power. Furthermore, this application determines the position change value of at least one view based on the transformation matrix, and determines the animation speed based on the position change value and the first screen refresh rate, solving the technical problem of not being able to use the applyTransformation() function in View.Animation for animation recognition, and improving the animation recognition rate.
[0154] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to realize the motion effect recognition method in the above embodiment.
[0155] 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; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the motion recognition method in the above method embodiments.
[0156] In this embodiment, the terminal device, computer storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0157] Through the above description of the implementation methods, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical 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.
[0158] 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 device, 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 devices or units may be electrical, mechanical, or other forms.
[0159] The unit described as a separate component may or may not be physically separate. The component shown as a unit can be one physical unit or multiple physical units, that is, it can be located in one place or distributed in multiple different places. Some or all of the units can be selected to achieve the purpose of the solution in this embodiment according to actual needs.
[0160] 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.
[0161] 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, essentially or in other words, 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.
[0162] The above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to the above preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions to the technical solutions of this application should not depart from the spirit and scope of the technical solutions of this application.
Claims
1. A motion effect recognition method, applied to an electronic device, the electronic device including a display screen, characterized in that, The method includes: A first interface is displayed on the screen, and the first interface includes a first control. In response to a user's operation on the first control, an animation effect is executed, the animation effect including at least one view; Obtain the first screen refresh rate of the display screen; The position change value of the at least one view is determined based on the transformation matrix of the motion effect; The motion speed of the animation is determined based on the position change value and the first screen refresh rate.
2. The motion effect recognition method as described in claim 1, characterized in that, The determination of the position change value of the at least one view based on the transformation matrix of the motion effect includes: Determine the first positions of multiple corner points of the at least one view; Based on the transformation matrix, the multiple corner points are transformed respectively to obtain the second positions of the multiple corner points; Calculate the difference between the second position and the first position of each corner point to obtain multiple differences, and take the maximum value among the multiple differences as the position change value of the at least one view.
3. The motion effect recognition method as described in claim 1, characterized in that, The process of determining the motion speed of the animation based on the position change value and the first screen refresh rate includes: The motion speed of the animation is determined by multiplying the position change value and the first screen refresh rate.
4. The motion effect recognition method as described in claim 1, characterized in that, The method further includes: The second screen refresh rate is determined based on the motion speed, and the refresh rate of the display screen is adjusted based on the second screen refresh rate.
5. The motion effect recognition method as described in claim 4, characterized in that, Determining the second screen refresh rate based on the motion effect speed includes: If the speed of the animation is less than the first speed threshold, the second screen refresh rate is determined to be the first preset value; If the motion effect speed is greater than or equal to the first speed threshold and less than the second speed threshold, the second screen refresh rate is determined to be a second preset value. If the motion speed is greater than or equal to the second speed threshold, the second screen refresh rate is determined to be a third preset value, where the first speed threshold is less than the second speed threshold, the first preset value is less than the second preset value, and the second preset value is less than the third preset value.
6. The motion effect recognition method as described in claim 4, characterized in that, The method further includes: The frame rate of the animation is adjusted based on the second screen refresh rate.
7. The motion effect recognition method as described in claim 1, characterized in that, The method for determining the transformation matrix of the aforementioned motion effect includes: Call the applyLegacyAnimation() function to execute the animation effect; Obtain the transformation matrix output by the applyLegacyAnimation() function.
8. The motion effect recognition method as described in claim 1, characterized in that, The method further includes: Draw the animation frames of at least one of the views; The motion effect frames are synthesized into image data to obtain image frames; The image frame is sent to the display screen for display.
9. The motion effect recognition method as described in claim 1, characterized in that, The motion effect is one or more of the following: translational motion effect, scaling motion effect, and rotational motion effect.
10. An electronic device, characterized in that, The electronic device includes a memory and a processor: The memory is used to store program instructions; The processor is configured to read and execute the program instructions stored in the memory, and when the program instructions are executed by the processor, the electronic device performs the motion recognition method as described in any one of claims 1 to 9.
11. A computer storage medium, characterized in that, The computer storage medium stores program instructions that, when executed on an electronic device, cause the electronic device to perform the motion recognition method as described in any one of claims 1 to 9.