Electronic equipment control method and device, electronic equipment and storage medium
By simulating and cacheing shader files of multiple interface graphics generation processes when the electronic device is powered on and started, the interface lag and frame drop problems caused by obtaining shader files in the prior art are solved, and a smoother user experience is achieved.
Patent Information
- Application Number
- CN202311719992.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-14
- Publication Date
- 2025-06-17
AI Technical Summary
The prior art can easily cause interface lag and frame drops when obtaining shader files, resulting in poor user experience.
When the electronic device is powered on and started, multiple different interface graphics generation processes are simulated, and multiple shader files are generated and cached. After the startup is completed, respond to the interface graphics generation instructions and obtain the cached corresponding shader file to execute the interface graphics generation process.
By caching the shader file in advance, cache misses during the interface graphics generation process are avoided, frame loss and lag rate caused by loading the shader file is reduced, and user experience is improved.
Smart Images

Figure CN120163700A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of electronic devices, and in particular, to a control method, apparatus, electronic device, and storage medium for an electronic device. Background Art
[0002] In recent years, with the rapid development of electronic device graphics processing technology, the interface graphics generation system of electronic devices has become increasingly perfect, and can execute the interface generation process of display interfaces at different levels and in different scenarios. As a basic unit for processing vertex and pixel data of graphics, a shader needs to obtain a corresponding shader file during the interface graphics generation process to define characteristics such as the color or texture of the interface graphics.
[0003] However, with the shader file acquisition method using related technologies, problems such as interface lag and frame drops are likely to occur, resulting in poor user experience. Summary of the Invention
[0004] To overcome the problems existing in related technologies, the present disclosure provides a control method, apparatus, electronic device, and storage medium for an electronic device.
[0005] According to a first aspect of an embodiment of the present disclosure, a control method for an electronic device is provided. The control method for the electronic device includes:
[0006] In response to the startup of the electronic device, simulate a plurality of different interface graphics generation processes, generate a plurality of shader files, and cache each of the shader files;
[0007] After completing the startup, in response to an interface graphics generation instruction, obtain the cached shader file corresponding to the interface graphics generation instruction to execute the corresponding interface graphics generation process.
[0008] In some embodiments of the present disclosure, the simulating a plurality of different interface graphics generation processes includes:
[0009] Simulate each of the interface graphics generation processes based on the interface graphics generation parameter sets corresponding to each of the interface graphics generation processes;
[0010] Wherein, at least some of the graphics generation parameters in the interface graphics generation parameter sets have different parameter values.
[0011] In some embodiments of the present disclosure, the simulating each of the interface graphics generation processes based on the interface graphics generation parameter sets corresponding to each of the interface graphics generation processes, and generating a plurality of shader files includes:
[0012] Perform the following simulation process for each of the interface graphics generation parameter sets:
[0013] Based on each of the graphic generation parameters in the graphic generation parameter set, simulate the interface graphic generation scenario, and generate an interface graphic generation instruction;
[0014] Execute the interface graphic generation instruction to obtain the description information of the corresponding shader;
[0015] Compile the description information of the shader to obtain the shader file corresponding to the interface graphic generation instruction.
[0016] In some embodiments of the present disclosure, the graphic generation parameters include any one or any combination of a pixel format, a texture object reading method, and transparency.
[0017] In some embodiments of the present disclosure, the caching of each of the shader files includes:
[0018] Store each of the shader files in the form of key-value pairs, where the dictionary key of each of the shader files represents the relevant information of the interface graphic generation process corresponding to the shader file.
[0019] In some embodiments of the present disclosure, the interface graphic generation process includes a window interface graphic generation process and / or an application control interface graphic generation process.
[0020] In some embodiments of the present disclosure, the caching of each of the shader files includes:
[0021] Store the shader file corresponding to the window interface graphic generation process in a first cache directory;
[0022] Store the shader file corresponding to the application control interface graphic generation process in a second cache directory.
[0023] In some embodiments of the present disclosure, in response to an interface graphic generation instruction, obtain the cached shader file corresponding to the interface graphic generation instruction to execute the corresponding interface graphic generation process, including:
[0024] In response to a window change, execute the window interface graphic generation process;
[0025] Retrieve the shader file corresponding to the window interface graphic generation process from the first cache directory;
[0026] Based on the shader file, execute the image rendering process in the window interface graphic generation process; and / or,
[0027] In response to an application startup or a change in a control in the application, execute the application control interface graphic generation process;
[0028] Retrieve the shader file corresponding to the application control interface graphic generation process from the second cache directory;
[0029] Based on the shader file, execute the image rendering process in the application control interface graphic generation process.
[0030] According to the second aspect of the embodiments of the present disclosure, there is provided a control device for an electronic device, the control device for the electronic device includes:
[0031] An emulation module, the emulation module is configured to, in response to the startup of the electronic device, emulate a plurality of different interface graphic generation processes, generate a plurality of shader files, and cache each of the shader files;
[0032] An execution module, the execution module is configured to, after completing the startup, in response to an interface graphic generation instruction, obtain the cached shader file corresponding to the interface graphic generation instruction to execute the corresponding interface graphic generation process.
[0033] According to the third aspect of the embodiments of the present disclosure, there is provided an electronic device, the electronic device includes:
[0034] A processor;
[0035] A memory for storing processor-executable instructions;
[0036] Wherein, the processor is configured to:
[0037] In response to the startup of the electronic device, emulate a plurality of different interface graphic generation processes, generate a plurality of shader files, and cache each of the shader files;
[0038] After completing the startup, in response to an interface graphic generation instruction, obtain the cached shader file corresponding to the interface graphic generation instruction to execute the corresponding interface graphic generation process.
[0039] According to the fourth aspect of the embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enabling the electronic device to execute a control method for an electronic device, the control method for the electronic device includes:
[0040] In response to the startup of the electronic device, emulate a plurality of different interface graphic generation processes, generate a plurality of shader files, and cache each of the shader files;
[0041] After completing the startup, in response to an interface graphic generation instruction, obtain the cached shader file corresponding to the interface graphic generation instruction to execute the corresponding interface graphic generation process.
[0042] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects: By simulating the generation processes of multiple different interface graphics in advance when the electronic device is powered on and started, the generation and caching of shader files can be realized in advance, so that after the power-on startup is completed, the real interface graphics generation process can be executed by obtaining the pre-cached shader files, avoiding the cache miss of shader files in the interface graphics generation process, reducing the frame drop rate and stuttering rate caused by loading shader files, and improving the user experience.
[0043] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.
[0045] Figure 1 is a flowchart of a control method for an electronic device shown according to an exemplary embodiment.
[0046] Figure 2 is a flowchart of a simulation process performed on each set of interface graphics generation parameters shown according to an exemplary embodiment.
[0047] Figure 3 is a flowchart of caching each shader file shown according to an exemplary embodiment.
[0048] Figure 4 is a flowchart of obtaining the cached shader file corresponding to the interface graphics generation instruction in response to the interface graphics generation instruction to execute the corresponding interface graphics generation process shown according to an exemplary embodiment.
[0049] Figure 5 is a flowchart of obtaining the cached shader file corresponding to the interface graphics generation instruction in response to the interface graphics generation instruction to execute the corresponding interface graphics generation process shown according to another exemplary embodiment.
[0050] Figure 6 is a flowchart of a control method for an electronic device shown according to another exemplary embodiment.
[0051] Figure 7 is a flowchart of a control method for an electronic device shown according to another exemplary embodiment.
[0052] Figure 8 is a flowchart of a control method for an electronic device shown according to another exemplary embodiment.
[0053] Figure 9 It is a block diagram of a control device of an electronic device shown according to an exemplary embodiment.
[0054] Figure 10 It is a block diagram of an electronic device shown according to an exemplary embodiment.
[0055] In the figure:
[0056] 10 - Analog module; 20 - Execution module; 101 - Processing component; 102 - Memory; 103 - Power component; 104 - Multimedia component; 105 - Audio component; 106 - Input / output interface; 107 - Sensor component; 108 - Communication component; 109 - Processor. Detailed implementation manners
[0057] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present invention. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0058] In recent years, with the rapid development of electronic devices such as mobile phones and tablet computers in the fields of graphics processing-related hardware and algorithms, the interface graphics generation systems such as drawing and rendering of electronic devices have become increasingly perfect, and can relatively well execute the interface generation processes of display interfaces at different levels and in different scenarios such as system level and application level. In related technologies, a shader is used to define characteristics such as the color or texture of interface graphics, and is a basic unit for processing vertex and pixel data of graphics. When using graphics interfaces such as the Open Graphics Library (OpenGL), a large number of shaders are required, and shader files need to be obtained during the execution of the interface graphics generation process for interface graphics rendering.
[0059] However, when obtaining shader files using the methods of related technologies, due to the clearing of the cache after the electronic device is restarted, for each interface graphics generation process executed for the first time, the corresponding shader files cannot be searched in the cache, and cache misses of shader files will occur. The Graphics Processing Unit (GPU) must wait for data to be loaded from the main memory into the cache, and cannot execute other instructions during the loading process, which will lead to performance degradation and problems such as stuttering and frame dropping, resulting in a poor user experience.
[0060] Based on this, an exemplary embodiment of the present disclosure provides a control method for an electronic device. By simulating multiple different interface graphic generation processes in advance when the electronic device boots up, it is possible to pre-generate and cache shader files, so that after the boot-up is completed, the real interface graphic generation process can be executed by obtaining the pre-cached shader files, avoiding cache misses of shader files during the interface graphic generation process, reducing the frame drop rate and stuttering rate caused by loading shader files, and improving the user experience.
[0061] In an exemplary embodiment, a control method for an electronic device is provided. The electronic device may include, for example, devices capable of displaying images such as mobile phones, tablet computers, and laptop computers. Refer to Figure 1 As shown, the control method of the electronic device includes:
[0062] S100. In response to the boot-up of the electronic device, simulate multiple different interface graphic generation processes, generate multiple shader files, and cache each shader file.
[0063] In step S100, when the electronic device boots up, the electronic device has already started services for controlling graphic display, such as SurfaceFlinger or PreloadService, before displaying the desktop and system UI. The cached content during the previous startup usage is cleared after the electronic device restarts. When starting up the electronic device, services such as SurfaceFlinger or PreloadService can be started to simulate multiple different interface graphic generation processes. The interface graphic generation process may include, for example, a drawing process and a rendering process.
[0064] At this time, each interface graphic generation process is not actually executed according to the actual application scenario, but is simulated in advance based on a preset function algorithm and corresponding modules. The simulated interface graphic generation process can correspond to the interface graphic generation process actually executed in the actual application scenario. The simulated interface graphic generation process may be, for example, the interface graphic generation process that frequently appears in the actual application scenario.
[0065] By simulating multiple different interface graphic generation processes, shader files corresponding to the simulated interface graphic generation processes can be generated. The shader file may be, for example, a binary program file obtained by compiling the shader. The electronic device can execute the interface graphic generation process in the actual application scenario according to the shader file. After each shader file is generated, it can be immediately cached, and the shader file is stored in the cache of the electronic device, so that the electronic device can directly obtain the pre-stored shader file from the cache later.
[0066] S200. After completing the boot-up, in response to an interface graphics generation instruction, obtain the cached shader file corresponding to the interface graphics generation instruction to execute the corresponding interface graphics generation process.
[0067] In step S200, after completing the boot-up, the shader file generated by simulating the interface graphics generation process has been stored in the cache of the electronic device. When receiving an interface graphics generation instruction and needing to execute the interface graphics generation process, even if this is the first execution of the interface graphics generation process, since multiple different interface graphics generation processes were pre-simulated when generating the shader file, there will no longer be a cache miss of the shader file in the related art. The shader file corresponding to the interface graphics generation instruction can be directly obtained from the cache of the electronic device to execute the corresponding interface graphics generation process according to the obtained shader file.
[0068] In this embodiment, by pre-simulating multiple different interface graphics generation processes when the electronic device boots up, the generation and caching of shader files can be pre-implemented, so that after completing the boot-up, the real interface graphics generation process can be executed by obtaining the pre-cached shader files, avoiding the cache miss of the shader file in the interface graphics generation process, reducing the frame drop rate and stuttering rate caused by loading the shader file, and improving the user experience.
[0069] In some embodiments, the interface graphics generation process includes a window interface graphics generation process, or the interface graphics generation process includes an application control interface graphics generation process. Alternatively, the interface graphics generation process includes both a window interface graphics generation process and an application control interface graphics generation process.
[0070] The interface graphics generation process may include a window interface graphics generation process and an application control interface graphics generation process. Among them, the window interface graphics generation process is used for generating window graphics at the system level and application level, and the application control interface graphics generation process is used for generating control graphics within a single application at the application level.
[0071] The data between the window interface graphic generation process and the application control interface graphic generation process is not interoperable, so the simulation of the window interface graphic generation process and the application control interface graphic generation process needs to be implemented through different modules when different services are started. Exemplarily, the simulation of the window interface graphic generation process is performed when the SurfaceFlinger service as described above is started. The SurfaceFlinger service is responsible for the screen rendering and composition of the electronic device, including the composition of application windows, system UIs, and other graphic contents. The application control interface graphic generation process is performed when the PreloadService service as described above is started. The PreloadService service is responsible for preloading the data and resources required by the application in advance when the application is started, reducing the user waiting time to improve the response performance of the application.
[0072] Exemplarily, the simulation of the window interface graphic generation process can be implemented, for example, through the module corresponding to SurfaceFlinger. The simulation of the application control interface graphic generation process can be implemented through the skia (an open-source 2D graphics library) module corresponding to the GPU-accelerated 2D graphics engine (HardwareAccelerated Rendering Engine for UI, HWUI). HWUI is an application-level rendering engine responsible for handling the graphic drawing and animations of a single application.
[0073] In this embodiment, the interface graphic generation process includes the window interface graphic generation process and the application control interface graphic generation process, which can distinguish the interface graphic generation processes that need to be separately simulated and executed, ensure that the generated shader files can cover the window interface graphic generation process and the application control interface graphic generation process, and thus prevent the shader file cache misses from occurring in the subsequent window graphic and control graphic generation processes, reducing the frame drop rate and stuttering rate caused by loading shader files and improving the user experience.
[0074] In some embodiments, simulating multiple different interface graphic generation processes includes: simulating each interface graphic generation process based on the interface graphic generation parameter set corresponding to each interface graphic generation process. Among them, at least some of the graphic generation parameters in the interface graphic generation parameter sets have different parameter values.
[0075] After a large number of tests, it is found that when the graphic generation parameters change, the shader files corresponding to the interface graphic generation process also change accordingly. Therefore, when simulating each interface graphic generation process, the changes in the graphic generation parameters can be enumerated in advance, so that the graphic generation parameters in part or all of the interface graphic generation parameter sets have different parameter values, ensuring that the interface graphic parameter set covers as much as possible the interface graphic generation processes that frequently appear in the actual application scenario. The simulation of each interface graphic generation process can be carried out according to the interface graphic generation parameter set corresponding to each interface graphic generation process.
[0076] The number of the interface graphic generation parameter sets can be set by the user according to their needs and usage habits. For example, the interface graphic generation parameter sets can be obtained corresponding to the samples of different interface graphic generation processes and written into the electronic device in advance before the electronic device is prepared.
[0077] It should be noted that for different types of graphic generation processes, the parameter values of the graphic generation parameters in the interface graphic generation parameter set may be the same. For example, the window interface graphic generation process and the application control interface graphic generation process can be simulated based on the same interface graphic generation parameter set. Therefore, there may be some interface graphic generation parameter sets in which the parameter values of the graphic generation parameters are the same.
[0078] In this embodiment, according to the interface graphic generation parameter set corresponding to each interface graphic generation process, each interface graphic generation process is simulated, realizing the simulation of multiple different interface graphic generation processes. By changing the parameter values of the graphic generation parameters in the interface graphic generation parameter set, the interface graphic parameter set covers as much as possible the interface graphic generation processes that frequently appear in the actual application scenario, enumerating in advance the changes in the graphic generation parameters, ensuring that the corresponding shader files can be obtained when different interface graphic generation processes are executed subsequently, reducing the frame drop rate and stuttering rate caused by loading shader files, and improving the user experience.
[0079] In some embodiments, based on the interface graphic generation parameter set corresponding to each interface graphic generation process, each interface graphic generation process is simulated to generate multiple shader files, including:
[0080] Refer to Figure 2 As shown, the following simulation process is executed for each interface graphic generation parameter set:
[0081] S110. Based on each graphic generation parameter in the interface graphic generation parameter set, simulate the interface graphic generation scenario to generate an interface graphic generation instruction.
[0082] In step S110, each graphic generation parameter in the parameter set is generated according to the interface graphic, the interface graphic generation scenario is simulated, the corresponding interface graphic generation operation is executed under the simulated interface graphic generation scenario, and the corresponding interface graphic generation instruction is generated and recorded.
[0083] Exemplarily, when the interface graphic generation parameter set is used to simulate the window interface graphic generation process, for example, each graphic generation parameter in the interface graphic generation parameter set can be used as a basis, and the interface graphic generation scenario corresponding to the interface graphic generation parameter set can be simulated through the preset primeShaderCache function algorithm. When the interface graphic generation parameter set is used to simulate the application control interface graphic generation process, for example, each graphic generation parameter in the interface graphic generation parameter set can be used as a basis, and the interface graphic generation scenario corresponding to the interface graphic generation parameter set can be simulated through the skia module corresponding to HWUI.
[0084] S120. Execute the interface graphic generation instruction to obtain the description information of the corresponding shader.
[0085] In step S120, after the interface graphic generation instruction is generated, the electronic device executes the flush process. The flush process is used to ensure that the data and information in the cache are correctly refreshed to the screen of the electronic device. When executing the flush process, the electronic device first executes the generated interface graphic generation instruction, and matches the corresponding shader file in the cache according to the obtained interface graphic generation instruction. Since each interface graphic generation instruction corresponds to a simulated interface graphic generation scenario, and the simulated interface graphic generation scenario appears for the first time after the electronic device is started, the corresponding shader file cannot be found in the cache, which will trigger a cache miss of the shader file. After triggering the cache miss of the shader file, the description information of the shader corresponding to the interface graphic generation instruction will be obtained. The description information of the shader can be, for example, the source code of the shader.
[0086] S130. Compile the description information of the shader to obtain the shader file corresponding to the interface graphic generation instruction.
[0087] In step S130, the obtained shader description information can be compiled to obtain the shader file corresponding to the interface graphic generation instruction, realizing the generation of the corresponding shader file by simulating the interface graphic generation process. Exemplarily, for example, the shader file generation thread CreateProgram in the system can be started, and the source code of the shader sent to the skia module or the OpenGL graphics interface is compiled by the graphics processor to generate the corresponding binary shader file.
[0088] In this embodiment, a scene for generating an interface graph is simulated according to the graph generation parameters in the parameter set for generating an interface graph, and an instruction for generating an interface graph is generated, thereby simulating the process of generating each interface graph. By executing the interface graph instruction, the description information of the corresponding shader is obtained, and the description information of the shader is compiled, thereby generating the corresponding shader file. During the simulation process executed for each interface graph parameter set, the generation of the shader file is completed in advance during the simulation process by triggering a shader file miss in advance, ensuring that the generated shader file can be applied to the interface graph generation process executed in the actual application scenario, reducing the frame drop rate and stuttering rate caused by loading the shader file, and improving the user experience.
[0089] In some embodiments, the graph generation parameters include any one or any combination of a pixel format, a texture object reading method, and transparency.
[0090] When the pixel format, the reading method of the texture object, or the transparency changes, the shader file corresponding to the interface graph generation process also changes accordingly. Therefore, any one or any combination of the pixel format, the texture object reading method, and transparency can be used as the graph generation parameters. By changing the parameter values of the pixel format, the texture object reading method, and transparency in different interface graph generation parameter sets, the changes in the graph generation parameters are enumerated in advance, ensuring that the graph generation parameters cover as much as possible the interface graph generation processes that frequently occur in the actual application scenario.
[0091] It should be noted that when simulating the window interface graph generation process or the application control interface graph generation process, the pixel format, the texture object reading method, and transparency can be used as the graph generation parameters in the corresponding interface graph generation parameter set to obtain the shader file corresponding to the window interface graph generation process or the application control interface graph generation process.
[0092] In this embodiment, using any one or any combination of the pixel format, the texture object reading method, and transparency as the graph generation parameters can enable the interface graph generation parameter set including the graph generation parameters to simulate the interface graph generation scene and the interface graph generation process, enabling the interface graph parameter set to cover as much as possible the interface graph generation processes that frequently occur in the actual application scenario, ensuring that the corresponding shader file can be obtained when different interface graph generation processes are executed subsequently, reducing the frame drop rate and stuttering rate caused by loading the shader file, and improving the user experience.
[0093] In some embodiments, caching each shader file includes: storing each shader file in the form of key-value pairs, where the dictionary key of each shader file represents the relevant information of the interface graph generation process corresponding to the shader file.
[0094] When caching each generated shader file, each shader file is stored in the form of key-value pairs. Exemplarily, a dictionary can be generated based on each shader file, with the relevant information of the interface graphic generation process corresponding to the shader file as the dictionary key (key), and each shader file as the dictionary value (value) corresponding to each dictionary key one by one. The relevant information of the interface graphic generation process corresponding to the shader file can be, for example, rendering task information, so that the relevant information can be used as the identifier of the shader file to represent the execution purpose of the interface graphic generation process corresponding to each shader file through the relevant information.
[0095] After storing each shader file in the form of key-value pairs, in subsequent actual application scenarios when executing the interface graphic generation process, the corresponding shader file can be searched in the dictionary according to the relevant information of the interface graphic generation process to achieve fast matching and acquisition of the shader file.
[0096] In this embodiment, storing each shader file in the form of key-value pairs and enabling the dictionary key of each shader file to represent the relevant information of the interface graphic generation process corresponding to the shader file can use the relevant information as the storage identifier of the shader file, and can achieve fast matching and acquisition of the shader file when the corresponding shader file needs to be obtained during the subsequent execution of the interface graphic generation process, ensuring the standardization of shader file storage and the accuracy of retrieval, and improving the user experience.
[0097] In some embodiments, as shown in Figure 3 caching each shader file includes:
[0098] S140. Store the shader file corresponding to the window interface graphic generation process in the first cache directory.
[0099] S150. Store the shader file corresponding to the application control interface graphic generation process in the second cache directory.
[0100] As mentioned above, when the interface graphic generation process includes a window interface graphic generation process and an application control interface graphic generation process, the data between the window interface graphic generation process and the application control interface graphic generation process is not interoperable. The simulation of the two different interface graphic generation processes not only needs to be implemented by different modules when different services are started, but also the corresponding generated shader files need to be stored in different storage locations.
[0101] Exemplarily, the shader file corresponding to the window interface graphic generation process is stored in the first cache directory (SKLRUCache fMap) in the cache, and the shader file corresponding to the application control interface graphic generation process is stored in the second cache directory in the cache. Subsequently, when the interface graphic generation process is actually executed in an application scenario, the shader file corresponding to the window interface graphic generation process can be retrieved from the first cache directory, and the shader file corresponding to the application control interface graphic generation process can be retrieved from the second cache directory.
[0102] In this embodiment, the shader file corresponding to the window interface graphic generation process is stored in the first cache directory, and the shader file corresponding to the application control interface graphic generation process is stored in the second cache directory, so that the shader files generated by two different interface graphic generation processes can be stored in different storage locations according to requirements, realizing the classified storage of shader files, facilitating the search and acquisition of shader files in different cache directories when the interface graphic generation process is executed, and preventing confusion between the shader files of different types of interface graphic generation processes.
[0103] In some embodiments, referring to Figure 4 as shown, in response to an interface graphic generation instruction, a cached shader file corresponding to the interface graphic generation instruction is obtained to execute the corresponding interface graphic generation process, including:
[0104] S210. In response to a window change, execute the window interface graphic generation process.
[0105] In step S210, when the window changes, it means that the window interface graphic generation process needs to be executed in an actual application scenario to generate the window graphic. Exemplarily, the Surfaceflinger service will execute the corresponding target interface graphic generation operation according to the target graphic generation parameters passed in by the window service (Window Manager Service, WMS) and record the corresponding target interface graphic generation instruction.
[0106] S220. Retrieve the shader file corresponding to the window interface graphic generation process from the first cache directory.
[0107] In step S220, exemplarily, when the flush process is executed, the electronic device executes the target interface graphic generation instruction through the skia module and matches the target shader file in the first cache directory. Since the shader file corresponding to the window interface graphic generation process has been stored in the first cache directory when the electronic device is powered on and started, the shader file corresponding to the window interface graphic generation process can be directly retrieved from the first cache directory to obtain the target shader file.
[0108] S230. Execute the image rendering process during the window interface graph generation process based on the shader file.
[0109] In step S230, the shader file corresponding to the window interface graph generation process can be used for the image rendering process during the window interface graph generation process. The image rendering process during the window interface graph generation process can be executed according to the obtained target shader file to perform the rendering of the window graph, so that the electronic device can display the changed window.
[0110] In this embodiment, in response to the window change, the window interface graph generation process is executed, and the shader file corresponding to the window interface graph generation process is retrieved from the first cache directory. The image rendering process during the window interface graph generation process can be executed according to the shader file, realizing the acquisition of the shader file when the interface graph generation process is the window interface graph generation process to execute the corresponding image rendering process. When the electronic device needs to execute the window interface graph generation process in the actual application scenario, the corresponding shader file can be directly retrieved from the first cache directory, avoiding the cache miss of the shader file, reducing the frame drop rate and stuttering rate caused by loading the shader file, and improving the user experience.
[0111] In some other embodiments, refer to Figure 5 As shown, in response to the interface graph generation instruction, retrieve the cached shader file corresponding to the interface graph generation instruction to execute the corresponding interface graph generation process, including:
[0112] S240. In response to the application startup or the change of the control in the application, execute the application control interface graph generation process.
[0113] In step S240, when the application starts up or the control in the application changes, it means that the application control interface graph generation process needs to be executed in the actual application scenario to generate the control graph within a single application. Exemplarily, the PreloadService service will execute the corresponding target interface graph operation according to the target graph generation parameters and record the corresponding target interface graph generation instruction.
[0114] S250. Retrieve the shader file corresponding to the application control interface graph generation process from the second cache directory.
[0115] In step S250, exemplarily, when the flush process is executed, the electronic device executes the target interface graphic generation instruction through the skia module, and matches the target shader file in the second cache directory according to the target interface graphic generation instruction. Since the shader file corresponding to the application control interface graphic generation process has been stored in the second cache directory when the electronic device is powered on and started, the shader file corresponding to the application control interface graphic generation process can be directly retrieved from the second cache directory to obtain the target shader file.
[0116] S260. Based on the shader file, execute the image rendering process in the application control interface graphic generation process.
[0117] In step S260, the shader file corresponding to the application control interface graphic generation process can be used for the image rendering process in the application control interface graphic generation process. The image rendering process in the application control interface graphic generation process can be executed according to the obtained target shader file to render the graphics of the controls within a single application, so that the electronic device can display the changed controls.
[0118] In this embodiment, in response to the startup of the application or the change of the controls in the application, the application control interface graphic generation process is executed, and the shader file corresponding to the application control interface graphic generation process is retrieved from the second cache directory. The image rendering process in the application control interface graphic generation process can be executed according to the shader file, realizing the acquisition of the shader file when the interface graphic generation process is the application control interface graphic generation process to execute the corresponding image rendering process. When the electronic device needs to execute the application control interface graphic generation process in an actual application scenario, the corresponding shader file can be directly retrieved from the second cache directory, avoiding the cache miss of the shader file, reducing the frame drop rate and stuttering rate caused by loading the shader file, and improving the user experience.
[0119] In an exemplary embodiment, a control method for an electronic device is provided. Refer to Figure 6 As shown, the control method of the electronic device includes:
[0120] S1. In response to the startup of the electronic device, based on each graphic generation parameter in each set of interface graphic generation parameters, simulate the interface graphic generation scenario and generate an interface graphic generation instruction;
[0121] S2. Execute the interface graphic generation instruction to obtain the description information of the corresponding shader;
[0122] S3. Compile the description information of the shader to obtain the shader file corresponding to the interface graphic generation instruction;
[0123] S4. Store the shader file corresponding to the window interface graph generation process in the form of key-value pairs in the first cache directory;
[0124] S5. In response to a window change, execute the window interface graph generation process;
[0125] S6. Retrieve the shader file corresponding to the window interface graph generation process from the first cache directory;
[0126] S7. Based on the shader file, execute the image rendering process in the window interface graph generation process.
[0127] In this embodiment, by simulating multiple different interface graph generation processes in advance when the electronic device is powered on and started, the generation and caching of shader files can be realized in advance, so that after the power-on and startup are completed, the real window interface graph generation process can be executed by obtaining the pre-cached shader files, avoiding the cache miss of the shader files in the window interface graph generation process, reducing the frame drop rate and stuttering rate caused by loading the shader files, and improving the user experience.
[0128] In an exemplary embodiment, a control method for an electronic device is provided. Referring to Figure 7 as shown, the control method of the electronic device includes:
[0129] S11. In response to the power-on and startup of the electronic device, based on each graph generation parameter in each interface graph generation parameter set, simulate the interface graph generation scenario and generate an interface graph generation instruction;
[0130] S12. Execute the interface graph generation instruction to obtain the description information of the corresponding shader;
[0131] S13. Compile the description information of the shader to obtain the shader file corresponding to the interface graph generation instruction;
[0132] S14. Store the shader file corresponding to the application control interface graph generation process in the form of key-value pairs in the second cache directory;
[0133] S15. In response to the startup of the application or the change of the control in the application, execute the application control interface graph generation process;
[0134] S16. Retrieve the shader file corresponding to the application control interface graph generation process from the second cache directory;
[0135] S17. Based on the shader file, execute the image rendering process in the application control interface graph generation process.
[0136] Exemplarily, in an actual application scenario, in combination with Figure 8As shown, when the electronic device is powered on and the PreloadService service is started, the graphic generation parameters in the parameter set are used to simulate the interface graphic generation scenario according to the interface graphics, and the interface graphic generation instructions are generated by performing the interface graphic generation operation and recording the interface graphic generation instructions. When performing the flush process, the interface graphic generation instructions are executed to obtain the description information of the corresponding shader, and then the description information of the shader is compiled to obtain the shader file corresponding to the interface graphic generation instructions, and the shader file is stored in the second cache directory in the form of key-value pairs. When App1 or App2 is started, the application control interface graphic generation process is executed by performing the interface graphic generation operation, recording the interface graphic generation instructions, performing the flush process, and executing the interface graphic generation instructions, and the shader file corresponding to the application control interface graphic generation process is retrieved from the second cache directory, and then the image rendering process in the application control interface graphic generation process can be executed according to the shader file.
[0137] In this embodiment, by simulating multiple different interface graphic generation processes in advance when the electronic device is powered on, the generation and caching of shader files can be realized in advance, so that after the power-on startup is completed, the real application control interface graphic generation process can be executed by obtaining the pre-cached shader files, avoiding the cache miss of the shader files in the application control interface graphic generation process, reducing the frame drop rate and stuttering rate caused by loading the shader files, and improving the user experience.
[0138] In an exemplary embodiment, a control device for an electronic device is provided. Refer to Figure 9 As shown, the control device of the electronic device includes a simulation module 10 and an execution module 20. The simulation module 10 is configured to respond to the power-on startup of the electronic device, simulate multiple different interface graphic generation processes, generate multiple shader files, and cache each shader file. The execution module 20 is configured to, after the power-on startup is completed, respond to the interface graphic generation instructions, obtain the cached shader file corresponding to the interface graphic generation instructions, and execute the corresponding interface graphic generation process.
[0139] In this embodiment, by the simulation module 10 simulating multiple different interface graphic generation processes in advance when the electronic device is powered on, the generation and caching of shader files can be realized in advance, so that after the power-on startup is completed, the real interface graphic generation process can be executed by the execution module 20 obtaining the pre-cached shader files, avoiding the cache miss of the shader files in the interface graphic generation process, reducing the frame drop rate and stuttering rate caused by loading the shader files, and improving the user experience.
[0140] In one embodiment, the simulation module 10 is further configured to: generate a set of interface graphic generation parameters corresponding to each interface graphic generation process, and simulate each interface graphic generation process. Among them, at least some of the graphic generation parameters in the set of interface graphic generation parameters have different parameter values.
[0141] In one embodiment, the simulation module 10 is further configured to: perform the following simulation process for each set of interface graphic generation parameters: based on each graphic generation parameter in the set of interface graphic generation parameters, simulate an interface graphic generation scenario, generate an interface graphic generation instruction; execute the interface graphic generation instruction to obtain description information of the corresponding shader; compile the description information of the shader to obtain a shader file corresponding to the interface graphic generation instruction.
[0142] In one embodiment, the graphic generation parameters include any one or any combination of a pixel format, a texture object reading method, and transparency.
[0143] In one embodiment, the simulation module 10 is further configured to: store each shader file in the form of a key-value pair, where the dictionary key of each shader file represents information related to the interface graphic generation process corresponding to the shader file.
[0144] In one embodiment, the interface graphic generation process includes a window interface graphic generation process and / or an application control interface graphic generation process.
[0145] In one embodiment, the simulation module 10 is further configured to: store the shader file corresponding to the window interface graphic generation process in a first cache directory; store the shader file corresponding to the application control interface graphic generation process in a second cache directory.
[0146] In one embodiment, the execution module 20 is further configured to: in response to a window change, execute a window interface graphic generation process; retrieve the shader file corresponding to the window interface graphic generation process from the first cache directory; based on the shader file, execute an image rendering process in the window interface graphic generation process.
[0147] In one embodiment, the execution module 20 is further configured to: in response to an application startup or a change in a control in the application, execute an application control interface graphic generation process; retrieve the shader file corresponding to the application control interface graphic generation process from the second cache directory; based on the shader file, execute an image rendering process in the application control interface graphic generation process.
[0148] In an exemplary embodiment, an electronic device is provided. The electronic device may include, for example, a mobile phone, a tablet computer, a laptop computer, or other devices capable of displaying a screen.
[0149] Reference Figure 10As shown, the electronic device may include one or more of the following components: a processing component 101, a memory 102, a power component 103, a multimedia component 104, an audio component 105, an input / output (I / O) interface 106, a sensor component 107, and a communication component 108.
[0150] The processing component 101 generally controls the overall operation of the electronic device, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 101 may include one or more processors 109 to execute instructions. In addition, the processing component 101 may include one or more modules to facilitate interaction between the processing component 101 and other components. For example, the processing component 101 may include a multimedia module to facilitate interaction between the multimedia component 104 and the processing component 101.
[0151] The memory 102 is configured to store various types of data to support the operation of the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phone book data, messages, pictures, videos, etc. The memory 102 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0152] The power component 103 provides power to the various components of the electronic device. The power component 103 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device.
[0153] The multimedia component 104 includes a screen that provides an output interface between the electronic device and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of touch or swipe actions, but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 104 includes a front camera and / or a rear camera. When the electronic device is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each of the front camera and the rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0154] The audio component 105 is configured to output and / or input audio signals. For example, the audio component 105 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 102 or transmitted via the communication component 108. In some embodiments, the audio component 105 further includes a speaker for outputting audio signals.
[0155] The I / O interface 106 provides an interface between the processing component 101 and a peripheral interface module, and the peripheral interface module can be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a power button, and a lock button.
[0156] The sensor component 107 includes one or more sensors for providing status assessments of various aspects of the electronic device. For example, the sensor component 107 can detect the on / off state of the electronic device, the relative positioning of components, such as the display and keypad of the electronic device. The sensor component 107 can also detect a change in the position of the electronic device or a component of the electronic device, the presence or absence of user contact with the electronic device, the orientation or acceleration / deceleration of the electronic device, and the temperature change of the electronic device. The sensor component 107 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 107 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 107 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0157] The communication component 108 is configured to facilitate communication between the electronic device and other devices in a wired or wireless manner. The device can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 108 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 108 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0158] In an exemplary embodiment, the electronic device may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components for executing the control method applied to the electronic device.
[0159] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as the memory 102 including instructions, and the above instructions can be executed by the processor 109 of the electronic device to complete the above control method applied to the electronic device. For example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc. When the instructions in the storage medium are executed by the processor 109 of the electronic device, the electronic device can execute the above control method applied to the electronic device.
[0160] Those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention, which follow the general principles of the present invention and include common general knowledge or conventional technical means in the technical field not disclosed in this disclosure. The specification and the embodiments are only to be regarded as exemplary, and the true scope and spirit of the present invention are pointed out by the following claims.
[0161] It should be understood that the present invention is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is only limited by the appended claims.
Claims
1. A control method for an electronic device, characterized in that, The control method of the electronic device includes: In response to the startup of the electronic device, simulating a plurality of different interface graphic generation processes, generating a plurality of shader files, and caching each of the shader files; After the startup is completed, in response to an interface graphic generation instruction, obtaining the cached shader file corresponding to the interface graphic generation instruction to execute the corresponding interface graphic generation process.
2. The control method for an electronic device according to claim 1, characterized in that, The simulating a plurality of different interface graphic generation processes includes: Based on the interface graphic generation parameter sets corresponding to each of the interface graphic generation processes, simulating each of the interface graphic generation processes; Wherein, at least some of the graphic generation parameters in the interface graphic generation parameter sets have different parameter values.
3. The control method for an electronic device according to claim 2, characterized in that, The simulating each of the interface graphic generation processes based on the interface graphic generation parameter sets corresponding to each of the interface graphic generation processes and generating a plurality of shader files includes: Performing the following simulation process for each of the interface graphic generation parameter sets: Based on each of the graphic generation parameters in the interface graphic generation parameter set, simulating an interface graphic generation scenario to generate an interface graphic generation instruction; Executing the interface graphic generation instruction to obtain the description information of the corresponding shader; Compiling the description information of the shader to obtain the shader file corresponding to the interface graphic generation instruction.
4. The control method for an electronic device according to claim 2, characterized in that, The graphic generation parameters include any one or any combination of a pixel format, a texture object reading method, and transparency.
5. The control method for an electronic device according to claim 1, characterized in that, The caching each of the shader files includes: Storing each of the shader files in the form of key-value pairs, wherein the dictionary key of each of the shader files represents the relevant information of the interface graphic generation process corresponding to the shader file.
6. The control method for an electronic device according to any one of claims 1-5, characterized in that, The interface graphic generation process includes a window interface graphic generation process and / or an application control interface graphic generation process.
7. The control method for an electronic device according to claim 6, characterized in that, The caching each of the shader files includes: Storing the shader file corresponding to the window interface graphic generation process in a first cache directory; Storing the shader file corresponding to the application control interface graphic generation process in a second cache directory.
8. The control method for an electronic device according to claim 7, characterized in that, In response to an interface graphic generation instruction, obtaining the cached shader file corresponding to the interface graphic generation instruction to execute the corresponding interface graphic generation process includes: In response to a window change, executing a window interface graphic generation process; Retrieving the shader file corresponding to the window interface graphic generation process from the first cache directory; Based on the shader file, performing an image rendering process in the window interface graphic generation process; and / or, In response to an application startup or a change in a control in the application, executing an application control interface graphic generation process; Retrieving the shader file corresponding to the application control interface graphic generation process from the second cache directory; Based on the shader file, performing an image rendering process in the application control interface graphic generation process.
9. A control device for an electronic device, characterized in that, The control device of the electronic device includes: A simulation module, which is used to respond to the startup of the electronic device, simulate multiple different interface graphic generation processes, generate multiple shader files, and cache each of the shader files; An execution module, which is used to, after completing the startup, respond to an interface graphic generation instruction, obtain the cached shader file corresponding to the interface graphic generation instruction, so as to execute the corresponding interface graphic generation process.
10. An electronic device, characterized in that, The electronic device includes: A processor; A memory for storing instructions executable by the processor; Wherein, the processor is configured to: Respond to the startup of the electronic device, simulate multiple different interface graphic generation processes, generate multiple shader files, and cache each of the shader files; After completing the startup, respond to an interface graphic generation instruction, obtain the cached shader file corresponding to the interface graphic generation instruction, so as to execute the corresponding interface graphic generation process.
11. A non - transitory computer - readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute a control method of the electronic device, and the control method of the electronic device includes: Respond to the startup of the electronic device, simulate multiple different interface graphic generation processes, generate multiple shader files, and cache each of the shader files; After completing the startup, respond to an interface graphic generation instruction, obtain the cached shader file corresponding to the interface graphic generation instruction, so as to execute the corresponding interface graphic generation process.