WO2019238145A1 - Webgl-based graphics rendering method, apparatus and system - Google Patents
Webgl-based graphics rendering method, apparatus and system Download PDFInfo
- Publication number
- WO2019238145A1 WO2019238145A1 PCT/CN2019/100605 CN2019100605W WO2019238145A1 WO 2019238145 A1 WO2019238145 A1 WO 2019238145A1 CN 2019100605 W CN2019100605 W CN 2019100605W WO 2019238145 A1 WO2019238145 A1 WO 2019238145A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- instruction
- terminal device
- request
- graphic
- graphics
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T1/00—General purpose image data processing
- G06T1/60—Memory management
Definitions
- the present application relates to the technical field of computer graphics rendering, and in particular, to a WebGL-based graphics rendering method, device, and system.
- terminal devices need to perform a large number of multi-dimensional graphics (such as 2D graphics or 3D graphics) drawing work.
- the speed of drawing graphics determines to a large extent the response speed of various applications and programs on the terminal device to user operations, which in turn affects the user usage of the application or program.
- a specially developed runtime (RunTime) is generally used on the terminal device.
- the core components of the runtime include the JS parsing engine and the C ++ engine. Framework, the former is used to identify and parse the instruction set in a JS project, and the latter is used to call encapsulated C language functions to perform instructions.
- the JS parsing engine of the runner parses the instruction set in the JS code project, and then "parses” each parsed instruction in a "stack” manner. It is pushed to the C ++ engine framework for execution, and then rendered by OpenGLES, and finally completes the drawing of the predetermined graphics.
- the above method can successfully complete the graphics drawing work on the terminal device.
- the overall operating efficiency of the JS project is low and the resource consumption is large, resulting in short-term heating of the terminal device. Too large, especially when the terminal device is an iOS device, because the JIT function is disabled, the JavaScript performance of the iOS device is even lower.
- the operating efficiency of JS projects is different, which restricts the widespread application of JS projects.
- the embodiments of the present application provide a method, a device, and a system for drawing graphics based on WebGL, so as to improve or improve the efficiency of drawing graphics, reduce heat generation, and promote the widespread application of JS projects.
- the WebGL-based graphic drawing method provided by the embodiment of the present application includes:
- the server receives a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
- the server parses the drawing request, executes a JS project code corresponding to the drawing request, and forms a WebGL-based graphic drawing rule instruction set;
- the server sends the graphic drawing rule instruction set to the terminal device for execution in the form of an instruction stream through a network to implement drawing of a target graphic.
- the embodiment of the present application also provides another method for drawing graphics based on WebGL.
- the method includes:
- the terminal device sends a drawing request for drawing the target graphic in the JS project to the server through the network;
- the terminal device executes the instruction flow to achieve drawing of a target graphic.
- an embodiment of the present application provides a WebGL-based graphic drawing device, which is located on a server side and is characterized by including a request receiving unit, a parsing execution unit, and an instruction sending unit, where:
- a request receiving unit configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
- a parsing execution unit configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;
- An instruction sending unit is configured to send the graphic drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic.
- the embodiment of the present application further provides another WebGL-based graphic drawing device, which is located on the terminal device side, and is characterized by including a request sending unit, an instruction receiving unit, and an instruction execution unit, where:
- a request sending unit configured to send a drawing request for drawing a target graphic in a JS project to a server through a network
- An instruction receiving unit configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
- An instruction execution unit is configured to execute the instruction flow to achieve drawing of a target graphic.
- a WebGL-based graphics rendering system provided by an embodiment of the present application includes: the system includes a server and a terminal device,
- the server includes a request receiving unit, a parsing execution unit, and an instruction sending unit, where:
- a request receiving unit configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
- a parsing execution unit configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;
- An instruction sending unit configured to send the graphics drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic
- the terminal device includes a request sending unit, an instruction receiving unit, and an instruction execution unit, wherein:
- a request sending unit configured to send a drawing request for drawing a target graphic in a JS project to a server through a network
- An instruction receiving unit configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
- An instruction execution unit is configured to execute the instruction flow to achieve drawing of a target graphic.
- an embodiment of the present application provides another WebGL-based graphics rendering system, including: a memory, a processor, and a computer program stored in the memory and executable on the processor.
- the computer program is The processor executes the steps of the method as described above when executed.
- an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, implements the steps of the method described above.
- the server parses the drawing request, executes a JS project code corresponding to the drawing request, and forms a WebGL-based
- the graphics drawing rule instruction set is then sent to the terminal device for execution to complete the drawing of the target graphics.
- the underlying C ++ engine framework of the terminal device is only responsible for the "no difference" execution, which smoothes the differences between different terminal devices and facilitates the promotion and application of the JS project on various terminal devices. .
- Figure 1 is a schematic diagram of the framework structure of the Web engine end and the runner;
- FIG. 2 is a schematic flowchart of an embodiment of a graphic drawing method based on WebGL of the present application
- FIG. 3 is a signaling interaction diagram of an example of a WebGL-based graphic drawing method of the present application.
- FIG. 4 is a schematic structural diagram of an embodiment of a graphic rendering device based on WebGL of the present application.
- FIG. 5 is a schematic structural diagram of another embodiment of a WebGL-based graphic drawing device
- FIG. 6 is a schematic structural diagram of an embodiment of a graphic rendering system based on WebGL of the present application.
- the WebGL interface is similar to the HTML5 protocol.
- On the project application layer it is developed using JavaScript language (hereinafter referred to as JS language).
- JS JavaScript language
- this operation mode makes the JS project run at a low efficiency and high heat generation of terminal equipment.
- its compatibility is not strong, which restricts the promotion and application of JS projects on different terminal equipment.
- an embodiment of the present application provides a WebGL-based graphic drawing method.
- the embodiment method shown in the figure includes: S201: The server receives a target graphic in a JS project sent by a terminal device through a network. Make a drawing request for drawing; S202: the server parses the drawing request, executes a JS item code corresponding to the drawing request, and forms a WebGL-based graphic drawing rule instruction set; S203: the server sends the graphic drawing rule instruction set through the network Sending it to the terminal device for execution in the form of an instruction stream to achieve drawing of a target graphic.
- S201 The server receives a target graphic in a JS project sent by a terminal device through a network. Make a drawing request for drawing
- S202 the server parses the drawing request, executes a JS item code corresponding to the drawing request, and forms a WebGL-based graphic drawing rule instruction set
- S203 the server sends the graphic drawing rule instruction set through the network Sending it to the terminal device for execution in the form of an instruction stream
- the execution subject involved in each step in the above technical solution is a "server", and the terminal device and the runner on the terminal device are mentioned in the background art section, and a preliminary introduction is made here to reflect the similarities and differences between these concepts.
- the local terminal device includes the Web engine and the runner.
- the runner usually includes three parts: the first is JS parsing engine part, for example, V8 and JSC with this function. Although the code obtained from the Web engine side contains some content of the WebGL interface, it is still JS code. It needs to be parsed and identified by the JS parsing engine and converted into executable code that can be run by other parts of the runner.
- the second is the C ++ engine framework part.
- This part is the "main beam” of the runner. After the code is parsed by the JS parsing engine, this part will complete a large number of substantial operations. Because it is developed using the lower-level C ++ language, its operating efficiency is higher.
- rendering The drawing part such as OpenGLES, calls the OpenGLES function through C ++ code to complete the graphics drawing and submit the drawing result.
- the concept of the "runner” is mentioned in the embodiment of the present application, It should be noted that this runner cannot be simply regarded as the same runner as in the prior art.
- the runner in this embodiment is a modified runner and cooperates with the server to complete the purpose of the present invention.
- New runner Of course, it is open to whether or not it is called “runner”. In fact, with the above-mentioned capabilities, the name of "runner” does not constitute a limitation on understanding and application.
- a brand new platform mode (which can be called a server mode) is actually set up.
- the terminal device initiates a graphic drawing request to the server through the network.
- the server After receiving this request, it parses it, determines the JS project or the code segment in the JS project specified by the request, and then executes these project codes to form a WebGL-based graphic drawing rule instruction set.
- WebGL-based indicates the relationship between graphics drawing rule instructions and WebGL, which can be formed standard instructions based on the WebGL protocol, or extended instructions set by the user or a terminal according to the standard instructions of the WebGL protocol.
- the "correspondence" relationship between the drawing request and the JS item code is mentioned here.
- the server side can contain an unlimited number of JS items.
- the server When running a JS project, the server should be informed of the address of the JS project (in whole or in part), so that the server can find the project for subsequent operations. From this perspective, the “correspondence” relationship can be understood according to different stages and scenarios: For the initial startup project phase, the drawing request should at least include the URL address of the overall JS project on the server. In this way, “the execution corresponds to the drawing request "JS project code" is actually to find and execute the JS project code corresponding to the URL address.
- the user may perform certain operations on the terminal device's application client corresponding to the JS project, and then perform these operations.
- the result information is sent to the server through the drawing request.
- "executing the JS item code corresponding to the drawing request” is actually executing the piece of JS item code that can respond to user operation result information.
- this division is only an ideal state. In actual operation, even after starting the project, you may face "hanging up” and may not need to receive user operation result information and still need to run the JS project code segment. Therefore, the above two The situation may be mixed.
- the server forms the graphics drawing rule instruction set in response to the drawing request, and the information in the drawing request informs or triggers how the server should form the graphics drawing rule instruction set.
- the server can be used to describe the technical solution of this application.
- the technical solution of this application can also be better described from the perspective of the terminal device, that is, the terminal device sends the JS project to the server through the network.
- a drawing request for drawing a target graphic in the drawing a terminal device receives a WebGL-based drawing of a drawing formed by a JS project code corresponding to the drawing request by parsing the drawing request and executing the drawing request sent by the server through a network A rule instruction set; then, the terminal device executes the instruction flow to achieve drawing of a target graphic.
- graphics that is used for drawing graphics is understood in this embodiment from a broader perspective that conforms to industry habits.
- graphics may be limited to some geometrical figures, but in fact, in this embodiment, not only regular graphics, images, etc. may be included.
- drawing a graphic may be drawing a triangle, quadrilateral, etc. on the canvas.
- it can also perform operations such as coloring and covering a completed figure. For example, coloring a triangle that has been drawn at a certain time. This process of coloring a triangle can still be independently called Graphic drawing. In other embodiments, it may even include processing for some non-graphics.
- the graphic drawing in the embodiment of the present application may include a specific graphic drawing process, or may perform a certain operation on an existing graphic or non-graphic.
- the graphic drawing process is a process of performing an operation on a target object to be displayed on a screen or a target object associated with an object displayed on a screen.
- graphics drawing rule instruction mentioned in the above technical solution is not called “graphic drawing instruction” here, the main reason is that in this embodiment, the JS project can "make rules", and the runner side specifically “implements the rules” (Running rules) ", and then achieve less or no calculation at the JS code level, and leave a large amount of low-level calculation work to the runner to complete the graphics drawing performance from the perspective of the runner.
- the graphics drawing rule instruction can be a special "instruction” different from the conventional graphics drawing instruction, which is at least responsible for telling the runner “how to do it", rather than "in person” by itself.
- the operation rule determined by the instruction and the data involved in the operation are specified.
- the former is called an operation type in the following embodiments, and the latter is called an operation object.
- the parameter "operateType” indicates the type of operation to be performed by this instruction. For example, it can be operations such as addition, subtraction, and assignment between data.
- the parameters "globalValueID” and “data” are the operation objects, and "globalValueID” It is an operation object specified in the form of a data index (which will be described in detail later), and "data” may be the operation data itself explicitly specified by the instruction.
- "operateType" that is, a drawing rule instruction for a graph, not the function itself (for example, setGlobalValue) is the operation type.
- the graphic drawing rule instruction has been explained in text and examples, it is therefore an error to understand the “graphic drawing rule instruction” as not being a specific graphic drawing instruction. That is, in some cases, the graphic drawing rule instruction can be directly embodied as a specific graphic drawing instruction, that is, in the terminology used in this application, the graphic drawing rule instruction includes both the "graphics” in the form of a specified rule. “Drawing rule instructions” also includes graphics drawing instructions in the form of graphics drawing instructions directly, so it needs to be considered in conjunction with specific application scenarios. For example, when a clear operation is performed on data in a data area, the graphics drawing rule instruction can be directly expressed as a clear instruction. Therefore, when understanding the concept of "graphic drawing rule instructions", the emphasis is not on whether the rule instructions are embodied as a rule instruction or a specific instruction, but on the possibility of separating the formulation of rules from the implementation rules.
- the "graphic drawing rule instruction” may be directly used in some places, while in other places, the “graphic drawing rule instruction and predetermined operations as its parameters may be used” "Type and operand", that is, the concept sometimes refers to the whole including its parameters, sometimes it refers to the part that does not include its parameters and only has a regular part.
- Type and operand that is, the concept sometimes refers to the whole including its parameters, sometimes it refers to the part that does not include its parameters and only has a regular part.
- the graphics drawing rule instruction set is composed of graphics drawing rule instructions and usually means that there are at least two instructions. As will be mentioned later, in one embodiment, these instructions can be divided into two types: one is an instruction that operates on a register; and one is an instruction that does not operate on a register. According to this classification of instructions using "registers" as a standard, three types of "graphic drawing rule instruction sets" will be generated: one is that all instructions in the instruction set operate on registers; the other is that in the instruction set All are instructions that do not operate on registers; the third is that the instruction set contains both instructions that operate on registers and instructions that do not operate on registers. This application focuses on the first type and the third type. Since the two types of instruction sets contain at least one instruction to operate on a register, the technical effects of this application can be demonstrated “with ease” (more details will be described later).
- the graphics drawing rule instruction set may be only the “dry” instructions themselves, or may include instructions including the instructions and the parameters corresponding to the instructions.
- the graphics drawing rule instruction set may be only the “dry” instructions themselves, or may include instructions including the instructions and the parameters corresponding to the instructions.
- some instructions have no operation object or operation type, and are just a non-functional instruction that is inserted to meet the needs of the current execution; the other may be the parameter corresponding to the instruction (Such as the operation object or operation type) is placed outside the instruction set, but contains instructions sent to the terminal device.
- the existence form of the graphics drawing rule instruction set may be a true "instruction" set that contains only the graphics drawing instruction itself (first This form of existence) may also be a complete type of "instruction" set (the second form of existence) containing a drawing rule instruction and parameters corresponding to the instruction.
- first form of existence may also be a complete type of "instruction” set (the second form of existence) containing a drawing rule instruction and parameters corresponding to the instruction.
- the first form of existence and the second form of existence in an instruction set, which depends on the preset settings, as long as it does not prevent subsequent runners from drawing target graphics according to the instruction set of graphics drawing rules. can.
- registers In describing the concept of the graphics drawing rule instruction set, as mentioned earlier, it involves "registers".
- registers In the embodiment of the present application, a register is operated, so that the register becomes an operation object. Operation data is stored in the register, and operations on the data in the register are implemented by operating the register.
- Registers in this application are temporary storage areas existing in memory. The “temporary” here is relative to the length of time that the memory itself exists.
- an application or program code segment
- a computing device usually needs to be opened. The memory area is used to store data and execute instructions.
- the storage area where the data always exists can be called a "permanent" storage area, for example, a global data area set as required.
- the register in this application indicates that the data stored on it may be erased and re-stored at any time, so that it cannot exist permanently, so it is a temporary storage area.
- the number of registers required may be more or less, depending on the need to run the corresponding program code and implement the corresponding function itself. Too many preset registers may cause waste. If the preset number of registers is too small, it may be "unused” and the best technical effect of the mechanism of this application cannot be fully exerted.
- the terminal device draws the target graphics according to the graphics drawing rule instruction set in the form of an instruction stream. It needs to be explained here that the completion of the operation on the operation object by the terminal device does not necessarily mean that the drawing of the target graphic is completed. In fact, in most cases, a terminal device can only perform operations on the operation object to complete its core content. In addition, it may also have some other operations, such as the OpenGLES function to interface with the GPU. , Rendering, etc. (see the "OpenGLES Functions" section shown in Figure 1). However, the focus of this embodiment is to highlight the core differences between the new runner on the terminal device and the existing technology, and to briefly or even omit other operations. Those skilled in the art must read this step of this embodiment without fail. Double check also.
- the first is to make full use of graphics card hardware to achieve drawing and display acceleration.
- the target object of this embodiment is a project formed by calling the WebGL interface from JS code. Since WebGL is developed based on OpenGLES, GPU instructions can be directly operated, and hardware acceleration can be achieved through a graphics card, which can greatly improve the efficiency of graphics drawing and display effects.
- the second is to implement the "WebGL +" concept and successfully simulate canvas.
- the project running in the C ++ engine framework of the runner is no longer a canvas interface called through the JS language, but has been changed to call the WebGL interface and WebGLl extended function interface in the JS language.
- the underlying nature of WebGL is consistent with the C ++ engine framework in the runner. , Speeding up operation efficiency.
- the "complementary advantages" of the server and terminal devices can be achieved, and the overall performance can be significantly improved.
- the terminal device does not directly respond to the request, so that a large amount of computing processing work is transferred from the terminal device to the server, thereby fully utilizing the "computing advantage" of the server.
- the terminal device is no longer burdened with too many computing tasks, and the calculation rules can be specified at the upper layer, which will not cause a large amount of heat generation, smoothing the individual differences caused by different terminal devices running JS projects, thereby increasing the terminal device.
- the flexibility and extensibility of the terminal fully utilizes the "inclusive advantage" of the terminal equipment side for different engine vendors. Based on the “clear division of labor” between the server and the terminal, and “recovering the weaknesses of each other”, it greatly improves the graphics rendering performance based on WebGL.
- the server receives the graphic drawing request sent from the terminal device through the network.
- the operation result of the user of the terminal device on the application (client) corresponding to the JS project is usually included. information.
- the operation result information As shown in FIG. 3, after the user of the terminal device starts the application, the user operates the application, and the operation result information formed by the operation will be sent to the server, so that the server can form a WebGL based on the operation result information in the drawing request.
- the operation result information here may be operation result information of a gravity sensor, a touch (TOUCH) event, user account information, user status information, and the like.
- the operation here may be a direct operation in some cases, for example, clicking a button on the application client corresponding to a JS project, setting some parameters, etc. In other cases, it may also be an indirect operation, such as, The user shakes the entire terminal device, which causes the gravity sensor to capture different attitude information, which is also considered as a result of user operations.
- the terminal device needs to send a graphic drawing request to the server through the network, and at the same time, the server needs to send the graphic drawing rule instruction set to the terminal device through the network after parsing the drawing request. Because data needs to be sent and received over the network, usually, the speed of data transmission will have a greater impact on the speed of drawing the target graphics.
- the computing process is moved from the terminal device to the server, although the computing advantage of the server is used to help improve the efficiency of graphics drawing, in the graphics drawing process, in terms of user experience, it is not only necessary to have Stronger calculations and faster calculation speeds should also have faster transmission speeds.
- a terminal device is required to send a drawing request to draw the target graphics in the JS project through the network.
- the length of time is less than or equal to a predetermined time, and the time required for the server to send graphics drawing rule instructions to the terminal device in the form of an instruction stream through the network is less than or equal to another predetermined time.
- the length of these two periods can be configured.
- the principle of configuration can be determined according to the operation requirements of the JS project by the terminal device. If the project is an online game with high real-time requirements, usually its users have high expectations for time (that is, the feedback speed after operation).
- the network speed should be fast enough and the scheduled time will be Set it more briefly. If the users of this project are not particularly sensitive to time, but are more concerned about the clarity of the picture, you can require that the network speed is not particularly slow. Of course, with the development of communication technology, it is undeniable that the network speed is getting faster and faster.
- the network where the terminal device and the server are located is required to be a 5G network, and the transmission speed of the 5G network is usually high. For traditional 2G, 3G, 4G and other networks.
- the network transmission speed is greater than or Keep on the average speed of 5G network.
- the faster the network speed required by this application is, the better, which not only utilizes the powerful computing power of the server, but also does not affect the feedback speed of the JS project to the user, thereby greatly improving the user experience.
- the graphics drawing rule instruction set includes at least one instruction for operating a register.
- this will make the graphics drawing rule instruction set divided into three categories: one is the instruction set that contains instructions that operate on registers; the other is the instruction set that does not include operations on registers;
- the three types are instruction sets that mix the above two instructions.
- the register serves as a temporary data storage place and can store intermediate data in different data calculation processes. Multiple registers can be used to operate on multiple data at the same time, so when facing complex application scenarios, it has greater flexibility and adaptability. These technical effects also enhance the scalability of the terminal device (runner) from another aspect.
- the graphics drawing rule instruction is an instruction other than an instruction to operate a register
- the operation object can be directly reflected in the graphics drawing request, this will make the graphics drawing request “bloated”, especially
- the operation object is represented by "large volume and complex structure" data, it is even more "overwhelmed”, and when the graphics drawing rule instructions need to be modified, the operation object needs to be re-designated, which adds unnecessary overhead to the system.
- a mechanism for separating graphics drawing rule instructions from its operating objects can be adopted, that is, the index of the operating object is included in the graphics drawing request, and the data corresponding to the index is performed in the data storage area temporarily or permanently opened in the runner Storage, so that when changing (increasing or adjusting) the graphics drawing rule instruction, as long as the index of the operation object does not change, the instruction does not change, and only the data in the data storage area needs to be modified.
- the specific method is: specify the index of the operation object in the graphics drawing request, and the runner obtains the corresponding specific operation data from the data area according to the operation object index, and then the operator operates the operation data according to the predetermined operation type. Then complete graphics drawing. Take the following examples to illustrate:
- the data area can be divided into different types according to the actual situation and different division criteria. For example, it can be divided into a global data area and a local data area. The former is used to store global data or intermediate results, and the latter is used to store local data. Of course, in the actual application process, these two data areas can be physically adjacent storage locations or different physical storage locations separated by “thousands of mountains and rivers”.
- the data in it can be configured on the Web engine side, such as defining it during initialization, and then synchronizing these configured data to or before receiving a graphics drawing request.
- the data area that the runner can access In the data area that the runner can access. For example, you can configure global data in the data area as follows:
- varvalueID GL.addValueDefine (modifyType, type, size, defaultData)
- the graphics drawing request includes the following:
- the types of operations involved in the graphics drawing process include conventional addition, subtraction, multiplication, division, and vertex deformation types.
- one of the above operations can be adopted to complete the operation. Examples are as follows:
- the content of this instruction indicates that a certain data specified by valueID in the global data area is used to modify some data in the graphics card vertex buffer specified by vdoPosID in the vertex buffer data area, and calculation is performed according to the operation type specified by operatorType.
- the operation mode is to transform the vertex data in a matrix. This operation is performed in the code in the C ++ of the runner, which greatly improves the efficiency.
- the register as an operation object usually exists in the form of a register index, that is, when the data is manipulated, the graphics drawing rule instruction passes the register index (for example, regID ) Indicates which register to operate on, as long as the data is stored in the register, the corresponding operation may be completed.
- the data sources in the register can include the following two sources: First, when the graphics drawing rule instruction is executed, the predetermined data is written into the register through a predetermined function, so that the register has the corresponding data and can be completed.
- the data writing operation in the register can be completed before the graphics drawing rule instruction is executed, and the operation can be performed directly after the index number of the register of the operation is specified.
- the operation object index is also specified in the instruction, then the operation data corresponding to the operation object index can be obtained from the data area according to the operation object index, and then the data is written to Corresponding register.
- the runner can operate the operation data in the register according to the predetermined operation type according to the graphics drawing rule instructions to complete the target image. Drawing work.
- the so-called judgment-type operation is a conditional statement, which judges whether a certain condition is satisfied. When it is satisfied, a certain judgment branch is executed; when it is not satisfied, another judgment branch is executed, which can be embodied as an IF statement, a WHILE statement, and the like.
- a certain judgment branch is executed; when it is not satisfied, another judgment branch is executed, which can be embodied as an IF statement, a WHILE statement, and the like.
- a certain graphics drawing rule instruction in specific implementation, it can directly specify the target graphics drawing rule instruction for the jump To jump directly to the instruction execution, or just specify
- loadInt (dataID, offset, reg [0]); // Set the value to the 0th register
- arithmetic operations are operations such as addition, subtraction, multiplication, division, and matrix operations on the data in a register.
- operations on data in a register such as power, increment, decrement, etc.
- the data in multiple registers can also be operated, and the data stored in the data area specified by the data in the registers and the operation object index can also be directly operated.
- the predetermined first data or the first data obtained from the data area may be written into the first register corresponding to the first register index, and the predetermined second data or from The second data obtained in the data area is written into a second register corresponding to the second register index, or before the runner operates the operation object according to the graphic drawing rule instruction and the predetermined operation type, Write predetermined first data or first data obtained from the data area into the first register corresponding to the first register index, and write predetermined second data or second data obtained from the data area into the first register
- the second register index corresponds to the second register. Then, an operation is performed on the operation data in the first register and the second register.
- the register is first filled with data by a function, and then the data in the register is operated according to a predetermined operation type.
- loadData (dataID, offset, reg [0]);
- loadData (dataID, offset, reg [1]);
- loadData (dataID, offset, reg [2]);
- loadData (dataID, offset, reg [3]);
- the following is an optimized technical solution that may coexist regardless of whether the graphics drawing rule instruction is an instruction that operates a register or an instruction that does not operate a register.
- the graphics drawing rule instructions formed after parsing the graphics drawing request and executing the JS project code may include the graphics drawing rule instruction itself or the index of the graphics drawing rule instruction.
- the terminal device or The server may determine the graphics drawing rule instruction set corresponding to the graphics drawing rule instruction index based on the graphics drawing rule instruction index, specifically:
- the terminal device finds the instruction set corresponding to the graphic drawing rule instruction index from the storage device according to the graphic drawing rule instruction index.
- the storage device stores different graphic drawing rule instruction indexes and different graphic drawing rules.
- multiple rule instruction sets for drawing different target graphics may be determined according to the method described above, and the multiple rule instruction sets and graphics drawing rules may be determined.
- the instruction index is correspondingly stored in a storage device. In this way, when drawing different target graphics, an instruction set corresponding to a different drawing instruction instruction index can be obtained from the storage device.
- the instruction set may correspond to a data area, and the combination of the data area and the instruction set may be used to draw a target graphic; moreover, all The instruction set can also correspond to multiple data areas. After each of the data areas and the instruction set are combined, they can be used to draw different target graphics, that is, multiple different target graphics can be shared using one instruction set. The drawing of the target graphics. In this way, since multiple target graphics can be drawn according to the same instruction set, the number of stored instruction sets can be effectively reduced, thereby effectively reducing the storage space occupied by the instruction sets.
- instruction set A may correspond to data area 1 and data area 2.
- the target figure A1 may be drawn.
- the target figure A2 can be drawn. Because the target graphics A1 and A2 can both be drawn according to the instruction set A, the number of instruction sets can be reduced, thereby reducing the storage space occupied by the instruction set.
- FIG. 4 is a schematic structural diagram of a graphic drawing device according to an embodiment of the present application.
- the trunk is located on the server side and includes: a request receiving unit 41, a parsing execution unit 42, and an instruction sending unit 43, where:
- the request receiving unit 41 is configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
- the parsing execution unit 42 is configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;
- the instruction sending unit 43 is configured to send the graphic drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic.
- the above device can obtain the same technical effects as the foregoing method embodiments. To avoid repetition, details are not repeated here.
- the drawing request sent by the terminal device for drawing the target graphic in the JS project through the network includes the operation result information of the user of the terminal device operating the application corresponding to the JS project, then: the analysis execution unit 42, Specifically used to parse the drawing request, execute the JS project code corresponding to the operation result information, and form a WebGL-based graphic drawing rule instruction set.
- the operation result information here may be one or more of the following: operation result information on the gravity sensor; touch (TOUCH) event information; user account information; user status information.
- the terminal device sends a drawing request time for drawing a target graphic in a JS project through a network, which is less than or equal to a first predetermined duration; and the server sends the graphic drawing rule instruction set through the network.
- the time period sent to the terminal device in the form of an instruction stream is less than or equal to a second predetermined time period.
- the first predetermined duration or the second predetermined duration may be the same or different, and needs to be determined according to actual conditions.
- the device includes a request sending list 51, an instruction receiving unit 52, and an instruction execution unit 53, where:
- a request sending unit 51 configured to send a drawing request for drawing a target graphic in a JS project to a server through a network;
- An instruction receiving unit 52 is configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
- the instruction execution unit 53 is configured to execute the instruction flow to implement drawing of a target graphic.
- the above-mentioned devices located on the server side and the terminal side may be implemented as a system in some cases.
- Such a system includes services and terminal equipment, of which:
- the server includes a request receiving unit, a parsing execution unit, and an instruction sending unit, where:
- a request receiving unit configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
- a parsing execution unit configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;
- An instruction sending unit configured to send the graphics drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic
- the terminal device includes: a request sending unit, an instruction receiving unit, and an instruction execution unit, where:
- a request sending unit configured to send a drawing request for drawing a target graphic in a JS project to a server through a network
- An instruction receiving unit configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
- An instruction execution unit is configured to execute the instruction flow to achieve drawing of a target graphic.
- FIG. 6 is a schematic structural diagram of another embodiment of a system based on WebGL drawing in the present application.
- the system 60 includes a memory 61, a processor 62, and a memory 61 that can be run on the processor 62.
- a computer program that, when executed by the processor 62, implements the steps of the graphics drawing method described above.
- An embodiment of the present application further provides a computer-readable storage medium.
- a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the graphics drawing method described above are implemented.
- this application may be provided as a method, a system, or a computer program product. Therefore, this application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
- computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
- These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to work in a specific manner such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device, the instructions
- the device implements the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
- These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of steps can be performed on the computer or other programmable device to produce a computer-implemented process, which can be executed on the computer or other programmable device.
- the instructions provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.
- a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
- processors CPUs
- input / output interfaces output interfaces
- network interfaces network interfaces
- memory volatile and non-volatile memory
- Memory may include non-persistent memory, random access memory (RAM), and / or non-volatile memory in computer-readable media, such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
- RAM random access memory
- ROM read-only memory
- flash RAM flash memory
- Computer-readable media includes permanent and non-persistent, removable and non-removable media.
- Information storage can be accomplished by any method or technology.
- Information may be computer-readable instructions, data structures, modules of a program, or other data.
- Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), and read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, read-only disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transmitting medium may be used to store information that can be accessed by a computing device.
- computer-readable media does not include temporary computer-readable media, such as modulated data signals and carrier waves.
- this application may be provided as a method, a system, or a computer program product. Therefore, this application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
- computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Image Generation (AREA)
Abstract
Disclosed are a WebGL-based graphics rendering method, apparatus and system. The method comprises: a server receives a rendering request, for rendering target graphics in a JS project, sent by a terminal device via a network; the server analyses the rendering request, executes JS project code corresponding to the rendering request, and forms a WebGL-based graphics rendering rule command set; the server sends the graphics rendering rule command set in the form of a command flow to the terminal device for execution, in order to render the target graphics. The present technical solution solves the problem of low graphics rendering efficiency, increases compatibility, and expands the application range of JS projects.
Description
本申请涉及计算机图形绘制技术领域,尤其涉及一种基于WebGL的图形绘制方法、装置及系统。The present application relates to the technical field of computer graphics rendering, and in particular, to a WebGL-based graphics rendering method, device, and system.
在网络游戏、动画展现等应用场景中,终端设备需要进行大量的多维图形(比如2D图形或3D图形)的绘制工作。图形绘制的快慢在较大程度上决定终端设备上的各种应用、程序对用户操作的响应速度,进而影响到该应用或程序的用户使用量。为提高图形绘制效率,在不依赖于浏览器为载体的情况下,一般在终端设备上使用专门开发的运行器(RunTime),如图1,运行器的核心组成部分包括JS解析引擎和C++引擎框架,前者用于对JS项目中的指令集进行识别、解析,后者用于调用封装的C语言函数对指令进行执行操作。运行器运行JS代码(JavaScript语言编写的代码)形成的JS项目时,由运行器的JS解析引擎对JS代码项目中的指令集进行解析,然后将解析后的各条指令以“压栈”方式推送到C++引擎框架中执行,再通过OpenGLES进行渲染,最终完成预定图形的绘制工作。In application scenarios such as online games and animation, terminal devices need to perform a large number of multi-dimensional graphics (such as 2D graphics or 3D graphics) drawing work. The speed of drawing graphics determines to a large extent the response speed of various applications and programs on the terminal device to user operations, which in turn affects the user usage of the application or program. In order to improve the efficiency of graphics drawing, without relying on the browser as a carrier, a specially developed runtime (RunTime) is generally used on the terminal device. As shown in Figure 1, the core components of the runtime include the JS parsing engine and the C ++ engine. Framework, the former is used to identify and parse the instruction set in a JS project, and the latter is used to call encapsulated C language functions to perform instructions. When the runner runs a JS project formed by JS code (code written in the JavaScript language), the JS parsing engine of the runner parses the instruction set in the JS code project, and then "parses" each parsed instruction in a "stack" manner. It is pushed to the C ++ engine framework for execution, and then rendered by OpenGLES, and finally completes the drawing of the predetermined graphics.
在大多数情况下,上述方式能够在终端设备上顺利完成图形绘制工作,但是,基于终端设备的运算能力,JS项目的整体运行效率低下、资源消耗量较大,导致终端设备短时内发热量过大,尤其终端设备为iOS设备时,由于JIT功能被禁用,iOS设备执行JavaScript脚本的效率更为低下。此外,由于不同的终端设备本身的差异,导致JS项目的运行效率各不相同,制约着JS项目的广泛应用。In most cases, the above method can successfully complete the graphics drawing work on the terminal device. However, based on the computing capabilities of the terminal device, the overall operating efficiency of the JS project is low and the resource consumption is large, resulting in short-term heating of the terminal device. Too large, especially when the terminal device is an iOS device, because the JIT function is disabled, the JavaScript performance of the iOS device is even lower. In addition, due to the differences in different terminal devices, the operating efficiency of JS projects is different, which restricts the widespread application of JS projects.
发明内容Summary of the Invention
本申请实施例提供一种基于WebGL的图形绘制方法和装置、系统,以提高或改善图形绘制的效率,减少发热量,促进JS项目的广泛应用。The embodiments of the present application provide a method, a device, and a system for drawing graphics based on WebGL, so as to improve or improve the efficiency of drawing graphics, reduce heat generation, and promote the widespread application of JS projects.
一方面,本申请实施例提供的基于WebGL的图形绘制方法,包括:In one aspect, the WebGL-based graphic drawing method provided by the embodiment of the present application includes:
服务器接收终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求;The server receives a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
所述服务器解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;The server parses the drawing request, executes a JS project code corresponding to the drawing request, and forms a WebGL-based graphic drawing rule instruction set;
所述服务器通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备执行,以实现目标图形的绘制。The server sends the graphic drawing rule instruction set to the terminal device for execution in the form of an instruction stream through a network to implement drawing of a target graphic.
另一方面,本申请实施例还提供另一种基于WebGL的图形绘制方法,该方法包括:On the other hand, the embodiment of the present application also provides another method for drawing graphics based on WebGL. The method includes:
终端设备通过网络向服务器发送对JS项目中的目标图形进行绘制的绘制请求;The terminal device sends a drawing request for drawing the target graphic in the JS project to the server through the network;
所述终端设备接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;Receiving, by the terminal device, a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
所述终端设备执行所述指令流,以实现目标图形的绘制。The terminal device executes the instruction flow to achieve drawing of a target graphic.
再一方面,本申请实施例提供基于WebGL的图形绘制装置,该装置位于服务器侧,其特征在于,包括请求接收单元、解析执行单元和指令发送单元,其中:In another aspect, an embodiment of the present application provides a WebGL-based graphic drawing device, which is located on a server side and is characterized by including a request receiving unit, a parsing execution unit, and an instruction sending unit, where:
请求接收单元,用于接收终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求;A request receiving unit, configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
解析执行单元,用于解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;A parsing execution unit, configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;
指令发送单元,用于通过网络将所述图形绘制规则指令集以指令流形式 发送给所述终端设备执行,以实现目标图形的绘制。An instruction sending unit is configured to send the graphic drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic.
又一方面,本申请实施例还提供另一种基于WebGL的图形绘制装置,所述装置位于终端设备侧,其特征在于,包括请求发送单元、指令接收单元和指令执行单元,其中:In another aspect, the embodiment of the present application further provides another WebGL-based graphic drawing device, which is located on the terminal device side, and is characterized by including a request sending unit, an instruction receiving unit, and an instruction execution unit, where:
请求发送单元,用于通过网络向服务器发送对JS项目中的目标图形进行绘制的绘制请求;A request sending unit, configured to send a drawing request for drawing a target graphic in a JS project to a server through a network;
指令接收单元,用于接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;An instruction receiving unit, configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
指令执行单元,用于执行所述指令流,以实现目标图形的绘制。An instruction execution unit is configured to execute the instruction flow to achieve drawing of a target graphic.
再一方面,本申请实施例提供的基于WebGL的图形绘制系统,包括:所述系统包括服务器和终端设备,In another aspect, a WebGL-based graphics rendering system provided by an embodiment of the present application includes: the system includes a server and a terminal device,
所述服务器包括请求接收单元、解析执行单元和指令发送单元,其中:The server includes a request receiving unit, a parsing execution unit, and an instruction sending unit, where:
请求接收单元,用于接收终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求;A request receiving unit, configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
解析执行单元,用于解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;A parsing execution unit, configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;
指令发送单元,用于通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备执行,以实现目标图形的绘制;An instruction sending unit, configured to send the graphics drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic;
所述终端设备包括:请求发送单元、指令接收单元和指令执行单元,其中:The terminal device includes a request sending unit, an instruction receiving unit, and an instruction execution unit, wherein:
请求发送单元,用于通过网络向服务器发送对JS项目中的目标图形进行绘制的绘制请求;A request sending unit, configured to send a drawing request for drawing a target graphic in a JS project to a server through a network;
指令接收单元,用于接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;An instruction receiving unit, configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
指令执行单元,用于执行所述指令流,以实现目标图形的绘制。An instruction execution unit is configured to execute the instruction flow to achieve drawing of a target graphic.
又一方面,本申请实施例提供另一种基于WebGL的图形绘制系统,包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如上所述的方法的步骤。In another aspect, an embodiment of the present application provides another WebGL-based graphics rendering system, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. The computer program is The processor executes the steps of the method as described above when executed.
再一方面,本申请实施例提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上所述的方法的步骤。In another aspect, an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, implements the steps of the method described above.
本申请实施例采用的上述至少一个技术方案能够达到以下有益效果:The at least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
本申请实施例提供的技术方案在服务器接收到终端设备发送的对JS项目中的目标图形进行绘制的绘制请求后,由服务器解析绘制请求,执行与绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集,然后再发送终端设备执行,完成目标图形的绘制。通过该技术方案,由于基于WebGL的图形绘制规则指令集是在服务器端形成的,服务器具有较强的运算能力,避免了终端设备的超负荷运行,减少其发热量,有利于提高用户体验和图形绘制效率。此外,由于在服务器上形成图形绘制规则指令,终端设备底层的C++引擎框架仅负责“无差别”的执行,平滑了不同终端设备的差异性,有利于JS项目在各种终端设备上的推广应用。In the technical solution provided in the embodiment of the present application, after the server receives a drawing request for drawing a target graphic in a JS project sent by a terminal device, the server parses the drawing request, executes a JS project code corresponding to the drawing request, and forms a WebGL-based The graphics drawing rule instruction set is then sent to the terminal device for execution to complete the drawing of the target graphics. Through this technical solution, because the WebGL-based graphics drawing rule instruction set is formed on the server side, the server has strong computing capabilities, which avoids overloading the terminal device and reduces its heat generation, which is beneficial to improving the user experience and graphics. Drawing efficiency. In addition, because the graphics drawing rule instructions are formed on the server, the underlying C ++ engine framework of the terminal device is only responsible for the "no difference" execution, which smoothes the differences between different terminal devices and facilitates the promotion and application of the JS project on various terminal devices. .
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The schematic embodiments of the present application and the descriptions thereof are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
图1为Web引擎端与运行器的框架结构示意图;Figure 1 is a schematic diagram of the framework structure of the Web engine end and the runner;
图2为本申请基于WebGL的图形绘制方法实施例的流程示意图;FIG. 2 is a schematic flowchart of an embodiment of a graphic drawing method based on WebGL of the present application; FIG.
图3为本申请基于WebGL的图形绘制方法的一个实例的信令交互图;3 is a signaling interaction diagram of an example of a WebGL-based graphic drawing method of the present application;
图4为本申请基于WebGL的图形绘制装置实施例的结构示意图;FIG. 4 is a schematic structural diagram of an embodiment of a graphic rendering device based on WebGL of the present application; FIG.
图5为本申请另一个基于WebGL的图形绘制装置实施例的结构示意图;FIG. 5 is a schematic structural diagram of another embodiment of a WebGL-based graphic drawing device;
图6为本申请基于WebGL的图形绘制系统实施例的结构示意图。FIG. 6 is a schematic structural diagram of an embodiment of a graphic rendering system based on WebGL of the present application.
在对本申请的各种实施例进行充分介绍之前,为便于理解,先对一些基本背景进行介绍。随着计算机技术的发展,人们对计算机信息处理的响应速度要求越来越高,尤其在一些实时应用场景之中,更是如此。比如,常见的网络对战型的实时性网络游戏,这些游戏通常涉及大量目标对象的动作、场景、角色、能力值、武器装备等的迅速变换,为更好呈现视觉效果,需要在终端设备上进行“任务艰巨”的图形绘制,图形绘制的速度成为这类软件吸引用户量的关键瓶颈。HTML5协议在网络展现上的广泛、深入的发展,对网络Web画面的显现提出了更高的要求,早期,人们通过canvas(画布)提供的标准绘图API实现丰富画面的展现。但是,这种方式的效果有限,后续逐步出现了WebGL(英文全称:Web Graphics Library)接口协议,该接口协议能够对显卡GPU进行直接控制,为HTML5Canvas提供硬件加速渲染,大大提高了2D或3D的显示效率和显示效果。Before the various embodiments of the present application are fully introduced, in order to facilitate understanding, some basic backgrounds are introduced first. With the development of computer technology, people's response speed to computer information processing is getting higher and higher, especially in some real-time application scenarios. For example, common online battle-type real-time online games, these games usually involve the rapid transformation of a large number of target object actions, scenes, characters, ability values, weapons and equipment, etc. In order to better present visual effects, they need to be played on terminal devices. The "hard task" of drawing graphics, the speed of drawing graphics has become a key bottleneck for attracting users of this type of software. The extensive and in-depth development of the HTML5 protocol in network display has put forward higher requirements for the appearance of network Web screens. In the early days, people realized the rich screen display through the standard drawing API provided by canvas. However, the effect of this method is limited, and the WebGL (English: Web) Graphics interface protocol has gradually appeared in the future. This interface protocol can directly control the graphics card GPU and provide hardware accelerated rendering for HTML5Canvas, which greatly improves the 2D or 3D. Display efficiency and display effect.
WebGL接口与HTML5协议类似,在项目应用层上,使用JavaScript语言(以下简称JS语言)开发。在将终端设备的Web引擎端(从服务器上下载的JS项目所在处)将JS项目导入到运行器中运行时,将由运行器中的JS解析器进行解析,然后将解析后的指令按照执行顺序以压栈方式推送给C++引擎框架中执行。如前所述,这种作业模式使JS项目运行效率仍然较低,终端设备的发热量较高,此外,其兼容性也不强,制约了JS项目在不同终端设备上的推广应用。The WebGL interface is similar to the HTML5 protocol. On the project application layer, it is developed using JavaScript language (hereinafter referred to as JS language). When the JS project is imported into the runner when the web engine side of the terminal device (where the JS project downloaded from the server is located) is run, it will be parsed by the JS parser in the runner, and the parsed instructions will be executed according to the execution order Push the stack to the C ++ engine framework for execution. As mentioned earlier, this operation mode makes the JS project run at a low efficiency and high heat generation of terminal equipment. In addition, its compatibility is not strong, which restricts the promotion and application of JS projects on different terminal equipment.
为了解决上述问题,本申请实施例提供一种基于WebGL的图形绘制方法,参见图2,该图示出的实施例方法包括:S201:服务器接收终端设备通 过网络发送的对JS项目中的目标图形进行绘制的绘制请求;S202:服务器解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;S203:服务器通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备执行,以实现目标图形的绘制。为了更好理解该技术方案,在前述背景介绍的基础上,对该方案中的一些重要信息进行说明:In order to solve the foregoing problem, an embodiment of the present application provides a WebGL-based graphic drawing method. Referring to FIG. 2, the embodiment method shown in the figure includes: S201: The server receives a target graphic in a JS project sent by a terminal device through a network. Make a drawing request for drawing; S202: the server parses the drawing request, executes a JS item code corresponding to the drawing request, and forms a WebGL-based graphic drawing rule instruction set; S203: the server sends the graphic drawing rule instruction set through the network Sending it to the terminal device for execution in the form of an instruction stream to achieve drawing of a target graphic. In order to better understand this technical solution, based on the foregoing background introduction, some important information in this solution is explained:
上述技术方案中各步骤涉及的执行主体为“服务器”,而在背景技术部分提到了终端设备以及在终端设备上的运行器,这里做一初步介绍,以体现出这些概念之间的异同。参见图1所示,在一般认识中,运行JS项目是在终端设备本地进行,本地的终端设备包括Web引擎端和运行器两大部分,对于运行器而言,通常又包含三部分:一是JS解析引擎部分,比如,具有该功能的V8、JSC等。从Web引擎端获得的代码尽管包含WebGL接口的一些内容,但仍然是JS代码,需要通过该JS解析引擎解析、识别,转换成运行器其他部分可运行的目标代码;二是C++引擎框架部分,该部分是运行器的“主梁”,经过JS解析引擎解析后的代码,将由该部分来完成大量的实质运算处理工作,由于采用较为底层的C++语言开发,其运行效率较高;三是渲染绘制部分,比如OpenGLES,通过C++代码调用OpenGLES函数完成图形绘制以及绘制结果提交。在本申请实施例中,由于已将一般认识中的“运行器”的部分职能创造性地移交到“服务器”上进行,因而,在本申请的实施例中如果提到“运行器”的概念,需要注意不能简单地将该运行器视为与现有技术相同的运行器,准确地说,本实施例中的运行器是进行改造后的运行器,是和服务器共同作用完成本申请发明目的的新的运行器。当然,对于是否一定称呼其为“运行器”,则是开放性的,实际上,在具备上述能力的情况下,“运行器”之名对其并不构成理解和运用上的限制。The execution subject involved in each step in the above technical solution is a "server", and the terminal device and the runner on the terminal device are mentioned in the background art section, and a preliminary introduction is made here to reflect the similarities and differences between these concepts. As shown in Figure 1, in general, running a JS project is performed locally on the terminal device. The local terminal device includes the Web engine and the runner. The runner usually includes three parts: the first is JS parsing engine part, for example, V8 and JSC with this function. Although the code obtained from the Web engine side contains some content of the WebGL interface, it is still JS code. It needs to be parsed and identified by the JS parsing engine and converted into executable code that can be run by other parts of the runner. The second is the C ++ engine framework part. This part is the "main beam" of the runner. After the code is parsed by the JS parsing engine, this part will complete a large number of substantial operations. Because it is developed using the lower-level C ++ language, its operating efficiency is higher. Third, rendering The drawing part, such as OpenGLES, calls the OpenGLES function through C ++ code to complete the graphics drawing and submit the drawing result. In the embodiment of the present application, since some functions of the "runner" in the general knowledge have been creatively transferred to the "server" for implementation, if the concept of the "runner" is mentioned in the embodiment of the present application, It should be noted that this runner cannot be simply regarded as the same runner as in the prior art. To be precise, the runner in this embodiment is a modified runner and cooperates with the server to complete the purpose of the present invention. New runner. Of course, it is open to whether or not it is called "runner". In fact, with the above-mentioned capabilities, the name of "runner" does not constitute a limitation on understanding and application.
通过将传统运行器进行改造,以得到本申请的技术方案,实际上搭建了 一个全新的平台模式(可以称为服务器模式),在该模式中,终端设备通过网络向服务器发起图形绘制请求,服务器在接收到这个请求后,对其进行解析,确定该请求指明的JS项目或JS项目中的代码段,然后执行这些项目代码,进而形成基于WebGL的图形绘制规则指令集。“基于WebGL”表明了图形绘制规则指令与WebGL之间的关系,即可以是形成的基于WebGL协议的标准指令,也可以是由用户或某个终端根据WebGL协议的标准指令设定的扩展指令。这里提到了绘制请求与JS项目代码的“对应”关系,实际上,由于在本申请实施例的模式下,JS项目是放在服务器侧的,服务器侧可以包含无数多个JS项目,终端设备要运行某个JS项目,那么应当告知服务器该JS项目(整体或局部)的地址,从而服务器能够找到该项目进行执行后续操作。从这个角度,可以将“对应”关系按照不同的阶段和场景来理解:对于初始启动项目阶段,该绘制请求中至少应当包含整体JS项目在服务器上的URL地址,这样,“执行与绘制请求对应的JS项目代码”实际上就是找到该URL地址对应的JS项目代码并执行;对于项目运行阶段,用户在终端设备上可能会在该JS项目对应的应用客户端进行某些操作,然后将这些操作结果信息通过该绘制请求发送到服务器侧,这样,“执行与绘制请求对应的JS项目代码”实际上就是执行能够响应用户操作结果信息的那段JS项目代码。当然,这种划分仅仅是一种理想的状态,实际运行中即便启动项目之后,可能面临“挂机”,可能不需要接收用户操作结果信息仍需要运行的JS项目代码段,因而,上述的两种情形可能是混合型的。总而言之,服务器形成图形绘制规则指令集,是响应绘制请求的结果,而绘制请求中的信息告知或触发了服务器应当如何去形成图形绘制规则指令集。By transforming the traditional runner to obtain the technical solution of the present application, a brand new platform mode (which can be called a server mode) is actually set up. In this mode, the terminal device initiates a graphic drawing request to the server through the network. The server After receiving this request, it parses it, determines the JS project or the code segment in the JS project specified by the request, and then executes these project codes to form a WebGL-based graphic drawing rule instruction set. "WebGL-based" indicates the relationship between graphics drawing rule instructions and WebGL, which can be formed standard instructions based on the WebGL protocol, or extended instructions set by the user or a terminal according to the standard instructions of the WebGL protocol. The "correspondence" relationship between the drawing request and the JS item code is mentioned here. In fact, since the JS item is placed on the server side in the mode of the embodiment of the present application, the server side can contain an unlimited number of JS items. When running a JS project, the server should be informed of the address of the JS project (in whole or in part), so that the server can find the project for subsequent operations. From this perspective, the “correspondence” relationship can be understood according to different stages and scenarios: For the initial startup project phase, the drawing request should at least include the URL address of the overall JS project on the server. In this way, “the execution corresponds to the drawing request "JS project code" is actually to find and execute the JS project code corresponding to the URL address. For the project running phase, the user may perform certain operations on the terminal device's application client corresponding to the JS project, and then perform these operations. The result information is sent to the server through the drawing request. In this way, "executing the JS item code corresponding to the drawing request" is actually executing the piece of JS item code that can respond to user operation result information. Of course, this division is only an ideal state. In actual operation, even after starting the project, you may face "hanging up" and may not need to receive user operation result information and still need to run the JS project code segment. Therefore, the above two The situation may be mixed. In a word, the server forms the graphics drawing rule instruction set in response to the drawing request, and the information in the drawing request informs or triggers how the server should form the graphics drawing rule instruction set.
这里还需要说明的是,以服务器作为主体可以描述本申请的技术方案,反过来,从终端设备的角度同样可以较好地描述本申请的技术方案,即终端设备通过网络向服务器发送对JS项目中的目标图形进行绘制的绘制请求;终端设备接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求 并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;然后,终端设备执行所述指令流,以实现目标图形的绘制。What needs to be explained here is that the server can be used to describe the technical solution of this application. Conversely, the technical solution of this application can also be better described from the perspective of the terminal device, that is, the terminal device sends the JS project to the server through the network. A drawing request for drawing a target graphic in the drawing; a terminal device receives a WebGL-based drawing of a drawing formed by a JS project code corresponding to the drawing request by parsing the drawing request and executing the drawing request sent by the server through a network A rule instruction set; then, the terminal device executes the instruction flow to achieve drawing of a target graphic.
上述技术方案中提及图形绘制之“图形”的用语,在本实施例中,应当朝着符合行业习惯的更为广泛的角度去理解其含义。通常而言,“图形”可能限于一些几何图形,但实际上,在本实施例中不仅可以包含常规图形、图像等,比如,绘制一个图形,可以是在画布上绘制一个三角形、四边性等,而且还可以是对一个已完成的某个图形进行填色、遮盖等操作,比如,对一个已在某个时刻绘制完成的三角形进行填色,这种对三角形填色的过程仍可以独立称为图形绘制。在另一些实施例中,甚至还可以包括对一些非图形进行的处理。比如,在一张画布上布置无数离散的点,虽然其最终可能并不构成某个规范的图形,但该过程仍可称为图形绘制。也就是说,本申请实施例中的图形绘制可能包括一个具体的图形绘制过程,也可能是对已有图形或者非图形进行一定的操作。总而言之,图形绘制过程是对将要显示在画面中目标对象或与显示在画面中的对象关联的目标对象进行某个操作的过程。In the above technical solution, the term "graphics" that is used for drawing graphics is understood in this embodiment from a broader perspective that conforms to industry habits. Generally speaking, "graphics" may be limited to some geometrical figures, but in fact, in this embodiment, not only regular graphics, images, etc. may be included. For example, drawing a graphic may be drawing a triangle, quadrilateral, etc. on the canvas. Moreover, it can also perform operations such as coloring and covering a completed figure. For example, coloring a triangle that has been drawn at a certain time. This process of coloring a triangle can still be independently called Graphic drawing. In other embodiments, it may even include processing for some non-graphics. For example, arranging countless discrete points on a canvas, although it may not eventually constitute a standard figure, this process can still be called graphics drawing. That is to say, the graphic drawing in the embodiment of the present application may include a specific graphic drawing process, or may perform a certain operation on an existing graphic or non-graphic. In a word, the graphic drawing process is a process of performing an operation on a target object to be displayed on a screen or a target object associated with an object displayed on a screen.
上述技术方案中提及“图形绘制规则指令”的用语,这里没有称为“图形绘制指令”,主要原因在于本实施例中可以是由JS项目“制定规则”,而运行器端具体“实现规则(运行规则)”,进而达到JS代码层面少运算,甚至不运算,而将大量的底层运算工作交由运行器来完成,从而最终从运行器运行的角度提高图形绘制的性能。换句话说,图形绘制规则指令可以是不同于常规图形绘制指令的一条特殊“指令”,它至少负责告诉运行器应当“怎么干”,而不是越俎代庖式地自己“亲自上”。具体而言,在一条图形绘制规则指令中,指定了该指令确定的运算规则以及运算涉及的数据,前者在随后实施例中称为操作类型,后者称为操作对象,当运行器获得这些信息后,将按照操作类型的要求,对操作对象进行操作。举例说明如下:The term "graphic drawing rule instruction" mentioned in the above technical solution is not called "graphic drawing instruction" here, the main reason is that in this embodiment, the JS project can "make rules", and the runner side specifically "implements the rules" (Running rules) ", and then achieve less or no calculation at the JS code level, and leave a large amount of low-level calculation work to the runner to complete the graphics drawing performance from the perspective of the runner. In other words, the graphics drawing rule instruction can be a special "instruction" different from the conventional graphics drawing instruction, which is at least responsible for telling the runner "how to do it", rather than "in person" by itself. Specifically, in a graphics drawing rule instruction, the operation rule determined by the instruction and the data involved in the operation are specified. The former is called an operation type in the following embodiments, and the latter is called an operation object. When the runner obtains this information, After that, the operation object will be operated according to the requirements of the operation type. An example is as follows:
setGlobalValue(globalValueID,data,operateType)setGlobalValue (globalValueID, data, operateType)
在该条指令中,参数“operateType”指明本指令将进行的操作类型,比如,可以是数据之间的加、减、赋值等操作,参数“globalValueID”、“data”是操作对象,“globalValueID”是以数据索引的形式指明的操作对象(后续还将详细叙述),“data”则可以是该指令明确指明的操作数据本身。在这条指令中,指明了要按照“operateType”指明的操作类型对“globalValueID”和“data”进行操作,即为一种图形绘制规则指令,而不是函数本身(例如setGlobalValue)即是操作类型。In this instruction, the parameter "operateType" indicates the type of operation to be performed by this instruction. For example, it can be operations such as addition, subtraction, and assignment between data. The parameters "globalValueID" and "data" are the operation objects, and "globalValueID" It is an operation object specified in the form of a data index (which will be described in detail later), and "data" may be the operation data itself explicitly specified by the instruction. In this instruction, it is specified that the "globalValueID" and "data" are to be operated according to the operation type indicated by "operateType", that is, a drawing rule instruction for a graph, not the function itself (for example, setGlobalValue) is the operation type.
尽管上述已对“图形绘制规则指令”做文字和举例解释,但由此就将“图形绘制规则指令”理解成不可能为一条具体的图形绘制指令,则亦为错误。也就是说,某些情况下,图形绘制规则指令可以直接体现为一条具体的图形绘制指令,即在本申请中使用的术语概念中,图形绘制规则指令既包含以指定规则的形式存在的“图形绘制规则指令”,也包含直接为图形绘制指令形式的图形绘制指令,因而需要结合具体的应用场景来考虑。比如,对某个数据区内的数据执行清除操作,该图形绘制规则指令可以直接表现为一条清除指令。由此,在理解“图形绘制规则指令”的概念时,重点不在于该规则指令体现为一条规则指令,还是一条具体指令,而在于体现出制定规则与实施规则相分离的一种可能性。Although the "graphic drawing rule instruction" has been explained in text and examples, it is therefore an error to understand the "graphic drawing rule instruction" as not being a specific graphic drawing instruction. That is, in some cases, the graphic drawing rule instruction can be directly embodied as a specific graphic drawing instruction, that is, in the terminology used in this application, the graphic drawing rule instruction includes both the "graphics" in the form of a specified rule. “Drawing rule instructions” also includes graphics drawing instructions in the form of graphics drawing instructions directly, so it needs to be considered in conjunction with specific application scenarios. For example, when a clear operation is performed on data in a data area, the graphics drawing rule instruction can be directly expressed as a clear instruction. Therefore, when understanding the concept of "graphic drawing rule instructions", the emphasis is not on whether the rule instructions are embodied as a rule instruction or a specific instruction, but on the possibility of separating the formulation of rules from the implementation rules.
还需要说明的是,在本实施例中,基于描述需要,在某些地方可能直接使用“图形绘制规则指令”,而在另一些地方,则使用“图形绘制规则指令及作为其参数的预定操作类型和操作对象”,即该概念有时是指代包含其参数在内的整体,有时是指代不包含其参数、仅具有规则部分的局部,实际应用过程中涉及到该概念理解时,不可不结合上下文进行全面的理解。It should also be noted that, in this embodiment, based on the description needs, the "graphic drawing rule instruction" may be directly used in some places, while in other places, the "graphic drawing rule instruction and predetermined operations as its parameters may be used" "Type and operand", that is, the concept sometimes refers to the whole including its parameters, sometimes it refers to the part that does not include its parameters and only has a regular part. When the concept is understood in actual application, it is necessary to Comprehensive understanding in context.
上述对图形绘制规则指令介绍清楚后,与之关联的是“图形绘制规则指令集”的概念。下面针对该概念,重点叙述如下两个方面:一是图形绘制规 则指令集的内容;二是图形绘制规则指令集的形式。After the graphic drawing rule instructions are introduced clearly above, what is associated with it is the concept of "graphic drawing rule instruction set". Following this concept, the following two aspects are emphasized: one is the content of the instruction set of graphics drawing rules; the other is the form of the instruction set of graphics drawing rules.
就图形绘制规则指令集的内容而言,图形绘制规则指令集是由图形绘制规则指令组成,且通常意味着至少具有两条指令。在后续还会提到,一种实施例中,这些指令可以划分为两种:一种是对寄存器进行操作的指令;一种是不对寄存器进行操作的指令。按照这种以“寄存器”为标准对指令进行的分类,将产生出三种内容的“图形绘制规则指令集”:一是指令集内全部均为对寄存器进行操作的指令;二是指令集内全部均为非对寄存器进行操作的指令;三是指令集内既包含对寄存器进行操作的指令,又包含非对寄存器进行操作的指令。本申请重点针对第一类和第三类,由于这两类指令集中至少包含一条对寄存器进行操作的指令,使得本申请的技术效果得以“游刃有余”的展现(后续将详叙)。As far as the content of the graphics drawing rule instruction set is concerned, the graphics drawing rule instruction set is composed of graphics drawing rule instructions and usually means that there are at least two instructions. As will be mentioned later, in one embodiment, these instructions can be divided into two types: one is an instruction that operates on a register; and one is an instruction that does not operate on a register. According to this classification of instructions using "registers" as a standard, three types of "graphic drawing rule instruction sets" will be generated: one is that all instructions in the instruction set operate on registers; the other is that in the instruction set All are instructions that do not operate on registers; the third is that the instruction set contains both instructions that operate on registers and instructions that do not operate on registers. This application focuses on the first type and the third type. Since the two types of instruction sets contain at least one instruction to operate on a register, the technical effects of this application can be demonstrated "with ease" (more details will be described later).
就图形绘制规则指令集的形式而言,图形绘制规则指令集内可以仅仅是“干巴巴”的各条指令本身,也可以是包含各条指令以及各条指令对应的参数在内的指令。在前者的情况下,可能的一种情形是某些指令本身就没有操作对象或操作类型,仅仅是适应当前执行的需要插入的一条非功能性指令;另外的一种可能是将指令对应的参数(比如操作对象或操作类型)放在指令集之外,但包含发送给终端设备的指令之中。也就是说,基于图形绘制规则指令的不同形态及对图形绘制规则指令参数的不同处置方式,图形绘制规则指令集的存在形式可以是仅仅包含图形绘制指令本身的真正的“指令”集(第一种存在形式),也可以是包含有图形绘制规则指令以及该指令对应的参数的完整型的“指令”集(第二种存在形式)。当然,还可能在一个指令集中,既包含第一种存在形式,也包含第二种存在形式,这取决于预先的设置,只要不妨碍后续运行器依据图形绘制规则指令集实现目标图形的绘制即可。As far as the form of the graphics drawing rule instruction set is concerned, the graphics drawing rule instruction set may be only the “dry” instructions themselves, or may include instructions including the instructions and the parameters corresponding to the instructions. In the former case, a possible situation is that some instructions have no operation object or operation type, and are just a non-functional instruction that is inserted to meet the needs of the current execution; the other may be the parameter corresponding to the instruction (Such as the operation object or operation type) is placed outside the instruction set, but contains instructions sent to the terminal device. That is to say, based on different forms of graphics drawing rule instructions and different treatment methods for the parameters of graphics drawing rule instructions, the existence form of the graphics drawing rule instruction set may be a true "instruction" set that contains only the graphics drawing instruction itself (first This form of existence) may also be a complete type of "instruction" set (the second form of existence) containing a drawing rule instruction and parameters corresponding to the instruction. Of course, it is also possible to include both the first form of existence and the second form of existence in an instruction set, which depends on the preset settings, as long as it does not prevent subsequent runners from drawing target graphics according to the instruction set of graphics drawing rules. can.
在叙述图形绘制规则指令集概念过程中,如前所述,涉及到“寄存器”,这里对寄存器做些介绍。本申请实施例对寄存器进行操作,使得寄存器成为 操作对象,寄存器内存储操作数据,通过对寄存器进行操作实现对寄存器内的数据的操作。寄存器在本申请中是内存中存在的临时存储区域,这里的“临时”是相对于内存本身的存在时长而言的,在一个应用程序(或程序代码段)在运行时,计算设备通常需要开辟内存区域供存储数据和执行指令,应用程序运行完毕后(比如,用户关闭或退出应用程序),该段内存将被释放(又新的应用程序或代码段使用),而在内存被占用的整个期间,其上的数据始终都存在的存储区域,可以称为一种“永久”性存储区域,比如,根据需要设置的全局数据区。本申请的寄存器则表明其上存储的数据随时可能被擦除、被重新,从而不能永久性存在,因而是一种临时存储区域。对于在一个技术方案实施过程中,需要的寄存器数量,可多可少,取决于运行相应的程序代码和实现相应的功能本身的需要而定,预先设定的寄存器数量过多,可能带来浪费,预先设定的寄存器数量过少,则可能“才不尽用”,不能充分发挥本申请机制的最佳技术效果。In describing the concept of the graphics drawing rule instruction set, as mentioned earlier, it involves "registers". Here we introduce the registers. In the embodiment of the present application, a register is operated, so that the register becomes an operation object. Operation data is stored in the register, and operations on the data in the register are implemented by operating the register. Registers in this application are temporary storage areas existing in memory. The "temporary" here is relative to the length of time that the memory itself exists. When an application (or program code segment) is running, a computing device usually needs to be opened. The memory area is used to store data and execute instructions. After the application finishes running (for example, the user closes or exits the application), this section of memory will be released (for new applications or code segments), and the entire area occupied by the memory During this period, the storage area where the data always exists can be called a "permanent" storage area, for example, a global data area set as required. The register in this application indicates that the data stored on it may be erased and re-stored at any time, so that it cannot exist permanently, so it is a temporary storage area. For the implementation of a technical solution, the number of registers required may be more or less, depending on the need to run the corresponding program code and implement the corresponding function itself. Too many preset registers may cause waste. If the preset number of registers is too small, it may be "unused" and the best technical effect of the mechanism of this application cannot be fully exerted.
在上述技术方案中,提及终端设备根据指令流形式的图形绘制规则指令集对目标图形进行绘制。这里需要说明的是,终端设备完成对操作对象的操作并不一定就意味着目标图形绘制完成。实际上,终端设备对操作对象进行操作在大多数情况下,仅能认为是完成其较为核心部分的内容,除此之外,还可能具有一些其他操作,比如,由OpenGLES函数完成与GPU的对接、渲染等(参见图1所示中所示的“OpenGLES函数”部分)。但是,本实施例的重点在于突出终端设备上的新运行器相对于现有技术的核心区别,对其他操作进行简略甚至省略介绍,本领域技术人员在阅读本实施例的该步骤时,不可不细查也。In the above technical solution, it is mentioned that the terminal device draws the target graphics according to the graphics drawing rule instruction set in the form of an instruction stream. It needs to be explained here that the completion of the operation on the operation object by the terminal device does not necessarily mean that the drawing of the target graphic is completed. In fact, in most cases, a terminal device can only perform operations on the operation object to complete its core content. In addition, it may also have some other operations, such as the OpenGLES function to interface with the GPU. , Rendering, etc. (see the "OpenGLES Functions" section shown in Figure 1). However, the focus of this embodiment is to highlight the core differences between the new runner on the terminal device and the existing technology, and to briefly or even omit other operations. Those skilled in the art must read this step of this embodiment without fail. Double check also.
通过上述对技术方案的说明,应能排除对本实施例的理解偏差。本实施例相对于现有技术是一个突破性的发明,其技术效果呈现出如下显著特点:Through the above description of the technical solution, deviations in understanding of the embodiment should be eliminated. Compared with the prior art, this embodiment is a breakthrough invention, and its technical effects show the following significant features:
一是充分利用显卡硬件,实现绘制显示加速。该实施例针对的对象是由 JS代码调用WebGL接口形成的项目,由于WebGL是在OpenGLES基础上开发,可以直接操作GPU指令,从而通过显卡实现硬件加速,可以大大提高图形绘制的效率和显示效果。The first is to make full use of graphics card hardware to achieve drawing and display acceleration. The target object of this embodiment is a project formed by calling the WebGL interface from JS code. Since WebGL is developed based on OpenGLES, GPU instructions can be directly operated, and hardware acceleration can be achieved through a graphics card, which can greatly improve the efficiency of graphics drawing and display effects.
二是贯彻“WebGL+”理念,成功模拟canvas。在运行器的C++引擎框架内运行的项目不再是通过JS语言调用的canvas接口,而是变更为JS语言调用WebGL接口以及WebGLl扩展函数接口,WebGL的底层性与运行器内的C++引擎框架契合,加快了运行效率。The second is to implement the "WebGL +" concept and successfully simulate canvas. The project running in the C ++ engine framework of the runner is no longer a canvas interface called through the JS language, but has been changed to call the WebGL interface and WebGLl extended function interface in the JS language. The underlying nature of WebGL is consistent with the C ++ engine framework in the runner. , Speeding up operation efficiency.
三是可以实现服务器端与终端设备端的“优势互补”,整体性能得以显著提升。一方面,由于接收的绘制请求后,并非由终端设备端直接响应该请求,使得大量运算处理工作由终端设备端转移到服务器上,由此充分利用了服务器的“运算优势”。另一方面,终端设备端不再背负过多计算任务,在上层指明运算规则即可,不会导致大量热量产生,抹平了不同终端设备运行JS项目带来的个体差异,从而增加了终端设备端的灵活性和扩展性,充分发挥了终端设备端面向不同引擎商的“包容优势”。基于服务器、终端设备端“分工明确”,相互“取长补短”,大大提升了基于WebGL的图形绘制性能。Third, the "complementary advantages" of the server and terminal devices can be achieved, and the overall performance can be significantly improved. On the one hand, after receiving the drawing request, the terminal device does not directly respond to the request, so that a large amount of computing processing work is transferred from the terminal device to the server, thereby fully utilizing the "computing advantage" of the server. On the other hand, the terminal device is no longer burdened with too many computing tasks, and the calculation rules can be specified at the upper layer, which will not cause a large amount of heat generation, smoothing the individual differences caused by different terminal devices running JS projects, thereby increasing the terminal device. The flexibility and extensibility of the terminal fully utilizes the "inclusive advantage" of the terminal equipment side for different engine vendors. Based on the “clear division of labor” between the server and the terminal, and “recovering the weaknesses of each other”, it greatly improves the graphics rendering performance based on WebGL.
在上述实施例中,服务器接收来自终端设备通过网络发送的图形绘制请求,在该请求中,如前所述,通常包含终端设备的用户对JS项目对应的应用(客户端)进行操作的操作结果信息。参见图3所示,在终端设备的用户启动应用后,用户对应用会进行操作,该操作形成的操作结果信息将发送到服务器,以便服务器根据绘制请求中的操作结果信息,来形成基于WebGL的图形绘制规则指令集。这里的操作结果信息可以是对重力感应器的操作结果信息、触摸(TOUCH)事件、用户账户信息、用户状态信息等。这里的操作在一些情况下可能是直接的操作,比如,在JS项目对应的应用客户端上点击某个按钮,设置某些参数等,在另一些情况下,也可能是间接的操作,比如,用户对整个终端设备进行摇晃,导致重力感应器捕捉到不同的姿态信 息,这也视为用户操作的结果。In the above embodiment, the server receives the graphic drawing request sent from the terminal device through the network. In the request, as described above, the operation result of the user of the terminal device on the application (client) corresponding to the JS project is usually included. information. As shown in FIG. 3, after the user of the terminal device starts the application, the user operates the application, and the operation result information formed by the operation will be sent to the server, so that the server can form a WebGL based on the operation result information in the drawing request. Graphic drawing rule instruction set. The operation result information here may be operation result information of a gravity sensor, a touch (TOUCH) event, user account information, user status information, and the like. The operation here may be a direct operation in some cases, for example, clicking a button on the application client corresponding to a JS project, setting some parameters, etc. In other cases, it may also be an indirect operation, such as, The user shakes the entire terminal device, which causes the gravity sensor to capture different attitude information, which is also considered as a result of user operations.
在前述实施例中提到终端设备需要通过网络向服务器发送图形绘制请求,同时,服务器在解析绘制请求形成图形绘制规则指令集后需要以指令流的形式通过网络发送给终端设备。由于需要经过网络发送、接收数据,因而通常情况下,数据传输的速度对目标图形的绘制快慢将产生较大的影响。本申请实施例由于将运算过程由终端设备移到服务器来完成,虽然借助了服务器的运算优势,有利于提高图形绘制的效率,但在图形绘制过程中,就用户的体验而言,不仅需要有较强的运算和较快的运算速度,同时还应当有较快的传输速度。为此,在另一些实施例中,对网络的传输速度(即数据发送、接收的时长)可能具有一些要求,比如,要求终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求的时长,小于等于某个预定时长,以及要求服务器通过网络将图形绘制规则指令以指令流形式发送给终端设备的时长,小于等于另一个预定时长。而这两个时长的长短,可以进行配置,进行配置的原则可以根据终端设备对JS项目的运行要求来确定。假如该项目是一个对实时性要求较高的网络游戏,通常其用户对时间(即操作后的反馈速度)有较高的期望,这种情况下,则应当要求网络速度足够快,将预定时长设定得更为短暂。如果该项目的用户对时间不是特别敏感,而更关注画面的清晰度,则可以要求网络速度不是特别的慢即可。当然,随着通信技术的发展,不可否认的是,网络速度越来越快,这种情形下,比如,可以要求终端设备和服务器所处的网络为5G网络,而5G网络的传输速度通常高于传统的2G、3G、4G等网络。当然,在5G网络环境下,由于各种因素的影响,可能并不必然能有较快的速度,但为实施本申请的技术方案,可以要求在本技术方案实施过程中,网络传输速度大于或者保持在5G网络的平均速度上。从本申请技术方案的效果的角度来讲,本申请要求的网络速度越快越好,这样既利用了服务器的强大运算能力,也没有影响到JS项目对用户的 反馈速度,从而大大提高用户体验。In the foregoing embodiment, it was mentioned that the terminal device needs to send a graphic drawing request to the server through the network, and at the same time, the server needs to send the graphic drawing rule instruction set to the terminal device through the network after parsing the drawing request. Because data needs to be sent and received over the network, usually, the speed of data transmission will have a greater impact on the speed of drawing the target graphics. In the embodiment of the present application, because the computing process is moved from the terminal device to the server, although the computing advantage of the server is used to help improve the efficiency of graphics drawing, in the graphics drawing process, in terms of user experience, it is not only necessary to have Stronger calculations and faster calculation speeds should also have faster transmission speeds. For this reason, in other embodiments, there may be some requirements on the transmission speed of the network (that is, the duration of data transmission and reception). For example, a terminal device is required to send a drawing request to draw the target graphics in the JS project through the network. The length of time is less than or equal to a predetermined time, and the time required for the server to send graphics drawing rule instructions to the terminal device in the form of an instruction stream through the network is less than or equal to another predetermined time. The length of these two periods can be configured. The principle of configuration can be determined according to the operation requirements of the JS project by the terminal device. If the project is an online game with high real-time requirements, usually its users have high expectations for time (that is, the feedback speed after operation). In this case, the network speed should be fast enough and the scheduled time will be Set it more briefly. If the users of this project are not particularly sensitive to time, but are more concerned about the clarity of the picture, you can require that the network speed is not particularly slow. Of course, with the development of communication technology, it is undeniable that the network speed is getting faster and faster. In this case, for example, the network where the terminal device and the server are located is required to be a 5G network, and the transmission speed of the 5G network is usually high. For traditional 2G, 3G, 4G and other networks. Of course, in the 5G network environment, due to various factors, it may not necessarily be faster, but in order to implement the technical solution of this application, it may be required that during the implementation of this technical solution, the network transmission speed is greater than or Keep on the average speed of 5G network. From the perspective of the effect of the technical solution of this application, the faster the network speed required by this application is, the better, which not only utilizes the powerful computing power of the server, but also does not affect the feedback speed of the JS project to the user, thereby greatly improving the user experience. .
在本申请的一个实施例中,图形绘制规则指令集至少包含一条对寄存器进行操作的指令。如前所述,这样将会使得图形绘制规则指令集被划分为三大类:一类是全部包含对寄存器进行操作的指令的指令集;一类是不包含对寄存器进行操作的指令集;第三类是混合有上述两种指令的指令集。实际上,通过引入寄存器的概念,至少可以取得如下的技术效果:一是可以支持判断型语句,提高代码重用性。由于图形规则指令集中包含对寄存器操作的指令,该类指令可以支持判断语句,在汇编语言级别上对寄存器进行操作,使得该指令可以直接通过压栈方式(即指令流的形式)推送给运行器的C++框架部分执行,在具体执行时,根据该对寄存器的操作决定是否进行语句的跳转,从而不用针对判断型语句的分支分别进行压栈,大大提高了代码重用性,有利于提高图形绘制的效率。二是可以支持更复杂化的场景应用。现有技术中由于执行代码的固定模式,缺乏灵活性,而在本申请实施例中,由于存在对寄存器进行操作的指令,寄存器作为临时数据存储地,可以存储不同数据计算过程中的中间数据,可以同时利用多个寄存器对多个数据进行操作,因而面对复杂化的应用场景时,灵活性更强,适应能力更突出。这些技术效果从另一方面也增强了终端设备(运行器)的扩展性。In an embodiment of the present application, the graphics drawing rule instruction set includes at least one instruction for operating a register. As mentioned before, this will make the graphics drawing rule instruction set divided into three categories: one is the instruction set that contains instructions that operate on registers; the other is the instruction set that does not include operations on registers; The three types are instruction sets that mix the above two instructions. In fact, by introducing the concept of registers, at least the following technical effects can be achieved: First, it can support judgmental statements and improve code reuse. Because the graphics rule instruction set contains instructions for register operations, this type of instructions can support judgment statements and operate on registers at the assembly language level, so that the instructions can be pushed directly to the runner by pushing the stack (that is, in the form of instruction streams). Partial execution of the C ++ framework. During the specific execution, whether to jump to the statement is determined according to the operation of the register, so that the branch of the judgment statement is not pushed separately, which greatly improves code reuse and is beneficial to improving graphics drawing. s efficiency. The second is to support more complicated scene applications. In the prior art, due to the fixed mode of executing code, there is a lack of flexibility. In the embodiment of the present application, because there are instructions for operating the register, the register serves as a temporary data storage place and can store intermediate data in different data calculation processes. Multiple registers can be used to operate on multiple data at the same time, so when facing complex application scenarios, it has greater flexibility and adaptability. These technical effects also enhance the scalability of the terminal device (runner) from another aspect.
下面在此基础上,从两个大的方向对进一步的优化技术方案进行说明,即当图形绘制规则指令为对寄存器进行操作的指令时的情形,以及当图形绘制规则指令为对寄存器进行操作的指令以外的指令时的情形,如下先从后一个方向进行描述。Based on this, the following describes the further optimization technical solutions from two major directions, that is, when the graphics drawing rule instruction is an instruction to operate on a register, and when the graphics drawing rule instruction is to operate on a register The case of instructions other than instructions will be described from the latter direction first.
在前述实施例中,当图形绘制规则指令为对寄存器进行操作的指令以外的指令时,尽管可以将操作对象直接体现在图形绘制请求之中,但是,这样 将使图形绘制请求“臃肿”,尤其在操作对象体现为“量大而结构复杂”的数据时,更为“不堪其重负”,而且,当需要修改图形绘制规则指令时,又需要重新指定操作对象,给系统增加无谓的开销。为此,可以采取一种图形绘制规则指令与其操作对象分离的机制,即在图形绘制请求中包含操作对象的索引,而将索引对应的数据在运行器中临时或长久开辟的数据存储区中进行存储,这样在改变(增加或调整)图形绘制规则指令时,只要操作对象的索引不发生变化,该指令便可不变化,而仅需要修改数据存储区的数据即可。具体做法是:在图形绘制请求中指定操作对象的索引,运行器根据该操作对象索引从数据区中获取其对应的具体操作数据,然后由运行器根据预定的操作类型对该操作数据进行操作,进而完成图形绘制。举如下实例说明之:In the foregoing embodiment, when the graphics drawing rule instruction is an instruction other than an instruction to operate a register, although the operation object can be directly reflected in the graphics drawing request, this will make the graphics drawing request “bloated”, especially When the operation object is represented by "large volume and complex structure" data, it is even more "overwhelmed", and when the graphics drawing rule instructions need to be modified, the operation object needs to be re-designated, which adds unnecessary overhead to the system. To this end, a mechanism for separating graphics drawing rule instructions from its operating objects can be adopted, that is, the index of the operating object is included in the graphics drawing request, and the data corresponding to the index is performed in the data storage area temporarily or permanently opened in the runner Storage, so that when changing (increasing or adjusting) the graphics drawing rule instruction, as long as the index of the operation object does not change, the instruction does not change, and only the data in the data storage area needs to be modified. The specific method is: specify the index of the operation object in the graphics drawing request, and the runner obtains the corresponding specific operation data from the data area according to the operation object index, and then the operator operates the operation data according to the predetermined operation type. Then complete graphics drawing. Take the following examples to illustrate:
假设图形绘制请求中包含如下内容:Assume that the graphics drawing request contains the following:
SetValueByShareData(offset,operateType)SetValueByShareData (offset, operateType)
该内容中“SetValueByShareData”为图形绘制规则指令,“offset”、“operateType”为图形绘制规则指令的参数,前者指明待操作对象在数据区中的位置,后者指明针对该操作对象要进行何种类型的操作。这种情况下,如果offset=10,operateType为擦除操作,则运行器在运行该规则指令时,先根据offset从数据区中获取偏离值为10位置上对应的数据作为操作对象,然后对该数据执行擦除操作。通过这种数据与指令的分离机制,可以提高操作的便捷性,为进行其他的进一步改进提供了技术保障。In this content, "SetValueByShareData" is a graphic drawing rule instruction, and "offset" and "operateType" are parameters of the graphic drawing rule instruction. The former indicates the position of the object to be operated in the data area, and the latter indicates what to do for the operation object Type of operation. In this case, if offset = 10 and operateType is an erase operation, when the runner runs the rule instruction, it first obtains the data corresponding to the offset value 10 from the data area according to the offset as the operation object, and then Data is erased. Through this mechanism of separation of data and instructions, the convenience of operation can be improved, and technical guarantee is provided for other further improvements.
在前述实现图形绘制规则指令与图形绘制规则指令的操作对象的分离(指令与数据分离)机制情景下,维护数据区内的数据便变得至关重要。根据实际情况和不同的划分标准,数据区可以划分为不同的类型。比如,可以划分为全局数据区和局部数据区,前者用于存储带有全局性的数据或者存储中间结果,后者用于存储带有局部性质的数据。当然,在实际应用过程中,这两个数据区可以在物理上为相邻的存储位置,也可以为隔着“千山万水” 的不同物理存储位置。无论是全局数据区,还是局部数据区,其当中的数据均可在Web引擎端进行配置,比如在初始化时进行定义,然后在接受到图形绘制请求时或者之前,将这些配置好的数据同步到运行器能够访问的数据区中。比如,可以按照如下的方式配置数据区内的全局数据:In the aforementioned scenario of separating the operation objects (instruction and data) of the graphics drawing rule instruction and the graphics drawing rule instruction, maintaining the data in the data area becomes very important. The data area can be divided into different types according to the actual situation and different division criteria. For example, it can be divided into a global data area and a local data area. The former is used to store global data or intermediate results, and the latter is used to store local data. Of course, in the actual application process, these two data areas can be physically adjacent storage locations or different physical storage locations separated by “thousands of mountains and rivers”. Regardless of whether it is a global data area or a local data area, the data in it can be configured on the Web engine side, such as defining it during initialization, and then synchronizing these configured data to or before receiving a graphics drawing request. In the data area that the runner can access. For example, you can configure global data in the data area as follows:
varvalueID=GL.addValueDefine(modifyType,type,size,defaultData)varvalueID = GL.addValueDefine (modifyType, type, size, defaultData)
定义alpha型数据:type=float,size=1,defaultData=[1]Define alpha data: type = float, size = 1, defaultData = [1]
定义matrix型数据:type=float,size=6,defaultData=[1,0,0,1,0,0]Define matrix data: type = float, size = 6, defaultData = [1,0,0,1,0,0]
既然在某些情况下存在全局数据区和局部数据区之别,那么便可能存在只针对全局数据区或局部数据区内数据进行的操作,也可能存在一部分数据来自全局数据区,另一部分数据来自局部数据区,将两者进行某种操作的情况。也就是说,可以仅仅针对同类型的数据区内的数据进行操作,也可以在不同性质的数据区内进行数据操作,比如,图形绘制中涉及到的矩阵计算、顶点计算等情形,在需要对多个数据进行操作时,图形绘制请求中包含的操作对象(操作对象索引)则可能为多个。下面以对全局数据区内的一个数据和局部数据区内的一个数据进行矩阵运算为例进行说明:Since in some cases there is a difference between the global data area and the local data area, there may be operations performed only on the data in the global data area or the local data area, or there may be a part of the data from the global data area and another part of the data from Local data area, a case where the two perform some operation. In other words, you can operate only on the data in the same type of data area, and you can also perform data operations on data areas of different properties, such as matrix calculations and vertex calculations involved in graphics drawing. When multiple data are operated, there may be multiple operation objects (operation object index) included in the graphics drawing request. In the following, matrix calculation is performed on one data in the global data area and one data in the local data area as an example:
图形绘制请求中包含如下内容:The graphics drawing request includes the following:
setValueByShareData(id,offset,operateType)setValueByShareData (id, offset, operateType)
该指令内容的id代表全局数据区的全局索引,假设其值为2,offset代表局部数据区内的局部索引,假设其值为4,如果当前预定的操作类型为矩阵运算,则运行器会首先根据全局数据区的全局索引id指明的位置,从全局数据区id=2的位置获取第一操作数据,根据局部数据区的局部索引offset指明的位置,从局部数据区offset=4的位置获取第二操作数据,然后按照operateType指明的操作类型,对第一操作数据和第二操作数据进行矩阵运算。需要强调的是,这些计算在运行器内完成,而运行器包含C++引擎框架,计算效率比现有技术中在Web引擎端高很多。在实际应用过程中,图形绘制中涉及大量的矩阵运算,通过在运行器内计算而得以大大节约处理资源。The id of the instruction content represents the global index of the global data area, assuming its value is 2, and offset represents the local index of the local data area, assuming its value is 4, if the currently scheduled operation type is matrix operation, the runner will first According to the position indicated by the global index id of the global data area, the first operation data is obtained from the position of the global data area id = 2, and according to the position indicated by the local index offset of the local data area, the first operation data is obtained from the position of the local data area offset = 4. Two operation data, and then perform matrix operations on the first operation data and the second operation data according to the operation type indicated by the operateType. It should be emphasized that these calculations are completed in the runner, and the runner contains the C ++ engine framework, and the calculation efficiency is much higher than that in the prior art on the Web engine side. In the actual application process, a large number of matrix operations are involved in graphic drawing, and processing resources can be greatly saved by calculating in the runner.
实际上,除了矩阵运算外,图形绘制过程中涉及的操作类型还包括常规的加、减、乘、除以及顶点变形等运算类型。比如,对于图形绘制中的大量的顶点数据,可以采取上述运算中的一种来完成运算。举例如下:In fact, in addition to matrix operations, the types of operations involved in the graphics drawing process include conventional addition, subtraction, multiplication, division, and vertex deformation types. For example, for a large amount of vertex data in graphic drawing, one of the above operations can be adopted to complete the operation. Examples are as follows:
modifyMesh(valueID,vdoPosID,operatorType)modifyMesh (valueID, vdoPosID, operatorType)
该指令内容表示使用全局数据区中valueID指明的某个数据修改顶点缓冲数据区中vdoPosID指明的显卡顶点缓冲区内的某个数据,按照operatorType指定操作类型进行计算。The content of this instruction indicates that a certain data specified by valueID in the global data area is used to modify some data in the graphics card vertex buffer specified by vdoPosID in the vertex buffer data area, and calculation is performed according to the operation type specified by operatorType.
假设使用全局数据区中valueID=2对应的数据,去修改顶点缓冲数据区中的vdoPosID=0(顶点的x、y坐标)对应的数据,操作方式是矩阵变形顶点数据。该运算在运行器的C++中的代码中运算,大为提高效率。Assume that the data corresponding to valueID = 2 in the global data area is used to modify the data corresponding to vdoPosID = 0 (the x and y coordinates of the vertices) in the vertex buffer data area. The operation mode is to transform the vertex data in a matrix. This operation is performed in the code in the C ++ of the runner, which greatly improves the efficiency.
下面从图形绘制规则指令为对寄存器进行操作的指令时的情形进行描述优化方案。与前述的道理类似,在图形绘制规则指令的参数中,作为操作对象的寄存器,通常是以寄存器索引的形式存在的,即在对数据进行操作时,图形绘制规则指令通过寄存器索引(比如,regID)指明了对哪个寄存器进行操作,只要寄存器内存储了数据,便可能完成相应的操作。寄存器内的数据来源可以包括如下两种来源:一是在执行图形绘制规则指令时,通过预定的函数将事先预定的数据写入到该寄存器中,使得寄存器内具有了相应的数据,进而可完成相应的数据操作,当然,从时间的角度考虑,也可以是在执行图形绘制规则指令之前即已完成寄存器内的数据写入操作,在指明了操作的寄存器索引号后直接对其操作即可。二是在执行图形绘制规则指令时,在该指令中还指明了操作对象索引,那么可以依据该操作对象索引从数据区中先获取该操作对象索引对应的操作数据,然后将该数据写入到对应的寄存器内。当寄存器内或者采取第一种方式或者采取第二种方式顺利填入操作数据后,运行器便可根据图形绘制规则指令按照预定的操作类型对寄存器内的操作数据进行操作,以完成对目标图像的绘制工作。The optimization scheme is described below from the situation when the graphics drawing rule instruction is an instruction to operate a register. Similar to the foregoing reason, in the parameters of the graphics drawing rule instruction, the register as an operation object usually exists in the form of a register index, that is, when the data is manipulated, the graphics drawing rule instruction passes the register index (for example, regID ) Indicates which register to operate on, as long as the data is stored in the register, the corresponding operation may be completed. The data sources in the register can include the following two sources: First, when the graphics drawing rule instruction is executed, the predetermined data is written into the register through a predetermined function, so that the register has the corresponding data and can be completed. The corresponding data operation, of course, from the perspective of time, the data writing operation in the register can be completed before the graphics drawing rule instruction is executed, and the operation can be performed directly after the index number of the register of the operation is specified. Second, when executing the graphics drawing rule instruction, the operation object index is also specified in the instruction, then the operation data corresponding to the operation object index can be obtained from the data area according to the operation object index, and then the data is written to Corresponding register. When the operation data is successfully filled in the register either in the first or second way, the runner can operate the operation data in the register according to the predetermined operation type according to the graphics drawing rule instructions to complete the target image. Drawing work.
下面以两种具体的预定操作类型为例,说明对寄存器的操作。The following uses two specific types of predetermined operations as examples to describe the operation of the register.
(1)对于预定操作类型为判断型操作的情况。(1) For the case where the predetermined operation type is a judgment operation.
所谓判断型操作即是条件型语句,判断某个条件是否满足,当满足时,执行某个判断分支;当不满足时,执行另一个判断分支,具体可以体现为IF语句、WHILE语句等。比如,为了实现语句跳转,可以通过判断寄存器内的数据是否达到预定条件,如果达到,就跳转到某条图形绘制规则指令(具体实现时,可以是直接指明跳转的目标图形绘制规则指令,从而直接跳转到该指令执行,也可以是仅指明需要跳转的指令条数,跳转后到达的指令即为目标指令),如果未达到,则按照原来顺序执行。如下面的实例,通过判断寄存器内数据的情况,执行语句跳转:The so-called judgment-type operation is a conditional statement, which judges whether a certain condition is satisfied. When it is satisfied, a certain judgment branch is executed; when it is not satisfied, another judgment branch is executed, which can be embodied as an IF statement, a WHILE statement, and the like. For example, in order to achieve a statement jump, you can determine whether the data in the register has reached a predetermined condition, and if it is, jump to a certain graphics drawing rule instruction (in specific implementation, it can directly specify the target graphics drawing rule instruction for the jump To jump directly to the instruction execution, or just specify the number of instructions that need to be jumped, and the instruction that arrives after the jump is the target instruction), if not, it will be executed in the original order. As the following example, by judging the data in the register, execute the statement jump:
loadInt(dataID,offset,reg[0]);//设置值到寄存器第0个上loadInt (dataID, offset, reg [0]); // Set the value to the 0th register
ifE0(regID,skipStatementN);//如果reg值==0,则跳过语句执行ifE0 (regID, skipStatementN); // If the reg value == 0, skip the statement execution
ifNE0(regID,skipStatementN);//如果reg值!=0,则跳过语句执行ifNE0 (regID, skipStatementN); // If the reg value! = 0, skip statement execution
ifGE0(regID,skipStatementN);//如果reg值>=0,则跳过语句执行ifGE0 (regID, skipStatementN); // If reg value> = 0, skip statement execution
ifG0(regID,skipStatementN);//如果reg值>0,则跳过语句执行ifG0 (regID, skipStatementN); // If the reg value is> 0, skip the statement execution
ifL0(regID,skipStatementN);//如果reg值<0,则跳过语句执行ifL0 (regID, skipStatementN); // If the reg value is <0, skip the statement execution
ifLE0(regID,skipStatementN);//如果reg值<=0,则跳过语句执行ifLE0 (regID, skipStatementN); // If the reg value is <= 0, skip the statement execution
循环语句的情形是判断型语句的复杂化,道理相同,此处不再繁复叙述。The situation of the loop sentence is the complication of the judgment sentence, the reason is the same, and it will not be described here again.
(2)对于预定操作是运算型操作的情况。(2) For a case where the predetermined operation is an arithmetic operation.
所谓运算型操作即是对寄存器内的数据进行加、减、乘、除、矩阵等运算操作,具体可以是对一个寄存器内的数据进行操作(比如,乘方、自增、自减等),也可以对多个寄存器内的数据进行操作,还可以对寄存器内数据和操作对象索引指明的存储在数据区内的数据直接进行操作。当对多个寄存器进行操作时,可先将预定的第一数据或者从数据区中获取的第一数据写入所述第一寄存器索引对应的第一寄存器内,将预定的第二数据或者从数据区中获取的第二数据写入所述第二寄存器索引对应的第二寄存器内,或者,在 运行器根据所述图形绘制规则指令以及所述预定操作类型对所述操作对象进行操作之前,将预定的第一数据或者从数据区中获取的第一数据写入所述第一寄存器索引对应的第一寄存器内,将预定的第二数据或者从数据区中获取的第二数据写入所述第二寄存器索引对应的第二寄存器内。然后对第一寄存器和第二寄存器内的操作数据进行运算操作。如下面的实例,先通过函数对寄存器进行数据填充,然后按照预定操作类型对寄存器内的数据进行操作。下面的实例充分演示了上述内容。The so-called arithmetic operations are operations such as addition, subtraction, multiplication, division, and matrix operations on the data in a register. Specifically, operations on data in a register (such as power, increment, decrement, etc.), The data in multiple registers can also be operated, and the data stored in the data area specified by the data in the registers and the operation object index can also be directly operated. When operating on multiple registers, the predetermined first data or the first data obtained from the data area may be written into the first register corresponding to the first register index, and the predetermined second data or from The second data obtained in the data area is written into a second register corresponding to the second register index, or before the runner operates the operation object according to the graphic drawing rule instruction and the predetermined operation type, Write predetermined first data or first data obtained from the data area into the first register corresponding to the first register index, and write predetermined second data or second data obtained from the data area into the first register The second register index corresponds to the second register. Then, an operation is performed on the operation data in the first register and the second register. As shown in the following example, the register is first filled with data by a function, and then the data in the register is operated according to a predetermined operation type. The following example fully demonstrates the above.
function set XXX()function setXXX ()
{{
//第一个参数dataID,offset值,放入寄存器索引对应的寄存器中;// The first parameter dataID, offset value, is placed in the register corresponding to the register index;
loadData(dataID,offset,reg[0]);loadData (dataID, offset, reg [0]);
loadData(dataID,offset,reg[1]);loadData (dataID, offset, reg [1]);
loadData(dataID,offset,reg[2]);loadData (dataID, offset, reg [2]);
loadData(dataID,offset,reg[3]);loadData (dataID, offset, reg [3]);
//对寄存器索引号为0和3的寄存器进行操作,并将操作后的值存储到寄存器索引号为2的寄存器中,type为具体的预定运算操作类型;// Operate the registers with the register index numbers 0 and 3, and store the value of the operation into the register with the register index number 2, and type is the specific predetermined operation operation type;
operate(2,0,3,type);operate (2,0,3, type);
operate(1,0,3,type);operate (1,0,3, type);
}}
在介绍完两个大的方向后,下面对无论图形绘制规则指令是操作寄存器的指令,还是不操作寄存器的指令,都可能共同存在的优化技术方案。After introducing the two major directions, the following is an optimized technical solution that may coexist regardless of whether the graphics drawing rule instruction is an instruction that operates a register or an instruction that does not operate a register.
优化方向之一:用图形绘制规则指令索引作为定位图形绘制规则指令。与前述讨论操作对象类似的道理,在解析图形绘制请求并执行JS项目代码后形成的图形绘制规则指令中,可以包含图形绘制规则指令本身,也可以包含图形绘制规则指令的索引,这样终端设备或者服务器便可以根所述图形绘制规则指令索引,确定与该图形绘制规则指令索引对应的图形绘制规则指令 集,具体而言:One of the optimization directions: use the drawing rule instruction index as the positioning drawing instruction rule. Similar to the previous discussion of operating objects, the graphics drawing rule instructions formed after parsing the graphics drawing request and executing the JS project code may include the graphics drawing rule instruction itself or the index of the graphics drawing rule instruction. In this way, the terminal device or The server may determine the graphics drawing rule instruction set corresponding to the graphics drawing rule instruction index based on the graphics drawing rule instruction index, specifically:
终端设备(运行器)根据图形绘制规则指令索引,从存储设备中查找与图形绘制规则指令索引对应的指令集,所述存储设备中存储有不同的图形绘制规则指令索引以及与不同的图形绘制规则指令索引对应的指令集。需要说明的是,这里的存储设备可以位于服务器上,也可以位于终端设备侧上,如果是位于终端设备侧上,则在终端设备接收到服务器发送的指令流后,解析出指令流后从终端设备的存储设备上根据所述图形绘制规则指令索引查找对应的指令集。The terminal device (runner) finds the instruction set corresponding to the graphic drawing rule instruction index from the storage device according to the graphic drawing rule instruction index. The storage device stores different graphic drawing rule instruction indexes and different graphic drawing rules. The instruction set corresponding to the instruction index. It should be noted that the storage device here can be located on the server or on the terminal device side. If it is on the terminal device side, after the terminal device receives the instruction stream sent by the server, it parses the instruction stream from the terminal. The storage device of the device searches for a corresponding instruction set according to the graphics drawing rule instruction index.
在本申请实施例中,为了便于对不同的目标图形进行绘制,可以按照上述记载的方法确定对不同的目标图形进行绘制的多个规则指令集,并将该多个规则指令集与图形绘制规则指令索引对应存储至存储设备中,这样,在绘制不同的目标图形时,可以从所述存储设备中查找得到与不同的图形绘制规则指令索引对应的指令集。In the embodiment of the present application, in order to facilitate drawing of different target graphics, multiple rule instruction sets for drawing different target graphics may be determined according to the method described above, and the multiple rule instruction sets and graphics drawing rules may be determined. The instruction index is correspondingly stored in a storage device. In this way, when drawing different target graphics, an instruction set corresponding to a different drawing instruction instruction index can be obtained from the storage device.
优化方向之二:在本实施例中,针对一个指令集而言,所述指令集可以对应一个数据区,所述数据区与所述指令集结合可以用于绘制得到一个目标图形;此外,所述指令集也可以对应多个数据区,每一个所述数据区与所述指令集相结合后,可以用于绘制得到不同的目标图形,即多个不同的目标图形可以共同使用一个指令集进行目标图形的绘制,这样,由于多个目标图形可以根据同一个指令集绘制得到,因此,可以有效减少存储的指令集的个数,从而有效减少指令集对存储空间的占用。Second optimization direction: In this embodiment, for an instruction set, the instruction set may correspond to a data area, and the combination of the data area and the instruction set may be used to draw a target graphic; moreover, all The instruction set can also correspond to multiple data areas. After each of the data areas and the instruction set are combined, they can be used to draw different target graphics, that is, multiple different target graphics can be shared using one instruction set. The drawing of the target graphics. In this way, since multiple target graphics can be drawn according to the same instruction set, the number of stored instruction sets can be effectively reduced, thereby effectively reducing the storage space occupied by the instruction sets.
例如,指令集A可以对应数据区1和数据区2,根据指令集A和数据区1中的操作对象数据,可以绘制得到目标图形A1,根据指令集A和数据区2中的操作对象数据,可以绘制得到目标图形A2。由于目标图形A1和A2均可以根据指令集A绘制得到,因此,可以减少指令集的个数,从而减少指令集占用的存储空间。For example, instruction set A may correspond to data area 1 and data area 2. According to the operation object data in instruction set A and data area 1, the target figure A1 may be drawn. According to the operation object data in instruction set A and data area 2, The target figure A2 can be drawn. Because the target graphics A1 and A2 can both be drawn according to the instruction set A, the number of instruction sets can be reduced, thereby reducing the storage space occupied by the instruction set.
上述介绍内容着重从图形绘制方法的角度进行说明,实际上,本申请实施例还提供了相应的装置实施例。图4为本申请的一个实施例图形绘制装置的结构示意图。该主干枝位于服务器侧,包括:请求接收单元41、解析执行单元42以及指令发送单元43,其中:The above description focuses on the description from the perspective of graphics drawing methods. In fact, the embodiments of the present application also provide corresponding device embodiments. FIG. 4 is a schematic structural diagram of a graphic drawing device according to an embodiment of the present application. The trunk is located on the server side and includes: a request receiving unit 41, a parsing execution unit 42, and an instruction sending unit 43, where:
请求接收单元41,用于接收终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求;The request receiving unit 41 is configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
解析执行单元42,用于解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;The parsing execution unit 42 is configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;
指令发送单元43,用于通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备执行,以实现目标图形的绘制。The instruction sending unit 43 is configured to send the graphic drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic.
上述装置能够取得与前述方法实施例同样的技术效果,为避免重复,这里不再赘言。The above device can obtain the same technical effects as the foregoing method embodiments. To avoid repetition, details are not repeated here.
可选地,终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求,包括所述终端设备的用户对JS项目对应的应用进行操作的操作结果信息,则:解析执行单元42,具体用于解析所述绘制请求,执行与所述操作结果信息对应的JS项目代码,形成基于WebGL的图形绘制规则指令集。这里的操作结果信息可以是如下中一种或多种:对重力感应器的操作结果信息;触摸(TOUCH)事件信息;用户账号信息;用户状态信息。Optionally, the drawing request sent by the terminal device for drawing the target graphic in the JS project through the network includes the operation result information of the user of the terminal device operating the application corresponding to the JS project, then: the analysis execution unit 42, Specifically used to parse the drawing request, execute the JS project code corresponding to the operation result information, and form a WebGL-based graphic drawing rule instruction set. The operation result information here may be one or more of the following: operation result information on the gravity sensor; touch (TOUCH) event information; user account information; user status information.
在上述装置实施例中,所述终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求的时长,小于等于第一预定时长;所述服务器通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备的时长,小于等于第二预定时长。这里的第一预定时长或第二预定时长可以相同,也可以不同,需要根据实际情况确定。In the above device embodiment, the terminal device sends a drawing request time for drawing a target graphic in a JS project through a network, which is less than or equal to a first predetermined duration; and the server sends the graphic drawing rule instruction set through the network. The time period sent to the terminal device in the form of an instruction stream is less than or equal to a second predetermined time period. Here, the first predetermined duration or the second predetermined duration may be the same or different, and needs to be determined according to actual conditions.
参见图5,与上述位于服务器侧的装置对应的,本申请实施例还可以在终端设备侧部署另一个装置,该装置包括请求发送单51、指令接收单元52 和指令执行单元53,其中:Referring to FIG. 5, corresponding to the above-mentioned device on the server side, in the embodiment of the present application, another device may be deployed on the terminal device side. The device includes a request sending list 51, an instruction receiving unit 52, and an instruction execution unit 53, where:
请求发送单元51,用于通过网络向服务器发送对JS项目中的目标图形进行绘制的绘制请求;A request sending unit 51, configured to send a drawing request for drawing a target graphic in a JS project to a server through a network;
指令接收单元52,用于接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;An instruction receiving unit 52 is configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
指令执行单元53,用于执行所述指令流,以实现目标图形的绘制。The instruction execution unit 53 is configured to execute the instruction flow to implement drawing of a target graphic.
上述位于服务器侧和终端侧的装置在某些情况下可以实施为一个系统,这样的系统包括服务和终端设备,其中:The above-mentioned devices located on the server side and the terminal side may be implemented as a system in some cases. Such a system includes services and terminal equipment, of which:
服务器包括请求接收单元、解析执行单元和指令发送单元,其中:The server includes a request receiving unit, a parsing execution unit, and an instruction sending unit, where:
请求接收单元,用于接收终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求;A request receiving unit, configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;
解析执行单元,用于解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;A parsing execution unit, configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;
指令发送单元,用于通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备执行,以实现目标图形的绘制;An instruction sending unit, configured to send the graphics drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic;
终端设备包括:请求发送单元、指令接收单元和指令执行单元,其中:The terminal device includes: a request sending unit, an instruction receiving unit, and an instruction execution unit, where:
请求发送单元,用于通过网络向服务器发送对JS项目中的目标图形进行绘制的绘制请求;A request sending unit, configured to send a drawing request for drawing a target graphic in a JS project to a server through a network;
指令接收单元,用于接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;An instruction receiving unit, configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;
指令执行单元,用于执行所述指令流,以实现目标图形的绘制。An instruction execution unit is configured to execute the instruction flow to achieve drawing of a target graphic.
图6为本申请基于WebGL的图形绘制另一个系统实施例的结构示意图,所述系统60中包含存储器61、处理器62及存储在所述存储器61上并可在所述处理器62上运行的计算机程序,所述计算机程序被所述处理器62执行 时实现上述记载的图形绘制方法的步骤。FIG. 6 is a schematic structural diagram of another embodiment of a system based on WebGL drawing in the present application. The system 60 includes a memory 61, a processor 62, and a memory 61 that can be run on the processor 62. A computer program that, when executed by the processor 62, implements the steps of the graphics drawing method described above.
本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现上述记载的图形绘制方法的步骤。An embodiment of the present application further provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the graphics drawing method described above are implemented.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as a method, a system, or a computer program product. Therefore, this application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。This application is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that each process and / or block in the flowcharts and / or block diagrams, and combinations of processes and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, so that the instructions generated by the processor of the computer or other programmable data processing device are used to generate instructions Means for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to work in a specific manner such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device, the instructions The device implements the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of steps can be performed on the computer or other programmable device to produce a computer-implemented process, which can be executed on the computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-persistent memory, random access memory (RAM), and / or non-volatile memory in computer-readable media, such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes permanent and non-persistent, removable and non-removable media. Information storage can be accomplished by any method or technology. Information may be computer-readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), and read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, read-only disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transmitting medium may be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "including", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, product, or device that includes a series of elements includes not only those elements, but also Other elements not explicitly listed, or those that are inherent to such a process, method, product, or device. Without more restrictions, the elements defined by the sentence "including a ..." do not exclude the existence of other identical elements in the process, method, product or equipment including the elements.
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as a method, a system, or a computer program product. Therefore, this application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
以上仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above are only examples of the present application and are not intended to limit the present application. For those skilled in the art, this application may have various modifications and changes. Any modification, equivalent replacement, and improvement made within the spirit and principle of this application shall be included in the scope of claims of this application.
Claims (17)
- 一种基于WebGL的图形绘制方法,其特征在于,包括:A method for drawing graphics based on WebGL, including:服务器接收终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求;The server receives a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;所述服务器解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;The server parses the drawing request, executes a JS project code corresponding to the drawing request, and forms a WebGL-based graphic drawing rule instruction set;所述服务器通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备执行,以实现目标图形的绘制。The server sends the graphic drawing rule instruction set to the terminal device for execution in the form of an instruction stream through a network to implement drawing of a target graphic.
- 根据权利要求1所述的方法,其特征在于,所述终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求,包括所述终端设备的用户对JS项目对应的应用进行操作的操作结果信息,则所述服务器解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集,包括:The method according to claim 1, wherein the drawing request sent by the terminal device for drawing the target graphics in the JS project through the network comprises a user of the terminal device operating the application corresponding to the JS project. The operation result information, the server parses the drawing request, executes the JS project code corresponding to the drawing request, and forms a WebGL-based graphic drawing rule instruction set, including:所述服务器解析所述绘制请求,执行与所述操作结果信息对应的JS项目代码,形成基于WebGL的图形绘制规则指令集。The server parses the drawing request, executes a JS item code corresponding to the operation result information, and forms a WebGL-based graphic drawing rule instruction set.
- 根据权利要求2所述的方法,其特征在于,所述终端设备的用户对JS项目对应的应用进行操作的操作结果信息,包括如下一项或多项信息:The method according to claim 2, wherein the operation result information of the operation of the application corresponding to the JS project by the user of the terminal device includes one or more of the following information:对重力感应器的操作结果信息;Information on the operation results of the gravity sensor;触摸事件信息;Touch event information;用户账号信息;User account information;用户状态信息。User status information.
- 根据权利要求1所述的方法,其特征在于,所述终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求的时长,小于等于第一预定时长;所述服务器通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备的时长,小于等于第二预定时长。The method according to claim 1, wherein the duration of the drawing request for drawing the target graphics in the JS project sent by the terminal device through the network is less than or equal to a first predetermined duration; and the server sends all The duration of sending the graphics drawing rule instruction set to the terminal device in the form of instruction stream is less than or equal to the second predetermined duration.
- 根据权利要求4所述的方法,其特征在于,所述第一预定时长和/或第二预定时长根据所述终端设备的用户对所述图形绘制的时长的要求确定。The method according to claim 4, wherein the first predetermined duration and / or the second predetermined duration are determined according to a requirement of a user of the terminal device for the duration of drawing the graphic.
- 根据权利要求1至5中任何一项所述的方法,其特征在于,所述网络为5G网络,基于所述第一预定时长、第二预定时长确定的网络传输速度,大于等于5G网络的平均速度。The method according to any one of claims 1 to 5, wherein the network is a 5G network, and a network transmission speed determined based on the first predetermined duration and the second predetermined duration is equal to or greater than an average of the 5G network. speed.
- 一种基于WebGL的图形绘制方法,其特征在于,包括:A method for drawing graphics based on WebGL, including:终端设备通过网络向服务器发送对JS项目中的目标图形进行绘制的绘制请求;The terminal device sends a drawing request for drawing the target graphic in the JS project to the server through the network;所述终端设备接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;Receiving, by the terminal device, a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;所述终端设备执行所述指令流,以实现目标图形的绘制。The terminal device executes the instruction flow to achieve drawing of a target graphic.
- 根据权利要求7所述的方法,其特征在于,所述图形绘制规则指令集至少包含一条对寄存器进行操作的指令,所述寄存器为内存中的临时存储区域。The method according to claim 7, wherein the graphics drawing rule instruction set includes at least one instruction for operating a register, and the register is a temporary storage area in a memory.
- 根据权利要求8所述的方法,其特征在于,所述图形绘制规则指令集包括所述图形绘制规则指令,以及作为所述图形绘制规则指令的参数的预定操作类型和操作对象;The method according to claim 8, wherein the graphic drawing rule instruction set includes the graphic drawing rule instruction, and a predetermined operation type and operation object as parameters of the graphic drawing rule instruction;所述终端设备执行所述指令流,以实现目标图形绘制,包括:The execution of the instruction flow by the terminal device to achieve a target graphic drawing includes:所述终端设备根据所述指令流中的指令以及所述预定操作类型对所述操作对象进行操作,以对所述目标图形进行绘制。The terminal device operates the operation object according to an instruction in the instruction stream and the predetermined operation type to draw the target graphic.
- 根据权利要求9所述的方法,其特征在于,当所述图形绘制规则指令为对寄存器进行操作的指令时,The method according to claim 9, wherein when the graphics drawing rule instruction is an instruction to operate a register,所述操作对象包括操作对象索引和寄存器索引,则终端设备根据所述图形绘制规则指令以及所述预定操作类型对所述操作对象进行操作,包括:The operation object includes an operation object index and a register index, and the terminal device operates the operation object according to the graphic drawing rule instruction and the predetermined operation type, including:所述终端设备根据所述操作对象索引从数据区中获取所述操作对象索引对应的操作数据,并写入到所述寄存器索引对应的寄存器内;Obtaining, by the terminal device, operation data corresponding to the operation object index from a data area according to the operation object index, and writing the operation data to a register corresponding to the register index;所述终端设备根据所述图形绘制规则指令按照所述预定操作类型对所述寄存器内的操作数据进行操作;The terminal device operates the operation data in the register according to the predetermined drawing type instruction according to the graphic drawing rule instruction;或者,所述操作对象包括寄存器索引,则所述终端设备根据所述图形绘制规则指令以及所述预定操作类型对所述操作对象进行操作,包括:Alternatively, the operation object includes a register index, and the terminal device operates the operation object according to the graphic drawing rule instruction and the predetermined operation type, including:所述终端设备将预定数据写入所述寄存器索引对应的寄存器内,或者,在所述终端设备根据所述图形绘制规则指令以及所述预定操作类型对所述操作对象进行操作之前,将预定数据写入所述寄存器索引对应的寄存器内;The terminal device writes predetermined data in a register corresponding to the register index, or, before the terminal device operates the operation object according to the graphic drawing rule instruction and the predetermined operation type, Write into a register corresponding to the register index;所述终端设备根据所述图形绘制规则指令按照所述预定操作类型对所述寄存器内的操作数据进行操作。The terminal device operates the operation data in the register according to the graphic drawing rule instruction according to the predetermined operation type.
- 一种基于WebGL的图形绘制装置,所述装置位于服务器侧,其特征在于,包括请求接收单元、解析执行单元和指令发送单元,其中:A WebGL-based graphic drawing device is located on a server side and is characterized by including a request receiving unit, a parsing execution unit, and an instruction sending unit, wherein:请求接收单元,用于接收终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求;A request receiving unit, configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;解析执行单元,用于解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;A parsing execution unit, configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;指令发送单元,用于通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备执行,以实现目标图形的绘制。An instruction sending unit is configured to send the graphics drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic.
- 根据权利要求11所述的装置,其特征在于,所述终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求,包括所述终端设备的用户对JS项目对应的应用进行操作的操作结果信息,则:The device according to claim 11, wherein the drawing request for drawing the target graphics in the JS project sent by the terminal device through the network comprises a user of the terminal device operating the application corresponding to the JS project. Operation result information, then:所述解析执行单元,具体用于解析所述绘制请求,执行与所述操作结果信息对应的JS项目代码,形成基于WebGL的图形绘制规则指令集。The analysis execution unit is specifically configured to parse the drawing request, execute a JS item code corresponding to the operation result information, and form a WebGL-based graphic drawing rule instruction set.
- 根据权利要求11所述的装置,其特征在于,所述终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求的时长,小于等于第一预定时长;所述服务器通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备的时长,小于等于第二预定时长。The apparatus according to claim 11, wherein the duration of the drawing request for drawing the target graphics in the JS project sent by the terminal device through the network is less than or equal to a first predetermined duration; and the server sends all The duration of sending the graphics drawing rule instruction set to the terminal device in the form of instruction stream is less than or equal to the second predetermined duration.
- 一种基于WebGL的图形绘制装置,所述装置位于终端设备侧,其特征在于,包括请求发送单元、指令接收单元和指令执行单元,其中:A device for drawing graphics based on WebGL. The device is located on a terminal device side, and is characterized by including a request sending unit, an instruction receiving unit, and an instruction execution unit, wherein:请求发送单元,用于通过网络向服务器发送对JS项目中的目标图形进行 绘制的绘制请求;A request sending unit, configured to send a drawing request for drawing a target graphic in a JS project to a server through a network;指令接收单元,用于接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;An instruction receiving unit, configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;指令执行单元,用于执行所述指令流,以实现目标图形的绘制。An instruction execution unit is configured to execute the instruction flow to achieve drawing of a target graphic.
- 一种基于WebGL的图形绘制系统,其特征在于,所述系统包括服务器和终端设备,A WebGL-based graphics rendering system, characterized in that the system includes a server and a terminal device,所述服务器包括请求接收单元、解析执行单元和指令发送单元,其中:The server includes a request receiving unit, a parsing execution unit, and an instruction sending unit, where:请求接收单元,用于接收终端设备通过网络发送的对JS项目中的目标图形进行绘制的绘制请求;A request receiving unit, configured to receive a drawing request for drawing a target graphic in a JS project sent by a terminal device through a network;解析执行单元,用于解析所述绘制请求,执行与所述绘制请求对应的JS项目代码,形成基于WebGL的图形绘制规则指令集;A parsing execution unit, configured to parse the drawing request, execute a JS project code corresponding to the drawing request, and form a WebGL-based graphic drawing rule instruction set;指令发送单元,用于通过网络将所述图形绘制规则指令集以指令流形式发送给所述终端设备执行,以实现目标图形的绘制;An instruction sending unit, configured to send the graphics drawing rule instruction set to the terminal device for execution through a network in order to implement drawing of a target graphic;所述终端设备包括:请求发送单元、指令接收单元和指令执行单元,其中:The terminal device includes a request sending unit, an instruction receiving unit, and an instruction execution unit, wherein:请求发送单元,用于通过网络向服务器发送对JS项目中的目标图形进行绘制的绘制请求;A request sending unit, configured to send a drawing request for drawing a target graphic in a JS project to a server through a network;指令接收单元,用于接收所述服务器通过网络以指令流形式发送的、解析所述绘制请求并执行与所述绘制请求对应的JS项目代码形成的、基于WebGL的图形绘制规则指令集;An instruction receiving unit, configured to receive a WebGL-based graphic drawing rule instruction set formed by the server in the form of an instruction stream through a network, which parses the drawing request and executes a JS project code corresponding to the drawing request;指令执行单元,用于执行所述指令流,以实现目标图形的绘制。An instruction execution unit is configured to execute the instruction flow to achieve drawing of a target graphic.
- 一种基于WebGL的图形绘制系统,其特征在于,所述系统包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如权利要求1至10中任一项所述的方法的步骤。A WebGL-based graphics rendering system, characterized in that the system includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is processed by the processor. The implementation of the method implements the steps of the method according to any one of claims 1 to 10.
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至10中任一项所述的方法的步骤。A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented step.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810627271.8 | 2018-06-15 | ||
CN201810627271.8A CN110609677A (en) | 2018-06-15 | 2018-06-15 | WebGL-based graph drawing method, device and system |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019238145A1 true WO2019238145A1 (en) | 2019-12-19 |
Family
ID=68841799
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2019/100605 WO2019238145A1 (en) | 2018-06-15 | 2019-08-14 | Webgl-based graphics rendering method, apparatus and system |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110609677A (en) |
WO (1) | WO2019238145A1 (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111598988A (en) * | 2020-05-19 | 2020-08-28 | 北京海致星图科技有限公司 | D3-based method and system for rendering knowledge graph data nodes |
CN114565697A (en) * | 2020-11-27 | 2022-05-31 | 广州视源电子科技股份有限公司 | Graph drawing method, device, equipment and storage medium based on web drawing board |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111275782B (en) * | 2020-01-17 | 2023-09-08 | 广州图匠数据科技有限公司 | Graph drawing method and device, terminal equipment and storage medium |
CN111552898A (en) * | 2020-03-19 | 2020-08-18 | 中国平安人寿保险股份有限公司 | Flowchart drawing method and device based on Html5, computer equipment and storage medium |
CN111737618A (en) * | 2020-06-24 | 2020-10-02 | 广联达科技股份有限公司 | Vector diagram display method and device for Web end and computer equipment |
CN112416489A (en) * | 2020-11-06 | 2021-02-26 | 万翼科技有限公司 | Engineering drawing display method and related device |
CN112614210B (en) * | 2020-12-23 | 2024-03-19 | 深圳市万翼数字技术有限公司 | Engineering drawing display method, system and related device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102254292A (en) * | 2010-05-20 | 2011-11-23 | 盛乐信息技术(上海)有限公司 | Remote 3D instruction rendering system and method |
CN102799636A (en) * | 2012-06-26 | 2012-11-28 | 北京奇虎科技有限公司 | Method and system for displaying webpage by mobile terminal |
CN103677951A (en) * | 2013-12-11 | 2014-03-26 | 北京掌中经纬技术有限公司 | Method and system for controlling executing process of JavaScript |
US20150347198A1 (en) * | 2014-05-29 | 2015-12-03 | Apple Inc. | Web browser for spoofing supported features |
CN107832108A (en) * | 2016-09-14 | 2018-03-23 | 阿里巴巴集团控股有限公司 | Rendering intent, device and the electronic equipment of 3D canvas web page elements |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8799357B2 (en) * | 2010-11-08 | 2014-08-05 | Sony Corporation | Methods and systems for use in providing a remote user interface |
US10062141B2 (en) * | 2012-10-24 | 2018-08-28 | Nubo Software | Server-based fast remote display on client devices |
JP6265337B2 (en) * | 2014-06-03 | 2018-01-24 | 株式会社スクウェア・エニックス | Program, recording medium, and drawing apparatus determination method |
CN107506517B (en) * | 2017-07-04 | 2022-04-26 | 网易(杭州)网络有限公司 | Building model display method, building model display device, building model data processing method, building model data processing device, building model data processing medium, building model data processing equipment and building model data processing system |
-
2018
- 2018-06-15 CN CN201810627271.8A patent/CN110609677A/en active Pending
-
2019
- 2019-08-14 WO PCT/CN2019/100605 patent/WO2019238145A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102254292A (en) * | 2010-05-20 | 2011-11-23 | 盛乐信息技术(上海)有限公司 | Remote 3D instruction rendering system and method |
CN102799636A (en) * | 2012-06-26 | 2012-11-28 | 北京奇虎科技有限公司 | Method and system for displaying webpage by mobile terminal |
CN103677951A (en) * | 2013-12-11 | 2014-03-26 | 北京掌中经纬技术有限公司 | Method and system for controlling executing process of JavaScript |
US20150347198A1 (en) * | 2014-05-29 | 2015-12-03 | Apple Inc. | Web browser for spoofing supported features |
CN107832108A (en) * | 2016-09-14 | 2018-03-23 | 阿里巴巴集团控股有限公司 | Rendering intent, device and the electronic equipment of 3D canvas web page elements |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111598988A (en) * | 2020-05-19 | 2020-08-28 | 北京海致星图科技有限公司 | D3-based method and system for rendering knowledge graph data nodes |
CN111598988B (en) * | 2020-05-19 | 2022-01-25 | 北京海致星图科技有限公司 | D3-based method and system for rendering knowledge graph data nodes |
CN114565697A (en) * | 2020-11-27 | 2022-05-31 | 广州视源电子科技股份有限公司 | Graph drawing method, device, equipment and storage medium based on web drawing board |
Also Published As
Publication number | Publication date |
---|---|
CN110609677A (en) | 2019-12-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019238145A1 (en) | Webgl-based graphics rendering method, apparatus and system | |
TWI808393B (en) | Page processing method, device, apparatus and storage medium | |
CN111881401B (en) | WebAssemble-based browser deep learning method and system | |
US9069549B2 (en) | Machine processor | |
US9176757B2 (en) | Method, system and an executable piece of code for the virtualization of a hardware resource associated with a computer system | |
TW201812613A (en) | 3d canvas web page element rendering method and apparatus, and electronic device | |
US10719970B2 (en) | Low latency firmware command selection using a directed acyclic graph | |
US20190080017A1 (en) | Method, system, and device that invokes a web engine | |
US11094036B2 (en) | Task execution on a graphics processor using indirect argument buffers | |
US20230403437A1 (en) | Graphics engine and graphics processing method applicable to player | |
US20170329622A1 (en) | Shared virtual data structure of nested hypervisors | |
CN111625290B (en) | Layout file preloading method and device under Android platform and electronic equipment | |
US20130176320A1 (en) | Machine processor | |
CN110443880B (en) | Image rendering method and device, storage medium and electronic equipment | |
US20130103931A1 (en) | Machine processor | |
CN115131470A (en) | Image-text material synthesis method and device, electronic equipment and storage medium | |
US9448823B2 (en) | Provision of a download script | |
US10620980B2 (en) | Techniques for native runtime of hypertext markup language graphics content | |
CN110609682B (en) | Graphics drawing method, device and system based on WebGL | |
Zhang et al. | A webpage offloading framework for smart devices | |
US20240033625A1 (en) | Rendering method and apparatus for virtual scene, electronic device, computer-readable storage medium, and computer program product | |
Kushsairy et al. | Embedded vision: Enhancing embedded platform for face detection system | |
WO2023245369A1 (en) | Application starting method and apparatus, electronic device, and storage medium | |
CN118860842A (en) | Data processing method, device, equipment and readable storage medium | |
CN113271497B (en) | Video playing method, intelligent terminal, storage medium and program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19819462 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 19819462 Country of ref document: EP Kind code of ref document: A1 |