[go: up one dir, main page]

CN103677828B - Coverage drawing method, drawing engine and terminal equipment - Google Patents

Coverage drawing method, drawing engine and terminal equipment Download PDF

Info

Publication number
CN103677828B
CN103677828B CN201310671747.5A CN201310671747A CN103677828B CN 103677828 B CN103677828 B CN 103677828B CN 201310671747 A CN201310671747 A CN 201310671747A CN 103677828 B CN103677828 B CN 103677828B
Authority
CN
China
Prior art keywords
pel
summit
information
post
layer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201310671747.5A
Other languages
Chinese (zh)
Other versions
CN103677828A (en
Inventor
姜霄棠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201310671747.5A priority Critical patent/CN103677828B/en
Publication of CN103677828A publication Critical patent/CN103677828A/en
Application granted granted Critical
Publication of CN103677828B publication Critical patent/CN103677828B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Generation (AREA)
  • Image Processing (AREA)

Abstract

本发明实施例涉及计算机技术。本发明实施例提供一种图层绘制方法、绘图引擎及终端设备,该方法包括:接收绘图指令;接收后处理信息,根据所述后处理信息确定预处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理;基于所述绘图指令中的顶点变换信息对所述绘图指令中包含的图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;然后再进行光栅化和片断着色以得到待绘制的图层。该方案是对顶点变换后得到的顶点变换中间结果再次进行坐标变换处理,从而降低了对图层做特效处理的代价。

Embodiments of the present invention relate to computer technology. An embodiment of the present invention provides a layer drawing method, a drawing engine, and a terminal device. The method includes: receiving a drawing instruction; receiving post-processing information, and determining pre-processing information according to the post-processing information, and the post-processing information is used to represent Perform coordinate transformation processing on the layer to be drawn; perform coordinate transformation processing on the vertices of the primitive corresponding to the primitive information contained in the drawing instruction based on the vertex transformation information in the drawing instruction, and obtain the vertex transformation of the primitive Intermediate results; based on the preprocessing information, coordinate transformation processing is performed on the intermediate results of the vertex transformation of the primitives again to obtain the final results of the vertex transformations of the primitives; then rasterization and fragment coloring are performed to obtain the graph to be drawn layer. This solution is to perform coordinate transformation processing on the intermediate result of vertex transformation obtained after vertex transformation, thereby reducing the cost of special effect processing on the layer.

Description

一种图层绘制方法、绘图引擎及终端设备Layer drawing method, drawing engine and terminal equipment

技术领域technical field

本发明涉及计算机技术,尤其涉及一种图层绘制方法、绘图引擎及终端设备。The invention relates to computer technology, in particular to a layer drawing method, a drawing engine and a terminal device.

背景技术Background technique

当前Android系统的应用主要采用OpenGL绘图,OpenGL(Open Graphic Library)是一个开放性图形硬件标准,它提供了一系列应用程序接口(API,ApplicationProgramming Interface)供开发者使用。在OpenGL的硬件标准下对待绘制的图层做涉及坐标变换的处理时,需要首先绘制完成该图层,然后对该图层做所述涉及坐标变换的处理,比如旋转处理和/或缩放处理等,由于绘制完成的图层包含大量的像素点,所以在对该图层做涉及坐标变换的处理时需要处理的数据量比较大,付出的图像特效处理代价比较大。The current application of the Android system mainly uses OpenGL drawing. OpenGL (Open Graphic Library) is an open graphics hardware standard, which provides a series of application programming interfaces (API, Application Programming Interface) for developers to use. Under the OpenGL hardware standard, when processing the layer to be drawn that involves coordinate transformation, it is necessary to first draw the layer, and then perform the processing that involves coordinate transformation on the layer, such as rotation processing and/or scaling processing, etc. , since the drawn layer contains a large number of pixels, the amount of data to be processed is relatively large when processing the layer involving coordinate transformation, and the cost of image special effect processing is relatively large.

发明内容Contents of the invention

本发明实施例提供一种图层绘制方法、绘图引擎及终端设备,用于减少涉及坐标变换的图像特效的处理代价。Embodiments of the present invention provide a layer drawing method, a drawing engine and a terminal device, which are used to reduce the processing cost of image special effects involving coordinate transformation.

第一方面,本发明实施例提供一种图层绘制方法,该方法包括:接收绘图指令,所述绘图指令中包含图元信息、顶点变换信息以及片断着色信息;接收后处理信息,根据所述后处理信息确定预处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理;基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果;基于所述绘图指令中的片断着色信息对所述图元的光栅化处理结果进行片断着色处理,得到所述图元的片断着色处理结果;根据所述图元的片断着色处理结果在所述待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层。In the first aspect, an embodiment of the present invention provides a layer drawing method, the method includes: receiving a drawing instruction, the drawing instruction includes primitive information, vertex transformation information, and fragment coloring information; receiving post-processing information, according to the The post-processing information determines the pre-processing information, and the post-processing information is used to represent the coordinate transformation processing of the layer to be drawn; based on the vertex transformation information in the drawing instruction, the coordinates of the vertices of the primitive corresponding to the primitive information are transformation processing, to obtain the intermediate result of the vertex transformation of the primitive; based on the preprocessing information, perform coordinate transformation processing again on the intermediate result of the vertex transformation of the primitive, to obtain the final result of the vertex transformation of the primitive; Perform rasterization processing on the final vertex transformation result of the primitive to obtain the rasterization processing result of the primitive; perform fragment shading processing on the rasterization processing result of the primitive based on the fragment shading information in the drawing instruction to obtain the rasterization processing result of the primitive The fragment shading processing result of the primitive; performing pixel filling within the display range of the layer to be drawn according to the fragment shading processing result of the primitive to obtain the layer to be drawn.

结合第一方面,在第一种实现方式下,所述接收后处理信息,根据所述后处理信息确定预处理信息,包括:接收后处理信息,所述后处理信息包括旋转参数;根据所述后处理信息中包括的旋转参数确定旋转矩阵,所述旋转矩阵表示所述预处理信息;所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,包括:基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标,所述第二顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转的效果。With reference to the first aspect, in a first implementation manner, the receiving post-processing information and determining pre-processing information according to the post-processing information include: receiving post-processing information, the post-processing information including rotation parameters; according to the The rotation parameters included in the post-processing information determine a rotation matrix, and the rotation matrix represents the pre-processing information; based on the pre-processing information, the intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again to obtain the The final result of the vertex transformation of the primitive includes: performing coordinate transformation again on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive based on the rotation matrix, and obtaining the first vertex coordinate representing the final result of the vertex transformation of the primitive. Two vertex coordinates, the primitive represented by the second vertex coordinate has a rotation effect relative to the primitive represented by the first vertex coordinate.

结合第一方面,在第二种实现方式下,所述接收后处理信息,根据所述后处理信息确定预处理信息,包括:接收后处理信息,所述后处理信息包括缩放参数;根据所述后处理信息中包括的缩放参数确定缩放矩阵,所述缩放矩阵表示所述预处理信息;所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,包括:基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标,所述第三顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有缩放的效果。With reference to the first aspect, in a second implementation manner, the receiving post-processing information and determining pre-processing information according to the post-processing information include: receiving post-processing information, the post-processing information includes scaling parameters; according to the The scaling parameters included in the post-processing information determine a scaling matrix, and the scaling matrix represents the pre-processing information; based on the pre-processing information, the intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again to obtain the The final result of the vertex transformation of the primitive includes: performing coordinate transformation processing on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive based on the scaling matrix, and obtaining the first vertex coordinate representing the final result of the vertex transformation of the primitive. Three vertex coordinates, the primitive represented by the third vertex coordinate has a zoom effect relative to the primitive represented by the first vertex coordinate.

结合第一方面,在第三种实现方式下,所述接收后处理信息,根据所述后处理信息确定预处理信息,包括:接收后处理信息,所述后处理信息包括旋转参数和缩放参数;根据所述后处理信息中包括的旋转参数确定旋转矩阵;根据所述后处理信息中包括的缩放参数确定缩放矩阵;将所述旋转矩阵和所述缩放矩阵相乘得到预处理矩阵,所述预处理矩阵表示所述预处理信息;所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,包括:基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标,所述第四顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转和缩放的效果。With reference to the first aspect, in a third implementation manner, the receiving post-processing information and determining pre-processing information according to the post-processing information include: receiving post-processing information, the post-processing information including rotation parameters and scaling parameters; Determine a rotation matrix according to the rotation parameters included in the post-processing information; determine a scaling matrix according to the scaling parameters included in the post-processing information; multiply the rotation matrix and the scaling matrix to obtain a pre-processing matrix, the pre-processing matrix The processing matrix represents the preprocessing information; the coordinate transformation process is performed on the intermediate result of the vertex transformation of the primitive based on the preprocessing information to obtain the final result of the vertex transformation of the primitive, including: based on the preprocessing information The processing matrix performs coordinate transformation processing on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive, and obtains the fourth vertex coordinate representing the final result of the vertex transformation of the primitive, and the graph represented by the fourth vertex coordinate The element has the effect of rotation and scaling relative to the primitive represented by the first vertex coordinates.

结合第一方面的第一种实现方式,在第四种实现方式下,在所述接收后处理信息,所述后处理信息包括旋转参数之后,所述方法还包括:在所述旋转参数表示的旋转角度是90或者270度时,基于所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;在所述基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标之后,还包括:根据调整后的宽属性和高属性,对表示所述图元的顶点变换终极结果的第二顶点坐标进行裁剪,得到裁剪后的第二顶点坐标;所述对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果,包括:对所述裁剪后的第二顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the first implementation manner of the first aspect, in the fourth implementation manner, after receiving the post-processing information, the post-processing information includes a rotation parameter, the method further includes: When the rotation angle is 90 or 270 degrees, the width attribute parameter and the height attribute parameter of the layer to be drawn are adjusted based on the rotation parameter, so that the adjusted width attribute and height attribute are consistent with the layer to be drawn The display range of the primitive is matched; the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again based on the rotation matrix, and the second coordinate transformation representing the final result of the vertex transformation of the primitive is obtained. After the vertex coordinates, it also includes: according to the adjusted width attribute and height attribute, clipping the second vertex coordinates representing the final result of the vertex transformation of the primitive to obtain the clipped second vertex coordinates; Performing rasterization processing on the final vertex transformation result of the primitive to obtain the rasterization processing result of the primitive, including: performing rasterization processing on the clipped second vertex coordinates to obtain the rasterization processing result of the primitive. .

结合第一方面的第二种实现方式,在第五种实现方式下,在所述接收后处理信息,所述后处理信息包括缩放参数之后,所述方法还包括:基于所述缩放参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;在所述基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标之后,还包括:根据调整后的宽属性和高属性,对表示所述图元的顶点变换终极结果的第三顶点坐标进行裁剪,得到裁剪后的第三顶点坐标;所述对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果,包括:对所述裁剪后的第三顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the second implementation manner of the first aspect, in a fifth implementation manner, after receiving the post-processing information, the post-processing information includes scaling parameters, the method further includes: Adjust the width attribute parameter and height attribute parameter of the layer to be drawn, so that the adjusted width attribute and height attribute match the display range of the layer to be drawn; in the representation based on the scaling matrix The first vertex coordinate of the intermediate result of the vertex transformation of the graphics primitive is subjected to coordinate transformation processing again, and after obtaining the third vertex coordinate representing the final result of the vertex transformation of the primitive, it also includes: according to the adjusted width attribute and height attribute , clipping the coordinates of the third vertex representing the final result of the vertex transformation of the primitive to obtain the coordinates of the third vertex after clipping; performing rasterization processing on the final result of the transformation of the vertex of the primitive to obtain the graph The rasterization processing result of the primitive includes: performing rasterization processing on the clipped third vertex coordinates to obtain the rasterization processing result of the primitive.

结合第一方面的第三种实现方式,在第六种实现方式下,在所述接收后处理信息,所述后处理信息包括旋转参数和缩放参数之后,所述方法还包括:基于所述缩放参数和所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;在所述基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标之后,还包括:根据调整后的宽属性和高属性,对表示所述图元的顶点变换终极结果的第四顶点坐标进行裁剪,得到裁剪后的第四顶点坐标;所述对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果,包括:对所述裁剪后的第四顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the third implementation manner of the first aspect, in the sixth implementation manner, after receiving the post-processing information, the post-processing information includes a rotation parameter and a scaling parameter, the method further includes: based on the scaling parameter and the rotation parameter adjust the width attribute parameter and the height attribute parameter of the layer to be drawn, so that the adjusted width attribute and height attribute match the display range of the layer to be drawn; After performing coordinate transformation processing on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive based on the preprocessing matrix, and obtaining the fourth vertex coordinate representing the final result of the vertex transformation of the primitive, it also includes: According to the adjusted width attribute and height attribute, the fourth vertex coordinate representing the final result of the vertex transformation of the primitive is clipped to obtain the clipped fourth vertex coordinate; the final result of the vertex transformation of the primitive is obtained. Performing rasterization processing to obtain a rasterization processing result of the primitive includes: performing rasterization processing on the clipped fourth vertex coordinates to obtain a rasterization processing result of the primitive.

第二方面,本发明实施例提供一种绘图引擎,该绘图引擎包括:接收单元,用于接收绘图指令,所述绘图指令中包含图元信息、顶点变换信息以及片断着色信息;以及还用于接收后处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理;预处理接口单元,用于根据所述后处理信息确定预处理信息;顶点着色器,用于基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;以及还用于基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;光栅化器,用于对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果;片断着色器,用于基于所述绘图指令中的片断着色信息对所述图元的光栅化处理结果进行片断着色处理,得到所述图元的片断着色处理结果;图层获得单元,用于根据所述图元的片断着色处理结果在所述待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层。In a second aspect, an embodiment of the present invention provides a drawing engine, which includes: a receiving unit configured to receive a drawing instruction, the drawing instruction including primitive information, vertex transformation information, and fragment shading information; Receiving post-processing information, the post-processing information is used to indicate that the layer to be drawn is subjected to coordinate transformation processing; a pre-processing interface unit is used to determine pre-processing information according to the post-processing information; a vertex shader is used to determine the pre-processing information based on the The vertex transformation information in the drawing instruction performs coordinate transformation processing on the vertex of the primitive corresponding to the primitive information to obtain the intermediate result of the vertex transformation of the primitive; and is also used to transform the primitive based on the preprocessing information The intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again to obtain the final result of the vertex transformation of the primitive; the rasterizer is used to perform rasterization processing on the final result of the vertex transformation of the primitive to obtain the raster of the primitive the result of the rendering process; the fragment shader, which is used to perform fragment coloring processing on the rasterization processing result of the graphics element based on the fragment coloring information in the drawing instruction, and obtain the fragment coloring processing result of the graphics element; the layer obtaining unit , for performing pixel filling within the display range of the layer to be drawn according to the fragment shading processing result of the primitive to obtain the layer to be drawn.

结合第二方面,在第一种实现方式下,在所述接收后处理信息的操作上,所述接收单元具体用于接收包括旋转参数的后处理信息;所述预处理接口单元具体用于根据所述后处理信息中包括的旋转参数确定旋转矩阵,所述旋转矩阵表示所述预处理信息;在所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果的操作上,所述顶点着色器具体用于基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标,其中所述第二顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转的效果。With reference to the second aspect, in the first implementation manner, in the operation of receiving post-processing information, the receiving unit is specifically configured to receive post-processing information including rotation parameters; the pre-processing interface unit is specifically configured to The rotation parameter included in the post-processing information determines a rotation matrix, and the rotation matrix represents the pre-processing information; performing coordinate transformation processing on the intermediate result of the vertex transformation of the primitive based on the pre-processing information again, In the operation of obtaining the final result of the vertex transformation of the primitive, the vertex shader is specifically configured to perform coordinate transformation on the coordinates of the first vertex representing the intermediate result of the vertex transformation of the primitive based on the rotation matrix, to obtain Represents the second vertex coordinates of the ultimate result of the vertex transformation of the primitive, wherein the primitive represented by the second vertex coordinate has a rotation effect relative to the primitive represented by the first vertex coordinate.

结合第二方面,在第二种实现方式下,所述接收单元具体用于接收包括缩放参数的后处理信息;所述预处理接口单元具体用于根据所述后处理信息中包括的缩放参数确定缩放矩阵,所述缩放矩阵表示所述预处理信息;在所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果的操作上,所述顶点着色器具体用于基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标,所述第三顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有缩放的效果。With reference to the second aspect, in a second implementation manner, the receiving unit is specifically configured to receive post-processing information including scaling parameters; the pre-processing interface unit is specifically configured to determine according to the scaling parameters included in the post-processing information A scaling matrix, wherein the scaling matrix represents the preprocessing information; performing coordinate transformation processing again on the intermediate result of the vertex transformation of the primitive based on the preprocessing information to obtain the final result of the vertex transformation of the primitive In operation, the vertex shader is specifically configured to perform coordinate transformation processing again on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive based on the scaling matrix, to obtain the final result representing the vertex transformation of the primitive The third vertex coordinates, the primitive represented by the third vertex coordinates has a scaling effect relative to the primitive represented by the first vertex coordinates.

结合第二方面,在第三种实现方式下,所述接收单元具体用于接收包括旋转参数和缩放参数的后处理信息;所述预处理接口单元具体用于根据所述后处理信息中包括的旋转参数确定旋转矩阵,根据所述后处理信息中包括的缩放参数确定缩放矩阵,将所述旋转矩阵和所述缩放矩阵相乘得到预处理矩阵,所述预处理矩阵表示所述预处理信息;在所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果的操作上,所述顶点着色器具体用于基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标,所述第四顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转和缩放的效果。With reference to the second aspect, in a third implementation manner, the receiving unit is specifically configured to receive post-processing information including rotation parameters and scaling parameters; the pre-processing interface unit is specifically configured to The rotation parameter determines a rotation matrix, determines a scaling matrix according to a scaling parameter included in the post-processing information, and multiplies the rotation matrix and the scaling matrix to obtain a pre-processing matrix, where the pre-processing matrix represents the pre-processing information; In the operation of performing coordinate transformation again on the intermediate result of the vertex transformation of the primitive based on the preprocessing information to obtain the final result of the vertex transformation of the primitive, the vertex shader is specifically configured to The preprocessing matrix performs coordinate transformation processing on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive to obtain the fourth vertex coordinate representing the final result of the vertex transformation of the primitive, and the fourth vertex coordinate represents The primitive has the effect of rotation and scaling relative to the primitive represented by the first vertex coordinates.

结合第二方面的第一种实现方式,在第四种实现方式下,所述预处理接口单元还用于在所述旋转参数表示的旋转角度是90或者270度时,基于所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;所述顶点着色器还用于根据调整后的宽属性和高属性,对表示所述图元的顶点变换终极结果的第二顶点坐标进行裁剪,得到裁剪后的第二顶点坐标;所述光栅化器具体用于对所述裁剪后的第二顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the first implementation of the second aspect, in the fourth implementation, the preprocessing interface unit is further configured to, when the rotation angle represented by the rotation parameter is 90 or 270 degrees, based on the rotation parameter The width attribute parameter and the height attribute parameter of the layer to be drawn are adjusted so that the adjusted width attribute and height attribute match the display range of the layer to be drawn; the vertex shader is also used to The adjusted width and height attributes are used to clip the second vertex coordinates representing the final result of the vertex transformation of the primitive to obtain the clipped second vertex coordinates; the rasterizer is specifically used to clip the clipped Rasterization processing is performed on the second vertex coordinates of the primitive to obtain the rasterization processing result of the primitive.

结合第二方面的第二种实现方式,在第五种实现方式下,所述预处理接口单元还用于基于所述缩放参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;所述顶点着色器还用于根据调整后的宽属性和高属性,对表示所述图元的顶点变换终极结果的第三顶点坐标进行裁剪,得到裁剪后的第三顶点坐标;所述光栅化器具体用于对所述裁剪后的第三顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the second implementation of the second aspect, in the fifth implementation, the preprocessing interface unit is further configured to perform a wide attribute parameter and a high attribute parameter of the layer to be drawn based on the scaling parameter Adjust, so that the adjusted width attribute and height attribute match the display range of the layer to be drawn; the vertex shader is also used to represent the primitive according to the adjusted width attribute and height attribute The coordinates of the third vertex of the final result of vertex transformation are clipped to obtain the coordinates of the third vertex after clipping; the rasterizer is specifically used to perform rasterization processing on the coordinates of the third vertex after clipping to obtain the coordinates of the primitive Rasterize the result.

结合第二方面的第三种实现方式,在第六种实现方式下,所述预处理接口单元还用于基于所述缩放参数和所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;所述顶点着色器还用于根据调整后的宽属性和高属性,对表示所述顶点变换终极结果的第四顶点坐标进行裁剪,得到裁剪后的第四顶点坐标;所述光栅化器具体用于对所述裁剪后的第四顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the third implementation manner of the second aspect, in the sixth implementation manner, the preprocessing interface unit is further configured to adjust the width attribute parameter of the layer to be drawn based on the scaling parameter and the rotation parameter and high attribute parameters are adjusted so that the adjusted width and height attributes match the display range of the layer to be drawn; the vertex shader is also used to represent The fourth vertex coordinates of the final result of the vertex transformation are clipped to obtain the clipped fourth vertex coordinates; the rasterizer is specifically used to rasterize the clipped fourth vertex coordinates to obtain the image The result of the rasterization process for the element.

第三方面,本发明实施例提供一种显示方法,该方法包括:接收绘图指令,所述绘图指令中包含图元信息、顶点变换信息以及片断着色信息;接收后处理信息,根据所述后处理信息确定预处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理;基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果;基于所述绘图指令中的片断着色信息对所述图元的光栅化处理结果进行片断着色处理,得到所述图元的片断着色处理结果;根据所述图元的片断着色处理结果在所述待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层;将所述待绘制的图层输出显示。In a third aspect, an embodiment of the present invention provides a display method, the method comprising: receiving a drawing instruction, the drawing instruction including primitive information, vertex transformation information, and fragment shading information; receiving post-processing information, according to the post-processing The information determines the preprocessing information, and the postprocessing information is used to indicate that the layer to be drawn is subjected to coordinate transformation processing; based on the vertex transformation information in the drawing instruction, the coordinate transformation processing is performed on the vertex of the primitive corresponding to the primitive information , to obtain the intermediate result of the vertex transformation of the primitive; based on the preprocessing information, perform coordinate transformation processing on the intermediate result of the vertex transformation of the primitive to obtain the final result of the vertex transformation of the primitive; Perform rasterization processing on the final result of the vertex transformation to obtain the rasterization processing result of the primitive; perform fragment coloring processing on the rasterization processing result of the primitive based on the fragment shading information in the drawing instruction to obtain the graph The fragment shading processing result of the primitive; according to the fragment shading processing result of the graphics primitive, perform pixel filling within the display range of the layer to be drawn to obtain the layer to be drawn; output the layer to be drawn show.

结合第三方面,在第一种实现方式下,当所述待绘制的图层的数目是两个以上时,所述将所述待绘制的图层输出显示,包括:对两个以上的所述待绘制的图层进行合成处理生成目标图像并将所述目标图像输出显示。With reference to the third aspect, in the first implementation manner, when the number of the layers to be drawn is more than two, the outputting and displaying the layers to be drawn includes: The layers to be drawn are synthesized to generate a target image, and the target image is output for display.

结合第三方面或者第三方面的第一种实现方式,在第二种实现方式下,所述接收后处理信息,根据所述后处理信息确定预处理信息,包括:接收后处理信息,所述后处理信息包括旋转参数;根据所述后处理信息中包括的旋转参数确定旋转矩阵,所述旋转矩阵表示所述预处理信息;所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,包括:基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标,所述第二顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转的效果。With reference to the third aspect or the first implementation manner of the third aspect, in the second implementation manner, the receiving post-processing information and determining the pre-processing information according to the post-processing information include: receiving the post-processing information, the The post-processing information includes rotation parameters; a rotation matrix is determined according to the rotation parameters included in the post-processing information, and the rotation matrix represents the pre-processing information; the vertex transformation of the primitive based on the pre-processing information is intermediate As a result, coordinate transformation processing is performed again to obtain the final result of the vertex transformation of the primitive, including: performing coordinate transformation processing again on the coordinates of the first vertex representing the intermediate result of the vertex transformation of the primitive based on the rotation matrix, and obtaining the final result representing the vertex transformation of the primitive. The second vertex coordinates of the final result of the vertex transformation of the primitive, the primitive represented by the second vertex coordinate has a rotation effect relative to the primitive represented by the first vertex coordinate.

结合第三方面或者第三方面的第一种实现方式,在第三种实现方式下,所述接收后处理信息,根据所述后处理信息确定预处理信息,包括:接收后处理信息,所述后处理信息包括缩放参数;根据所述后处理信息中包括的缩放参数确定缩放矩阵,所述缩放矩阵表示所述预处理信息;所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,包括:基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标,所述第三顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有缩放的效果。With reference to the third aspect or the first implementation manner of the third aspect, in the third implementation manner, the receiving post-processing information and determining the pre-processing information according to the post-processing information include: receiving the post-processing information, the The post-processing information includes scaling parameters; a scaling matrix is determined according to the scaling parameters included in the post-processing information, and the scaling matrix represents the pre-processing information; the vertex transformation of the primitive based on the pre-processing information is intermediate As a result, coordinate transformation processing is performed again to obtain the final result of the vertex transformation of the primitive, including: performing coordinate transformation processing again on the coordinates of the first vertex representing the intermediate result of the vertex transformation of the primitive based on the scaling matrix, and obtaining the final result representing the vertex transformation of the primitive. The coordinates of the third vertex of the final result of the vertex transformation of the primitive, and the primitive represented by the coordinate of the third vertex has a scaling effect relative to the primitive represented by the coordinate of the first vertex.

结合第三方面或者第三方面的第一种实现方式,在第四种实现方式下,所述接收后处理信息,根据所述后处理信息确定预处理信息,包括:接收后处理信息,所述后处理信息包括旋转参数和缩放参数;With reference to the third aspect or the first implementation manner of the third aspect, in a fourth implementation manner, the receiving post-processing information and determining the pre-processing information according to the post-processing information include: receiving the post-processing information, the Post-processing information includes rotation parameters and scaling parameters;

根据所述后处理信息中包括的旋转参数确定旋转矩阵;根据所述后处理信息中包括的缩放参数确定缩放矩阵;将所述旋转矩阵和所述缩放矩阵相乘得到预处理矩阵,所述预处理矩阵表示所述预处理信息;所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,包括:基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标,所述第四顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转和缩放的效果。Determine a rotation matrix according to the rotation parameters included in the post-processing information; determine a scaling matrix according to the scaling parameters included in the post-processing information; multiply the rotation matrix and the scaling matrix to obtain a pre-processing matrix, the pre-processing matrix The processing matrix represents the preprocessing information; the coordinate transformation process is performed on the intermediate result of the vertex transformation of the primitive based on the preprocessing information to obtain the final result of the vertex transformation of the primitive, including: based on the preprocessing information The processing matrix performs coordinate transformation processing on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive, and obtains the fourth vertex coordinate representing the final result of the vertex transformation of the primitive, and the graph represented by the fourth vertex coordinate The element has the effect of rotation and scaling relative to the primitive represented by the first vertex coordinates.

结合第三方面的第二种实现方式,在第五种实现方式下,在所述接收后处理信息,所述后处理信息包括旋转参数之后,所述方法还包括:在所述旋转参数表示的旋转角度是90或者270度时,基于所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;在所述基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标之后,还包括:根据调整后的宽属性和高属性,对表示所述图元的顶点变换终极结果的第二顶点坐标进行裁剪,得到裁剪后的第二顶点坐标;所述对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果,包括:对所述裁剪后的第二顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the second implementation manner of the third aspect, in the fifth implementation manner, after receiving the post-processing information, the post-processing information includes a rotation parameter, the method further includes: When the rotation angle is 90 or 270 degrees, the width attribute parameter and the height attribute parameter of the layer to be drawn are adjusted based on the rotation parameter, so that the adjusted width attribute and height attribute are consistent with the layer to be drawn The display range of the primitive is matched; the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again based on the rotation matrix, and the second coordinate transformation representing the final result of the vertex transformation of the primitive is obtained. After the vertex coordinates, it also includes: according to the adjusted width attribute and height attribute, clipping the second vertex coordinates representing the final result of the vertex transformation of the primitive to obtain the clipped second vertex coordinates; Performing rasterization processing on the final vertex transformation result of the primitive to obtain the rasterization processing result of the primitive, including: performing rasterization processing on the clipped second vertex coordinates to obtain the rasterization processing result of the primitive. .

结合第三方面的第三种实现方式,在第六种实现方式下,在所述接收后处理信息,所述后处理信息包括缩放参数之后,所述方法还包括:基于所述缩放参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;在所述基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标之后,还包括:根据调整后的宽属性和高属性,对表示所述图元的顶点变换终极结果的第三顶点坐标进行裁剪,得到裁剪后的第三顶点坐标;所述对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果,包括:对所述裁剪后的第三顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the third implementation manner of the third aspect, in the sixth implementation manner, after receiving the post-processing information, where the post-processing information includes scaling parameters, the method further includes: Adjust the width attribute parameter and height attribute parameter of the layer to be drawn, so that the adjusted width attribute and height attribute match the display range of the layer to be drawn; in the representation based on the scaling matrix The first vertex coordinate of the intermediate result of the vertex transformation of the graphics primitive is subjected to coordinate transformation processing again, and after obtaining the third vertex coordinate representing the final result of the vertex transformation of the primitive, it also includes: according to the adjusted width attribute and height attribute , clipping the coordinates of the third vertex representing the final result of the vertex transformation of the primitive to obtain the coordinates of the third vertex after clipping; performing rasterization processing on the final result of the transformation of the vertex of the primitive to obtain the graph The rasterization processing result of the primitive includes: performing rasterization processing on the clipped third vertex coordinates to obtain the rasterization processing result of the primitive.

结合第三方面的第四种实现方式,在第七种实现方式下,在所述接收后处理信息,所述后处理信息包括旋转参数和缩放参数之后,所述方法还包括:基于所述缩放参数和所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配;在所述基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标之后,还包括:根据调整后的宽属性和高属性,对表示所述图元的顶点变换终极结果的第四顶点坐标进行裁剪,得到裁剪后的第四顶点坐标;所述对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果,包括:对所述裁剪后的第四顶点坐标进行光栅化处理,得到所述图元的光栅化处理结果。With reference to the fourth implementation manner of the third aspect, in the seventh implementation manner, after receiving the post-processing information, the post-processing information includes a rotation parameter and a scaling parameter, the method further includes: based on the scaling parameter and the rotation parameter adjust the width attribute parameter and the height attribute parameter of the layer to be drawn, so that the adjusted width attribute and height attribute match the display range of the layer to be drawn; After performing coordinate transformation processing on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive based on the preprocessing matrix, and obtaining the fourth vertex coordinate representing the final result of the vertex transformation of the primitive, it also includes: According to the adjusted width attribute and height attribute, the fourth vertex coordinate representing the final result of the vertex transformation of the primitive is clipped to obtain the clipped fourth vertex coordinate; the final result of the vertex transformation of the primitive is obtained. Performing rasterization processing to obtain a rasterization processing result of the primitive includes: performing rasterization processing on the clipped fourth vertex coordinates to obtain a rasterization processing result of the primitive.

第四方面,本发明实施例还提供一种终端设备,该终端设备包括显示控制器、显示屏幕组件以及如第三方面或者第三方面的第一种实现方式至第三方面的第七种实现方式中任一种实现方式所述的绘图引擎,其中:所述显示控制器用于将所述绘图引擎得到的所述待绘制的图层输出显示到所述显示屏幕组件上。In a fourth aspect, an embodiment of the present invention further provides a terminal device, which includes a display controller, a display screen component, and the third aspect or the first implementation manner of the third aspect to the seventh implementation manner of the third aspect In any one of the manners, the drawing engine described in the manner is implemented, wherein: the display controller is configured to display the output of the layer to be drawn obtained by the drawing engine on the display screen component.

结合第四方面,在第一种实现方式下,当所述待绘制的图层的数目是两个以上时,所述显示控制器具体用于将所述绘图引擎得到的两个以上的所述待绘制的图层进行合成生成目标图像并将所述目标图像输出显示到所述显示屏幕组件上。With reference to the fourth aspect, in the first implementation manner, when the number of layers to be drawn is more than two, the display controller is specifically configured to use the two or more layers obtained by the drawing engine The layers to be drawn are synthesized to generate a target image, and the target image is output and displayed on the display screen component.

结合第四方面,在第二种实现方式下,该终端设备还包括合成器,其中:当所述待绘制的图层的数目是两个以上时,所述合成器用于将所述绘图引擎得到的两个以上的所述待绘制的图层进行合成生成目标图像;所述显示控制器具体用于将所述目标图像输出显示到所述显示屏幕组件上。With reference to the fourth aspect, in the second implementation manner, the terminal device further includes a synthesizer, wherein: when the number of layers to be drawn is more than two, the synthesizer is used to obtain the drawing engine The two or more layers to be drawn are synthesized to generate a target image; the display controller is specifically configured to output and display the target image on the display screen component.

可知,本发明实施例提供的图层绘制方法、绘图引擎及终端设备,在接收绘图指令后,首先按照现有技术中的顶点变换处理方法,依据所述绘图指令中包含的顶点变换信息对所述绘图指令中包含的图元信息对应的图元的顶点进行坐标变换处理,并得到所述图元的顶点变换中间结果;然后基于根据接收的后处理信息确定的预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;然后再对所述图元的顶点变换终极结果进行光栅化处理以及片段着色处理,最终得到待绘制的图层。采用本发明实施例所述的技术方案,是在顶点变换之后,基于预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理的,由于顶点变换之后得到的所述图元的顶点变换中间结果包含的数据量比较少,所以对其再次进行坐标变换时处理的代价比较小。It can be seen that the layer drawing method, the drawing engine and the terminal device provided by the embodiment of the present invention, after receiving the drawing instruction, first follow the vertex transformation processing method in the prior art, according to the vertex transformation information included in the drawing instruction Perform coordinate transformation processing on the vertices of the primitives corresponding to the primitive information contained in the drawing instruction, and obtain the intermediate results of the vertex transformation of the primitives; then perform the coordinate transformation on the primitives based on the preprocessing information determined according to the received postprocessing information The intermediate result of the vertex transformation is processed again to obtain the final result of the vertex transformation of the primitive; then the final result of the vertex transformation of the primitive is rasterized and fragment shading processed, and finally the layer to be drawn is obtained . According to the technical solution described in the embodiment of the present invention, after the vertex transformation, the intermediate result of the vertex transformation of the primitive is processed again based on the preprocessing information. Since the vertex of the primitive obtained after the vertex transformation The amount of data contained in the transformation intermediate result is relatively small, so the processing cost of performing coordinate transformation on it again is relatively small.

附图说明Description of drawings

为了更清楚地说明本发明实施例的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some of the present invention. Embodiments, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.

图1a是基于OpenGL硬件标准的图层渲染管线图;Figure 1a is a layer rendering pipeline diagram based on the OpenGL hardware standard;

图1b是现有技术中基于OpenGL硬件标准的图层绘制流程图;Fig. 1b is a flow chart of layer drawing based on the OpenGL hardware standard in the prior art;

图1c是本发明实施例提供的图层绘制流程图;Fig. 1c is a flow chart of layer drawing provided by an embodiment of the present invention;

图2是现有终端设备的逻辑结构示意图Figure 2 is a schematic diagram of the logical structure of existing terminal equipment

图3a是本发明实施例提供的一种图层绘制方法的方法流程示意图;Fig. 3a is a schematic flow chart of a layer drawing method provided by an embodiment of the present invention;

图3b是本发明实施例提供的另一种图层绘制方法的方法流程示意图;Fig. 3b is a schematic flow chart of another layer drawing method provided by an embodiment of the present invention;

图4是本发明实施例提供的一种绘图引擎的结构示意图;Fig. 4 is a schematic structural diagram of a drawing engine provided by an embodiment of the present invention;

图5是本发明实施例提供的一种显示方法的方法流程示意图;Fig. 5 is a schematic flow chart of a display method provided by an embodiment of the present invention;

图6a是本发明实施例提供的一种终端设备的结构框图;Fig. 6a is a structural block diagram of a terminal device provided by an embodiment of the present invention;

图6b是本发明实施例提供的一种终端设备的结构框图;Fig. 6b is a structural block diagram of a terminal device provided by an embodiment of the present invention;

图7是本发明实施例提供的另一种终端设备的结构示意图。Fig. 7 is a schematic structural diagram of another terminal device provided by an embodiment of the present invention.

具体实施方式detailed description

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

实施例一Embodiment one

如图1a所示,为基于OpenGL硬件标准下的图层渲染管线图,参阅该附图可知在OpenGL硬件标准下绘制图层至少需要经历顶点变换、光栅化以及片断着色三个过程,具体的,首先由顶点着色器基于顶点数据进行顶点变换,并将得到的几何顶点组合成图元;然后对这些图元进行光栅化处理生成一系列的插值纹理坐标和顶点坐标;再然后利用片断着色器渲染所述纹理坐标和顶点坐标对应位置的像素点,将组成待绘制的图层的所有像素点在所述待绘制的图层的显示范围内进行填充就得到所述待绘制的图层。As shown in Figure 1a, it is a layer rendering pipeline diagram based on the OpenGL hardware standard. Referring to the accompanying drawing, it can be seen that drawing a layer under the OpenGL hardware standard requires at least three processes of vertex transformation, rasterization, and fragment coloring. Specifically, First, the vertex shader performs vertex transformation based on the vertex data, and combines the obtained geometric vertices into primitives; then rasterizes these primitives to generate a series of interpolated texture coordinates and vertex coordinates; then renders with the fragment shader The pixel points corresponding to the texture coordinates and the vertex coordinates are filled with all the pixel points constituting the layer to be drawn within the display range of the layer to be drawn to obtain the layer to be drawn.

附图1b是现有技术中基于OpenGL硬件标准的图层绘制流程图,基于该附图可知如果需要对图层做旋转处理,现有技术采用的方案是在绘制完成所述待绘制的图层之后,再基于旋转需求对该图层做相应的旋转处理以得到经旋转的图层。Accompanying drawing 1b is the layer drawing flow chart based on OpenGL hardware standard in the prior art, based on this drawing, if need to do rotation processing to the layer, the solution adopted in the prior art is to draw described layer to be drawn Afterwards, the layer is rotated accordingly based on the rotation requirement to obtain a rotated layer.

附图1c是本发明实施例提供的图层绘制流程图,参阅该附图可知在本发明实施例提供的图层绘制方法中如果需要对图层做旋转处理,该旋转是在顶点变换之后光栅化之前进行的,所述顶点变换即是附图1a所示的图层渲染管线图中顶点着色器基于顶点数据进行的顶点变换。具体的,采用本发明实施例提供的方法绘制图层且需要对该图层进行旋转处理的,首先进行OpenGL硬件标准中所述的顶点变换,得到图1c所示的顶点变换中间结果,然后再基于旋转需求对再次进行坐标变换处理得到顶点变换终极结果,然后再按照OpenGL硬件标准下的光栅化和片断着色流程对顶点变换终极结果进行光栅化处理和片断着色处理以得到经旋转的图层。Accompanying drawing 1c is the layer drawing flow chart provided by the embodiment of the present invention, referring to this figure, it can be seen that in the layer drawing method provided by the embodiment of the present invention, if the layer needs to be rotated, the rotation is done after the vertex transformation. The vertex transformation is the vertex transformation performed by the vertex shader based on the vertex data in the layer rendering pipeline diagram shown in Figure 1a. Specifically, if the method provided by the embodiment of the present invention is used to draw a layer and the layer needs to be rotated, the vertex transformation described in the OpenGL hardware standard is first performed to obtain the intermediate result of the vertex transformation shown in Figure 1c, and then Based on the rotation requirements, the coordinate transformation process is performed again to obtain the final result of the vertex transformation, and then the final result of the vertex transformation is rasterized and fragment shaded according to the rasterization and fragment shading process under the OpenGL hardware standard to obtain the rotated layer.

附图1b和附图1c以需要对图层旋转为例说明了本发明与现有技术的区别,现有技术中基于旋转需求的旋转操作是在图层绘制完成后针对所述待绘制的图层进行的,本发明中基于旋转需求的旋转操作是在顶点变换完成后光栅化开始前进行的,绘制完成的图层包含了大量的像素点,对所述待绘制的图层进行旋转处理需要处理的数据量比较大;顶点变换之后得到的只是少量的顶点,对所述顶点进行坐标变换处理需要处理的数据量比较少,所以付出的处理代价比较小。Figure 1b and Figure 1c illustrate the difference between the present invention and the prior art by taking the need to rotate the layer as an example. In the prior art, the rotation operation based on the rotation requirement is for the image to be drawn after the drawing of the layer is completed. The rotation operation based on the rotation requirement in the present invention is carried out after the vertex transformation is completed and before the rasterization starts. The drawn layer contains a large number of pixels, and the rotation process of the layer to be drawn requires The amount of data to be processed is relatively large; only a small number of vertices are obtained after the vertex transformation, and the amount of data to be processed for the coordinate transformation of the vertices is relatively small, so the processing cost paid is relatively small.

实施例二Embodiment two

参阅附图3a,为本发明实施例提供的一种图层绘制方法的方法流程图,该图层绘制方法可以应用于计算机系统中,该计算机系统可以位于一台物理主机上,也可以分布位于多台物理主机上。具体的,该计算机系统可以位于一台或多台计算机、便携式电脑、手持设备(例如手机,PAD等)、服务器等类型的终端上。Referring to accompanying drawing 3a, it is a method flowchart of a layer drawing method provided by an embodiment of the present invention, the layer drawing method can be applied to a computer system, and the computer system can be located on a physical host or can be distributed in on multiple physical hosts. Specifically, the computer system may be located on one or more computers, portable computers, handheld devices (such as mobile phones, PADs, etc.), servers and other types of terminals.

以图2为例介绍本发明实施例提供的图层绘制方法应用的计算节点的逻辑结构。该计算节点可以是终端设备,该终端设备具体可以为一智能手机。如图2所示,该终端设备的硬件层包括CPU、GPU等,当然还可以包括存储器、输入/输出设备、内存、内存控制器、网络接口等,输入设备可包括键盘、鼠标、触摸屏等,输出设备可包括显示设备如LCD、CRT、全息成像(Holographic)、投影(Projector)等。在硬件层之上是驱动层,包括中央处理器驱动、图像处理器驱动、显示控制器驱动等。驱动层上面是核心库层,核心库是操作系统的核心部分,包括输入/输出服务、核心服务、图形设备接口以及实现CPU、GPU图形处理的图形服务(Graphics Engine)等。图形服务可包括2D引擎、3D引擎、合成器(Composition)、帧缓冲区(Frame Buffer)、OpenGL等。除此之外,该终端还包括框架层和应用层。框架层可包括图形服务(Graphic Service)、系统服务(System service)、网页服务(Web Service)和用户服务(Customer Service)等;图形服务中,可包括如微件(Widget)、画布(Canvas)、视图(Views)、Render Script等。应用层可包括桌面(launcher)、媒体播放器(Media Player)、浏览器(Browser)等。Taking FIG. 2 as an example, the logical structure of the computing nodes applied in the layer drawing method provided by the embodiment of the present invention is introduced. The computing node may be a terminal device, and specifically, the terminal device may be a smart phone. As shown in Figure 2, the hardware layer of the terminal device includes CPU, GPU, etc., and of course may also include memory, input/output device, memory, memory controller, network interface, etc., and the input device may include keyboard, mouse, touch screen, etc. The output device may include a display device such as LCD, CRT, holographic imaging (Holographic), projection (Projector), and the like. Above the hardware layer is the driver layer, including CPU drivers, image processor drivers, display controller drivers, etc. Above the driver layer is the core library layer. The core library is the core part of the operating system, including input/output services, core services, graphics device interfaces, and graphics services (Graphics Engine) for CPU and GPU graphics processing. The graphics service may include a 2D engine, a 3D engine, a compositor (Composition), a frame buffer (Frame Buffer), OpenGL, and the like. In addition, the terminal also includes a framework layer and an application layer. The framework layer can include Graphic Service, System Service, Web Service and Customer Service, etc.; in Graphic Service, it can include such as Widget, Canvas , Views, Render Script, etc. The application layer may include desktop (launcher), media player (Media Player), browser (Browser), etc.

如图3a所示,本发明实施例提供的图形处理方法包括:As shown in Figure 3a, the graphics processing method provided by the embodiment of the present invention includes:

S301、接收绘图指令,所述绘图指令中包含图元信息、顶点变换信息以及片断着色信息;S301. Receive a drawing instruction, where the drawing instruction includes primitive information, vertex transformation information, and fragment shading information;

具体的,应用程序将绘图指令传递给框架层(Framework)的显示系统控制中心(Surface Flinger),Surface Flinger依据该绘图指令向系统申请绘制图层的画布,其中该画布的大小依据所述绘图指令包含的待绘制图层的宽高参数确定;系统基于SurfaceFlinger的申请调用图层内存分配单元(Gralloc)为其分配用于绘制图层的画布;同时该Surface Flinger将其获取所述绘图指令传递给核心库层的渲染驱动(RenderingDriver),用于使Rendering Driver驱使绘图引擎基于所述绘图指令绘制图层。需要说明的是,这里所述的绘图引擎是指基于图形处理器GPU的绘图引擎,包括2D绘图引擎、3D绘图引擎等。Specifically, the application program transmits the drawing instruction to the display system control center (Surface Flinger) of the framework layer (Framework), and Surface Flinger applies to the system for drawing the canvas of the layer according to the drawing instruction, wherein the size of the canvas is based on the drawing instruction The width and height parameters of the layer to be drawn are determined; the system calls the layer memory allocation unit (Gralloc) based on SurfaceFlinger's application to allocate a canvas for drawing the layer; at the same time, the Surface Flinger passes the drawing command to The rendering driver (RenderingDriver) of the core library layer is used to make the Rendering Driver drive the drawing engine to draw the layer based on the drawing instruction. It should be noted that the drawing engine mentioned here refers to a drawing engine based on a graphics processing unit GPU, including a 2D drawing engine, a 3D drawing engine, and the like.

值得注意的是,所述绘图指令中包含了图元信息、顶点变换信息以及片段着色信息。其中,图元是图形软件用于操作和组织画面的最基本的素材,一幅画面由图元组成,图元是一组最简单的、最通用的集合图形或者字符,比如点、线段、三角形、多边形等。It should be noted that the drawing instruction includes primitive information, vertex transformation information and fragment shading information. Among them, primitives are the most basic materials used by graphics software to operate and organize pictures. A picture is composed of primitives, which are a group of the simplest and most common collection of graphics or characters, such as points, line segments, and triangles. , polygons, etc.

需要说明的是,所述绘图指令可以是用户通过触摸屏触摸、键盘输入、鼠标点击等方式输入的,本发明实施例对此并不作限定。It should be noted that the drawing instruction may be input by the user through touch screen touch, keyboard input, mouse click, etc., which is not limited in this embodiment of the present invention.

S302、接收后处理信息,根据所述后处理信息确定预处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理;S302. Receive post-processing information, and determine pre-processing information according to the post-processing information, where the post-processing information is used to indicate that coordinate transformation processing is performed on the layer to be drawn;

所述后处理信息用于表示对待绘制的图层做坐标变换处理,所述后处理信息包括旋转参数、缩放参数或者两者的结合,所述后处理信息还可以包括显示布局(Source Crop)以及图层范围(Display Frame)等,其中,Source Crop表示采集Buffer哪部分区域去进行合成,Display Frame表示这个Buffer要被合成到屏幕上的哪个区域上,当然,所述后处理信息中可以用于表示对待绘制的图层做其他坐标变换处理,此处不做限制性规定。The post-processing information is used to represent the coordinate transformation processing of the layer to be drawn. The post-processing information includes rotation parameters, scaling parameters or a combination of both. The post-processing information may also include display layout (Source Crop) and Layer range (Display Frame), etc., where Source Crop indicates which part of the Buffer is collected for synthesis, and Display Frame indicates which area on the screen the Buffer is to be synthesized. Of course, the post-processing information can be used for Indicates that other coordinate transformations should be performed on the layer to be drawn, and there are no restrictive regulations here.

所述预处理信息用于表示对图元的顶点变换中间结果再次进行坐标变换的矩阵,所述预处理信息包括旋转矩阵、缩放矩阵或者两者的结合,所述预处理信息还可以包括其他用于对图元的顶点变换中间结果再次进行坐标变换的矩阵,此处不做限制性规定。The preprocessing information is used to represent the coordinate transformation matrix for the intermediate result of the vertex transformation of the primitive. The preprocessing information includes a rotation matrix, a scaling matrix or a combination of the two. The preprocessing information may also include other It is the matrix that performs coordinate transformation again on the intermediate result of the vertex transformation of the primitive, and there are no restrictive regulations here.

值得注意的是,所述后处理信息是指现有技术中基于OpenGL硬件标准的图层渲染模式下表示对绘制完成的图层进行处理的信息,所述后处理信息包括对绘制完成的图层进行旋转和/或缩放以及其他涉及进行坐标变换处理的信息,此处不再一一列举。It is worth noting that the post-processing information refers to the information indicating that the drawn layer is processed in the layer rendering mode based on the OpenGL hardware standard in the prior art, and the post-processing information includes processing the drawn layer Rotation and/or scaling and other information related to coordinate transformation processing will not be listed here.

具体的,所述根据所述后处理信息确定预处理信息包括但不限于以下情形:在后处理信息中包含的旋转参数(Transform Hint)不为0时,确定对应于所述旋转参数的旋转矩阵,所述预处理信息即是该旋转矩阵;在后处理信息中包含缩放参数不为0时,确定对应于所述缩放参数的缩放矩阵,所述预处理信息即是该缩放矩阵,需要说明的是,所述缩放参数包括水平缩放参数和垂直缩放参数;在后处理信息中包含的旋转参数不为0且其包含缩放参数也不为0时,根据所述旋转参数确定出对应的旋转矩阵,根据所述缩放参数确定出对应的缩放矩阵,然后再将所述旋转矩阵乘以所述缩放矩阵即得到预处理矩阵,则所述预处理信息即是该预处理矩阵,同样,所述缩放参数包括水平缩放参数和垂直缩放参数。值得注意的是,根据所述后处理信息得到的也有可能是顶点变换指令集或者其他形式的预处理信息,不限于上述的矩阵形式。Specifically, the determining the pre-processing information according to the post-processing information includes but is not limited to the following situation: when the rotation parameter (Transform Hint) contained in the post-processing information is not 0, determine the rotation matrix corresponding to the rotation parameter , the pre-processing information is the rotation matrix; when the post-processing information contains a scaling parameter that is not 0, determine the scaling matrix corresponding to the scaling parameter, the pre-processing information is the scaling matrix, what needs to be explained Yes, the scaling parameter includes a horizontal scaling parameter and a vertical scaling parameter; when the rotation parameter included in the post-processing information is not 0 and the scaling parameter included is also not 0, the corresponding rotation matrix is determined according to the rotation parameter, Determine the corresponding scaling matrix according to the scaling parameters, and then multiply the rotation matrix by the scaling matrix to obtain a preprocessing matrix, then the preprocessing information is the preprocessing matrix, similarly, the scaling parameters Including horizontal scaling parameters and vertical scaling parameters. It should be noted that the information obtained according to the post-processing information may also be a vertex transformation instruction set or other forms of pre-processing information, and is not limited to the above-mentioned matrix form.

需要说明的是,所述接收后处理信息并根据所述后处理信息确定预处理信息是由Surface Flinger在接收绘图指令后通过检测绘图环境获取后处理信息并根据所述后处理信息确定所述预处理信息的。It should be noted that the receiving post-processing information and determining the pre-processing information according to the post-processing information is that Surface Flinger obtains the post-processing information by detecting the drawing environment after receiving the drawing instruction and determines the pre-processing information according to the post-processing information. process information.

S303、基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;S303. Based on the vertex transformation information in the drawing instruction, perform coordinate transformation processing on the vertex of the primitive corresponding to the primitive information, and obtain an intermediate result of the vertex transformation of the primitive;

具体的,所述基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,包括:基于所述绘图指令中的顶点变换信息确定出第一顶点变换矩阵,然后基于所述第一顶点变换矩阵对所述图元信息对应的图元的初始顶点坐标进行坐标变换处理,得到表示所述图元的顶点变换中间结果的第一顶点坐标。Specifically, performing coordinate transformation processing on the vertices of the primitive corresponding to the primitive information based on the vertex transformation information in the drawing instruction includes: determining the first vertex transformation based on the vertex transformation information in the drawing instruction matrix, and then perform coordinate transformation processing on the initial vertex coordinates of the primitive corresponding to the primitive information based on the first vertex transformation matrix, to obtain the first vertex coordinates representing the intermediate result of the vertex transformation of the primitive.

S304、基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;S304. Based on the preprocessing information, perform coordinate transformation processing on the intermediate vertex transformation result of the primitive to obtain the final result of the vertex transformation of the primitive;

值得注意的是,所述预处理信息可以是旋转矩阵、缩放矩阵或者是预处理矩阵,也有可能是其他用于指示对坐标进行变换处理的矩阵。It should be noted that the preprocessing information may be a rotation matrix, a scaling matrix, or a preprocessing matrix, and may also be other matrices used to indicate transformation processing on coordinates.

参阅附图3b,作为本发明的一个实施例,当所述预处理信息是根据所述后处理信息中包含的旋转参数确定的旋转矩阵时,所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,是指基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标,所述第二顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转的效果。需要说明的是,在所述后处理信息中包含的旋转参数表示的旋转角度是90或者270度时,本发明实施例提供的图层绘制方法还包括根据所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的所述待绘制的图层的宽属性和高属性与所述待绘制的图层的显示范围相匹配。Referring to Fig. 3b, as an embodiment of the present invention, when the pre-processing information is a rotation matrix determined according to the rotation parameters contained in the post-processing information, the graphics primitives based on the pre-processing information Perform coordinate transformation processing again on the intermediate result of the vertex transformation of the primitive to obtain the final result of the vertex transformation of the primitive, which refers to performing coordinate transformation processing again on the coordinates of the first vertex representing the intermediate result of the vertex transformation of the primitive based on the rotation matrix , to obtain the second vertex coordinates representing the final result of the vertex transformation of the primitive, and the primitive represented by the second vertex coordinates has a rotation effect relative to the primitive represented by the first vertex coordinates. It should be noted that when the rotation angle represented by the rotation parameter included in the post-processing information is 90 or 270 degrees, the layer rendering method provided in the embodiment of the present invention further includes: The width attribute parameter and height attribute parameter of the layer are adjusted, so that the adjusted width attribute and height attribute of the layer to be drawn match the display range of the layer to be drawn.

作为本发明的另一个实施例,当所述预处理信息是根据所述后处理信息中包含的缩放参数确定的缩放矩阵时,所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,是指基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标,所述第三顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有缩放的效果。其中,所述后处理信息中包含的缩放参数包括垂直缩放参数和水平缩放参数,所述根据所述后处理信息中包含的缩放参数确定的缩放矩阵,实际上是指根据所述后处理信息中包含的垂直缩放参数和水平缩放参数确定的缩放矩阵。需要说明的是,本发明实施例提供的图层绘制方法还包括根据所述后处理信息中包含的缩放参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的所述待绘制的图层的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the pre-processing information is a scaling matrix determined according to the scaling parameters contained in the post-processing information, the vertex transformation of the primitive based on the pre-processing information is intermediate As a result, the coordinate transformation processing is performed again to obtain the final result of the vertex transformation of the primitive, which means that the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again based on the scaling matrix, and the result representing the vertex transformation of the primitive is obtained. The coordinates of the third vertex of the final result of the vertex transformation of the primitive, and the primitive represented by the coordinate of the third vertex has a scaling effect relative to the primitive represented by the coordinate of the first vertex. Wherein, the scaling parameters contained in the post-processing information include vertical scaling parameters and horizontal scaling parameters, and the scaling matrix determined according to the scaling parameters contained in the post-processing information actually refers to Contains the scaling matrix determined by the vertical scaling parameters and horizontal scaling parameters. It should be noted that the layer drawing method provided by the embodiment of the present invention further includes adjusting the width attribute parameter and the height attribute parameter of the layer to be drawn according to the scaling parameter contained in the post-processing information, so that the adjustment The width attribute and height attribute of the layer to be drawn are matched with the display range of the layer to be drawn.

作为本发明的再一个实施例,当所述后处理信息中包括旋转参数和缩放参数,所述预处理信息是通过将根据所述旋转参数确定的旋转矩阵与根据所述缩放参数确定的缩放矩阵相乘得到的预处理矩阵。所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,是指基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标进行预处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标,所述第四顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转和缩放的效果。其中,所述缩放参数包括垂直缩放参数和水平缩放参数,所述根据所述缩放参数确定的缩放矩阵是指根据所述垂直缩放参数和水平缩放参数确定的缩放矩阵。需要说明的是,本发明实施例提供的图层绘制方法还包括根据所述后处理信息中包含的所述缩放参数和所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the post-processing information includes rotation parameters and scaling parameters, the pre-processing information is obtained by combining the rotation matrix determined according to the rotation parameters with the scaling matrix determined according to the scaling parameters Multiply the resulting preprocessing matrix. The step of performing coordinate transformation again on the intermediate result of the vertex transformation of the primitive based on the preprocessing information to obtain the final result of the vertex transformation of the primitive refers to the representation of the primitive based on the preprocessing matrix The first vertex coordinates of the intermediate result of vertex transformation are preprocessed to obtain the fourth vertex coordinates representing the final result of vertex transformation of the primitive, and the primitive represented by the fourth vertex coordinates is relative to the primitive represented by the first vertex coordinates. Primitives have the effect of rotation and scaling. Wherein, the scaling parameter includes a vertical scaling parameter and a horizontal scaling parameter, and the scaling matrix determined according to the scaling parameter refers to a scaling matrix determined according to the vertical scaling parameter and the horizontal scaling parameter. It should be noted that the layer drawing method provided by the embodiment of the present invention further includes adjusting the width attribute parameter and height attribute of the layer to be drawn according to the zoom parameter and the rotation parameter included in the post-processing information. The parameter is adjusted so that the adjusted width attribute and height attribute match the display range of the layer to be drawn.

需要说明的是,所述预处理信息包括但不限于上述的旋转和/或缩放矩阵,还包括其他用于对图层进行特效处理的参数,凡是现有技术中用于指示对图层进行涉及坐标变换的后端处理的后处理信息都可以转化为所述预处理信息,本发明对此不做限定。It should be noted that the preprocessing information includes but is not limited to the above-mentioned rotation and/or scaling matrix, and also includes other parameters for performing special effect processing on the layer. The post-processing information of the back-end processing of the coordinate transformation can be converted into the pre-processing information, which is not limited in the present invention.

S305、对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果;S305. Perform rasterization processing on the final vertex transformation result of the primitive to obtain the rasterization processing result of the primitive;

S306、基于所述绘图指令中的片断着色信息对所述图元的光栅化处理结果进行片断着色处理,得到所述图元的片断着色处理结果;S306. Perform fragment shading processing on the rasterization processing result of the primitive based on the fragment shading information in the drawing instruction, to obtain the fragment shading processing result of the primitive;

S307、根据所述图元的片断着色处理结果在所述待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层。S307. Perform pixel filling within the display range of the layer to be drawn according to the fragment shading processing result of the primitive to obtain the layer to be drawn.

具体的,光栅化是将一个几何图元转变成一个二维图像的过程。片断着色处理的对象是光栅化之后的数据,经过片断着色器的着色处理之后生成的即是像素,该像素是图层的组成部分,每一个图层中均包含多个像素点。Specifically, rasterization is the process of converting a geometric primitive into a two-dimensional image. The object of the fragment shading process is the rasterized data, and the pixel is generated after the shading process by the fragment shader, and the pixel is a component of a layer, and each layer contains multiple pixel points.

需要说明的是,所述根据所述图元的片断着色处理结果在待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层是指将经过片断着色处理得到的像素点在所述待绘制的图层的画布上进行填充以得到所述待绘制的图层。It should be noted that, the filling of pixels within the display range of the layer to be drawn to obtain the layer to be drawn according to the result of the fragment coloring processing of the primitive refers to the pixel points obtained through the fragment coloring processing in the The canvas of the layer to be drawn is filled to obtain the layer to be drawn.

值得注意的是,本发明实施例所述的图层绘制方法应用的对象不限于对图层进行旋转和/或缩放处理,还可以应用于现有技术中其他只涉及进行坐标变换的后端处理的情形。将本发明实施例提供的图层绘制方法应用在游戏应用的场合时,能够使游戏的滑动更加流畅,并且能够增加图像的特效。It is worth noting that the object of the layer drawing method described in the embodiment of the present invention is not limited to rotating and/or scaling the layer, and can also be applied to other back-end processing in the prior art that only involves coordinate transformation situation. When the layer drawing method provided by the embodiment of the present invention is applied to a game application, the sliding of the game can be made smoother, and the special effect of the image can be increased.

本发明实施例提供一种图层绘制方法,在顶点变换完成之后,依据预处理信息对顶点变换后得到的顶点进行预处理,由于在顶点变换之后进行所述预处理处理的数据量比较少,可以减少对图层做涉及坐标变换的特效处理的代价。An embodiment of the present invention provides a layer drawing method. After the vertex transformation is completed, the vertices obtained after the vertex transformation are preprocessed according to the preprocessing information. Since the amount of data for the preprocessing after the vertex transformation is relatively small, It can reduce the cost of special effect processing involving coordinate transformation on the layer.

实施例三Embodiment Three

请参阅附图4,为本发明实施例提供的一种绘图引擎40的结构示意图,该绘图引擎40可以应用于图2所示的终端设备上。具体的,所述绘图引擎40包括接收单元41、预处理接口单元42、顶点着色器43、光栅化器44、片段着色器45以及图层获得单元46.Please refer to FIG. 4 , which is a schematic structural diagram of a drawing engine 40 provided by an embodiment of the present invention. The drawing engine 40 can be applied to the terminal device shown in FIG. 2 . Specifically, the drawing engine 40 includes a receiving unit 41, a preprocessing interface unit 42, a vertex shader 43, a rasterizer 44, a fragment shader 45, and a layer obtaining unit 46.

所述接收单元41用于接收绘图指令,所述绘图指令中包含图元信息、顶点变换信息以及片断着色信息;还用于接收后处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理。The receiving unit 41 is used to receive drawing instructions, which include primitive information, vertex transformation information, and fragment shading information; and is also used to receive post-processing information, which is used to represent the layer to be drawn Do coordinate transformation processing.

其中,图元是图形软件用于操作和组织画面的最基本的素材,一幅画面由图元组成,图元是一组最简单的、最通用的集合图形或者字符,比如点、线段、三角形、多边形等。Among them, primitives are the most basic materials used by graphics software to operate and organize pictures. A picture is composed of primitives, which are a group of the simplest and most common collection of graphics or characters, such as points, line segments, and triangles. , polygons, etc.

所述后处理信息用于表示对待绘制的图层做坐标变换处理,所述后处理信息包括旋转参数、缩放参数或者两者的结合,所述后处理信息还可以包括显示布局(Source Crop)以及图层范围(Display Frame)等,其中,Source Crop表示采集Buffer哪部分区域去进行合成,Display Frame表示这个Buffer要被合成到屏幕上的哪个区域上,当然,所述后处理信息中可以用于表示对待绘制的图层做其他坐标变换处理,此处不做限制性规定。The post-processing information is used to represent the coordinate transformation processing of the layer to be drawn. The post-processing information includes rotation parameters, scaling parameters or a combination of both. The post-processing information may also include display layout (Source Crop) and Layer range (Display Frame), etc., where Source Crop indicates which part of the Buffer is collected for synthesis, and Display Frame indicates which area on the screen the Buffer is to be synthesized. Of course, the post-processing information can be used for Indicates that other coordinate transformations should be performed on the layer to be drawn, and there are no restrictive regulations here.

所述预处理信息用于表示对图元的顶点变换中间结果再次进行坐标变换的矩阵,所述预处理信息包括旋转矩阵、缩放矩阵或者两者的结合,所述预处理信息还可以包括其他用于对图元的顶点变换中间结果再次进行坐标变换的矩阵,此处不做限制性规定。The preprocessing information is used to represent the coordinate transformation matrix for the intermediate result of the vertex transformation of the primitive. The preprocessing information includes a rotation matrix, a scaling matrix or a combination of the two. The preprocessing information may also include other It is the matrix that performs coordinate transformation again on the intermediate result of the vertex transformation of the primitive, and there are no restrictive regulations here.

需要说明的是,所述绘图指令可以是用户通过触摸屏触摸、键盘输入、鼠标点击等方式输入的,本发明实施例对此并不作限定。It should be noted that the drawing instruction may be input by the user through touch screen touch, keyboard input, mouse click, etc., which is not limited in this embodiment of the present invention.

所述预处理接口单元42用于根据所述后处理信息确定预处理信息。The pre-processing interface unit 42 is configured to determine pre-processing information according to the post-processing information.

作为本发明的一个实施例,当所述后处理信息中包含旋转参数时,所述预处理接口单元42具体用于根据所述旋转参数确定出对应的旋转矩阵,所述旋转矩阵即用于表示所述预处理信息;需要说明的是,在所述后处理信息中包含的旋转参数是90或者270度时,则所述预处理接口单元42还用于基于所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As an embodiment of the present invention, when the post-processing information includes rotation parameters, the pre-processing interface unit 42 is specifically used to determine the corresponding rotation matrix according to the rotation parameters, and the rotation matrix is used to represent The pre-processing information; it should be noted that when the rotation parameter contained in the post-processing information is 90 or 270 degrees, the pre-processing interface unit 42 is also used to Adjust the width attribute parameter and height attribute parameter of the layer, so that the adjusted width attribute and height attribute match the display range of the layer to be drawn.

作为本发明的另一个实施例,当所述后处理信息中包含缩放参数时,所述预处理接口单元42具体用于根据所述缩放参数确定出对应的缩放矩阵,所述缩放矩阵用于表示所述预处理信息;需要说明的是,所述预处理接口单元42还用于基于所述后处理信息中包含的缩放参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the post-processing information includes scaling parameters, the pre-processing interface unit 42 is specifically configured to determine a corresponding scaling matrix according to the scaling parameters, and the scaling matrix is used to represent The pre-processing information; it should be noted that the pre-processing interface unit 42 is also configured to adjust the width attribute parameter and the high attribute parameter of the layer to be drawn based on the scaling parameters contained in the post-processing information , so that the adjusted width and height attributes match the display range of the layer to be drawn.

作为本发明的再一个实施例,当所述后处理信息中不仅包含旋转参数还包含缩放参数时,所述预处理接口单元42具体用于根据所述旋转参数确定出对应的旋转矩阵,根据所述缩放参数确定出对应的缩放矩阵,然后依据所述旋转矩阵与所述缩放矩阵的乘积确定预处理矩阵,所述预处理矩阵用于表示所述预处理信息;需要说明的是,所述预处理接口单元42还用于基于所述后处理信息中包含的所述缩放参数和所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the post-processing information includes not only rotation parameters but also scaling parameters, the pre-processing interface unit 42 is specifically configured to determine the corresponding rotation matrix according to the rotation parameters, and according to the The scaling parameters determine the corresponding scaling matrix, and then determine the preprocessing matrix according to the product of the rotation matrix and the scaling matrix, and the preprocessing matrix is used to represent the preprocessing information; it should be noted that the preprocessing The processing interface unit 42 is further configured to adjust the width attribute parameter and the height attribute parameter of the layer to be drawn based on the zoom parameter and the rotation parameter included in the post-processing information, so that the adjusted width The attributes and high attributes match the display range of the layer to be drawn.

需要说明的是,当所述后处理信息中包含其他涉及用于指示对坐标进形变换的参数时,所述预处理接口单元42还具体用于根据所述后处理信息确定出与其相对应的预处理信息。It should be noted that when the post-processing information contains other parameters related to indicating the transformation of coordinates, the pre-processing interface unit 42 is also specifically configured to determine the corresponding parameters according to the post-processing information. Preprocess information.

所述顶点着色器43用于基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;以及还用于基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果。The vertex shader 43 is configured to perform coordinate transformation processing on the vertices of the primitive corresponding to the primitive information based on the vertex transformation information in the drawing instruction, to obtain an intermediate result of the vertex transformation of the primitive; and is also used to The intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again based on the preprocessing information to obtain the final result of the vertex transformation of the primitive.

具体的,在所述基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果的操作上,所述顶点着色器43具体用于基于所述绘图指令中的顶点变换信息确定顶点变换矩阵;基于所述顶点变换矩阵对表示所述图元的顶点的初始顶点坐标进行坐标变换处理,得到表示所述图元的顶点变换中间结果的第一顶点坐标。Specifically, on the basis of the vertex transformation information in the drawing instruction, the coordinate transformation process is performed on the vertex of the primitive corresponding to the primitive information to obtain the intermediate result of the vertex transformation of the primitive, the vertex The shader 43 is specifically configured to determine a vertex transformation matrix based on the vertex transformation information in the drawing instruction; based on the vertex transformation matrix, perform coordinate transformation processing on the initial vertex coordinates representing the vertices of the graphics primitive to obtain The first vertex coordinate of the vertex transformation intermediate result.

值得注意的是,所述预处理信息具体表现为一个矩阵,比如旋转矩阵、缩放矩阵或者是预处理矩阵等,用于指示对组成图层的图元的顶点坐标进行变换处理。It is worth noting that the preprocessing information is embodied as a matrix, such as a rotation matrix, a scaling matrix, or a preprocessing matrix, etc., and is used to instruct to perform transformation processing on the coordinates of vertices of primitives composing the layer.

作为本发明的一个实施例,当所述预处理信息是根据所述后处理信息中包含的旋转参数确定的旋转矩阵时,所述顶点着色器43具体用于基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标,其中所述第二顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转的效果。As an embodiment of the present invention, when the pre-processing information is a rotation matrix determined according to the rotation parameters contained in the post-processing information, the vertex shader 43 is specifically configured to represent the The first vertex coordinate of the intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again to obtain the second vertex coordinate representing the final result of the vertex transformation of the primitive, wherein the primitive represented by the second vertex coordinate is relative to the The primitive represented by the coordinates of the first vertex has the effect of rotation.

作为本发明的另一个实施例,当所述预处理信息是根据所述后处理信息中包含的缩放参数确定的缩放矩阵时,所述顶点着色器43具体用于基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标,所述第三顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有缩放的效果。As another embodiment of the present invention, when the pre-processing information is a scaling matrix determined according to the scaling parameters included in the post-processing information, the vertex shader 43 is specifically configured to represent the scaling matrix based on the scaling matrix. The first vertex coordinate of the intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again to obtain the third vertex coordinate representing the final result of the vertex transformation of the primitive, and the primitive represented by the third vertex coordinate is relative to the The primitive represented by the coordinates of the first vertex has a scaling effect.

作为本发明的再一个实施例,当所述后处理信息中包括旋转参数和缩放参数,且所述缩放参数包括垂直缩放参数和水平缩放参数,所述预处理信息是根据所述旋转参数确定的旋转矩阵与根据所述垂直缩放参数和水平缩放参数确定的缩放矩阵的乘积确定的预处理矩阵。所述顶点着色器43具体用于基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标,所述第四顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转和缩放的效果。As another embodiment of the present invention, when the post-processing information includes a rotation parameter and a scaling parameter, and the scaling parameter includes a vertical scaling parameter and a horizontal scaling parameter, the pre-processing information is determined according to the rotation parameter A preprocessing matrix determined by the product of the rotation matrix and the scaling matrix determined according to the vertical scaling parameter and the horizontal scaling parameter. The vertex shader 43 is specifically configured to perform coordinate transformation again on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive based on the preprocessing matrix, to obtain the first vertex coordinate representing the final result of the vertex transformation of the primitive. Four vertex coordinates, the primitive represented by the fourth vertex coordinate has the effect of rotation and scaling relative to the primitive represented by the first vertex coordinate.

需要说明的是,所述后处理信息中包含的参数包括但不限于上述的旋转和/或缩放参数,还包括其他仅涉及坐标变换处理的参数,则对应的是,所述顶点着色器的功能随着所述后处理信息中包含的参数的不同而不同,也即所述顶点着色器包括但不限于上述功能。It should be noted that the parameters contained in the post-processing information include but are not limited to the above-mentioned rotation and/or scaling parameters, and also include other parameters that only involve coordinate transformation processing. Correspondingly, the function of the vertex shader The parameters included in the post-processing information are different, that is, the vertex shader includes but not limited to the above functions.

所述光栅化器44用于对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果;The rasterizer 44 is configured to perform rasterization processing on the final result of the vertex transformation of the primitive to obtain the rasterization processing result of the primitive;

所述片断着色器45用于基于所述绘图指令中的片断着色信息对所述图元的光栅化处理结果进行片断着色处理,得到所述图元的片断着色处理结果;The fragment shader 45 is configured to perform fragment shading processing on the rasterization processing result of the primitive based on the fragment shading information in the drawing instruction, to obtain the fragment shading processing result of the primitive;

所述待绘制的图层获得单元46用于根据所述图元的片断着色处理结果在待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层。The layer to be drawn obtaining unit 46 is configured to perform pixel filling within the display range of the layer to be drawn to obtain the layer to be drawn according to the fragment coloring processing result of the primitive.

具体的,所述待绘制的图层获得单元46具体用于将绘制完成的buffer由SurfaceFlinger传递给合成器,由所述合成器调用增强显示控制器EDC将所述Buffer进行合成生成所述待绘制的图层。Specifically, the to-be-drawn layer obtaining unit 46 is specifically configured to transfer the drawn buffer to the synthesizer by SurfaceFlinger, and the synthesizer calls the enhanced display controller EDC to synthesize the buffer to generate the to-be-drawn layer.

本发明实施例提供一种绘图引擎,利用该绘图引擎绘制图层时,是在顶点变换完成后,依据预处理信息对顶点变换结果进行预处理的,由于顶点变换阶段针对的只是较少的顶点,所以采用本发明实施例提供的绘图引擎对图层进行预处理,因为处理的数据量比较少,所以处理代价比较小;进一步的,本发明实施例提供的绘图引擎还包括在确定预处理信息后,根据所述预处理信息对应的旋转和/或缩放参数调整图层的宽高属性,使得所述待绘制的图层的宽高与其显示范围相匹配,使得后续的光栅化以及片断着色直接针对图层的顶点变化结果进行操作,进一步减小了处理代价。An embodiment of the present invention provides a drawing engine. When using the drawing engine to draw a layer, after the vertex transformation is completed, the vertex transformation result is preprocessed according to the preprocessing information. Since the vertex transformation stage only targets fewer vertices , so the drawing engine provided by the embodiment of the present invention is used to preprocess the layer, because the amount of processed data is relatively small, so the processing cost is relatively small; further, the drawing engine provided by the embodiment of the present invention also includes determining the preprocessing information Finally, adjust the width and height attributes of the layer according to the rotation and/or scaling parameters corresponding to the preprocessing information, so that the width and height of the layer to be drawn match its display range, so that subsequent rasterization and fragment coloring can be directly Operating on the vertex change results of the layer further reduces the processing cost.

实施例四Embodiment Four

请参阅附图5,为本发明实施例提供的一种显示方法的方法流程图,该图层绘制方法可以应用于计算机系统中,该计算机系统可以位于一台物理主机上,也可以分布位于多台物理主机上。具体的,该计算机系统可以位于一台或多台计算机、便携式电脑、手持设备(例如手机,PAD等)、服务器等类型的终端上,其中该计算机系统的逻辑结构可以参阅附图2。Please refer to accompanying drawing 5, which is a method flowchart of a display method provided by an embodiment of the present invention. The layer drawing method can be applied to a computer system, and the computer system can be located on a physical host or distributed across multiple locations. on a physical host. Specifically, the computer system can be located on one or more computers, portable computers, handheld devices (such as mobile phones, PADs, etc.), servers and other types of terminals, wherein the logical structure of the computer system can refer to FIG. 2 .

具体的,如图5所示,本发明实施例提供的显示方法包括下述流程:Specifically, as shown in FIG. 5, the display method provided by the embodiment of the present invention includes the following process:

S501、接收绘图指令,所述绘图指令中包含图元信息、顶点变换信息以及片断着色信息;S501. Receive a drawing instruction, where the drawing instruction includes primitive information, vertex transformation information, and fragment shading information;

具体的,所述绘图指令中包含了图元信息、顶点变换信息以及片段着色信息。其中,图元是图形软件用于操作和组织画面的最基本的素材,一幅画面由图元组成,图元是一组最简单的、最通用的集合图形或者字符,比如点、线段、三角形、多边形等。Specifically, the drawing instruction includes primitive information, vertex transformation information and fragment shading information. Among them, primitives are the most basic materials used by graphics software to operate and organize pictures. A picture is composed of primitives, which are a group of the simplest and most common collection of graphics or characters, such as points, line segments, and triangles. , polygons, etc.

需要说明的是,所述绘图指令可以是用户通过触摸屏触摸、键盘输入、鼠标点击等方式输入的,本发明实施例对此并不作限定。It should be noted that the drawing instruction may be input by the user through touch screen touch, keyboard input, mouse click, etc., which is not limited in this embodiment of the present invention.

S502、接收后处理信息,根据所述后处理信息确定预处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理;S502. Receive post-processing information, and determine pre-processing information according to the post-processing information, where the post-processing information is used to indicate that coordinate transformation processing is performed on the layer to be drawn;

所述后处理信息用于表示对待绘制的图层做坐标变换处理,所述后处理信息包括旋转参数、缩放参数或者两者的结合,所述后处理信息还可以包括显示布局(Source Crop)以及图层范围(Display Frame)等,其中,Source Crop表示采集Buffer哪部分区域去进行合成,Display Frame表示这个Buffer要被合成到屏幕上的哪个区域上,当然,所述后处理信息中可以用于表示对待绘制的图层做其他坐标变换处理,此处不做限制性规定。The post-processing information is used to represent the coordinate transformation processing of the layer to be drawn. The post-processing information includes rotation parameters, scaling parameters or a combination of both. The post-processing information may also include display layout (Source Crop) and Layer range (Display Frame), etc., where Source Crop indicates which part of the Buffer is collected for synthesis, and Display Frame indicates which area on the screen the Buffer is to be synthesized. Of course, the post-processing information can be used for Indicates that other coordinate transformations should be performed on the layer to be drawn, and there are no restrictive regulations here.

所述预处理信息用于表示对图元的顶点变换中间结果再次进行坐标变换的矩阵,所述预处理信息包括旋转矩阵、缩放矩阵或者两者的结合,所述预处理信息还可以包括其他用于对图元的顶点变换中间结果再次进行坐标变换的矩阵,此处不做限制性规定。The preprocessing information is used to represent the coordinate transformation matrix for the intermediate result of the vertex transformation of the primitive. The preprocessing information includes a rotation matrix, a scaling matrix or a combination of the two. The preprocessing information may also include other It is the matrix that performs coordinate transformation again on the intermediate result of the vertex transformation of the primitive, and there are no restrictive regulations here.

值得注意的是,所述后处理信息是指现有技术中基于OpenGL硬件标准的图层渲染模式下用于指示为绘制完成的图层进行处理的信息,所述后处理信息包括对绘制完成的图层进行旋转和/或缩放以及其他涉及进行坐标变换处理的信息,此处不再一一列举。It is worth noting that the post-processing information refers to the information used to indicate that the layer that has been drawn is processed in the layer rendering mode based on the OpenGL hardware standard in the prior art. Layer rotation and/or scaling and other information related to coordinate transformation processing are not listed here.

具体的,所述根据所述后处理信息确定预处理信息包括但不限于以下情形:Specifically, the determination of pre-processing information based on the post-processing information includes but is not limited to the following situations:

作为本发明的一个实施例,在后处理信息中包含的旋转参数(Transform Hint)不为0时,确定对应于所述旋转参数的旋转矩阵,所述预处理信息即是该旋转矩阵;需要说明的是,在后处理信息中包含旋转参数表示的旋转角度是90或者270度时,本发明实施例所述的技术方案还包括基于所述缩放参数对所述待绘制的图层的宽属性参数以及高属性参数进行调整,以使调整后的所述待绘制的图层的宽高属性与所述待绘制的图层的显示范围相匹配。As an embodiment of the present invention, when the rotation parameter (Transform Hint) contained in the post-processing information is not 0, the rotation matrix corresponding to the rotation parameter is determined, and the pre-processing information is the rotation matrix; it needs to be explained Notably, when the rotation angle represented by the rotation parameter included in the post-processing information is 90 or 270 degrees, the technical solution described in the embodiment of the present invention further includes adjusting the width attribute parameter of the layer to be drawn based on the zoom parameter And the high attribute parameter is adjusted, so that the adjusted width and height attributes of the layer to be drawn match the display range of the layer to be drawn.

作为本发明的另一个实施例,在后处理信息中包含缩放参数不为0时,确定对应于所述缩放参数的缩放矩阵,所述预处理信息即是该缩放矩阵,需要说明的是,所述缩放参数包括水平缩放参数和垂直缩放参数;需要说明的是,在后处理信息中包含缩放参数时,本发明实施例所述的技术方案还包括基于所述缩放参数对所述待绘制的图层的宽属性参数以及高属性参数进行调整,以使调整后的所述待绘制的图层的宽高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the scaling parameter included in the post-processing information is not 0, the scaling matrix corresponding to the scaling parameter is determined, and the pre-processing information is the scaling matrix. It should be noted that the The scaling parameters include horizontal scaling parameters and vertical scaling parameters; it should be noted that when the post-processing information includes scaling parameters, the technical solution described in the embodiment of the present invention also includes The width attribute parameter and the height attribute parameter of the layer are adjusted, so that the adjusted width and height attributes of the layer to be drawn match the display range of the layer to be drawn.

作为本发明的再一个实施例,在后处理信息中包含的旋转参数不为0且其包含缩放参数也不为0时,根据所述旋转参数确定出对应的旋转矩阵,根据所述缩放参数确定出对应的缩放矩阵,然后再将所述旋转矩阵乘以所述缩放矩阵即得到预处理矩阵,则所述预处理信息即是该预处理矩阵,同样,所述缩放参数包括水平缩放参数和垂直缩放参数。需要说明的是,在后处理信息中不仅包含旋转参数还包含缩放参数时,本发明实施例所述的技术方案还包括基于所述旋转参数和所述缩放参数对所述待绘制的图层的宽属性参数以及高属性参数进行调整,以使调整后的所述待绘制的图层的宽高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the rotation parameter included in the post-processing information is not 0 and the scaling parameter included is also not 0, the corresponding rotation matrix is determined according to the rotation parameter, and the corresponding rotation matrix is determined according to the scaling parameter. get the corresponding scaling matrix, and then multiply the rotation matrix by the scaling matrix to get the preprocessing matrix, then the preprocessing information is the preprocessing matrix, similarly, the scaling parameters include horizontal scaling parameters and vertical scaling parameter. It should be noted that when the post-processing information includes not only the rotation parameter but also the scaling parameter, the technical solution described in the embodiment of the present invention also includes the adjustment of the layer to be drawn based on the rotation parameter and the scaling parameter. The width attribute parameter and the height attribute parameter are adjusted so that the adjusted width and height attributes of the layer to be drawn match the display range of the layer to be drawn.

需要说明的是,所述预处理信息包括但不限于上述的旋转和/或缩放矩阵,还包括其他用于对图层进行特效处理的参数,凡是现有技术中用于指示对图层进行涉及坐标变换的后端处理的后处理信息都可以转化为所述预处理信息,本发明对此不做限定。It should be noted that the preprocessing information includes but is not limited to the above-mentioned rotation and/or scaling matrix, and also includes other parameters for performing special effect processing on the layer. The post-processing information of the back-end processing of the coordinate transformation can be converted into the pre-processing information, which is not limited in the present invention.

S503、基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;S503. Based on the vertex transformation information in the drawing instruction, perform coordinate transformation processing on the vertex of the primitive corresponding to the primitive information, and obtain an intermediate result of the vertex transformation of the primitive;

具体的,所述基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,包括:基于所述绘图指令中的顶点变换信息确定出第一顶点变换矩阵,然后基于所述第一顶点变换矩阵对所述图元信息对应的图元的初始顶点坐标进行坐标变换处理,得到表示所述图元的顶点变换中间结果的第一顶点坐标。Specifically, performing coordinate transformation processing on the vertices of the primitive corresponding to the primitive information based on the vertex transformation information in the drawing instruction includes: determining the first vertex transformation based on the vertex transformation information in the drawing instruction matrix, and then perform coordinate transformation processing on the initial vertex coordinates of the primitive corresponding to the primitive information based on the first vertex transformation matrix, to obtain the first vertex coordinates representing the intermediate result of the vertex transformation of the primitive.

S504、基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;S504. Based on the preprocessing information, perform coordinate transformation processing on the intermediate vertex transformation result of the primitive to obtain the final result of the vertex transformation of the primitive;

值得注意的是,所述预处理信息包括但不限于是旋转矩阵、缩放矩阵或者是预处理矩阵,也有可能是其他用于指示对坐标进行变换处理的矩阵。It should be noted that the preprocessing information includes, but is not limited to, a rotation matrix, a scaling matrix, or a preprocessing matrix, and may also be other matrices used to indicate transformation processing on coordinates.

作为本发明的一个实施例,当所述预处理信息是根据所述后处理信息中包含的旋转参数确定的旋转矩阵时,所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,是指基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标,所述第二顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转的效果。需要说明的是,在所述后处理信息中包含的旋转参数表示的旋转角度是90或者270度时,本发明实施例提供的图层绘制方法还包括根据所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的所述待绘制的图层的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As an embodiment of the present invention, when the preprocessing information is a rotation matrix determined according to the rotation parameters contained in the postprocessing information, the intermediate result of the vertex transformation of the primitive based on the preprocessing information is Carrying out the coordinate transformation processing again to obtain the final result of the vertex transformation of the primitive refers to performing coordinate transformation processing again on the coordinates of the first vertex representing the intermediate result of the vertex transformation of the primitive based on the rotation matrix to obtain the The second vertex coordinates of the final result of the vertex transformation of the primitive, the primitive represented by the second vertex coordinates has a rotation effect relative to the primitive represented by the first vertex coordinates. It should be noted that when the rotation angle represented by the rotation parameter included in the post-processing information is 90 or 270 degrees, the layer rendering method provided in the embodiment of the present invention further includes: The width attribute parameter and height attribute parameter of the layer are adjusted, so that the adjusted width attribute and height attribute of the layer to be drawn match the display range of the layer to be drawn.

作为本发明的另一个实施例,当所述预处理信息是根据所述后处理信息中包含的缩放参数确定的缩放矩阵时,所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,是指基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标,所述第三顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有缩放的效果。其中,所述后处理信息中包含的缩放参数包括垂直缩放参数和水平缩放参数,所述根据所述后处理信息中包含的缩放参数确定的缩放矩阵,实际上是指根据所述后处理信息中包含的垂直缩放参数和水平缩放参数确定的缩放矩阵。需要说明的是,本发明实施例提供的图层绘制方法还包括根据所述后处理信息中包含的缩放参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的所述待绘制的图层的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the pre-processing information is a scaling matrix determined according to the scaling parameters contained in the post-processing information, the vertex transformation of the primitive based on the pre-processing information is intermediate As a result, the coordinate transformation processing is performed again to obtain the final result of the vertex transformation of the primitive, which means that the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive is subjected to coordinate transformation processing again based on the scaling matrix, and the result representing the vertex transformation of the primitive is obtained. The coordinates of the third vertex of the final result of the vertex transformation of the primitive, and the primitive represented by the coordinate of the third vertex has a scaling effect relative to the primitive represented by the coordinate of the first vertex. Wherein, the scaling parameters contained in the post-processing information include vertical scaling parameters and horizontal scaling parameters, and the scaling matrix determined according to the scaling parameters contained in the post-processing information actually refers to Contains the scaling matrix determined by the vertical scaling parameters and horizontal scaling parameters. It should be noted that the layer drawing method provided by the embodiment of the present invention further includes adjusting the width attribute parameter and the height attribute parameter of the layer to be drawn according to the scaling parameter contained in the post-processing information, so that the adjustment The width attribute and height attribute of the layer to be drawn are matched with the display range of the layer to be drawn.

作为本发明的再一个实施例,当所述后处理信息中包括旋转参数和缩放参数,且所述缩放参数包括垂直缩放参数和/或水平缩放参数,所述预处理信息是根据所述旋转参数确定的旋转矩阵与根据所述垂直缩放参数和/或水平缩放参数确定的缩放矩阵的乘积确定的预处理矩阵。所述基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果,是指基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标,所述第四顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转和缩放的效果。其中,所述缩放参数包括垂直缩放参数和水平缩放参数,所述根据所述缩放参数确定的缩放矩阵是指根据所述垂直缩放参数和水平缩放参数确定的缩放矩阵。需要说明的是,本发明实施例提供的图层绘制方法还包括根据所述后处理信息中包含的所述缩放参数和所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the post-processing information includes rotation parameters and scaling parameters, and the scaling parameters include vertical scaling parameters and/or horizontal scaling parameters, the pre-processing information is based on the rotation parameters A preprocessing matrix determined by the product of the determined rotation matrix and the scaling matrix determined according to the vertical scaling parameter and/or the horizontal scaling parameter. The step of performing coordinate transformation again on the intermediate result of the vertex transformation of the primitive based on the preprocessing information to obtain the final result of the vertex transformation of the primitive refers to the representation of the primitive based on the preprocessing matrix The first vertex coordinate of the vertex transformation intermediate result is subjected to coordinate transformation processing again, and the fourth vertex coordinate representing the final result of the vertex transformation of the primitive is obtained, and the primitive represented by the fourth vertex coordinate is relative to the first vertex coordinate The primitive represented has the effect of rotation and scaling. Wherein, the scaling parameter includes a vertical scaling parameter and a horizontal scaling parameter, and the scaling matrix determined according to the scaling parameter refers to a scaling matrix determined according to the vertical scaling parameter and the horizontal scaling parameter. It should be noted that the layer drawing method provided by the embodiment of the present invention further includes adjusting the width attribute parameter and height attribute of the layer to be drawn according to the zoom parameter and the rotation parameter included in the post-processing information. The parameter is adjusted so that the adjusted width attribute and height attribute match the display range of the layer to be drawn.

需要说明的是,所述预处理信息包括但不限于上述的旋转和/或缩放矩阵,还包括其他用于对图层进行特效处理的参数,凡是现有技术中用于指示对图层进行涉及坐标变换的后端处理的后处理信息都可以转化为所述预处理信息,本发明对此不做限定。It should be noted that the preprocessing information includes but is not limited to the above-mentioned rotation and/or scaling matrix, and also includes other parameters for performing special effect processing on the layer. The post-processing information of the back-end processing of the coordinate transformation can be converted into the pre-processing information, which is not limited in the present invention.

S505、对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果;S505. Perform rasterization processing on the final vertex transformation result of the primitive to obtain a rasterization processing result of the primitive;

S506、基于所述绘图指令中的片断着色信息对所述图元的光栅化处理结果进行片断着色处理,得到所述图元的片断着色处理结果;S506. Perform fragment shading processing on the rasterization processing result of the primitive based on the fragment shading information in the drawing instruction, to obtain the fragment shading processing result of the primitive;

S507、根据所述图元的片断着色处理结果在待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层;S507. Perform pixel filling within the display range of the layer to be drawn according to the fragment coloring processing result of the primitive to obtain the layer to be drawn;

具体的,光栅化是将一个几何图元转变成一个二维图像的过程。片断着色处理的对象是光栅化之后的数据,经过片断着色器的着色处理之后生成的即是像素,该像素是图层的组成部分,每一个图层中均包含多个像素点。Specifically, rasterization is the process of converting a geometric primitive into a two-dimensional image. The object of the fragment shading process is the rasterized data, and the pixel is generated after the shading process by the fragment shader, and the pixel is a component of a layer, and each layer contains multiple pixel points.

需要说明的是,所述根据所述图元的片断着色处理结果在待绘制的图层上进行像素填充得到所述待绘制的图层是指将经过片断着色处理得到的像素点在所述待绘制的图层的画布上进行填充以得到所述待绘制的图层。It should be noted that, the filling of pixels on the layer to be drawn to obtain the layer to be drawn according to the result of the fragment coloring processing of the primitive means that the pixel points obtained through the fragment coloring process are placed on the layer to be drawn. The canvas of the layer to be drawn is filled to obtain the layer to be drawn.

S508、将所述待绘制的图层输出显示。S508. Output and display the layer to be drawn.

值得注意的是,当所述待绘制的图层的数目是两个以上时,在将所述待绘制的图层输出显示之前,还包括对两个以上的所述待绘制的图层进行合成处理生成目标图像,然后将所述目标图像输出显示。其中,用于将两个以上的所述待绘制的图层进行合成处理以生成目标图像的可以是合成器,也可以是增强显示控制器;用于将所述目标图像输出显示的是增强显示控制器。It is worth noting that when the number of the layers to be drawn is more than two, before outputting and displaying the layers to be drawn, it also includes synthesizing the two or more layers to be drawn Processing generates a target image, and then outputs the target image for display. Wherein, the one used for combining two or more layers to be drawn to generate the target image may be a synthesizer, or an enhanced display controller; the one used for outputting and displaying the target image is an enhanced display controller.

值得注意的是,本发明实施例所述的显示方法应用的对象不限于对图层进行旋转和/或缩放处理,还可以应用于现有技术中其他只涉及进行坐标变换的后端处理的情形。将本发明实施例提供的图层绘制方法应用在游戏应用的场合时,能够使游戏的滑动更加流畅,并且能够增加图像的特效。It is worth noting that the object of the display method described in the embodiment of the present invention is not limited to the rotation and/or scaling of the layer, and can also be applied to other situations in the prior art that only involve the back-end processing of coordinate transformation . When the layer drawing method provided by the embodiment of the present invention is applied to a game application, the sliding of the game can be made smoother, and the special effect of the image can be increased.

可知,采用本发明实施例提供的显示方法时,预处理是在顶点变换阶段进行的,由于顶点变换阶段针对的只是较少的顶点,所以采用本发明实施例提供的技术方案进行所述预处理需要处理的数据量比较少,处理速度比较快,减少涉及坐标变换的图像特效的处理代价;再者,在所述待绘制的图层的数目是两个以上时,在输出显示所述两个以上图层之前还需要对其进行合成处理以生成图像,基于所述待绘制的图层已经完成预处理,所以在进行图像合成时需要处理的数据量比较小,能够进一步减小处理的代价,提高显示性能。It can be seen that when the display method provided by the embodiment of the present invention is used, the preprocessing is performed in the vertex transformation stage. Since the vertex transformation stage only targets fewer vertices, the technical solution provided by the embodiment of the present invention is used to perform the preprocessing The amount of data to be processed is relatively small, the processing speed is relatively fast, and the processing cost of image special effects involving coordinate transformation is reduced; moreover, when the number of layers to be drawn is more than two, the output displays the two The above layers need to be synthesized before to generate images. Based on the preprocessing of the layers to be drawn, the amount of data that needs to be processed during image synthesis is relatively small, which can further reduce the processing cost. Improve display performance.

实施例五Embodiment five

请参阅附图6a,为本发明提供的一种终端设备600的结构框图,该终端设备600具体可以为一台、便携式电脑、手持设备(例如手机,PAD等)、服务器等,且该终端设备600的逻辑结构图可以参阅附图2.具体的,如图6a所示,所述终端设备600中包含绘图引擎601、显示控制器603以及显示屏幕组件605;Please refer to accompanying drawing 6a, which is a structural block diagram of a terminal device 600 provided by the present invention. Specifically, the terminal device 600 can be a computer, a portable computer, a handheld device (such as a mobile phone, a PAD, etc.), a server, etc., and the terminal device For the logical structure diagram of 600, please refer to accompanying drawing 2. Specifically, as shown in FIG.

其中,所述绘图引擎601用于接收绘图指令,所述绘图指令中包含图元信息、顶点变换信息以及片断着色信息;接收后处理信息,根据所述后处理信息确定预处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理;基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果;基于所述绘图指令中的片断着色信息对所述图元的光栅化处理结果进行片断着色处理,得到所述图元的片断着色处理结果;根据所述图元的片断着色处理结果在待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层。Wherein, the drawing engine 601 is used to receive drawing instructions, the drawing instructions include primitive information, vertex transformation information and fragment shading information; receive post-processing information, determine pre-processing information according to the post-processing information, and the post-processing information The processing information is used to represent the coordinate transformation processing of the layer to be drawn; based on the vertex transformation information in the drawing instruction, the coordinate transformation processing is performed on the vertex of the primitive corresponding to the primitive information to obtain the vertex transformation of the primitive intermediate results; based on the preprocessing information, perform coordinate transformation processing again on the intermediate results of the vertex transformation of the primitives to obtain the final results of the vertex transformations of the primitives; perform rasterization processing on the final results of the vertex transformations of the primitives , to obtain the rasterization processing result of the primitive; perform fragment shading processing on the rasterization processing result of the primitive based on the fragment shading information in the drawing instruction, and obtain the fragment shading processing result of the primitive; according to the The fragment shading processing result of the primitive is filled with pixels within the display range of the layer to be drawn to obtain the layer to be drawn.

具体的,所述绘图引擎601接收的所述绘图指令可以是用户通过触摸屏触摸、键盘输入、鼠标点击等方式输入的,本发明实施例对此并不作限定。Specifically, the drawing instruction received by the drawing engine 601 may be input by the user through touch screen touch, keyboard input, mouse click, etc., which is not limited in this embodiment of the present invention.

所述后处理信息用于表示对待绘制的图层做坐标变换处理,所述后处理信息包括旋转参数、缩放参数或者两者的结合,所述后处理信息还可以包括显示布局(Source Crop)以及图层范围(Display Frame)等,其中,Source Crop表示采集Buffer哪部分区域去进行合成,Display Frame表示这个Buffer要被合成到屏幕上的哪个区域上,当然,所述后处理信息中可以用于表示对待绘制的图层做其他坐标变换处理,此处不做限制性规定。The post-processing information is used to represent the coordinate transformation processing of the layer to be drawn. The post-processing information includes rotation parameters, scaling parameters or a combination of both. The post-processing information may also include display layout (Source Crop) and Layer range (Display Frame), etc., where Source Crop indicates which part of the Buffer is collected for synthesis, and Display Frame indicates which area on the screen the Buffer is to be synthesized. Of course, the post-processing information can be used for Indicates that other coordinate transformations should be performed on the layer to be drawn, and there are no restrictive regulations here.

所述预处理信息用于表示对图元的顶点变换中间结果再次进行坐标变换的矩阵,所述预处理信息包括旋转矩阵、缩放矩阵或者两者的结合,所述预处理信息还可以包括其他用于对图元的顶点变换中间结果再次进行坐标变换的矩阵,此处不做限制性规定。The preprocessing information is used to represent the coordinate transformation matrix for the intermediate result of the vertex transformation of the primitive. The preprocessing information includes a rotation matrix, a scaling matrix or a combination of the two. The preprocessing information may also include other It is the matrix that performs coordinate transformation again on the intermediate result of the vertex transformation of the primitive, and there are no restrictive regulations here.

作为本发明的一个实施例,当所述后处理信息中包含旋转参数时,所述绘图引擎601具体用于根据所述旋转参数确定出对应的旋转矩阵,所述旋转矩阵即用于表示所述预处理信息;需要说明的是,在所述后处理信息中包含的旋转参数是90或者270度时,则所述绘图引擎601还用于基于所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的所述待绘制的图层的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As an embodiment of the present invention, when the post-processing information includes rotation parameters, the drawing engine 601 is specifically configured to determine a corresponding rotation matrix according to the rotation parameters, and the rotation matrix is used to represent the pre-processing information; it should be noted that, when the rotation parameter contained in the post-processing information is 90 or 270 degrees, the drawing engine 601 is also used for the layer to be drawn based on the rotation parameter The width attribute parameter and the height attribute parameter are adjusted so that the adjusted width attribute and height attribute of the layer to be drawn match the display range of the layer to be drawn.

作为本发明的另一个实施例,当所述后处理信息中包含缩放参数时,,所述绘图引擎601具体用于根据所述缩放参数确定出对应的缩放矩阵,所述缩放矩阵用于表示所述预处理信息;需要说明的是,所述绘图引擎601还用于基于所述后处理信息中包含的缩放参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的所述待绘制的图层的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the post-processing information includes scaling parameters, the drawing engine 601 is specifically configured to determine a corresponding scaling matrix according to the scaling parameters, and the scaling matrix is used to represent the the above preprocessing information; it should be noted that the drawing engine 601 is also configured to adjust the width attribute parameters and high attribute parameters of the layer to be drawn based on the scaling parameters contained in the post-processing information, so that The adjusted width attribute and height attribute of the layer to be drawn match the display range of the layer to be drawn.

作为本发明的再一个实施例,当所述后处理信息中不仅包含旋转参数还包含缩放参数时,所述绘图引擎601具体用于根据所述旋转参数确定出对应的旋转矩阵,根据所述缩放参数确定出对应的缩放矩阵,然后依据所述旋转矩阵与所述缩放矩阵的乘积确定预处理矩阵,所述预处理矩阵用于表示所述预处理信息;需要说明的是,所述绘图引擎601还用于基于所述后处理信息中包含的所述缩放参数和所述旋转参数对所述待绘制的图层的宽属性参数和高属性参数进行调整,以使得调整后的所述待绘制的图层的宽属性和高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, when the post-processing information includes not only rotation parameters but also scaling parameters, the drawing engine 601 is specifically configured to determine the corresponding rotation matrix according to the rotation parameters, and determine the corresponding rotation matrix according to the scaling parameters. The parameters determine the corresponding scaling matrix, and then determine the preprocessing matrix according to the product of the rotation matrix and the scaling matrix, and the preprocessing matrix is used to represent the preprocessing information; it should be noted that the drawing engine 601 It is also used to adjust the width attribute parameter and the height attribute parameter of the layer to be drawn based on the scaling parameter and the rotation parameter included in the post-processing information, so that the adjusted layer to be drawn The width attribute and height attribute of the layer match the display range of the layer to be drawn.

值得注意的是,所述绘图引擎601接收的所述后处理信息是指现有技术中基于OpenGL硬件标准的图层渲染模式下用于指示为绘制完成的图层进行处理的信息,所述后处理信息包括对绘制完成的图层进行旋转和/或缩放以及其他涉及进行坐标变换的处理信息,此处不再一一列举。It is worth noting that the post-processing information received by the drawing engine 601 refers to the information used to indicate that the layer that has been drawn is processed in the layer rendering mode based on the OpenGL hardware standard in the prior art. The processing information includes rotating and/or scaling the drawn layer and other processing information related to coordinate transformation, which will not be listed here.

所述显示控制器603用于将所述待绘制的图层输出显示;The display controller 603 is configured to output and display the layer to be drawn;

所述显示屏幕组件605用于显示所述待绘制的图层。The display screen component 605 is used to display the layer to be drawn.

具体的,当所述待绘制的图层的数目是两个以上时,在将所述待绘制的图层输出显示之前,还包括利用显示控制器603对两个以上的所述待绘制的图层进行合成处理生成目标图像将并所述目标图像输出显示,所述显示屏幕组件605具体用于显示到所述目标图像。Specifically, when the number of the layers to be drawn is more than two, before outputting and displaying the layers to be drawn, it also includes using the display controller 603 to perform an operation on two or more of the layers to be drawn Layers are synthesized to generate a target image, and the target image is output for display, and the display screen component 605 is specifically used to display the target image.

需要说明的是,作为本发明的另一个实施例,请参阅附图6b,所述终端设备610还包括合成器613,其中当所述待绘制的图层的数目是两个以上时,所述合成器613用于将两个以上的所述待绘制的图层进行合成生成目标图像,然后由显示控制器614将所述合成器613生成的目标图像输出显示,所述显示屏幕组件615具体用于显示所述目标图像。It should be noted that, as another embodiment of the present invention, please refer to FIG. 6b, the terminal device 610 also includes a synthesizer 613, wherein when the number of layers to be drawn is more than two, the The synthesizer 613 is used to synthesize more than two layers to be drawn to generate a target image, and then the display controller 614 outputs and displays the target image generated by the synthesizer 613, and the display screen component 615 specifically uses to display the target image.

当然所述终端设备610也包括绘图引擎611,且绘图引擎611在终端设备610中的功能与绘图引擎601在终端设备600中的功能是一样的,所以其具体功能参照绘图引擎601在终端设备600中的功能即可,此处不再赘述。Of course, the terminal device 610 also includes a drawing engine 611, and the function of the drawing engine 611 in the terminal device 610 is the same as that of the drawing engine 601 in the terminal device 600, so its specific functions refer to the drawing engine 601 in the terminal device 600. The functions in it are enough, so I won’t repeat them here.

可知,采用本发明实施例所述的终端设备绘制图层并显示所述待绘制的图层时,首先在绘制图层时,预处理是在顶点变换阶段进行的,由于顶点变换阶段针对的只是较少的顶点,所以采用本发明实施例所述的终端设备在预处理时需要处理的数据量比较少,处理代价比较小;再者,在所述待绘制的图层的数目是两个以上时,输出显示所述两个以上图层之前还需要对其进行合成处理以生成目标图像,基于所述待绘制的图层已经完成预处理,所以进行合成时需要处理的数据量比较小,进而在一定程度上提升系统的显示性能。It can be seen that when using the terminal device described in the embodiment of the present invention to draw a layer and display the layer to be drawn, firstly, when drawing a layer, the preprocessing is performed in the vertex transformation stage, because the vertex transformation stage is only for Fewer vertices, so the amount of data that needs to be processed during preprocessing by the terminal device described in the embodiment of the present invention is relatively small, and the processing cost is relatively small; moreover, when the number of layers to be drawn is more than two When the output shows the two or more layers, they need to be synthesized to generate the target image. Based on the preprocessing of the layers to be drawn, the amount of data that needs to be processed during the synthesis is relatively small, and then Improve the display performance of the system to a certain extent.

实施例六Embodiment six

相应的,本发明实施例还提供一种终端设备,如图7所示,该终端设备可以包括至少一个处理器701,例如CPU,至少一个网络接口704,例如物理网卡,或者其他的用户接口703,以及存储器705、显示器706和至少一个通信总线702。Correspondingly, the embodiment of the present invention also provides a terminal device. As shown in FIG. 7, the terminal device may include at least one processor 701, such as a CPU, at least one network interface 704, such as a physical network card, or other user interfaces 703 , and memory 705, display 706 and at least one communication bus 702.

其中,通信总线702用于实现这些组件之间的连接通信。Wherein, the communication bus 702 is used to realize connection and communication between these components.

网络接口704用于实现该终端设备和网络之间的连接通信,比如该网络接口704可以用于连接物理网卡和/或物理交换机等设备。The network interface 704 is used to realize connection and communication between the terminal device and the network, for example, the network interface 704 may be used to connect devices such as a physical network card and/or a physical switch.

可选的,用户接口703,可以包括显示器,键盘或者其他点击设备,例如,鼠标,轨迹球(trackball),触感板或者触感显示屏等。Optionally, the user interface 703 may include a display, a keyboard, or other pointing devices, such as a mouse, a trackball (trackball), a touch panel, or a touch display screen.

存储器705可能包括高速随机存取记忆体(RAM,Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。可选的,该存储器705还可以包括至少一个位于远离前述处理器701的存储装置。The memory 705 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory 705 may also include at least one storage device located away from the aforementioned processor 701 .

在一些实施方式中,存储器705存储了如下的元素,可执行模块或者数据结构,或者他们的子集,或者他们的扩展集:In some implementations, the memory 705 stores the following elements, executable modules or data structures, or their subsets, or their extensions:

操作系统7051,包含各种系统程序,用于实现各种基础业务以及处理基于硬件的任务;Operating system 7051, including various system programs, used to realize various basic services and handle hardware-based tasks;

应用模块7052,包含各种应用程序,用于实现各种应用业务。The application module 7052 includes various application programs for realizing various application services.

具体地,所述处理器701,用于接收绘图指令,所述绘图指令中包含图元信息、顶点变换信息以及片断着色信息;接收后处理信息,根据所述后处理信息确定预处理信息,所述后处理信息用于表示对待绘制的图层做坐标变换处理;基于所述绘图指令中的顶点变换信息对所述图元信息对应的图元的顶点进行坐标变换处理,得到所述图元的顶点变换中间结果;基于所述预处理信息对所述图元的顶点变换中间结果再次进行坐标变换处理,得到所述图元的顶点变换终极结果;对所述图元的顶点变换终极结果进行光栅化处理,得到所述图元的光栅化处理结果;基于所述绘图指令中的片断着色信息对所述图元的光栅化处理结果进行片断着色处理,得到所述图元的片断着色处理结果;根据所述图元的片断着色处理结果在待绘制的图层的显示范围内进行像素填充得到所述待绘制的图层,将所述待绘制的图层输出显示。Specifically, the processor 701 is configured to receive a drawing instruction, the drawing instruction includes primitive information, vertex transformation information, and fragment shading information; receive post-processing information, determine pre-processing information according to the post-processing information, and The post-processing information is used to represent the coordinate transformation processing of the layer to be drawn; based on the vertex transformation information in the drawing instruction, the coordinate transformation processing is performed on the vertex of the primitive corresponding to the primitive information to obtain the coordinate transformation of the primitive The intermediate result of vertex transformation; based on the preprocessing information, coordinate transformation processing is performed on the intermediate result of vertex transformation of the primitive to obtain the final result of vertex transformation of the primitive; rasterization is performed on the final result of vertex transformation of the primitive performing a fragment shading process on the rasterization processing result of the graphic element based on the fragment shading information in the drawing instruction to obtain a fragment shading processing result of the graphic element; Performing pixel filling within the display range of the layer to be drawn according to the fragment coloring processing result of the primitive to obtain the layer to be drawn, and outputting the layer to be drawn for display.

具体的,当所述待绘制的图层的数目是两个以上时,所述处理器701还用于对两个以上的所述待绘制的图层进行合成处理生成目标目标图像并将所述目标图像输出显示。Specifically, when the number of the layers to be drawn is more than two, the processor 701 is further configured to perform synthesis processing on the two or more layers to be drawn to generate a target image and combine the The target image output is displayed.

作为本发明的一个实施例,所述处理器701具体用于在接收到的所述后处理信息中包含旋转参数时,根据所述旋转参数确定对应的旋转矩阵,所述预处理信息即是该旋转矩阵。具体的,在所述后处理信息中包含的旋转参数中包含的旋转角度是90或者270度时,所述处理器701还用于基于所述旋转参数对所述待绘制的图层的宽属性参数以及高属性参数进行调整,以使调整后的宽高属性与所述待绘制的图层的显示范围相匹配。值得注意的是,所述处理器701还具体用于基于所述旋转矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第二顶点坐标,所述第二顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转的效果。As an embodiment of the present invention, the processor 701 is specifically configured to determine a corresponding rotation matrix according to the rotation parameters when the received post-processing information includes rotation parameters, and the pre-processing information is the rotation matrix. Specifically, when the rotation angle contained in the rotation parameter contained in the post-processing information is 90 or 270 degrees, the processor 701 is further configured to set the width attribute of the layer to be drawn based on the rotation parameter parameters and height attribute parameters are adjusted so that the adjusted width and height attributes match the display range of the layer to be drawn. It is worth noting that the processor 701 is also specifically configured to perform coordinate transformation processing on the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive based on the rotation matrix to obtain the vertex transformation representing the primitive The second vertex coordinate of the final result, the primitive represented by the second vertex coordinate has a rotation effect relative to the primitive represented by the first vertex coordinate.

作为本发明的另一个实施例,所述处理器701具体用于在后处理信息中包含缩放参数时,根据所述缩放参数确定对应的缩放矩阵,所述预处理信息即是该缩放矩阵,值得注意的是,所述缩放参数包括垂直缩放参数和/或水平缩放参数,所述根据所述缩放参数确定对应的缩放矩阵即是根据所述垂直缩放参数和/或水平缩放参数确定对应的缩放矩阵。需要说明的是,在后处理信息中包含缩放参数时,所述处理器701还用于基于所述缩放参数对所述待绘制的图层的宽属性参数以及高属性参数进行调整,以使调整后的宽高属性与所述待绘制的图层的显示范围相匹配。值得注意的是,当所述预处理信息是根据所述后处理信息中包含的缩放参数确定的缩放矩阵时,所述处理器701具体用于基于所述缩放矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第三顶点坐标,所述第三顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有缩放的效果。As another embodiment of the present invention, the processor 701 is specifically configured to determine a corresponding scaling matrix according to the scaling parameter when the post-processing information includes the scaling parameter, and the pre-processing information is the scaling matrix, which is worth It should be noted that the scaling parameters include vertical scaling parameters and/or horizontal scaling parameters, and determining the corresponding scaling matrix according to the scaling parameters is determining the corresponding scaling matrix according to the vertical scaling parameters and/or horizontal scaling parameters . It should be noted that, when the post-processing information includes a scaling parameter, the processor 701 is also configured to adjust the width attribute parameter and the high attribute parameter of the layer to be drawn based on the scaling parameter, so that the adjusted The following width and height attributes match the display range of the layer to be drawn. It should be noted that when the pre-processing information is a scaling matrix determined according to the scaling parameters included in the post-processing information, the processor 701 is specifically configured to represent the vertex of the primitive based on the scaling matrix pair Transform the first vertex coordinates of the intermediate result to the coordinate transformation process again to obtain the third vertex coordinates representing the final result of the vertex transformation of the primitive, and the primitive represented by the third vertex coordinates is expressed relative to the first vertex coordinates The primitives have the effect of scaling.

作为本发明的再一个实施例,所述处理器701具体用于在后处理信息中不仅包含旋转参数还包含缩放参数时,根据所述旋转参数确定出对应的旋转矩阵,根据所述缩放参数确定出对应的缩放矩阵,然后再将所述旋转矩阵乘以所述缩放矩阵得到预处理矩阵,则所述预处理信息即是该预处理矩阵,值得注意的是,所述缩放参数包括垂直缩放参数和/或水平缩放参数,所述根据所述缩放参数确定对应的缩放矩阵即是根据所述垂直缩放参数和/或水平缩放参数确定对应的缩放矩阵。需要说明的是,在后处理信息中不仅包含旋转参数还包含缩放参数时,所述处理器701还用于基于所述旋转参数和所述缩放参数对所述待绘制的图层的宽属性参数以及高属性参数进行调整,以使调整后的宽高属性与所述待绘制的图层的显示范围相匹配。As another embodiment of the present invention, the processor 701 is specifically configured to determine the corresponding rotation matrix according to the rotation parameters when the post-processing information includes not only the rotation parameters but also the scaling parameters, and determine the corresponding rotation matrix according to the scaling parameters. get the corresponding scaling matrix, and then multiply the rotation matrix by the scaling matrix to obtain a preprocessing matrix, then the preprocessing information is the preprocessing matrix, it is worth noting that the scaling parameters include vertical scaling parameters and/or horizontal scaling parameters, the determining the corresponding scaling matrix according to the scaling parameters is determining the corresponding scaling matrix according to the vertical scaling parameters and/or horizontal scaling parameters. It should be noted that, when the post-processing information includes not only the rotation parameter but also the scaling parameter, the processor 701 is also configured to set the width attribute parameter of the layer to be drawn based on the rotation parameter and the scaling parameter and height attribute parameters are adjusted so that the adjusted width and height attributes match the display range of the layer to be drawn.

值得注意的是,当所述后处理信息中包括旋转参数和缩放参数,且所述缩放参数包括垂直缩放参数和/或水平缩放参数,所述预处理信息是根据所述旋转参数确定的旋转矩阵与根据所述缩放参数确定的缩放矩阵的乘积确定的预处理矩阵时,所述处理器701具体用于基于所述预处理矩阵对表示所述图元的顶点变换中间结果的第一顶点坐标再次进行坐标变换处理,得到表示所述图元的顶点变换终极结果的第四顶点坐标,所述第四顶点坐标表示的图元相对于所述第一顶点坐标表示的图元具有旋转和缩放的效果。It should be noted that when the post-processing information includes rotation parameters and scaling parameters, and the scaling parameters include vertical scaling parameters and/or horizontal scaling parameters, the pre-processing information is a rotation matrix determined according to the rotation parameters When the preprocessing matrix is determined by multiplying the scaling matrix determined according to the scaling parameter, the processor 701 is specifically configured to re-determine the first vertex coordinate representing the intermediate result of the vertex transformation of the primitive based on the preprocessing matrix Carry out coordinate transformation processing to obtain the fourth vertex coordinate representing the final result of the vertex transformation of the primitive, and the primitive represented by the fourth vertex coordinate has the effect of rotation and scaling relative to the primitive represented by the first vertex coordinate .

需要说明的是,所述后处理信息是指现有技术中基于OpenGL硬件标准的图层渲染模式下用于指示为绘制完成的图层进行处理的信息,所述后处理信息包括对绘制完成的图层进行旋转和/或缩放以及其他涉及进行坐标变换处理的信息,此处不再一一列举。对应的,所述预处理信息可以是所述旋转和/或缩放矩阵以及其他对图元的顶点坐标进行变换处理的矩阵,所述处理器701能够实现的功能包括但不限于上述实施例所述的功能。It should be noted that the post-processing information refers to the information used to indicate that the drawn layer is processed in the layer rendering mode based on the OpenGL hardware standard in the prior art, and the post-processing information includes the finished drawing Layer rotation and/or scaling and other information related to coordinate transformation processing are not listed here. Correspondingly, the preprocessing information may be the rotation and/or scaling matrix and other matrices for transforming the vertex coordinates of primitives, and the functions that the processor 701 can implement include but are not limited to function.

所述显示器706用于显示所述待绘制的图层。The display 706 is used to display the layer to be drawn.

值得注意的是,当所述待绘制的图层的数目是两个以上时,所述处理器701还用于将两个以上的所述待绘制的图层进行合成生成目标图像,然后将所述目标图像输出显示。对应的,所述显示器706用于显示所述目标图像。It should be noted that when the number of the layers to be drawn is more than two, the processor 701 is further configured to synthesize the two or more layers to be drawn to generate a target image, and then combine the The above target image output display. Correspondingly, the display 706 is used to display the target image.

以上各个设备的具体实施可参见前面的实施例,在此不再赘述。For the specific implementation of each of the above devices, reference may be made to the foregoing embodiments, and details are not repeated here.

可知,采用本发明实施例所述的终端设备绘制图层并显示所述待绘制的图层时,首先在绘制图层时,预处理是在顶点变换阶段中进行的,由于顶点变换阶段针对的只是较少的顶点,所以采用本发明实施例所述的终端设备进行预处理操作时需要处理的数据量比较少,处理代价比较小;再者,在所述待绘制的图层的数目是两个以上时,输出显示所述两个以上图层之前还需要对其进行合成处理以生成目标图像,基于所述待绘制的图层已经完成预处理,所以进行合成时需要处理的数据量比较小,进而能够在一定程度上提升系统的显示性能。It can be seen that when using the terminal device described in the embodiment of the present invention to draw a layer and display the layer to be drawn, firstly, when drawing a layer, preprocessing is performed in the vertex transformation stage, because the vertex transformation stage is aimed at There are only fewer vertices, so when using the terminal device described in the embodiment of the present invention to perform preprocessing operations, the amount of data to be processed is relatively small, and the processing cost is relatively small; moreover, when the number of layers to be drawn is two When there are more than two layers, it is necessary to synthesize them before displaying the two or more layers to generate the target image. Based on the fact that the layers to be drawn have been pre-processed, the amount of data that needs to be processed when synthesizing is relatively small , which can improve the display performance of the system to a certain extent.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those skilled in the art can appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present invention.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions described above are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk, and other media that can store program codes. .

以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。The above is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Anyone skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present invention. Should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims (25)

1. a kind of figure layer method for drafting is it is characterised in that methods described includes:
Receive drawing for order, in described drawing for order, comprise primitive information, summit information converting and segment shading information;
Receive post-processing information, pretreatment information is determined according to described post-processing information, described post-processing information is used for representing right Figure layer to be drawn does coordinate transform processing;
Coordinate change is carried out to the summit of the corresponding pel of described primitive information based on the summit information converting in described drawing for order Change process, obtain the summit conversion intermediate result of described pel;
Coordinate transform processing is carried out again to the summit conversion intermediate result of described pel based on described pretreatment information, obtains institute The summit stating pel converts ultimate result;
Rasterization process is carried out to the summit ultimate result of conversion of described pel, obtains the rasterization process result of described pel;
Based on the segment shading information in described drawing for order, the rasterization process result of described pel is carried out at segment coloring Reason, obtains the segment coloring treatment result of described pel;
Segment coloring treatment result according to described pel is described in carrying out pixel filling and obtaining in the indication range of described figure layer Figure layer to be drawn.
2. figure layer method for drafting according to claim 1 is it is characterised in that described reception post-processing information, according to described Post-processing information determines pretreatment information, including:
Receive post-processing information, described post-processing information includes rotation parameter;
Spin matrix is determined according to the rotation parameter that described post-processing information includes, described spin matrix represents described pretreatment Information;
Described coordinate transform processing is carried out again to the summit of described pel conversion intermediate result based on described pretreatment information, obtain Summit to described pel converts ultimate result, including:
Sat again based on the first apex coordinate that described spin matrix converts intermediate result to the summit representing described pel Mark conversion process, obtains representing that the summit of described pel converts the second apex coordinate of ultimate result, described second apex coordinate The pel that the pel representing represents with respect to described first apex coordinate has the effect of rotation.
3. figure layer method for drafting according to claim 1 is it is characterised in that described reception post-processing information, according to described Post-processing information determines pretreatment information, including:
Receive post-processing information, described post-processing information includes zooming parameter;
Scaled matrix is determined according to the zooming parameter that described post-processing information includes, described scaled matrix represents described pretreatment Information;
Described coordinate transform processing is carried out again to the summit of described pel conversion intermediate result based on described pretreatment information, obtain Summit to described pel converts ultimate result, including:
Sat again based on the first apex coordinate that described scaled matrix converts intermediate result to the summit representing described pel Mark conversion process, obtains representing that the summit of described pel converts the 3rd apex coordinate of ultimate result, described 3rd apex coordinate The pel that the pel representing represents with respect to described first apex coordinate has the effect of scaling.
4. figure layer method for drafting according to claim 1 is it is characterised in that described reception post-processing information, according to described Post-processing information determines pretreatment information, including:
Receive post-processing information, described post-processing information includes rotation parameter and zooming parameter;
Spin matrix is determined according to the rotation parameter that described post-processing information includes;
Scaled matrix is determined according to the zooming parameter that described post-processing information includes;
Described spin matrix is multiplied with described scaled matrix and obtains preconditioning matrix, described preconditioning matrix represents described pre- place Reason information;
Described coordinate transform processing is carried out again to the summit of described pel conversion intermediate result based on described pretreatment information, obtain Summit to described pel converts ultimate result, including:
Carried out again based on the first apex coordinate that described preconditioning matrix converts intermediate result to the summit representing described pel Coordinate transform processing, obtains representing that the summit of described pel converts the 4th apex coordinate of ultimate result, described 4th summit is sat The pel that the pel that mark represents represents with respect to described first apex coordinate has rotation and the effect of scaling.
5. figure layer method for drafting according to claim 2 is it is characterised in that in described reception post-processing information, described after After processing information includes rotation parameter, methods described also includes:
When the anglec of rotation representing in described rotation parameter is 90 or 270 degree, wait to draw to described based on described rotation parameter The wide property parameters of figure layer and high property parameters are adjusted so that the wide attribute after adjusting and high attribute are waited to draw with described The indication range of figure layer match;
In described the first apex coordinate that intermediate result is converted to the summit representing described pel based on described spin matrix again Carry out coordinate transform processing, after obtaining representing that the summit of described pel converts the second apex coordinate of ultimate result, also include:
According to the wide attribute after adjustment and high attribute, the second apex coordinate of ultimate result is converted to the summit representing described pel Carry out cutting, obtain the second apex coordinate after cutting;
The described summit to described pel converts ultimate result and carries out rasterization process, obtains the rasterization process knot of described pel Really, including:
Rasterization process is carried out to the second apex coordinate after described cutting, obtains the rasterization process result of described pel.
6. figure layer method for drafting according to claim 3 is it is characterised in that in described reception post-processing information, described after After processing information includes zooming parameter, methods described also includes:
Based on described zooming parameter, the wide property parameters of described figure layer to be drawn and high property parameters are adjusted so that adjusting Wide attribute after whole and high attribute are matched with the indication range of described figure layer to be drawn;
In described the first apex coordinate that intermediate result is converted to the summit representing described pel based on described scaled matrix again Carry out coordinate transform processing, after obtaining representing that the summit of described pel converts the 3rd apex coordinate of ultimate result, also include:
According to the wide attribute after adjustment and high attribute, the 3rd apex coordinate of ultimate result is converted to the summit representing described pel Carry out cutting, obtain the 3rd apex coordinate after cutting;
The described summit to described pel converts ultimate result and carries out rasterization process, obtains the rasterization process knot of described pel Really, including:
Rasterization process is carried out to the 3rd apex coordinate after described cutting, obtains the rasterization process result of described pel.
7. figure layer method for drafting according to claim 4 is it is characterised in that in described reception post-processing information, described after After processing information includes rotation parameter and zooming parameter, methods described also includes:
Based on described zooming parameter and described rotation parameter to the wide property parameters of described figure layer to be drawn and high property parameters It is adjusted so that the wide attribute after adjusting and high attribute are matched with the indication range of described figure layer to be drawn;
In described the first apex coordinate that intermediate result is converted to the summit representing described pel based on described preconditioning matrix again Secondary carry out coordinate transform processing, after obtaining representing that the summit of described pel converts the 4th apex coordinate of ultimate result, also wrap Include:
According to the wide attribute after adjustment and high attribute, the 4th apex coordinate of ultimate result is converted to the summit representing described pel Carry out cutting, obtain the 4th apex coordinate after cutting;
The described summit to described pel converts ultimate result and carries out rasterization process, obtains the rasterization process knot of described pel Really, including:
Rasterization process is carried out to the 4th apex coordinate after described cutting, obtains the rasterization process result of described pel.
8. a kind of drawing engine is it is characterised in that include:
Receiving unit, for receiving drawing for order, comprises primitive information, summit information converting and segment in described drawing for order Shading information;And be additionally operable to receive post-processing information, described post-processing information is used for representing that the figure layer treating drafting does coordinate Conversion process;
Pretreatment interface unit, for determining pretreatment information according to described post-processing information;
Vertex shader, for based on the summit information converting in described drawing for order to the corresponding pel of described primitive information Summit carries out coordinate transform processing, obtains the summit conversion intermediate result of described pel;And be additionally operable to based on described pretreatment Information carries out coordinate transform processing again to the summit conversion intermediate result of described pel, obtains the summit conversion of described pel eventually Pole result;
Rasterizer, carries out rasterization process for converting ultimate result to the summit of described pel, obtains the light of described pel Gated result;
Fragment shader, for the rasterization process result to described pel based on the segment shading information in described drawing for order Carry out segment coloring treatment, obtain the segment coloring treatment result of described pel;
Figure layer obtaining unit, for the segment coloring treatment result according to described pel described figure layer to be drawn display model Carry out in enclosing pixel filling obtain described in figure layer to be drawn.
9. drawing engine according to claim 8 it is characterised in that:
In the described operation receiving post-processing information, described receiving unit includes the post processing of rotation parameter specifically for receiving Information;
Described pretreatment interface unit specifically for spin matrix is determined according to the rotation parameter that described post-processing information includes, Described spin matrix represents described pretreatment information;
Described, coordinate transform processing is carried out again to the summit conversion intermediate result of described pel based on described pretreatment information, The summit obtaining described pel converts in the operation of ultimate result, and described vertex shader is specifically for based on described spin matrix The first apex coordinate converting intermediate result to the summit representing described pel carries out coordinate transform processing again, obtains representing institute The summit stating pel converts the second apex coordinate of ultimate result, and the pel that wherein said second apex coordinate represents is with respect to institute State the effect that the pel that the first apex coordinate represents has rotation.
10. drawing engine according to claim 8 it is characterised in that:
Described receiving unit includes the post-processing information of zooming parameter specifically for receiving;
Described pretreatment interface unit specifically for scaled matrix is determined according to the zooming parameter that described post-processing information includes, Described scaled matrix represents described pretreatment information;
Described, coordinate transform processing is carried out again to the summit conversion intermediate result of described pel based on described pretreatment information, The summit obtaining described pel converts in the operation of ultimate result, and described vertex shader is specifically for based on described scaled matrix The first apex coordinate converting intermediate result to the summit representing described pel carries out coordinate transform processing again, obtains representing institute The summit stating pel converts the 3rd apex coordinate of ultimate result, and the pel that described 3rd apex coordinate represents is with respect to described the The pel that one apex coordinate represents has the effect of scaling.
11. drawing engines according to claim 8 it is characterised in that:
Described receiving unit includes the post-processing information of rotation parameter and zooming parameter specifically for receiving;
Described pretreatment interface unit specifically for spin matrix is determined according to the rotation parameter that described post-processing information includes, Scaled matrix is determined according to the zooming parameter that described post-processing information includes, by described spin matrix and described scaled matrix phase Multiplied to preconditioning matrix, described preconditioning matrix represents described pretreatment information;
Described, coordinate transform processing is carried out again to the summit conversion intermediate result of described pel based on described pretreatment information, The summit obtaining described pel converts in the operation of ultimate result, and described vertex shader is specifically for based on described pretreatment square The first apex coordinate that battle array converts intermediate result to the summit representing described pel carries out coordinate transform processing again, is represented The summit of described pel converts the 4th apex coordinate of ultimate result, and the pel that described 4th apex coordinate represents is with respect to described The pel that first apex coordinate represents has rotation and the effect of scaling.
12. drawing engines according to claim 9 it is characterised in that:
When the anglec of rotation that described pretreatment interface unit is additionally operable to represent in described rotation parameter is 90 or 270 degree, it is based on Described rotation parameter is adjusted the width so that after adjusting to the described wide property parameters wait the figure layer drawn and high property parameters Attribute and high attribute are matched with the indication range of described figure layer to be drawn;
Described vertex shader is additionally operable to according to the wide attribute after adjusting and high attribute, whole to the summit conversion representing described pel Second apex coordinate of pole result carries out cutting, obtains the second apex coordinate after cutting;
Described rasterizer, specifically for carrying out rasterization process to the second apex coordinate after described cutting, obtains described pel Rasterization process result.
13. drawing engines according to claim 10 it is characterised in that:
Described pretreatment interface unit be additionally operable to based on described zooming parameter to the wide property parameters of described figure layer to be drawn and High property parameters are adjusted the indication range phase so that wide attribute after adjusting and high attribute and described figure layer to be drawn Join;
Described vertex shader is additionally operable to according to the wide attribute after adjusting and high attribute, whole to the summit conversion representing described pel 3rd apex coordinate of pole result carries out cutting, obtains the 3rd apex coordinate after cutting;
Described rasterizer, specifically for carrying out rasterization process to the 3rd apex coordinate after described cutting, obtains described pel Rasterization process result.
14. drawing engines according to claim 11 it is characterised in that:
Described pretreatment interface unit is additionally operable to based on described zooming parameter and described rotation parameter to described figure layer to be drawn Wide property parameters and high property parameters are adjusted so that wide attribute after adjusting and high attribute and described figure layer to be drawn Indication range match;
Described vertex shader is additionally operable to according to the wide attribute after adjusting and high attribute, and to expression, described summit converts ultimate result The 4th apex coordinate carry out cutting, obtain the 4th apex coordinate after cutting;
Described rasterizer, specifically for carrying out rasterization process to the 4th apex coordinate after described cutting, obtains described pel Rasterization process result.
A kind of 15. display packings are it is characterised in that methods described includes:
Receive drawing for order, in described drawing for order, comprise primitive information, summit information converting and segment shading information;
Receive post-processing information, pretreatment information is determined according to described post-processing information, described post-processing information is used for representing right Figure layer to be drawn does coordinate transform processing;
Coordinate change is carried out to the summit of the corresponding pel of described primitive information based on the summit information converting in described drawing for order Change process, obtain the summit conversion intermediate result of described pel;
Coordinate transform processing is carried out again to the summit conversion intermediate result of described pel based on described pretreatment information, obtains institute The summit stating pel converts ultimate result;
Rasterization process is carried out to the summit ultimate result of conversion of described pel, obtains the rasterization process result of described pel;
Based on the segment shading information in described drawing for order, the rasterization process result of described pel is carried out at segment coloring Reason, obtains the segment coloring treatment result of described pel;
Pixel filling is carried out in the indication range of described figure layer to be drawn according to the segment coloring treatment result of described pel Figure layer to be drawn described in obtaining;
By described figure layer output display to be drawn.
16. display packings according to claim 15 it is characterised in that:
When the described number wait the figure layer drawn is two or more,
Described by described figure layer output display to be drawn, including:
Plural described figure layer to be drawn is carried out with synthesis process generation target image and export described target image Display.
17. display packings according to claim 15 or 16 it is characterised in that described reception post-processing information, according to institute State post-processing information and determine pretreatment information, including:
Receive post-processing information, described post-processing information includes rotation parameter;
Spin matrix is determined according to the rotation parameter that described post-processing information includes, described spin matrix represents described pretreatment Information;
Described coordinate transform processing is carried out again to the summit of described pel conversion intermediate result based on described pretreatment information, obtain Summit to described pel converts ultimate result, including:
Sat again based on the first apex coordinate that described spin matrix converts intermediate result to the summit representing described pel Mark conversion process, obtains representing that the summit of described pel converts the second apex coordinate of ultimate result, described second apex coordinate The pel that the pel representing represents with respect to described first apex coordinate has the effect of rotation.
18. display packings according to claim 15 or 16 it is characterised in that described reception post-processing information, according to institute State post-processing information and determine pretreatment information, including:
Receive post-processing information, described post-processing information includes zooming parameter;
Scaled matrix is determined according to the zooming parameter that described post-processing information includes, described scaled matrix represents described pretreatment Information;
Described coordinate transform processing is carried out again to the summit of described pel conversion intermediate result based on described pretreatment information, obtain Summit to described pel converts ultimate result, including:
Sat again based on the first apex coordinate that described scaled matrix converts intermediate result to the summit representing described pel Mark conversion process, obtains representing that the summit of described pel converts the 3rd apex coordinate of ultimate result, described 3rd apex coordinate The pel that the pel representing represents with respect to described first apex coordinate has the effect of scaling.
19. display packings according to claim 15 or 16 it is characterised in that described reception post-processing information, according to institute State post-processing information and determine pretreatment information, including:
Receive post-processing information, described post-processing information includes rotation parameter and zooming parameter;
Spin matrix is determined according to the rotation parameter that described post-processing information includes;
Scaled matrix is determined according to the zooming parameter that described post-processing information includes;
Described spin matrix is multiplied with described scaled matrix and obtains preconditioning matrix, described preconditioning matrix represents described pre- place Reason information;
Described coordinate transform processing is carried out again to the summit of described pel conversion intermediate result based on described pretreatment information, obtain Summit to described pel converts ultimate result, including:
Carried out again based on the first apex coordinate that described preconditioning matrix converts intermediate result to the summit representing described pel Coordinate transform processing, obtains representing that the summit of described pel converts the 4th apex coordinate of ultimate result, described 4th summit is sat The pel that the pel that mark represents represents with respect to described first apex coordinate has rotation and the effect of scaling.
20. display packings according to claim 17 it is characterised in that in described reception post-processing information, described after locate After reason information includes rotation parameter, methods described also includes:
When the anglec of rotation representing in described rotation parameter is 90 or 270 degree, wait to draw to described based on described rotation parameter The wide property parameters of figure layer and high property parameters are adjusted so that the wide attribute after adjusting and high attribute are waited to draw with described The indication range of figure layer match;
In described the first apex coordinate that intermediate result is converted to the summit representing described pel based on described spin matrix again Carry out coordinate transform processing, after obtaining representing that the summit of described pel converts the second apex coordinate of ultimate result, also include:
According to the wide attribute after adjustment and high attribute, the second apex coordinate of ultimate result is converted to the summit representing described pel Carry out cutting, obtain the second apex coordinate after cutting;
The described summit to described pel converts ultimate result and carries out rasterization process, obtains the rasterization process knot of described pel Really, including:
Rasterization process is carried out to the second apex coordinate after described cutting, obtains the rasterization process result of described pel.
21. display packings according to claim 18 it is characterised in that in described reception post-processing information, described after locate After reason information includes zooming parameter, methods described also includes:
Based on described zooming parameter, the wide property parameters of described figure layer to be drawn and high property parameters are adjusted so that adjusting Wide attribute after whole and high attribute are matched with the indication range of described figure layer to be drawn;
In described the first apex coordinate that intermediate result is converted to the summit representing described pel based on described scaled matrix again Carry out coordinate transform processing, after obtaining representing that the summit of described pel converts the 3rd apex coordinate of ultimate result, also include:
According to the wide attribute after adjustment and high attribute, the 3rd apex coordinate of ultimate result is converted to the summit representing described pel Carry out cutting, obtain the 3rd apex coordinate after cutting;
The described summit to described pel converts ultimate result and carries out rasterization process, obtains the rasterization process knot of described pel Really, including:
Rasterization process is carried out to the 3rd apex coordinate after described cutting, obtains the rasterization process result of described pel.
22. display packings according to claim 19 it is characterised in that in described reception post-processing information, described after locate After reason information includes rotation parameter and zooming parameter, methods described also includes:
Based on described zooming parameter and described rotation parameter to the wide property parameters of described figure layer to be drawn and high property parameters It is adjusted so that the wide attribute after adjusting and high attribute are matched with the indication range of described figure layer to be drawn;
In described the first apex coordinate that intermediate result is converted to the summit representing described pel based on described preconditioning matrix again Secondary carry out coordinate transform processing, after obtaining representing that the summit of described pel converts the 4th apex coordinate of ultimate result, also wrap Include:
According to the wide attribute after adjustment and high attribute, the 4th apex coordinate of ultimate result is converted to the summit representing described pel Carry out cutting, obtain the 4th apex coordinate after cutting;
The described summit to described pel converts ultimate result and carries out rasterization process, obtains the rasterization process knot of described pel Really, including:
Rasterization process is carried out to the 4th apex coordinate after described cutting, obtains the rasterization process result of described pel.
A kind of 23. terminal units are it is characterised in that include display controller, display screen assembly and as claim 8-14 Drawing engine described in any one, wherein:
Described display controller be used for by described drawing engine obtain described in figure layer output display to be drawn to described display On screen assembly.
24. terminal units according to claim 23 it is characterised in that:
When the described number wait the figure layer drawn is two or more, described display controller is specifically for by described drawing engine The plural described figure layer to be drawn obtaining carries out being synthetically generated target image and by described target image output display To on described display screen assembly.
25. terminal units according to claim 23 are it is characterised in that also include synthesizer, wherein:
When the described number wait the figure layer drawn is two or more, described synthesizer is used for obtain described drawing engine two Individual above described in figure layer to be drawn carry out being synthetically generated target image;
Described display controller is specifically for by described target image output display to described display screen assembly.
CN201310671747.5A 2013-12-10 2013-12-10 Coverage drawing method, drawing engine and terminal equipment Active CN103677828B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310671747.5A CN103677828B (en) 2013-12-10 2013-12-10 Coverage drawing method, drawing engine and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310671747.5A CN103677828B (en) 2013-12-10 2013-12-10 Coverage drawing method, drawing engine and terminal equipment

Publications (2)

Publication Number Publication Date
CN103677828A CN103677828A (en) 2014-03-26
CN103677828B true CN103677828B (en) 2017-02-22

Family

ID=50315495

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310671747.5A Active CN103677828B (en) 2013-12-10 2013-12-10 Coverage drawing method, drawing engine and terminal equipment

Country Status (1)

Country Link
CN (1) CN103677828B (en)

Families Citing this family (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9684950B2 (en) * 2014-12-18 2017-06-20 Qualcomm Incorporated Vision correction through graphics processing
CN104809684B (en) 2015-04-02 2018-03-27 华为技术有限公司 Graphic processing method, apparatus and system
US10068366B2 (en) * 2016-05-05 2018-09-04 Nvidia Corporation Stereo multi-projection implemented using a graphics processing pipeline
CN106534880A (en) * 2016-11-28 2017-03-22 深圳Tcl数字技术有限公司 Video synthesis method and device
CN108933955A (en) * 2017-05-24 2018-12-04 阿里巴巴集团控股有限公司 A kind of method for drafting and device
CN107621951B (en) * 2017-08-29 2020-12-29 口碑(上海)信息技术有限公司 View level optimization method and device
CN107808367B (en) * 2017-11-29 2020-10-16 天津聚飞创新科技有限公司 Fisheye image correction method and device, unmanned aerial vehicle and storage medium
CN110018812B (en) * 2018-01-08 2022-09-09 北京蓝亚盒子科技有限公司 Graph drawing method and device
CN108711179B (en) * 2018-05-21 2022-07-19 杭州多技教育科技有限公司 Drawing reduction method and system
CN109840881B (en) * 2018-12-12 2023-05-05 奥比中光科技集团股份有限公司 3D special effect image generation method, device and equipment
CN109634548B (en) * 2018-12-24 2022-05-03 广州励丰文化科技股份有限公司 Layer cross-channel output method and system based on media server control system
CN109828818B (en) * 2019-01-29 2022-03-01 广联达科技股份有限公司 Primitive style transformation method based on browser-side display engine
CN110764764B (en) * 2019-09-16 2024-03-01 平安科技(深圳)有限公司 Webpage end image fixed stretching method and device, computer equipment and storage medium
CN110764757B (en) * 2019-10-22 2023-06-09 成都九洲电子信息系统股份有限公司 Interactive graphic drawing engine based on HTML5
CN112925593A (en) * 2019-12-05 2021-06-08 北京沃东天骏信息技术有限公司 Method and device for scaling and rotating target layer
CN111461960B (en) * 2020-03-19 2022-08-16 稿定(厦门)科技有限公司 Multi-layer matrix transformation method and device
CN113687823B (en) * 2021-07-30 2023-08-01 稿定(厦门)科技有限公司 Quadrilateral block nonlinear transformation method and system based on HTML
CN114781314B (en) * 2021-12-31 2025-09-16 杭州广立微电子股份有限公司 Method and system for rapidly drawing layout
CN116051627B (en) * 2023-02-02 2023-06-13 杭州比智科技有限公司 Method and system for realizing graphic self-adaption based on svg and Lottie

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1111502A2 (en) * 1999-12-16 2001-06-27 Class Technology Co., Ltd. Management of object oriented classes and methods
CN101017566A (en) * 2006-10-24 2007-08-15 图诚科技股份有限公司 Systems and methods for geometry processing
CN101388109A (en) * 2008-01-25 2009-03-18 威盛电子股份有限公司 Graphics processing system, cache system and data processing method
CN102104704A (en) * 2009-12-22 2011-06-22 佳能株式会社 Printing apparatus and printing apparatus control method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1111502A2 (en) * 1999-12-16 2001-06-27 Class Technology Co., Ltd. Management of object oriented classes and methods
CN101017566A (en) * 2006-10-24 2007-08-15 图诚科技股份有限公司 Systems and methods for geometry processing
CN101388109A (en) * 2008-01-25 2009-03-18 威盛电子股份有限公司 Graphics processing system, cache system and data processing method
CN102104704A (en) * 2009-12-22 2011-06-22 佳能株式会社 Printing apparatus and printing apparatus control method

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
图层技术在储层可视化中的应用研究;曲小纳;《中国优秀硕士学位论文全文数据库 信息科技辑》;20101015(第10期);第I138-617页 *
基于可编程图形硬件加速的若干技术研究;董朝;《中国优秀博硕士学位论文全文数据库(硕士) 信息科技辑》;20050615(第02期);第I138-604页 *
基于延迟着色技术的实时渲染引擎的研究;潘兆焕;《中国优秀硕士学位论文全文数据库 信息科技辑》;20110915(第09期);第I138-1181页 *

Also Published As

Publication number Publication date
CN103677828A (en) 2014-03-26

Similar Documents

Publication Publication Date Title
CN103677828B (en) Coverage drawing method, drawing engine and terminal equipment
US10614549B2 (en) Varying effective resolution by screen location by changing active color sample count within multiple render targets
JP6563048B2 (en) Tilt adjustment of texture mapping for multiple rendering targets with different resolutions depending on screen position
JP6392370B2 (en) An efficient re-rendering method for objects to change the viewport under various rendering and rasterization parameters
US8704830B2 (en) System and method for path rendering with multiple stencil samples per color sample
US9183651B2 (en) Target independent rasterization
US8044955B1 (en) Dynamic tessellation spreading for resolution-independent GPU anti-aliasing and rendering
US10331448B2 (en) Graphics processing apparatus and method of processing texture in graphics pipeline
JP6185211B1 (en) Bandwidth reduction using texture lookup with adaptive shading
JP2018537755A (en) Foveal geometry tessellation
US11120591B2 (en) Variable rasterization rate
KR102499397B1 (en) Method and apparatus for performing graphics pipelines
US12236541B2 (en) Geometry-aware augmented reality effects with real-time depth map
US20140320523A1 (en) Tessellation of two-dimensional curves using a graphics pipeline
CN114902274A (en) Hybrid binning
US11417058B2 (en) Anti-aliasing two-dimensional vector graphics using a multi-vertex buffer
US11302054B2 (en) Varying effective resolution by screen location by changing active color sample count within multiple render targets
KR102818622B1 (en) Method and apparatus for processing texture
US10311627B2 (en) Graphics processing apparatus and method of processing graphics pipeline thereof
JP5846373B2 (en) Image processing apparatus, image processing method, image processing program, and image processing system
US20240242403A1 (en) System and Method for Creating a Design Tool Using a Clockwise Fill Rule
KR101337558B1 (en) Mobile terminal having hub function for high resolution images or stereoscopic images, and method for providing high resolution images or stereoscopic images using the mobile terminal
WO2022135050A1 (en) Rendering method, device, and system
Nunes et al. Rendering tubes from discrete curves using hardware tessellation
HK1170051B (en) Target independent rasterization

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant