Method and system for reducing flicker phenomenon during 3D multi-scene switching
By defining the service interface and realizing memory sharing in the rendering service, the problem of flickering during 3D multi-scene switching is solved, reducing maintenance complexity and improving effect quality.
Patent Information
- Application Number
- CN202411138077.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-03
Smart Images

Figure CN119071459A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle technology, and in particular to a method, system, electronic device, storage medium and terminal for reducing flickering when switching between 3D multi-scenes. Background Art
[0002] Currently, there are three ways to implement 3D effect multi-scene switching:
[0003] 1. A separate page performs engine initialization and rendering. Other applications are made transparent and superimposed on the background, and scene change notifications are made through cross-process communication.
[0004] 2. A separate service performs engine initialization and rendering. Other applications use cross-process rendering to display the rendering results provided by the service and use cross-process communication to notify scene changes.
[0005] 3. A separate service performs engine initialization and rendering work. The system generates and controls independent drawing surfaces before other applications, and sends scene change notifications and gestures through cross-process communication;
[0006] Among them, the transparency of solution one affects the life cycle, requires the modification of multiple applications, and is complex to maintain; the transformation cost of solution three is high, and it is difficult to solve the occlusion problem; although solution two is simple to implement, there will be flickering when switching between multiple scenes, including flashing black and white, and the effect is not good.
[0007] Therefore, the present application provides a method for reducing the flickering phenomenon during 3D multi-scene switching to solve the above technical problem. Summary of the invention
[0008] The purpose of the present invention is to provide a method, system, electronic device, storage medium and terminal for reducing flickering during 3D multi-scene switching, so as to solve the technical problems in the prior art that 3D effect multi-scene switching is complex to maintain and flickering occurs during switching.
[0009] In order to solve the above technical problem, the present invention provides a method for reducing flickering phenomenon during 3D multi-scene switching, comprising:
[0010] The step of creating a service interface includes defining a service interface in a rendering service, wherein the service interface includes a method callable by an application and a communication protocol for rendering and memory sharing objects;
[0011] Implementing a remote service step, including creating and implementing a class inherited from Service in the application, wherein the class is used to implement the service interface and return an instance of the service interface in an onBind method;
[0012] The step of configuring the service list includes declaring the corresponding service in the list file of the application, and specifying the name of the service and the interface provided;
[0013] The steps of binding the service and calling the method include, in the application, copying the service interface, creating a ServiceConnection object and binding to the remote service through the bindService method, calling the remote service method based on the service interface instance obtained by binding, realizing the rendering and switching of the 3D scene, and calling the screenshot logic in the rendering callback, dynamically obtaining the placeholder image, and realizing the cross-process transmission of the placeholder image through memory sharing.
[0014] In some specific embodiments, the step of creating a service interface includes defining a service interface in a rendering service, wherein the service interface includes a method callable by an application, a communication protocol for rendering and memory sharing objects, and further includes:
[0015] Define an AIDL file, wherein the AIDL file includes a definition of the service interface;
[0016] Define at least one method in the AIDL file, where the method is used for the communication protocol when the remote service is called;
[0017] Compile the AIDL file to generate a corresponding Java class, which contains a specific implementation framework of the service interface.
[0018] In some specific embodiments, the remote service step includes creating and implementing a class inherited from Service in the application, wherein the class is used to implement the service interface and return an instance of the service interface in the onBind method, further comprising:
[0019] Create a class that inherits from Service and implement the defined service interface in the class;
[0020] In the onBind method of the class, an instance of the service interface is returned so that the application can bind and call the corresponding service;
[0021] Implement the methods defined in the service interface, including logic for processing rendering requests and memory sharing.
[0022] In some specific embodiments, the step of configuring the service list includes declaring the corresponding service in the manifest file of the application, specifying the name of the service and the provided interface, and further includes:
[0023] Declare the corresponding service in the AndroidManifest.xml file of the application;
[0024] Specifies the full class name of the service;
[0025] Use intent-filter or action or category elements in the service tag to specify the name of the service and the interface it provides;
[0026] Configure corresponding permissions and metadata so that the service can be called correctly.
[0027] In some specific embodiments, the steps of binding a service and calling a method include, in the application, copying the service interface, creating a ServiceConnection object, binding to a remote service through a bindService method, calling a remote service method based on the service interface instance obtained by binding, implementing rendering and switching of 3D scenes, and calling a screenshot logic in a rendering callback, dynamically obtaining a placeholder image, and implementing cross-process transmission of the placeholder image through memory sharing, further including:
[0028] In the application, copy the defined AIDL file to the corresponding package;
[0029] Create a ServiceConnection object to monitor changes in the service connection status;
[0030] Call the bindService method, passing in the application's Intent and ServiceConnection object to establish a connection with the service provider;
[0031] In the onServiceConnected callback of ServiceConnection, the method of the remote service is called through the returned service interface instance to realize the rendering and switching of the 3D scene;
[0032] In the rendering callback, start the background thread to execute the screenshot logic, obtain the placeholder image of the current rendering result, and pass the placeholder image to the rendering service or the corresponding application through memory sharing to reduce flickering.
[0033] In some specific embodiments, implementing the screenshot logic further includes:
[0034] In the background thread, capture the drawing results of the current rendering view;
[0035] Saving the captured drawing result as an image file or an image object in memory;
[0036] Use the shared memory mechanism to pass the reference of the image object or image file across processes to the rendering service or corresponding application;
[0037] Release the resources used in the background thread so that the main thread's drawing and event response are not affected.
[0038] Based on the same concept, the present invention also provides a system for reducing flickering during 3D multi-scene switching, comprising:
[0039] Creating a service interface module configured to define a service interface in a rendering service, wherein the service interface includes methods callable by an application and a communication protocol for rendering and memory sharing objects;
[0040] Implementing a remote service module, configured to create and implement a class inherited from Service in the application, wherein the class is used to implement the service interface and return an instance of the service interface in an onBind method;
[0041] A service list module is configured to provide a voice corresponding service in the list file of the application, specifying the name of the service and the interface provided;
[0042] The binding service and calling method module is configured to copy the service interface in the application, create a ServiceConnection object and bind to the remote service through the bindService method, call the remote service method based on the service interface instance obtained by binding, realize the rendering and switching of 3D scenes, and call the screenshot logic in the rendering callback to dynamically obtain the placeholder image, and realize the cross-process transmission of the placeholder image through memory sharing.
[0043] Based on the same concept, the present invention also provides an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of a method for reducing flickering when switching between 3D multiple scenes.
[0044] Based on the same concept, the present invention also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of a method for reducing flickering when switching between 3D multiple scenes.
[0045] Based on the same concept, the present invention further provides a terminal, wherein the terminal is provided with the above-mentioned system for reducing flickering phenomenon during 3D multi-scene switching.
[0046] Compared with the prior art, the invention has the following beneficial effects:
[0047] The present invention discloses a method, system, electronic device, storage medium and terminal for reducing flickering phenomenon during 3D multi-scene switching, which can reduce the complexity of 3D multi-scene switching maintenance and reduce flickering phenomenon during switching. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a flowchart of some specific embodiments of a method for reducing flickering phenomenon during 3D multi-scene switching according to the present invention;
[0049] Figure 2 It is a timing diagram of a method for reducing flickering during 3D multi-scene switching in some applications of the present invention;
[0050] Figure 3 It is a schematic diagram of the placeholder logic timing of a method for reducing flickering when switching between 3D multiple scenes in some applications of the present invention;
[0051] Figure 4 It is a structural schematic diagram of some specific embodiments of a system for reducing flickering phenomenon during 3D multi-scene switching according to the present invention;
[0052] Figure 5 It is a schematic diagram of the structure of an electronic device in some specific embodiments of the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0054] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two.
[0055] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0056] It should be understood that although the terms first, second, third, etc. may be used to describe in the embodiments of the present application, these descriptions should not be limited to these terms. These terms are only used to distinguish the descriptions. For example, without departing from the scope of the embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.
[0057] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0058] It should also be noted that the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the commodity or device including the elements.
[0059] It should be particularly noted that any symbols and / or numbers in the specification that are not marked in the accompanying drawings are not drawing marks.
[0060] Reference Figure 1 , a method for reducing flickering when switching between 3D multiple scenes, comprising:
[0061] S101, creating a service interface step, including defining a service interface in a rendering service, wherein the service interface includes a method callable by an application and a communication protocol for rendering and memory sharing objects;
[0062] In some of the applications, the steps of creating a service interface include defining a service interface in a rendering service, the service interface including methods that can be called by the application, defining an AIDL file in a communication protocol for rendering and memory shared objects, the AIDL file including a definition of the service interface; defining at least one method in the AIDL file, the method being used in the communication protocol for remote service calls; and compiling the AIDL file to generate a corresponding Java class, the Java class including a specific implementation framework of the service interface.
[0063] It is understandable that in the server project, it is first necessary to clarify which functions need to be exposed to external applications. For 3D scene rendering and switching scenarios, the service interface contains at least methods for starting rendering, obtaining rendering results, and operating memory shared objects.
[0064] Create an AIDL file. In the src / main / java / <package name> / directory of the project, create a new AIDL file, for example, named IRenderService.aidl.
[0065] AIDL file content:
[0066] In the IRenderService.aidl file, define the service interface IRenderService and include at least one method. For example, you can define the startRendering() method to start the rendering process, the getRenderedImage() method to get the rendered image, and the shareMemoryObject() method to share the memory object.
[0067] For example:
[0068] / / IRenderService.aidl
[0069] package;
[0070] interface IRenderService {
[0071] void startRendering();
[0072] Bitmap getRenderedImage();
[0073] android.os.IBinder shareMemoryObject();
[0074] }
[0075] As mentioned above, three methods have been defined in the IRenderService.aidl file, which are used for different communication protocols when calling remote services:
[0076] startRendering(): This method is called when an external application needs to render a new 3D scene.
[0077] getRenderedImage(): When rendering is completed, the external application can call this method to obtain the image of the rendering result.
[0078] shareMemoryObject(): Used to pass shared objects in memory (such as placeholders) to other applications or rendering services during or after rendering.
[0079] After completing all necessary definitions in the AIDL file, save the file.
[0080] Automatic compilation: Android Studio will automatically detect changes to the AIDL file and compile and generate the corresponding Java class. The compiled Java class is located in the build / generated / source / aidl / <package name> / directory and the file name is IRenderService.java.
[0081] The generated Java class: IRenderService.java file contains the specific implementation framework of the service interface, but does not contain the implementation body of the method. It only defines the structure of the interface for reference when the server implementation class and the service user call it.
[0082] For example, if the package name of the server is com.example.renderservice, the AIDL file should be located in the src / main / java / com / example / renderservice / directory. The compiled IRenderService.java is located in the build / generated / source / aidl / com / example / renderservice / directory.
[0083] When the server implements the IRenderService interface, it needs to create a class that inherits from Service (such as RenderService.java) and implement the IRenderService.Stub inner class in the class to provide specific implementations of methods such as startRendering(), getRenderedImage(), and shareMemoryObject().
[0084] When the service user (such as another application) needs to call the rendering service, it first needs to copy the IRenderService.aidl file to its own project and make sure the package name is consistent. Then, it establishes a connection with the rendering service by binding the service (bindService()), and obtains the instance of the IRenderService interface through the returned IBinder object, and then calls the methods it provides.
[0085] S102, implementing a remote service step, including creating and implementing a class inherited from Service in the application, wherein the class is used to implement the service interface and return an instance of the service interface in an onBind method;
[0086] In some of these applications, the steps for implementing remote services include creating and implementing a class that inherits from Service in the application, the class is used to implement the service interface, and returning an instance of the service interface in the onBind method; creating a class that inherits from Service and implements the defined service interface in the class; in the onBind method of the class, returning an instance of the service interface so that the application can bind and call the corresponding service; and implementing the methods defined in the service interface, including the logic for processing rendering requests and memory sharing.
[0087] It can be understood that, assuming there is already a service interface called IRenderService, now create a class called RenderService to implement this interface.
[0088] For example:
[0089] / / RenderService.java
[0090] package;
[0091] import android.app.Service;
[0092] import android.content.Intent;
[0093] import android.os.Binder;
[0094] import android.os.IBinder;
[0095] public class RenderService extends Service{
[0096] private final IRenderService.Stub binder=new IRenderService.Stub(){
[0097] @Override
[0098] public void startRendering(){
[0099] new Thread(()->{
[0100] }).start();
[0101] }
[0102] @Override
[0103] public Bitmap getRendered Image(){
[0104] return fetchRendered ImageFromSomewhere();
[0105] }
[0106] @Override
[0107] public IBinder shareMemoryObject(){
[0108] @Override
[0109] public IBinder onBind(Intent intent){
[0110] return binder;
[0111] }
[0112] private Bitmap fetchRenderedImageFromSomewhere(){
[0113] return null;
[0114] }
[0115] }
[0116] Register the service in AndroidManifest.xml
[0117] In order for the service to be recognized and started by the system, it needs to be declared in the AndroidManifest.xml file.
[0118] For example,
[0119] <manifestxmlns:android="http: / / schemas.android.com / apk / res / android"
[0120] package
[0121] <application
[0122] ...>
[0123] <service
[0124] android:name=".RenderService"
[0125] android:exported="true"
[0126] android:process="":remote">
[0127]
[0128]
[0129]
[0130] android:exported="true" means the service can be accessed by other applications. android:process=":remote" (optional) means the service will run in its own process, which helps isolate the service from other parts of the application and improve the stability and security of the application.
[0131] In the binder inner class of the RenderService class above, the startRendering(), getRenderedImage(), and shareMemoryObject() methods in the IRenderService interface have been implemented, which are used to process rendering requests, obtain rendered images, and implement memory sharing logic, respectively.
[0132] startRendering(): Starts a background thread to perform rendering tasks to avoid blocking the main thread.
[0133] getRenderedImage(): Assume there is a method that can get the rendered image and return it. In practice, you may need to pass the image data through callbacks, shared memory, or other mechanisms.
[0134] shareMemoryObject(): Returns a class instance that implements the IBinder interface for sharing memory objects across processes.
[0135] S103, configuring a service list step, including declaring corresponding services in a list file of the application, and specifying the names of the services and the interfaces provided;
[0136] In some of these applications, the steps of configuring the service manifest include declaring the corresponding service in the application's manifest file, specifying the name of the service and the provided interface, declaring the corresponding service in the application's AndroidManifest.xml file; specifying the full class name of the service; using intent-filter or action or category elements in the service tag to specify the name of the service and the provided interface; and configuring corresponding permissions and metadata so that the service can be called correctly.
[0137] It is understandable that in order to correctly identify and call services inside or outside an application, these services need to be declared and configured in the manifest file (ie, AndroidManifest.xml) of the application.
[0138] First, open the AndroidManifest.xml file and in <application>Add inside the tag <service>Tags to declare services.
[0139] For example,
[0140] <manifestxmlns:android="http: / / schemas.android.com / apk / res / android"
[0141] package
[0142] <application
[0143] <service
[0144] android:name
[0145] android:exported="true"
[0146] android:permission
[0147] android:process
[0148] <intent-filter>
[0149] <actionandroid:name="com.example.yourapp.YOUR_SERVICE_ACTION" / >
[0150] <category android:name="android.intent.category.DEFAULT" / >
[0151]
[0152] <meta-data
[0153] android:name
[0154] android:value
[0155] < / service>
[0156] < / application>
[0157]
[0158] The android:name attribute specifies the full class name of the service, including the package name and class name.
[0159] The android:exported attribute determines whether other applications are allowed to start this service. If it is used within the application, it can be set to false; if you want the service to be accessible to external applications, set it to true.
[0160] The android:permission attribute is used to specify the permissions required to call the service.
[0161] The android:process attribute allows services to run in different processes to improve application stability and performance.
[0162] Specify the service name and provided interface:
[0163] exist <intent-filter>In the tag, through <action>element to specify the name of the service (i.e., the action name), which is used to identify the specific functions provided by the service. <category>element to further qualify the type or purpose of the service.
[0164] For example,
[0165] The service action name is set to:
[0166] com.example.yourapp.YOUR_SERVICE_ACTION, so that other applications or components can call the service by sending an Intent containing this action.
[0167] If your service performs sensitive operations or requires specific permissions to be called, specify those permissions in the android:permission attribute. Clients must declare these permissions when attempting to bind to or start the service.
[0168] use <meta-data>Tags provide additional information about the service, such as API keys, configuration parameters, etc. They can be read at runtime through the PackageManager API.
[0169] S104, binding service and calling method steps, including in the application, copying the service interface, creating a ServiceConnection object and binding to the remote service through the bindService method, calling the remote service method based on the service interface instance obtained by binding, realizing the rendering and switching of 3D scenes, and calling the screenshot logic in the rendering callback, dynamically obtaining the placeholder image, and realizing the cross-process transmission of the placeholder image through memory sharing.
[0170] In some of the applications, the steps of binding services and calling methods include copying the service interface in the application, creating a ServiceConnection object and binding to the remote service through the bindService method, calling the remote service method based on the bound service interface instance to realize the rendering and switching of 3D scenes, and calling the screenshot logic in the rendering callback to dynamically obtain the placeholder image, and realize the cross-process transfer of the placeholder image through memory sharing. In the application, copy the defined AIDL file to the corresponding package; create a ServiceConnection object to monitor changes in the service connection status; call the bindService method, pass in the application's Intent and ServiceConnection objects to establish a connection with the service provider; in the onServiceConnected callback of ServiceConnection, call the remote service method through the returned service interface instance to realize the rendering and switching of 3D scenes; in the rendering callback, start the background thread to execute the screenshot logic, obtain the placeholder image of the current rendering result, and pass the placeholder image to the rendering service or the corresponding application through memory sharing to reduce flickering.
[0171] It is understandable that an AIDL interface file is prepared, which defines the interface provided by the service. This AIDL file is copied to the corresponding package of the Android project so that it can be referenced on both the client and the server.
[0172] For example,
[0173] package com.example.myapp;
[0174] interface IService{
[0175] void render3DScene(int sceneId);
[0176] void switchScene(int fromSceneId,int toSceneId);
[0177] Bitmap captureCurrentScene();
[0178] }
[0179] In the client application, create an anonymous class instance of ServiceConnection to monitor the connection status with the remote service.
[0180] For example,
[0181] private ServiceConnection mServiceConnection=new ServiceConnection(){
[0182] @Override
[0183] public void onServiceConnected(ComponentName name,IBinder service){
[0184] / / Convert IBinder to IService interface
[0185] IService mService=IService.Stub.asInterface(service);
[0186] }
[0187] @Override
[0188] public void onServiceDisconnected(ComponentName name){
[0189] }
[0190] };
[0191] Use the bindService method to bind the application to the remote service.
[0192] For example,
[0193] Intent intent=new Intent();
[0194] intent.setComponent(new ComponentName("com.example.serviceprovider","com.example.serviceprovider.MyService"));
[0195] bindService(intent,mServiceConnection,Context.BIND_AUTO_CREATE);
[0196] In the onServiceConnected callback, call the remote service method through the obtained service interface instance, such as rendering and switching 3D scenes.
[0197] For example,
[0198] @Override
[0199] public void onServiceConnected(ComponentName name,IBinder service){
[0200] IService mService=IService.Stub.asInterface(service);
[0201] mService.render3DScene(1);
[0202] }
[0203] In the render callback (assuming this is triggered by some means like a render completion callback), start a background thread to execute the screenshot logic.
[0204] For example,
[0205] new Thread(()->{
[0206] Bitmap screenshot=mService.captureCurrentScene();
[0207] saveBitmapToFile(screenshot,"screenshot.png");
[0208] }).start();
[0209] If file storage is used, the screenshot can be accessed through the file path in the service or client. If the scenario requires high real-time performance, a more efficient data sharing mechanism needs to be used, such as passing small blocks of data in memory through Binder or using memory-mapped files.
[0210] Through the above steps, you can bind to the remote service in the application, call its methods to render and switch 3D scenes, and dynamically obtain and pass the placeholder image of the rendering result during the rendering process, thereby reducing the interface flickering phenomenon.
[0211] In some of these applications, implementing the screenshot logic includes capturing the drawing results of the current rendering view in a background thread; saving the captured drawing results as an image file or an image object in memory; using a shared memory mechanism to pass a reference to the image object or image file across processes to a rendering service or a corresponding application; and releasing resources used in the background thread so that the drawing and event response of the main thread are not affected.
[0212] It is understandable that the screenshot operation should not block the main thread, so as not to affect the drawing and event response of the application. Therefore, the screenshot logic is executed in the background thread.
[0213] For example,
[0214] / / captureRenderResult
[0215] new Thread(()->{
[0216] Bitmap screenshot=captureRenderResultFromSurface(renderSurface);
[0217] / / captureRenderResultFromSurface
[0218] }).start();
[0219] captureRenderResultFromSurface is a hypothetical method that represents the specific implementation of capturing drawing results from a rendering surface (such as OpenGL ES's FBO, Android's SurfaceView, etc.).
[0220] Once a screenshot has been captured, it can be saved as an image file or used directly as an image object in memory.
[0221] For example,
[0222] if (screenshot!= null) {
[0223] File file=new File(getExternalFilesDir(null),"screenshot.png");
[0224] try(FileOutputStream fos=new FileOutputStream(file)){
[0225] screenshot.compress(Bitmap.CompressFormat.PNG,100,fos);
[0226] }catch(IOException e){
[0227] e.printStackTrace();
[0228] }
[0229] }
[0230] Use the shared memory mechanism to pass the reference of the image object or image file across processes to the rendering service or corresponding application. Since directly passing large image objects (such as Bitmap) across processes may be inefficient and complicated, it is recommended to pass the reference of the image file or use a more efficient IPC mechanism (such as Binder's Parcel to pass the reference of the thumbnail or image data).
[0231] For example,
[0232] String filePath=file.getAbsolutePath();
[0233] Intent intent=new Intent();
[0234] intent.putExtra("screenshot_path",filePath);
[0235] / / sendBroadcast(intent);
[0236] / / startActivity(intent);
[0237] / / bindService(...,intent,...);
[0238] After the background thread completes the screenshot and transfer operations, make sure to release all resources that are no longer needed, such as closing file streams, cleaning up temporary data, etc., to avoid memory leaks.
[0239] When transferring image data across processes, if the data size is large, use a more efficient compression algorithm, transfer small images or thumbnails, or use a dedicated image transfer service to optimize performance and reduce network / IPC overhead.
[0240] Through the above steps, the screenshot logic is implemented in the application, and the screenshot is passed across processes to the rendering service or the corresponding application without blocking the main thread.
[0241] Combine the following Figure 2 and Figure 3 The following describes some embodiments of the method for reducing flickering during 3D multi-scene switching according to the present invention in some applications:
[0242] like Figure 2 As shown in the figure, the reason for the flickering of 3D multi-scene switching caused by switching between applications is that it takes time to create the view used for drawing, and only after the creation is completed can the buffer be passed to the rendering service through binder communication before rendering can begin. Through time statistics, it is found that the average time consumption is more than 300ms, and the screen drawing interval is within 33ms, so it is easy to find the flickering phenomenon. This part of the time consumption can be compressed, but it cannot be eliminated, so it can only be hidden by means of a placeholder image.
[0243] like Figure 3 As shown in the figure, the logic of the placeholder needs to change with the changes of the currently displayed 3D scene, so dynamically obtaining and transmitting the placeholder becomes the core of the problem. The function of intercepting the drawing view through the background thread is used to solve the problem of dynamically obtaining the placeholder. Because the screenshot is taken in the background thread, it will not affect the drawing and event response of the main thread. Large file transfer is achieved through memory sharing, and the resource consumption of CPU and memory is reduced.
[0244] The rendering service needs to complete the following tasks:
[0245] Create a service interface: Create a service interface (AIDL file) in the rendering service to define methods that other applications can call. This interface describes the protocol for communication between the rendering and memory shared objects.
[0246] Implement remote service: Create a class that inherits from Service in the service provider application and implement the service interface defined in the previous step. Return an instance of the service interface in the service's onBind() method.
[0247] Configure the service manifest file: declare the service in the manifest file of the service provider application, specify the service name and the interface provided.
[0248] The application needs to complete the following tasks:
[0249] Copy service interface: Copy the service interface created by the rendering service to the top-level application package to establish the basis for the top-level application and the bottom-level application protocol.
[0250] Bind remote service: In the service consumer application, create a ServiceConnection object and bind it to the remote service in the service provider application through the bindService() method.
[0251] Implement the screenshot logic: In the rendering callback received from the rendering service, call the screenshot logic to complete the screenshot function of the current rendering result.
[0252] Call remote service methods: In the service consumer application, call the methods defined in the service interface by binding the remote service to the service interface instance obtained.
[0253] For the method steps disclosed in the above embodiments, the method steps are described as a series of action combinations for the purpose of simple description, but those skilled in the art should know that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0254] like Figure 4 As shown, the present invention also provides a system for reducing flickering during 3D multi-scene switching, comprising:
[0255] A service interface creation module 201 is configured to define a service interface in a rendering service, wherein the service interface includes a method callable by an application and a communication protocol for rendering and memory sharing objects;
[0256] Implementing a remote service module 202, configured to create and implement a class inherited from Service in the application, wherein the class is used to implement the service interface and return an instance of the service interface in an onBind method;
[0257] Configuration service list module 203, configured to provide a voice response service in the list file of the application, specifying the name of the service and the interface provided;
[0258] The binding service and calling method module 204 is configured to copy the service interface in the application, create a ServiceConnection object and bind to the remote service through the bindService method, call the remote service method based on the service interface instance obtained by binding, realize the rendering and switching of 3D scenes, and call the screenshot logic in the rendering callback, dynamically obtain the placeholder image, and realize the cross-process transmission of the placeholder image through memory sharing.
[0259] It is worth noting that although only some basic functional modules are disclosed in the embodiments of the present invention, it does not mean that the composition of the present system is limited to the above basic functional modules. On the contrary, what the present embodiment wants to express is that on the basis of the above basic functional modules, those skilled in the art can arbitrarily add one or more functional modules in combination with the prior art to form an infinite number of embodiments or technical solutions. In other words, the present system is open rather than closed. Just because the present embodiment only discloses individual basic functional modules, it cannot be considered that the protection scope of the claims of the present invention is limited to the disclosed basic functional modules. At the same time, for the convenience of description, the above devices are described in terms of functions and are described separately in various units and modules. Of course, when implementing the present invention, the functions of each unit and module can be implemented in the same or one or more software and / or hardware.
[0260] like Figure 5 As shown, the present invention also provides an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of a method for reducing flickering when switching between 3D multiple scenes.
[0261] Figure 5 Schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 5 The electronic device provided in the embodiment of the present invention includes: one or more processors 710 and a storage device 720; the processor 710 in the electronic device may be one or more, Figure 5 A processor 710 is taken as an example; the storage device 720 is used to store one or more programs; the one or more programs are executed by the one or more processors 710, so that the one or more processors 710 implement the method for reducing flickering during 3D multi-scene switching as described in any one of the embodiments of the present invention.
[0262] The electronic device may further include: an input device 730 and an output device 740 .
[0263] The processor 710, storage device 720, input device 730 and output device 740 in the electronic device can be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0264] The storage device 720 in the electronic device is a computer-readable storage medium that can be used to store one or more programs, which can be software programs, computer executable programs, and modules, such as program instructions / modules corresponding to the method for reducing flickering when switching between 3D multiple scenes provided in the embodiment of the present invention. The processor 710 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the storage device 720, that is, the method for reducing flickering when switching between 3D multiple scenes in the above method embodiment is implemented.
[0265] The storage device 720 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the storage device 720 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the storage device 720 may further include a memory remotely arranged relative to the processor 710, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0266] The input device 730 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 740 may include a display device such as a display screen.
[0267] The present invention also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of a method for reducing flickering when switching between 3D multiple scenes.
[0268] Specifically, the computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present embodiment, the computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0269] The present invention also provides a terminal, wherein the terminal is provided with the above-mentioned system for reducing flickering phenomenon during 3D multi-scene switching.
[0270] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention. < / category> < / action>
Claims
1. A method for reducing flickering when switching between 3D scenes, characterized in that: include: The step of creating a service interface includes defining a service interface in a rendering service, wherein the service interface includes a method callable by an application and a communication protocol for rendering and memory sharing objects; Implementing a remote service step, including creating and implementing a class inherited from Service in the application, wherein the class is used to implement the service interface and return an instance of the service interface in an onBind method; The step of configuring the service list includes declaring the corresponding service in the list file of the application, and specifying the name of the service and the interface provided; The steps of binding the service and calling the method include, in the application, copying the service interface, creating a ServiceConnection object and binding it to the remote service through the bindService method, calling the remote service method based on the service interface instance obtained by binding, realizing the rendering and switching of the 3D scene, and calling the screenshot logic in the rendering callback, dynamically obtaining the placeholder image, and realizing the cross-process transmission of the placeholder image through memory sharing.
2. The method for reducing flickering during 3D multi-scene switching according to claim 1, characterized in that: The step of creating a service interface includes defining a service interface in a rendering service, wherein the service interface includes a method that can be called by an application, a communication protocol for rendering and memory sharing objects, and further includes: Define an AIDL file, wherein the AIDL file includes a definition of the service interface; Define at least one method in the AIDL file, where the method is used for the communication protocol when the remote service is called; Compile the AIDL file to generate a corresponding Java class, which contains a specific implementation framework of the service interface.
3. The method for reducing flickering during 3D multi-scene switching according to claim 1, characterized in that: The step of implementing the remote service includes creating and implementing a class inherited from Service in the application, wherein the class is used to implement the service interface and return an instance of the service interface in the onBind method, further including: Create a class that inherits from Service and implement the defined service interface in the class; In the onBind method of the class, an instance of the service interface is returned so that the application can bind and call the corresponding service; Implement the methods defined in the service interface, including logic for processing rendering requests and memory sharing.
4. The method for reducing flickering during 3D multi-scene switching according to claim 1, characterized in that: The step of configuring the service list includes declaring the corresponding service in the list file of the application, clarifying the name of the service and the interface provided, and further includes: Declare the corresponding service in the AndroidManifest.xml file of the application; Specifies the full class name of the service; Use intent-filter or action or category elements in the service tag to specify the name of the service and the interface it provides; Configure corresponding permissions and metadata so that the service can be called correctly.
5. The method for reducing flickering during 3D multi-scene switching according to claim 1, characterized in that: The steps of binding the service and calling the method include, in the application, copying the service interface, creating a ServiceConnection object and binding to the remote service through the bindService method, calling the remote service method based on the service interface instance obtained by binding, realizing the rendering and switching of the 3D scene, and calling the screenshot logic in the rendering callback, dynamically obtaining the placeholder image, and realizing the cross-process transmission of the placeholder image through memory sharing, further including: In the application, copy the defined AIDL file to the corresponding package; Create a ServiceConnection object to monitor changes in the service connection status; Call the bindService method, passing in the application's Intent and ServiceConnection object to establish a connection with the service provider; In the onServiceConnected callback of ServiceConnection, the method of the remote service is called through the returned service interface instance to realize the rendering and switching of the 3D scene; In the rendering callback, start the background thread to execute the screenshot logic, obtain the placeholder image of the current rendering result, and pass the placeholder image to the rendering service or the corresponding application through memory sharing to reduce flickering.
6. The method for reducing flickering during 3D multi-scene switching according to claim 5, characterized in that: Implementing the screenshot logic further includes: In the background thread, capture the drawing results of the current rendering view; Saving the captured drawing result as an image file or an image object in memory; Use the shared memory mechanism to pass the reference of the image object or image file across processes to the rendering service or corresponding application; Release the resources used in the background thread so that the main thread's drawing and event response are not affected.
7. A system for reducing flickering during 3D multi-scene switching, characterized in that: include: Creating a service interface module configured to define a service interface in a rendering service, wherein the service interface includes methods callable by an application and a communication protocol for rendering and memory sharing objects; Implementing a remote service module, configured to create and implement a class inherited from Service in the application, wherein the class is used to implement the service interface and return an instance of the service interface in an onBind method; A configuration service list module is configured to provide a voice corresponding service in the list file of the application, specifying the name of the service and the interface provided; The binding service and calling method module is configured to copy the service interface in the application, create a ServiceConnection object and bind to the remote service through the bindService method, call the remote service method based on the service interface instance obtained by binding, realize the rendering and switching of 3D scenes, and call the screenshot logic in the rendering callback to dynamically obtain the placeholder image, and realize the cross-process transmission of the placeholder image through memory sharing.
8. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the method described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: It stores a computer program executable by an electronic device, and when the computer program runs on the electronic device, the electronic device executes the steps of the method described in any one of claims 1 to 6.
10. A terminal, characterized in that: The terminal is provided with the system for reducing flickering during 3D multi-scene switching as claimed in claim 7.
