CN112416470A - Command execution method and device, storage medium and electronic device - Google Patents

Command execution method and device, storage medium and electronic device Download PDF

Info

Publication number
CN112416470A
CN112416470A CN201910780738.7A CN201910780738A CN112416470A CN 112416470 A CN112416470 A CN 112416470A CN 201910780738 A CN201910780738 A CN 201910780738A CN 112416470 A CN112416470 A CN 112416470A
Authority
CN
China
Prior art keywords
function
webgl
intercepted
calling
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910780738.7A
Other languages
Chinese (zh)
Other versions
CN112416470B (en
Inventor
张长荣
王召伟
雷丹雄
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910780738.7A priority Critical patent/CN112416470B/en
Publication of CN112416470A publication Critical patent/CN112416470A/en
Application granted granted Critical
Publication of CN112416470B publication Critical patent/CN112416470B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses a command execution method and device, a storage medium and an electronic device. Wherein, the method comprises the following steps: intercepting a first interface function based on a first program language when the first interface function is called so as to cancel calling of a first processing function based on a second program language; writing the intercepted calling information of the first interface function into a shared command queue; under the condition that the shared command queue comprises a group of intercepted calling information of interface functions based on a first program language, calling a corresponding processing function based on a second program language to analyze the group of intercepted calling information of the interface functions based on the first program language to obtain a group of target commands; a set of target commands is executed. The invention solves the technical problem of large loss of program calling performance in the related technology.

Description

Command execution method and device, storage medium and electronic device
Technical Field
The present invention relates to the field of computers, and in particular, to a method and an apparatus for executing a command, a storage medium, and an electronic apparatus.
Background
In the related art, the open graphics library OpenGL is a cross-language, cross-platform application programming interface for rendering 2D, 3D vector graphics. The Web image library WebGL is a JavaScript Application Program Interface (API), and is used for presenting interactive 2D and 3D graphics in a Web browser. The interface design of WebGL is almost one-to-one corresponding to the interface of OpenGL ES. OpenGL ES continues its own complex and redundant API design. In traditional native OpenGL development, such API design does not cause performance bottlenecks due to the high performance of object-oriented C + +. However, when WebGL is used for development, a large number of frequent and redundant API calls trigger a large number of cross-language calls of JavaScript and C + +, and a large amount of data needs to be transmitted between two execution environments, thereby causing considerable performance loss.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a command execution method and device, a storage medium and an electronic device, and at least solves the technical problem of high program calling performance loss in the related art.
According to an aspect of an embodiment of the present invention, there is provided a method for executing a command, including: intercepting a first interface function based on a first program language when the first interface function is called so as to cancel calling of a first processing function based on a second program language, wherein the first interface function is used for calling the first processing function when the first interface function is called; writing intercepted calling information of the first interface function into a shared command queue, wherein the calling information comprises an identifier of the first interface function and calling parameters of the first interface function; when the shared command queue includes a set of intercepted call information of the interface function based on the first programming language, calling a corresponding processing function based on the second programming language to analyze the set of intercepted call information of the interface function based on the first programming language to obtain a set of target commands, wherein the set of intercepted call information of the interface function based on the first programming language includes the call information of the first interface function, and the processing function based on the second programming language includes the first processing function; the set of target commands is executed.
According to another aspect of the embodiments of the present invention, there is also provided a device for executing a command, including: the intercepting module is used for intercepting a first interface function based on a first program language when the first interface function is called so as to cancel calling of a first processing function based on a second program language, wherein the first interface function is used for calling the first processing function when the first interface function is called; a write-in module, configured to write intercepted call information of the first interface function into a shared command queue, where the call information includes an identifier of the first interface function and a call parameter of the first interface function; a first determining module, configured to, when the shared command queue includes a set of intercepted call information of interface functions based on the first programming language, call a corresponding processing function based on the second programming language to parse the set of intercepted call information of interface functions based on the first programming language, so as to obtain a set of target commands, where the set of intercepted call information of interface functions based on the first programming language includes the call information of the first interface function, and the processing function based on the second programming language includes the first processing function; and the execution module is used for executing the group of target commands.
Optionally, the intercepting module includes: the first intercepting unit is used for intercepting the first WebGL function on a scripting language JavaScript layer when the first drawing protocol WebGL function is called so as to cancel calling of a first OpenGL processing function of a C + + layer, wherein the first WebGL function is used for calling the first OpenGL processing function of the C + + layer when called;
the write module includes: a first writing unit, configured to write the intercepted call information of the first WebGL function into the shared command queue, where the call information of the first WebGL function includes an identifier of the first WebGL function and a call parameter of the first WebGL function;
the first calling module includes: a first determining unit, configured to, when the shared command queue includes a set of call information of intercepted WebGL functions, call a corresponding OpenGL processing function of the C + + layer to analyze the set of call information of intercepted WebGL functions, so as to obtain a set of target commands, where the set of call information of intercepted WebGL functions includes the call information of the first WebGL function, and the corresponding OpenGL processing function of the C + + layer includes the first OpenGL processing function.
Optionally, the first intercepting unit includes: the device comprises a first interception subunit, configured to intercept an object obtaining function in the JavaScript layer, and return a wrapped WebGL description object, where the object obtaining function is configured to obtain a WebGL description object from a Canvas element Canvas object, and the first WebGL function is configured to, when called, first call the object obtaining function to obtain the WebGL description object from the Canvas element Canvas object.
Optionally, the writing module includes: and a second writing unit, configured to write the call information of the first interface function into the shared command queue according to a predetermined format, where the shared command queue is configured to be shared between a layer where the first interface function is located and a layer where the first processing function is located, and the group of intercepted call information of the interface function based on the first programming language has the same predetermined format in the shared command queue.
Optionally, the writing module includes: a third writing unit, configured to write the call information of the first WebGL function into the shared command queue according to a predetermined format, where the shared command queue is configured to be shared between the JavaScript layer and the C + + layer, and the call information of the group of intercepted WebGL functions has the same predetermined format in the shared command queue.
Optionally, the first determining module includes: and a second determining unit, configured to determine that the shared command queue includes the group of call information of the intercepted interface functions in the first programming language when all or part of the interface functions in the first programming language are intercepted, and to call a corresponding processing function in the second programming language to analyze the group of call information of the intercepted interface functions in the first programming language, so as to obtain the group of target commands, where the group of call information of the intercepted interface functions in the first programming language includes all or part of the call information of the interface functions in the first programming language.
Optionally, the first determining unit includes: a first determining subunit, configured to determine that the shared command queue includes the call information of the group of intercepted WebGL functions when all or part of the WebGL functions are intercepted within a predetermined number of frames, and call a corresponding OpenGL processing function of the C + + layer to analyze the call information of the group of intercepted WebGL functions, so as to obtain the group of target commands, where the call information of the group of intercepted WebGL functions includes the call information of all or part of the WebGL functions.
According to still another aspect of the embodiments of the present invention, there is also provided a storage medium having a computer program stored therein, wherein the computer program is configured to execute the execution method of the above-mentioned command when running.
According to another aspect of the embodiments of the present invention, there is also provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for executing the command by using the computer program.
In the embodiment of the invention, when a first interface function based on a first program language is called, the first interface function is intercepted to cancel calling of a first processing function based on a second program language, wherein the first interface function is used for calling the first processing function when called; writing intercepted calling information of the first interface function into a shared command queue, wherein the calling information comprises an identifier of the first interface function and a calling parameter of the first interface function; under the condition that the shared command queue comprises a group of intercepted calling information of interface functions based on a first program language, calling a corresponding processing function based on a second program language to analyze the group of intercepted calling information of the interface functions based on the first program language to obtain a group of target commands, wherein the group of intercepted calling information of the interface functions based on the first program language comprises the calling information of the first interface function, and the processing function based on the second program language comprises the first processing function; the method for executing the group of target commands achieves the aim of reducing the calling of the first processing function by intercepting the first interface function, thereby realizing the technical effect of reducing the performance loss of program calling and further solving the technical problem of larger performance loss of program calling in the related technology.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a schematic diagram of an application environment for a method of executing an alternative command in accordance with an embodiment of the invention;
FIG. 2 is a flow diagram of an alternative method of command execution according to an embodiment of the invention;
FIG. 3 is a schematic diagram of an alternative command execution apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an alternative electronic device according to an embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to an aspect of the embodiments of the present invention, a method for executing a command is provided, and optionally, as an optional implementation, the method for executing a command may be applied to, but is not limited to, an environment as shown in fig. 1.
The terminal 102 of fig. 1 may interact with the various layers of the application. The terminal 102 includes a memory 104 for storing operational data. And a processor 106 for processing the operation data. As shown in fig. 1, when calling a first interface function (a first drawing protocol WebGL function) based on a first programming language, the terminal 102 may intercept the first interface function at a scripting language JavaScript layer to cancel calling a first processing function of a C + + layer based on a second programming language, where the first interface function is used to call the first processing function when called; the terminal 102 may write the intercepted call information of the first interface function into the shared command queue, where the call information includes an identifier of the first interface function and a call parameter of the first interface function; under the condition that the shared command queue comprises a group of intercepted calling information of interface functions based on a first program language, calling a corresponding processing function based on a second program language to analyze the group of intercepted calling information of the interface functions based on the first program language to obtain a group of target commands, wherein the group of intercepted calling information of the interface functions based on the first program language comprises the calling information of the first interface function, and the processing function based on the second program language comprises the first processing function; the terminal 102 executes a set of target commands.
Alternatively, the page display method may be applied to, but not limited to, a client running on the terminal 102 that can calculate data, and the terminal 102 may be a mobile phone, a tablet computer, a notebook computer, a PC, and the like.
Optionally, as an optional implementation manner, as shown in fig. 2, the method for executing the command includes:
s202: intercepting a first interface function based on a first program language when the first interface function is called so as to cancel calling of a first processing function based on a second program language, wherein the first interface function is used for calling the first processing function when the first interface function is called;
s204: writing intercepted calling information of the first interface function into a shared command queue, wherein the calling information comprises an identifier of the first interface function and a calling parameter of the first interface function;
s206: under the condition that the shared command queue comprises a group of intercepted calling information of interface functions based on a first program language, calling a corresponding processing function based on a second program language to analyze the group of intercepted calling information of the interface functions based on the first program language to obtain a group of target commands, wherein the group of intercepted calling information of the interface functions based on the first program language comprises the calling information of the first interface function, and the processing function based on the second program language comprises the first processing function;
s208: a set of target commands is executed.
Optionally, the first programming language includes, but is not limited to, JavaScript. The second programming language includes, but is not limited to, the C + + language. The first interface function includes, but is not limited to, a drawing protocol WebGL function; the first processing function includes, but is not limited to, an OpenGL processing function. The present embodiments include, but are not limited to, application in scenarios where data needs to be transferred between two execution environments. For example, when the WebGL is used for development, a call of an Application Program Interface (API) triggers cross-language calls of JavaScript and C + +, and data is transmitted between two execution environments.
Alternatively, for example, due to the large number of frequent and redundant API calls that trigger large numbers of JavaScript and C + + cross-language calls when developed using WebGL, large amounts of data need to be transferred between the two execution environments, resulting in a significant performance loss. Based on the problem, in this embodiment, the shared command queue is used to store the intercepted call information of the first interface function, and when the shared command queue includes a group of intercepted call information of interface functions based on the first programming language, the corresponding processing function based on the second programming language is called to analyze the group of intercepted call information of interface functions based on the first programming language, so as to obtain a group of target commands. The method can greatly reduce the inter-call and data transmission of JavaScript and C + + in the WebGL program, and greatly improve the rendering performance of the WebGL.
Optionally, in this embodiment, the calling information of the first interface function includes, but is not limited to, identification information and calling parameters of the first interface function. For example, in the case where the first interface function is the first WebGL function, the call information includes an identification of the first WebGL function, and a call parameter of the first WebGL function.
Optionally, the identification of the first WebGL function includes, but is not limited to, a name of the first WebGL function, and a number of the first WebGL function, such as, for example, the number 10 indicates a function createProgram. The calling parameters of the first WebGL function include, but are not limited to, numbers, strings, ArrayBuffer, and the like.
Optionally, the shared command queue in this embodiment may be an ArrayBuffer, where the ArrayBuffer is equivalent to a segment of binary memory, and may be shared with the C + + bottom layer, and consumption of transferring data to the C + + bottom layer after writing in data is almost 0. For example, a gl. drawrarray (gl. points,0,8) call, will write 4 numbers in the Array buffer in the Uint32 Array: points,0, 8. Therein, 42 denotes the command drawArrays.
According to the embodiment, the first interface function is intercepted through the shared command queue, and the corresponding processing function based on the second programming language is called to analyze the calling information of the intercepted interface function based on the first programming language, so that a group of target commands are obtained. Therefore, data calling among different execution environments is reduced, and performance loss is reduced.
In an optional embodiment, intercepting the first interface function to cancel the call of the first processing function based on the second programming language when the first interface function based on the first programming language is called comprises:
s1, intercepting a first WebGL function in a scripting language JavaScript layer when the first drawing protocol WebGL function is called, so as to cancel calling of a first OpenGL processing function of a C + + layer, wherein the first WebGL function is used for calling the first OpenGL processing function of the C + + layer when called;
writing the intercepted call information of the first interface function into a shared command queue comprises:
s2, writing the intercepted calling information of the first WebGL function into a shared command queue, wherein the calling information of the first WebGL function comprises the identification of the first WebGL function and the calling parameters of the first WebGL function;
under the condition that the shared command queue comprises a group of intercepted calling information of the interface function based on the first program language, calling a corresponding processing function based on the second program language to analyze the group of intercepted calling information of the interface function based on the first program language, and obtaining a group of target commands comprises:
s3, when the shared command queue includes a group of intercepted call information of the WebGL function, calling a corresponding OpenGL processing function of the C + + layer to analyze the group of intercepted call information of the WebGL function, so as to obtain a group of target commands, where the group of intercepted call information of the WebGL function includes call information of a first WebGL function, and the corresponding OpenGL processing function of the C + + layer includes the first OpenGL processing function.
Optionally, in this embodiment, the inter-call of data from the JavaScript layer to the C + + layer is mainly performed. When the WebGL is used for development, a large number of frequent and redundant API calls trigger a large number of cross-language calls of JavaScript and C + +, and a large amount of data needs to be transmitted between two execution environments, so that considerable performance loss is caused. Based on the problem, in this embodiment, the shared command queue is used to store the intercepted call information of the first WebGL function, and when the shared command queue includes a set of intercepted call information of the WebGL function, the corresponding OpenGL processing function of the C + + layer is called to analyze the set of intercepted call information of the WebGL function, so as to obtain a set of target commands. The method can greatly reduce the inter-call and data transmission of JavaScript and C + + in the WebGL program, and greatly improve the rendering performance of the WebGL.
Optionally, the identification of the first WebGL function includes, but is not limited to, a name of the first WebGL function, and a number of the first WebGL function, such as, for example, the number 10 indicates a function createProgram. The calling parameters of the first WebGL function include, but are not limited to, numbers, strings, ArrayBuffer, and the like.
According to the embodiment, the first WebGL function is intercepted through the shared command queue, the OpenGL processing function is called to analyze the calling information of the group of WebGL functions, and the group of target commands are obtained. Therefore, data calling between the C + + layer and the JavaScript layer is reduced, performance loss is reduced, and the rendering performance of WebGL is improved.
In an optional embodiment, intercepting the first WebGL function at the JavaScript layer includes:
and S1, intercepting an object acquisition function at a JavaScript layer, and returning a packaged WebGL description object, wherein the object acquisition function is used for acquiring the WebGL description object from a Canvas element Canvas object, and the first WebGL function is used for acquiring the WebGL description object from the Canvas element Canvas object by calling the object acquisition function first when being called.
Optionally, in this embodiment, for example, when the WebGL API is called in the WebGL program, first, a WebGLRenderingContext object needs to be acquired from a Canvas object, and the acquisition mode is through Canvas. That is, a wrapped WebGLRenderingContext can be returned by intercepting the getContext call, and then all call information of the WebGL API can be intercepted.
By the embodiment, the intercepted object acquisition function is realized by returning the packaged WebGL description object, and the intercepted function can be processed in batch at the C + + layer. Performance loss of data interaction is reduced.
In an optional embodiment, writing the intercepted call information of the first interface function into the shared command queue includes:
and S1, writing the calling information of the first interface function into a shared command queue according to a preset format, wherein the shared command queue is set to be shared between the layer where the first interface function is located and the layer where the first processing function is located, and a group of intercepted calling information of the interface function based on the first program language has the same preset format in the shared command queue.
Optionally, in this embodiment, the shared command queue may be an ArrayBuffer, where the ArrayBuffer is equivalent to a segment of binary memory, that is, the call information of the interface function is stored in the shared command queue in a binary form. And the data can be shared with the C + + bottom layer, and the consumption of transferring the data to the C + + bottom layer after the data is written is almost 0. For example, a gl. drawrarray (gl. points,0,8) call, will write 4 numbers in the Array buffer in the Uint32 Array: points,0, 8. Therein, 42 denotes the command drawArrays.
By the embodiment, the calling information of the first interface function is written into the shared command queue according to the preset format, so that the calling information of the C + + layer shared interface function can be quickly realized.
In an optional embodiment, in a case that the shared command queue includes a set of intercepted call information of the interface function based on the first programming language, calling a corresponding processing function based on the second programming language to parse the set of intercepted call information of the interface function based on the first programming language to obtain a set of target commands, including:
s1, when all or part of the interface functions based on the first program language in the preset number of frames are intercepted, determining that a group of intercepted calling information of the interface functions based on the first program language is included in the shared command queue, calling a corresponding processing function based on the second program language to analyze the group of intercepted calling information of the interface functions based on the first program language, and obtaining a group of target commands, wherein the group of intercepted calling information of the interface functions based on the first program language includes all or part of calling information of the interface functions based on the first program language.
Optionally, in this embodiment, the predetermined number of frames may be one frame, and the interface function that needs to be called for one frame of picture includes a plurality of interfaces. Under the condition that the shared command queue comprises a plurality of interface functions and before one frame is finished, batch submission is carried out on the C + + layer at one time for processing, so that the time consumption of calling the WebGL command of each frame is reduced.
In an optional embodiment, when the shared command queue includes a set of intercepted call information of the WebGL function, invoking a corresponding OpenGL processing function of the C + + layer to analyze the set of intercepted call information of the WebGL function, so as to obtain a set of target commands, includes:
s1, under the condition that all or part of the WebGL functions in the preset number of frames are intercepted, determining that a group of intercepted WebGL function calling information is included in the shared command queue, calling a corresponding OpenGL processing function of the C + + layer to analyze the group of intercepted WebGL function calling information, and obtaining a group of target commands, wherein the group of intercepted WebGL function calling information includes all or part of WebGL function calling information.
Optionally, in this embodiment, the predetermined number of frames may be one frame, and the interface function that needs to be called for one frame of picture includes a plurality of interfaces. Under the condition that the shared command queue comprises a plurality of WebGL functions and before one frame is finished, batch submission is carried out on the WebGL functions to the C + + layer at one time for processing, and therefore time consumption of calling of the WebGL commands of each frame is reduced.
Optionally, for example, when the JavaScript layer prepares the command queue data of one frame, the bottom layer C + + will parse the command from the shared ArrayBuffer memory. Firstly, 4-byte command numbers are analyzed, then, corresponding command analysis functions are switched to, and then, parameters are analyzed one by one. And circulating in sequence until the analysis is completed.
Alternatively, if a certain WebGL function has a return value. After the WebGL function is written into the shared command queue, the shared command queue needs to be triggered and executed immediately, and the return value of the last command execution of the shared command queue is used as the return value of the current WebGL function.
Through the embodiment, the WebGL functions in the shared command queue are analyzed in a centralized mode, so that data interaction is reduced, and performance loss is reduced.
In summary, the embodiment can greatly reduce the mutual invocation of JavaScript and C + + in the WebGL program, greatly reduce the performance overhead of data transmission caused by the mutual invocation, and effectively improve the frame rate of the WebGL game. For example, running WebGL Aqua 2000 fish, the time consumption per frame can be reduced by 25%, and the frame rate can be increased by 10 frames.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
According to another aspect of the embodiment of the present invention, there is also provided a command execution apparatus for implementing the above command execution method. As shown in fig. 3, the apparatus includes:
the intercepting module 32 is configured to intercept a first interface function based on a first programming language when the first interface function is called, so as to cancel calling of a first processing function based on a second programming language, where the first interface function is used to call the first processing function when the first interface function is called;
a writing module 34, configured to write intercepted call information of the first interface function into a shared command queue, where the call information includes an identifier of the first interface function and a call parameter of the first interface function;
a first determining module 36, configured to, when the shared command queue includes a set of intercepted call information of interface functions based on the first programming language, call a corresponding processing function based on the second programming language to parse the set of intercepted call information of interface functions based on the first programming language, so as to obtain a set of target commands, where the set of intercepted call information of interface functions based on the first programming language includes the call information of the first interface function, and the processing function based on the second programming language includes the first processing function;
an execution module 38 for executing a set of target commands.
Optionally, the intercepting module includes:
the first intercepting unit is used for intercepting the first WebGL function on a scripting language JavaScript layer when the first drawing protocol WebGL function is called so as to cancel calling of a first OpenGL processing function of a C + + layer, wherein the first WebGL function is used for calling the first OpenGL processing function of the C + + layer when called;
the write module includes:
a first writing unit, configured to write the intercepted call information of the first WebGL function into the shared command queue, where the call information of the first WebGL function includes an identifier of the first WebGL function and a call parameter of the first WebGL function;
the first calling module includes:
a first determining unit, configured to, when the shared command queue includes a set of call information of intercepted WebGL functions, call a corresponding OpenGL processing function of the C + + layer to analyze the set of call information of intercepted WebGL functions, so as to obtain a set of target commands, where the set of call information of intercepted WebGL functions includes the call information of the first WebGL function, and the corresponding OpenGL processing function of the C + + layer includes the first OpenGL processing function.
Optionally, the first intercepting unit includes:
the device comprises a first interception subunit, configured to intercept an object obtaining function in the JavaScript layer, and return a wrapped WebGL description object, where the object obtaining function is configured to obtain a WebGL description object from a Canvas element Canvas object, and the first WebGL function is configured to, when called, first call the object obtaining function to obtain the WebGL description object from the Canvas element Canvas object.
Optionally, the writing module includes:
and a second writing unit, configured to write the call information of the first interface function into the shared command queue according to a predetermined format, where the shared command queue is configured to be shared between a layer where the first interface function is located and a layer where the first processing function is located, and the group of intercepted call information of the interface function based on the first programming language has the same predetermined format in the shared command queue.
Optionally, the writing module includes:
a third writing unit, configured to write the call information of the first WebGL function into the shared command queue according to a predetermined format, where the shared command queue is configured to be shared between the JavaScript layer and the C + + layer, and the call information of the group of intercepted WebGL functions has the same predetermined format in the shared command queue.
Optionally, the first determining module includes:
and a second determining unit, configured to determine that the shared command queue includes the group of call information of the intercepted interface functions in the first programming language when all or part of the interface functions in the first programming language are intercepted, and to call a corresponding processing function in the second programming language to analyze the group of call information of the intercepted interface functions in the first programming language, so as to obtain the group of target commands, where the group of call information of the intercepted interface functions in the first programming language includes all or part of the call information of the interface functions in the first programming language.
Optionally, the first determining unit includes:
a first determining subunit, configured to determine that the shared command queue includes the call information of the group of intercepted WebGL functions when all or part of the WebGL functions are intercepted within a predetermined number of frames, and call a corresponding OpenGL processing function of the C + + layer to analyze the call information of the group of intercepted WebGL functions, so as to obtain the group of target commands, where the call information of the group of intercepted WebGL functions includes the call information of all or part of the WebGL functions.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
According to yet another aspect of the embodiments of the present invention, there is also provided an electronic device for implementing the method for executing the above command, as shown in fig. 4, the electronic device includes a memory 402 and a processor 404, the memory 402 stores a computer program, and the processor 404 is configured to execute the steps in any one of the above method embodiments through the computer program.
Optionally, in this embodiment, the electronic apparatus may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1: intercepting a first interface function based on a first program language when the first interface function is called so as to cancel calling of a first processing function based on a second program language, wherein the first interface function is used for calling the first processing function when the first interface function is called;
s2: writing intercepted calling information of the first interface function into a shared command queue, wherein the calling information comprises an identifier of the first interface function and a calling parameter of the first interface function;
s3: under the condition that the shared command queue comprises a group of intercepted calling information of interface functions based on a first program language, calling a corresponding processing function based on a second program language to analyze the group of intercepted calling information of the interface functions based on the first program language to obtain a group of target commands, wherein the group of intercepted calling information of the interface functions based on the first program language comprises the calling information of the first interface function, and the processing function based on the second program language comprises the first processing function;
s4: a set of target commands is executed.
Alternatively, it can be understood by those skilled in the art that the structure shown in fig. 4 is only an illustration, and the electronic device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 4 is a diagram illustrating the structure of the electronic device. For example, the electronic device may also include more or fewer components (e.g., network interfaces, etc.) than shown in FIG. 4, or have a different configuration than shown in FIG. 4.
The memory 402 may be used to store software programs and modules, such as program instructions/modules corresponding to the method and apparatus for executing commands in the embodiment of the present invention, and the processor 404 executes various functional applications and data processing by executing the software programs and modules stored in the memory 402, that is, implements the method for executing commands described above. The memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 402 may further include memory located remotely from the processor 404, which may be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. The memory 402 may be, but not limited to, specifically configured to store information such as interface functions. As an example, as shown in fig. 4, the intercepting module 32, the writing module 34, the first determining module 36, and the executing module 38 in the executing device that may include the command may be, but are not limited to, in the memory 402. In addition, other module units in the device for executing the above commands may also be included, but are not limited to these, and are not described in detail in this example.
Optionally, the transmission device 406 is used for receiving or sending data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmission device 406 includes a Network adapter (NIC) that can be connected to a router via a Network cable and other Network devices to communicate with the internet or a local area Network. In one example, the transmission device 406 is a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
In addition, the electronic device further includes: a display 408 for displaying information of the execution target command; and a connection bus 410 for connecting the respective module parts in the above-described electronic apparatus.
According to a further aspect of embodiments of the present invention, there is also provided a storage medium having a computer program stored therein, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be personal computers, servers, network devices, etc.) to execute all or part of the steps of the method according to the embodiments of the present invention.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A method for executing a command, comprising:
intercepting a first interface function based on a first program language when the first interface function is called so as to cancel calling of a first processing function based on a second program language, wherein the first interface function is used for calling the first processing function when the first interface function is called;
writing intercepted calling information of the first interface function into a shared command queue, wherein the calling information comprises an identifier of the first interface function and calling parameters of the first interface function;
under the condition that the shared command queue comprises a group of intercepted calling information of interface functions based on the first program language, calling a corresponding processing function based on the second program language to analyze the group of intercepted calling information of the interface functions based on the first program language to obtain a group of target commands, wherein the group of intercepted calling information of the interface functions based on the first program language comprises the calling information of the first interface function, and the processing function based on the second program language comprises the first processing function;
executing the set of target commands.
2. The method of claim 1,
intercepting a first interface function based on a first program language when the first interface function is called so as to cancel calling of a first processing function based on a second program language comprises the following steps: intercepting the first WebGL function in a scripting language JavaScript layer when the first drawing protocol WebGL function is called so as to cancel calling of a first OpenGL processing function of a C + + layer, wherein the first WebGL function is used for calling the first OpenGL processing function of the C + + layer when the first WebGL function is called;
writing the intercepted call information of the first interface function into a shared command queue comprises: writing the intercepted calling information of the first WebGL function into the shared command queue, wherein the calling information of the first WebGL function comprises an identification of the first WebGL function and calling parameters of the first WebGL function;
when the shared command queue includes a set of intercepted call information of the interface function based on the first programming language, calling a corresponding processing function based on the second programming language to analyze the set of intercepted call information of the interface function based on the first programming language, and obtaining a set of target commands includes: and under the condition that the shared command queue comprises a group of intercepted call information of the WebGL functions, calling corresponding OpenGL processing functions of the C + + layer to analyze the group of intercepted call information of the WebGL functions to obtain a group of target commands, wherein the group of intercepted call information of the WebGL functions comprises the call information of the first WebGL function, and the corresponding OpenGL processing functions of the C + + layer comprise the first OpenGL processing functions.
3. The method of claim 2, wherein intercepting the first WebGL function at the JavaScript layer comprises:
intercepting an object acquisition function at the JavaScript layer, and returning a packaged WebGL description object, wherein the object acquisition function is used for acquiring a WebGL description object from a Canvas element Canvas object, and the first WebGL function is used for acquiring the WebGL description object from the Canvas element Canvas object by calling the object acquisition function first when being called.
4. The method of claim 1, wherein writing the intercepted call information of the first interface function into a shared command queue comprises:
writing the calling information of the first interface function into the shared command queue according to a preset format, wherein the shared command queue is set to be shared between the layer where the first interface function is located and the layer where the first processing function is located, and the group of intercepted calling information of the interface function based on the first programming language has the same preset format in the shared command queue.
5. The method of claim 2, wherein writing the intercepted call information of the first WebGL function into the shared command queue comprises:
writing the call information of the first WebGL function into the shared command queue according to a preset format, wherein the shared command queue is set to be shared between the JavaScript layer and the C + + layer, and the call information of the intercepted group of WebGL functions has the same preset format in the shared command queue.
6. The method according to claim 1, wherein in a case that a set of intercepted call information of the interface function based on the first programming language is included in the shared command queue, invoking a corresponding processing function based on the second programming language to parse the set of intercepted call information of the interface function based on the first programming language to obtain a set of target commands, comprising:
and under the condition that all or part of the interface functions based on the first program language in a preset number of frames are intercepted, determining that the group of intercepted call information of the interface functions based on the first program language is included in the shared command queue, and calling a corresponding processing function based on the second program language to analyze the group of intercepted call information of the interface functions based on the first program language to obtain the group of target commands, wherein the group of intercepted call information of the interface functions based on the first program language includes all or part of call information of the interface functions based on the first program language.
7. The method of claim 2, wherein in a case that the shared command queue includes a set of call information of the intercepted WebGL function, calling a corresponding OpenGL processing function of the C + + layer to parse the set of call information of the intercepted WebGL function to obtain a set of target commands, includes:
determining that the shared command queue includes the call information of the group of intercepted WebGL functions under the condition that all or part of the WebGL functions within a predetermined number of frames are intercepted, and calling corresponding OpenGL processing functions of the C + + layer to analyze the call information of the group of intercepted WebGL functions to obtain the group of target commands, wherein the call information of the group of intercepted WebGL functions includes the call information of all or part of the WebGL functions.
8. An apparatus for executing a command, comprising:
the intercepting module is used for intercepting a first interface function based on a first program language when the first interface function is called so as to cancel calling of a first processing function based on a second program language, wherein the first interface function is used for calling the first processing function when the first interface function is called;
a write-in module, configured to write intercepted call information of the first interface function into a shared command queue, where the call information includes an identifier of the first interface function and a call parameter of the first interface function;
a first determining module, configured to, when the shared command queue includes a set of intercepted call information of interface functions based on the first programming language, call a corresponding processing function based on the second programming language to parse the set of intercepted call information of interface functions based on the first programming language, so as to obtain a set of target commands, where the set of intercepted call information of interface functions based on the first programming language includes the call information of the first interface function, and the processing function based on the second programming language includes the first processing function;
and the execution module is used for executing the group of target commands.
9. A storage medium comprising a stored program, wherein the program when executed performs the method of any of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 7 by means of the computer program.
CN201910780738.7A 2019-08-22 2019-08-22 Command execution method and device, storage medium and electronic device Active CN112416470B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910780738.7A CN112416470B (en) 2019-08-22 2019-08-22 Command execution method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910780738.7A CN112416470B (en) 2019-08-22 2019-08-22 Command execution method and device, storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN112416470A true CN112416470A (en) 2021-02-26
CN112416470B CN112416470B (en) 2023-08-25

Family

ID=74779487

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910780738.7A Active CN112416470B (en) 2019-08-22 2019-08-22 Command execution method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN112416470B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116991600A (en) * 2023-06-15 2023-11-03 上海一谈网络科技有限公司 Method, device, equipment and storage medium for processing graphic call instruction

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030145210A1 (en) * 2002-01-31 2003-07-31 Sun Microsystems, Inc. Method, system, program, and data structure for implementing a locking mechanism for a shared resource
US6785891B1 (en) * 1999-10-12 2004-08-31 International Business Machines Corporation Data sharing between application environments
WO2008054074A1 (en) * 2006-10-31 2008-05-08 Sk Telecom Co., Ltd. Terminal device having function of interfacing compilation libraries in heterogeneous languages, method of calling api, and method of creating compile function
JP2011113394A (en) * 2009-11-27 2011-06-09 Internatl Business Mach Corp <Ibm> Method for converting source code written in dynamic typing language into target code written in static typing language and executing the same, and computer program and computer system for the method
WO2014012504A1 (en) * 2012-07-20 2014-01-23 Tencent Technology (Shenzhen) Company Limited Method, device, and mobile terminal for api interception
CN106462407A (en) * 2014-05-16 2017-02-22 微软技术许可有限责任公司 Code service for language-independent dispatch
CN106506703A (en) * 2016-12-28 2017-03-15 掌阅科技股份有限公司 Based on the service discovery method of shared drive, apparatus and system, server
US20170147478A1 (en) * 2015-11-25 2017-05-25 International Business Machines Corporation Generic language application programming interface interpreter
US20180165175A1 (en) * 2016-12-13 2018-06-14 International Business Machines Corporation Common debug scripting framework for driving hybrid applications consisting of compiled languages and interpreted languages
CN108804243A (en) * 2018-05-23 2018-11-13 北京五八信息技术有限公司 A kind of exchange method, device, computer equipment and computer readable storage medium
CN109656637A (en) * 2018-12-13 2019-04-19 高新兴科技集团股份有限公司 Cross-platform rendering method, device and the computer storage medium for calling OpenGL ES
CN109669739A (en) * 2017-10-16 2019-04-23 阿里巴巴集团控股有限公司 A kind of interface rendering method, device, terminal device and storage medium
CN109857478A (en) * 2019-01-31 2019-06-07 北京小米移动软件有限公司 Operation method, device and the readable storage medium storing program for executing of destination application

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6785891B1 (en) * 1999-10-12 2004-08-31 International Business Machines Corporation Data sharing between application environments
US20030145210A1 (en) * 2002-01-31 2003-07-31 Sun Microsystems, Inc. Method, system, program, and data structure for implementing a locking mechanism for a shared resource
WO2008054074A1 (en) * 2006-10-31 2008-05-08 Sk Telecom Co., Ltd. Terminal device having function of interfacing compilation libraries in heterogeneous languages, method of calling api, and method of creating compile function
JP2011113394A (en) * 2009-11-27 2011-06-09 Internatl Business Mach Corp <Ibm> Method for converting source code written in dynamic typing language into target code written in static typing language and executing the same, and computer program and computer system for the method
WO2014012504A1 (en) * 2012-07-20 2014-01-23 Tencent Technology (Shenzhen) Company Limited Method, device, and mobile terminal for api interception
CN106462407A (en) * 2014-05-16 2017-02-22 微软技术许可有限责任公司 Code service for language-independent dispatch
US20170147478A1 (en) * 2015-11-25 2017-05-25 International Business Machines Corporation Generic language application programming interface interpreter
US20180165175A1 (en) * 2016-12-13 2018-06-14 International Business Machines Corporation Common debug scripting framework for driving hybrid applications consisting of compiled languages and interpreted languages
CN106506703A (en) * 2016-12-28 2017-03-15 掌阅科技股份有限公司 Based on the service discovery method of shared drive, apparatus and system, server
CN109669739A (en) * 2017-10-16 2019-04-23 阿里巴巴集团控股有限公司 A kind of interface rendering method, device, terminal device and storage medium
CN108804243A (en) * 2018-05-23 2018-11-13 北京五八信息技术有限公司 A kind of exchange method, device, computer equipment and computer readable storage medium
CN109656637A (en) * 2018-12-13 2019-04-19 高新兴科技集团股份有限公司 Cross-platform rendering method, device and the computer storage medium for calling OpenGL ES
CN109857478A (en) * 2019-01-31 2019-06-07 北京小米移动软件有限公司 Operation method, device and the readable storage medium storing program for executing of destination application

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
GLOWIN: "[译] 在 Node.js 和 C++ 之间使用 Buffer 共享数据", pages 1 - 25, Retrieved from the Internet <URL:《https://zhuanlan.zhihu.com/p/24847170/》> *
心灵*寄语&: "Javascript和C++数据传递(网页端视频播放器的设计实现总结)", Retrieved from the Internet <URL:《https://blog.csdn.net/pkx1993/article/details/79927887》> *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116991600A (en) * 2023-06-15 2023-11-03 上海一谈网络科技有限公司 Method, device, equipment and storage medium for processing graphic call instruction
CN116991600B (en) * 2023-06-15 2024-05-10 上海一谈网络科技有限公司 Method, device, equipment and storage medium for processing graphic call instruction

Also Published As

Publication number Publication date
CN112416470B (en) 2023-08-25

Similar Documents

Publication Publication Date Title
CN108563517B (en) Calling method and device of system interface
CN110691136B (en) Data interaction method and device, electronic equipment and storage medium
EP3627318B1 (en) Game rendering method and apparatus, terminal, and non-transitory computer-readable storage medium
CN108829868B (en) Data display method and device, storage medium and electronic device
CN111433743A (en) APP remote control method and related equipment
CN107368410A (en) The performance test methods and device of game engine, storage medium and electronic installation
CN107890671A (en) Threedimensional model rendering intent, device, computer equipment and the storage medium of WEB terminal
CN109213462B (en) Android horizontal and vertical screen data synchronization method and device, terminal and readable medium
CN111249744A (en) Resource loading method and device, storage medium and electronic device
CN102413183B (en) Cloud intelligence switch and processing method and system thereof
CN111899149A (en) Image processing method and device based on operator fusion and storage medium
WO2017166997A1 (en) Inic-side exception handling method and device
CN112416470B (en) Command execution method and device, storage medium and electronic device
CN105677491A (en) Method and device for transmitting data
CN104965786B (en) A kind of adjustment method of application program, debugging host and operation host
CN111462289B (en) Image rendering method, device and system
CN112667490A (en) Performance test method and device based on hook function
CN111242838B (en) Blurred image rendering method and device, storage medium and electronic device
CN114090083A (en) A visual component configuration method, device, device and storage medium
CN112036503A (en) Image processing method and device based on step-by-step threads and storage medium
CN113407259B (en) Scene loading method, device, equipment and storage medium
CN114095758B (en) Cloud image intercepting method and related device
CN113805854A (en) Method, system and device for realizing Hook of application layer based on Linux system and storage medium
CN112631638A (en) Terminal application updating method and device, storage medium and electronic equipment
CN111399942A (en) Network card configuration method, network card configuration device, network card configuration equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant