@next2d/webgl 1.14.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/BezierConverter.d.ts +59 -0
- package/dist/BezierConverter.js +106 -0
- package/dist/CanvasGradientToWebGL.d.ts +96 -0
- package/dist/CanvasGradientToWebGL.js +181 -0
- package/dist/CanvasPatternToWebGL.d.ts +39 -0
- package/dist/CanvasPatternToWebGL.js +66 -0
- package/dist/CanvasToWebGLContext.d.ts +591 -0
- package/dist/CanvasToWebGLContext.js +1427 -0
- package/dist/CanvasToWebGLContextBlend.d.ts +97 -0
- package/dist/CanvasToWebGLContextBlend.js +299 -0
- package/dist/CanvasToWebGLContextGrid.d.ts +74 -0
- package/dist/CanvasToWebGLContextGrid.js +283 -0
- package/dist/CanvasToWebGLContextMask.d.ts +113 -0
- package/dist/CanvasToWebGLContextMask.js +436 -0
- package/dist/CanvasToWebGLContextPath.d.ts +111 -0
- package/dist/CanvasToWebGLContextPath.js +210 -0
- package/dist/CanvasToWebGLContextStyle.d.ts +78 -0
- package/dist/CanvasToWebGLContextStyle.js +139 -0
- package/dist/ColorBufferPool.d.ts +58 -0
- package/dist/ColorBufferPool.js +134 -0
- package/dist/FrameBufferManager.d.ts +135 -0
- package/dist/FrameBufferManager.js +358 -0
- package/dist/StencilBufferPool.d.ts +56 -0
- package/dist/StencilBufferPool.js +142 -0
- package/dist/TextureManager.d.ts +130 -0
- package/dist/TextureManager.js +296 -0
- package/dist/VertexArrayObjectManager.d.ts +96 -0
- package/dist/VertexArrayObjectManager.js +277 -0
- package/dist/WebGLFillMeshGenerator.d.ts +31 -0
- package/dist/WebGLFillMeshGenerator.js +101 -0
- package/dist/WebGLStrokeMeshGenerator.d.ts +183 -0
- package/dist/WebGLStrokeMeshGenerator.js +504 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/interface/AttachmentImpl.d.ts +11 -0
- package/dist/interface/AttachmentImpl.js +1 -0
- package/dist/interface/BoundsImpl.d.ts +6 -0
- package/dist/interface/BoundsImpl.js +1 -0
- package/dist/interface/CapsStyleImpl.d.ts +1 -0
- package/dist/interface/CapsStyleImpl.js +1 -0
- package/dist/interface/ClipObjectImpl.d.ts +14 -0
- package/dist/interface/ClipObjectImpl.js +1 -0
- package/dist/interface/FillMeshImpl.d.ts +5 -0
- package/dist/interface/FillMeshImpl.js +1 -0
- package/dist/interface/GradientTypeImpl.d.ts +1 -0
- package/dist/interface/GradientTypeImpl.js +1 -0
- package/dist/interface/GridImpl.d.ts +6 -0
- package/dist/interface/GridImpl.js +1 -0
- package/dist/interface/IndexRangeImpl.d.ts +4 -0
- package/dist/interface/IndexRangeImpl.js +1 -0
- package/dist/interface/InterpolationMethodImpl.d.ts +1 -0
- package/dist/interface/InterpolationMethodImpl.js +1 -0
- package/dist/interface/JointStyleImpl.d.ts +1 -0
- package/dist/interface/JointStyleImpl.js +1 -0
- package/dist/interface/SpreadMethodImpl.d.ts +1 -0
- package/dist/interface/SpreadMethodImpl.js +1 -0
- package/dist/interface/StrokeMethImpl.d.ts +4 -0
- package/dist/interface/StrokeMethImpl.js +1 -0
- package/dist/interface/UniformDataImpl.d.ts +5 -0
- package/dist/interface/UniformDataImpl.js +1 -0
- package/dist/interface/VerticesImpl.d.ts +1 -0
- package/dist/interface/VerticesImpl.js +1 -0
- package/dist/shader/CanvasToWebGLShader.d.ts +85 -0
- package/dist/shader/CanvasToWebGLShader.js +192 -0
- package/dist/shader/CanvasToWebGLShaderList.d.ts +70 -0
- package/dist/shader/CanvasToWebGLShaderList.js +109 -0
- package/dist/shader/GradientLUTGenerator.d.ts +36 -0
- package/dist/shader/GradientLUTGenerator.js +123 -0
- package/dist/shader/WebGLShaderUniform.d.ts +52 -0
- package/dist/shader/WebGLShaderUniform.js +165 -0
- package/dist/shader/fragment/FragmentShaderLibrary.d.ts +18 -0
- package/dist/shader/fragment/FragmentShaderLibrary.js +35 -0
- package/dist/shader/fragment/FragmentShaderSource.d.ts +29 -0
- package/dist/shader/fragment/FragmentShaderSource.js +99 -0
- package/dist/shader/fragment/FragmentShaderSourceBlend.d.ts +67 -0
- package/dist/shader/fragment/FragmentShaderSourceBlend.js +319 -0
- package/dist/shader/fragment/FragmentShaderSourceGradient.d.ts +44 -0
- package/dist/shader/fragment/FragmentShaderSourceGradient.js +114 -0
- package/dist/shader/fragment/FragmentShaderSourceGradientLUT.d.ts +14 -0
- package/dist/shader/fragment/FragmentShaderSourceGradientLUT.js +58 -0
- package/dist/shader/fragment/FragmentShaderSourceTexture.d.ts +12 -0
- package/dist/shader/fragment/FragmentShaderSourceTexture.js +36 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceBlurFilter.d.ts +12 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceBlurFilter.js +42 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceColorMatrixFilter.d.ts +11 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceColorMatrixFilter.js +35 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.d.ts +16 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.js +80 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceDisplacementMapFilter.d.ts +15 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceDisplacementMapFilter.js +106 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceFilter.d.ts +112 -0
- package/dist/shader/fragment/filter/FragmentShaderSourceFilter.js +275 -0
- package/dist/shader/variants/BlendShaderVariantCollection.d.ts +99 -0
- package/dist/shader/variants/BlendShaderVariantCollection.js +239 -0
- package/dist/shader/variants/FilterShaderVariantCollection.d.ts +150 -0
- package/dist/shader/variants/FilterShaderVariantCollection.js +395 -0
- package/dist/shader/variants/GradientLUTShaderVariantCollection.d.ts +49 -0
- package/dist/shader/variants/GradientLUTShaderVariantCollection.js +107 -0
- package/dist/shader/variants/GradientShapeShaderVariantCollection.d.ts +61 -0
- package/dist/shader/variants/GradientShapeShaderVariantCollection.js +196 -0
- package/dist/shader/variants/ShapeShaderVariantCollection.d.ts +117 -0
- package/dist/shader/variants/ShapeShaderVariantCollection.js +427 -0
- package/dist/shader/vertex/VertexShaderLibrary.d.ts +18 -0
- package/dist/shader/vertex/VertexShaderLibrary.js +75 -0
- package/dist/shader/vertex/VertexShaderSource.d.ts +23 -0
- package/dist/shader/vertex/VertexShaderSource.js +92 -0
- package/dist/shader/vertex/VertexShaderSourceFill.d.ts +45 -0
- package/dist/shader/vertex/VertexShaderSourceFill.js +112 -0
- package/dist/shader/vertex/VertexShaderSourceStroke.d.ts +27 -0
- package/dist/shader/vertex/VertexShaderSourceStroke.js +149 -0
- package/package.json +37 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import { CanvasToWebGLShader } from "../CanvasToWebGLShader";
|
|
2
|
+
import { VertexShaderSourceStroke } from "../vertex/VertexShaderSourceStroke";
|
|
3
|
+
import { VertexShaderSourceFill } from "../vertex/VertexShaderSourceFill";
|
|
4
|
+
import { FragmentShaderSource } from "../fragment/FragmentShaderSource";
|
|
5
|
+
import { $getMap } from "@next2d/share";
|
|
6
|
+
/**
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
export class ShapeShaderVariantCollection {
|
|
10
|
+
/**
|
|
11
|
+
* @param {CanvasToWebGLContext} context
|
|
12
|
+
* @param {WebGL2RenderingContext} gl
|
|
13
|
+
* @constructor
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
constructor(context, gl) {
|
|
17
|
+
/**
|
|
18
|
+
* @type {CanvasToWebGLContext}
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
this._$context = context;
|
|
22
|
+
/**
|
|
23
|
+
* @type {WebGL2RenderingContext}
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
this._$gl = gl;
|
|
27
|
+
/**
|
|
28
|
+
* @type {Map}
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
this._$collection = $getMap();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @param {boolean} is_stroke
|
|
35
|
+
* @param {boolean} has_grid
|
|
36
|
+
* @return {CanvasToWebGLShader}
|
|
37
|
+
* @method
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
getSolidColorShapeShader(is_stroke, has_grid) {
|
|
41
|
+
const key = `s${is_stroke ? "y" : "n"}${has_grid ? "y" : "n"}`;
|
|
42
|
+
if (this._$collection.has(key)) {
|
|
43
|
+
const shader = this._$collection.get(key);
|
|
44
|
+
if (shader) {
|
|
45
|
+
return shader;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const highpLength = (has_grid ? 8 : 3) + (is_stroke ? 1 : 0);
|
|
49
|
+
const fragmentIndex = highpLength;
|
|
50
|
+
let vertexShaderSource;
|
|
51
|
+
if (is_stroke) {
|
|
52
|
+
vertexShaderSource = VertexShaderSourceStroke.TEMPLATE(highpLength, fragmentIndex, false, has_grid);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
vertexShaderSource = VertexShaderSourceFill.TEMPLATE(highpLength, false, false, has_grid);
|
|
56
|
+
}
|
|
57
|
+
const shader = new CanvasToWebGLShader(this._$gl, this._$context, vertexShaderSource, FragmentShaderSource.SOLID_COLOR());
|
|
58
|
+
this._$collection.set(key, shader);
|
|
59
|
+
return shader;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @param {boolean} is_stroke
|
|
63
|
+
* @param {boolean} repeat
|
|
64
|
+
* @param {boolean} has_grid
|
|
65
|
+
* @return {CanvasToWebGLShader}
|
|
66
|
+
* @method
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
getBitmapShapeShader(is_stroke, repeat, has_grid) {
|
|
70
|
+
const key = `b${is_stroke ? "y" : "n"}${repeat ? "y" : "n"}${has_grid ? "y" : "n"}`;
|
|
71
|
+
if (this._$collection.has(key)) {
|
|
72
|
+
const shader = this._$collection.get(key);
|
|
73
|
+
if (shader) {
|
|
74
|
+
return shader;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const highpLength = (has_grid ? 13 : 5) + (is_stroke ? 1 : 0);
|
|
78
|
+
const fragmentIndex = highpLength;
|
|
79
|
+
let vertexShaderSource;
|
|
80
|
+
if (is_stroke) {
|
|
81
|
+
vertexShaderSource = VertexShaderSourceStroke.TEMPLATE(highpLength, fragmentIndex, true, has_grid);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
vertexShaderSource = VertexShaderSourceFill.TEMPLATE(highpLength, true, false, has_grid);
|
|
85
|
+
}
|
|
86
|
+
const fragmentShaderSource = repeat
|
|
87
|
+
? FragmentShaderSource.BITMAP_PATTERN()
|
|
88
|
+
: FragmentShaderSource.BITMAP_CLIPPED();
|
|
89
|
+
const shader = new CanvasToWebGLShader(this._$gl, this._$context, vertexShaderSource, fragmentShaderSource);
|
|
90
|
+
this._$collection.set(key, shader);
|
|
91
|
+
return shader;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @param {boolean} is_stroke
|
|
95
|
+
* @param {boolean} has_grid
|
|
96
|
+
* @return {CanvasToWebGLShader}
|
|
97
|
+
* @method
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
getMaskShapeShader(is_stroke, has_grid) {
|
|
101
|
+
const key = `m${is_stroke ? "y" : "n"}${has_grid ? "y" : "n"}`;
|
|
102
|
+
if (this._$collection.has(key)) {
|
|
103
|
+
const shader = this._$collection.get(key);
|
|
104
|
+
if (shader) {
|
|
105
|
+
return shader;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const highpLength = (has_grid ? 8 : 3) + (is_stroke ? 1 : 0);
|
|
109
|
+
const fragmentIndex = highpLength;
|
|
110
|
+
let vertexShaderSource;
|
|
111
|
+
if (is_stroke) {
|
|
112
|
+
vertexShaderSource = VertexShaderSourceStroke.TEMPLATE(highpLength, fragmentIndex, false, has_grid);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
vertexShaderSource = VertexShaderSourceFill.TEMPLATE(highpLength, false, true, has_grid);
|
|
116
|
+
}
|
|
117
|
+
const shader = new CanvasToWebGLShader(this._$gl, this._$context, vertexShaderSource, FragmentShaderSource.MASK());
|
|
118
|
+
this._$collection.set(key, shader);
|
|
119
|
+
return shader;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @param {WebGLShaderUniform} uniform
|
|
123
|
+
* @param {boolean} is_stroke
|
|
124
|
+
* @param {number} half_width
|
|
125
|
+
* @param {number} face
|
|
126
|
+
* @param {number} miter_limit
|
|
127
|
+
* @param {boolean} has_grid
|
|
128
|
+
* @param {array} matrix
|
|
129
|
+
* @param {number} viewport_width
|
|
130
|
+
* @param {number} viewport_height
|
|
131
|
+
* @param {CanvasToWebGLContextGrid} [grid = null]
|
|
132
|
+
* @param {array} color
|
|
133
|
+
* @param {number} alpha
|
|
134
|
+
* @method
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
setSolidColorShapeUniform(uniform, is_stroke, half_width, face, miter_limit, has_grid, matrix, viewport_width, viewport_height, grid, color, alpha) {
|
|
138
|
+
const highp = uniform.highp;
|
|
139
|
+
let i;
|
|
140
|
+
if (has_grid) {
|
|
141
|
+
// vertex: u_parent_matrix
|
|
142
|
+
highp[0] = grid.parentMatrixA;
|
|
143
|
+
highp[1] = grid.parentMatrixB;
|
|
144
|
+
highp[2] = grid.parentMatrixC;
|
|
145
|
+
highp[4] = grid.parentMatrixD;
|
|
146
|
+
highp[5] = grid.parentMatrixE;
|
|
147
|
+
highp[6] = grid.parentMatrixF;
|
|
148
|
+
highp[8] = grid.parentMatrixG;
|
|
149
|
+
highp[9] = grid.parentMatrixH;
|
|
150
|
+
highp[10] = grid.parentMatrixI;
|
|
151
|
+
// vertex: u_ancestor_matrix
|
|
152
|
+
highp[12] = grid.ancestorMatrixA;
|
|
153
|
+
highp[13] = grid.ancestorMatrixB;
|
|
154
|
+
highp[14] = grid.ancestorMatrixC;
|
|
155
|
+
highp[16] = grid.ancestorMatrixD;
|
|
156
|
+
highp[17] = grid.ancestorMatrixE;
|
|
157
|
+
highp[18] = grid.ancestorMatrixF;
|
|
158
|
+
highp[20] = grid.ancestorMatrixG;
|
|
159
|
+
highp[21] = grid.ancestorMatrixH;
|
|
160
|
+
highp[22] = grid.ancestorMatrixI;
|
|
161
|
+
// vertex: u_viewport
|
|
162
|
+
highp[3] = viewport_width;
|
|
163
|
+
highp[7] = viewport_height;
|
|
164
|
+
// vertex: u_parent_viewport
|
|
165
|
+
highp[11] = grid.parentViewportX;
|
|
166
|
+
highp[15] = grid.parentViewportY;
|
|
167
|
+
highp[19] = grid.parentViewportW;
|
|
168
|
+
highp[23] = grid.parentViewportH;
|
|
169
|
+
// vertex: u_grid_min
|
|
170
|
+
highp[24] = grid.minXST;
|
|
171
|
+
highp[25] = grid.minYST;
|
|
172
|
+
highp[26] = grid.minXPQ;
|
|
173
|
+
highp[27] = grid.minYPQ;
|
|
174
|
+
// vertex: u_grid_max
|
|
175
|
+
highp[28] = grid.maxXST;
|
|
176
|
+
highp[29] = grid.maxYST;
|
|
177
|
+
highp[30] = grid.maxXPQ;
|
|
178
|
+
highp[31] = grid.maxYPQ;
|
|
179
|
+
i = 32;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// vertex: u_matrix
|
|
183
|
+
highp[0] = matrix[0];
|
|
184
|
+
highp[1] = matrix[1];
|
|
185
|
+
highp[2] = matrix[2];
|
|
186
|
+
highp[4] = matrix[3];
|
|
187
|
+
highp[5] = matrix[4];
|
|
188
|
+
highp[6] = matrix[5];
|
|
189
|
+
highp[8] = matrix[6];
|
|
190
|
+
highp[9] = matrix[7];
|
|
191
|
+
highp[10] = matrix[8];
|
|
192
|
+
// vertex: u_viewport
|
|
193
|
+
highp[3] = viewport_width;
|
|
194
|
+
highp[7] = viewport_height;
|
|
195
|
+
i = 12;
|
|
196
|
+
}
|
|
197
|
+
if (is_stroke) {
|
|
198
|
+
// vertex: u_half_width
|
|
199
|
+
highp[i] = half_width;
|
|
200
|
+
// vertex: u_face
|
|
201
|
+
highp[i + 1] = face;
|
|
202
|
+
// vertex: u_miter_limit
|
|
203
|
+
highp[i + 2] = miter_limit;
|
|
204
|
+
}
|
|
205
|
+
const mediump = uniform.mediump;
|
|
206
|
+
// fragment: u_color
|
|
207
|
+
mediump[0] = color[0];
|
|
208
|
+
mediump[1] = color[1];
|
|
209
|
+
mediump[2] = color[2];
|
|
210
|
+
mediump[3] = color[3] * alpha;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @param {WebGLShaderUniform} uniform
|
|
214
|
+
* @param {boolean} is_stroke
|
|
215
|
+
* @param {number} half_width
|
|
216
|
+
* @param {number} face
|
|
217
|
+
* @param {number} miter_limit
|
|
218
|
+
* @param {boolean} has_grid
|
|
219
|
+
* @param {Float32Array} matrix
|
|
220
|
+
* @param {array} inverse_matrix
|
|
221
|
+
* @param {number} viewport_width
|
|
222
|
+
* @param {number} viewport_height
|
|
223
|
+
* @param {CanvasToWebGLContextGrid} grid
|
|
224
|
+
* @param {number} texture_width
|
|
225
|
+
* @param {number} texture_height
|
|
226
|
+
* @param {number} mul1
|
|
227
|
+
* @param {number} mul2
|
|
228
|
+
* @param {number} mul3
|
|
229
|
+
* @param {number} mul4
|
|
230
|
+
* @param {number} add1
|
|
231
|
+
* @param {number} add2
|
|
232
|
+
* @param {number} add3
|
|
233
|
+
* @param {number} add4
|
|
234
|
+
* @return {void}
|
|
235
|
+
* @method
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
setBitmapShapeUniform(uniform, is_stroke, half_width, face, miter_limit, has_grid, matrix, inverse_matrix, viewport_width, viewport_height, grid, texture_width, texture_height, mul1, mul2, mul3, mul4, add1, add2, add3, add4) {
|
|
239
|
+
const highp = uniform.highp;
|
|
240
|
+
let i;
|
|
241
|
+
// vertex: u_matrix
|
|
242
|
+
highp[0] = matrix[0];
|
|
243
|
+
highp[1] = matrix[1];
|
|
244
|
+
highp[2] = matrix[2];
|
|
245
|
+
highp[4] = matrix[3];
|
|
246
|
+
highp[5] = matrix[4];
|
|
247
|
+
highp[6] = matrix[5];
|
|
248
|
+
highp[8] = matrix[6];
|
|
249
|
+
highp[9] = matrix[7];
|
|
250
|
+
highp[10] = matrix[8];
|
|
251
|
+
// vertex: u_inverse_matrix
|
|
252
|
+
highp[12] = inverse_matrix[0];
|
|
253
|
+
highp[13] = inverse_matrix[1];
|
|
254
|
+
highp[14] = inverse_matrix[2];
|
|
255
|
+
highp[16] = inverse_matrix[3];
|
|
256
|
+
highp[17] = inverse_matrix[4];
|
|
257
|
+
highp[18] = inverse_matrix[5];
|
|
258
|
+
highp[11] = inverse_matrix[6];
|
|
259
|
+
highp[15] = inverse_matrix[7];
|
|
260
|
+
highp[19] = inverse_matrix[8];
|
|
261
|
+
// vertex: u_viewport
|
|
262
|
+
highp[3] = viewport_width;
|
|
263
|
+
highp[7] = viewport_height;
|
|
264
|
+
i = 20;
|
|
265
|
+
if (has_grid) {
|
|
266
|
+
// vertex: u_parent_matrix
|
|
267
|
+
highp[i] = grid.parentMatrixA;
|
|
268
|
+
highp[i + 1] = grid.parentMatrixB;
|
|
269
|
+
highp[i + 2] = grid.parentMatrixC;
|
|
270
|
+
highp[i + 4] = grid.parentMatrixD;
|
|
271
|
+
highp[i + 5] = grid.parentMatrixE;
|
|
272
|
+
highp[i + 6] = grid.parentMatrixF;
|
|
273
|
+
highp[i + 8] = grid.parentMatrixG;
|
|
274
|
+
highp[i + 9] = grid.parentMatrixH;
|
|
275
|
+
highp[i + 10] = grid.parentMatrixI;
|
|
276
|
+
// vertex: u_ancestor_matrix
|
|
277
|
+
highp[i + 12] = grid.ancestorMatrixA;
|
|
278
|
+
highp[i + 13] = grid.ancestorMatrixB;
|
|
279
|
+
highp[i + 14] = grid.ancestorMatrixC;
|
|
280
|
+
highp[i + 16] = grid.ancestorMatrixD;
|
|
281
|
+
highp[i + 17] = grid.ancestorMatrixE;
|
|
282
|
+
highp[i + 18] = grid.ancestorMatrixF;
|
|
283
|
+
highp[i + 20] = grid.ancestorMatrixG;
|
|
284
|
+
highp[i + 21] = grid.ancestorMatrixH;
|
|
285
|
+
highp[i + 22] = grid.ancestorMatrixI;
|
|
286
|
+
// vertex: u_parent_viewport
|
|
287
|
+
highp[i + 11] = grid.parentViewportX;
|
|
288
|
+
highp[i + 15] = grid.parentViewportY;
|
|
289
|
+
highp[i + 19] = grid.parentViewportW;
|
|
290
|
+
highp[i + 23] = grid.parentViewportH;
|
|
291
|
+
// vertex: u_grid_min
|
|
292
|
+
highp[i + 24] = grid.minXST;
|
|
293
|
+
highp[i + 25] = grid.minYST;
|
|
294
|
+
highp[i + 26] = grid.minXPQ;
|
|
295
|
+
highp[i + 27] = grid.minYPQ;
|
|
296
|
+
// vertex: u_grid_max
|
|
297
|
+
highp[i + 28] = grid.maxXST;
|
|
298
|
+
highp[i + 29] = grid.maxYST;
|
|
299
|
+
highp[i + 30] = grid.maxXPQ;
|
|
300
|
+
highp[i + 31] = grid.maxYPQ;
|
|
301
|
+
i = 52;
|
|
302
|
+
}
|
|
303
|
+
if (is_stroke) {
|
|
304
|
+
// vertex: u_half_width
|
|
305
|
+
highp[i] = half_width;
|
|
306
|
+
// vertex: u_face
|
|
307
|
+
highp[i + 1] = face;
|
|
308
|
+
// vertex: u_miter_limit
|
|
309
|
+
highp[i + 2] = miter_limit;
|
|
310
|
+
}
|
|
311
|
+
const mediump = uniform.mediump;
|
|
312
|
+
// fragment: u_uv
|
|
313
|
+
mediump[0] = texture_width;
|
|
314
|
+
mediump[1] = texture_height;
|
|
315
|
+
// fragment: u_color_transform_mul
|
|
316
|
+
mediump[4] = mul1;
|
|
317
|
+
mediump[5] = mul2;
|
|
318
|
+
mediump[6] = mul3;
|
|
319
|
+
mediump[7] = mul4;
|
|
320
|
+
// fragment: u_color_transform_add
|
|
321
|
+
mediump[8] = add1;
|
|
322
|
+
mediump[9] = add2;
|
|
323
|
+
mediump[10] = add3;
|
|
324
|
+
mediump[11] = add4;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* @param {WebGLShaderUniform} uniform
|
|
328
|
+
* @param {boolean} has_grid
|
|
329
|
+
* @param {number} matrix_a
|
|
330
|
+
* @param {number} matrix_b
|
|
331
|
+
* @param {number} matrix_c
|
|
332
|
+
* @param {number} matrix_d
|
|
333
|
+
* @param {number} matrix_e
|
|
334
|
+
* @param {number} matrix_f
|
|
335
|
+
* @param {number} matrix_g
|
|
336
|
+
* @param {number} matrix_h
|
|
337
|
+
* @param {number} matrix_i
|
|
338
|
+
* @param {number} viewport_width
|
|
339
|
+
* @param {number} viewport_height
|
|
340
|
+
* @param {CanvasToWebGLContextGrid} grid
|
|
341
|
+
* @return {void}
|
|
342
|
+
* @method
|
|
343
|
+
* @public
|
|
344
|
+
*/
|
|
345
|
+
setMaskShapeUniform(uniform, has_grid, matrix_a, matrix_b, matrix_c, matrix_d, matrix_e, matrix_f, matrix_g, matrix_h, matrix_i, viewport_width, viewport_height, grid = null) {
|
|
346
|
+
const highp = uniform.highp;
|
|
347
|
+
if (has_grid && grid) {
|
|
348
|
+
// vertex: u_parent_matrix
|
|
349
|
+
highp[0] = grid.parentMatrixA;
|
|
350
|
+
highp[1] = grid.parentMatrixB;
|
|
351
|
+
highp[2] = grid.parentMatrixC;
|
|
352
|
+
highp[4] = grid.parentMatrixD;
|
|
353
|
+
highp[5] = grid.parentMatrixE;
|
|
354
|
+
highp[6] = grid.parentMatrixF;
|
|
355
|
+
highp[8] = grid.parentMatrixG;
|
|
356
|
+
highp[9] = grid.parentMatrixH;
|
|
357
|
+
highp[10] = grid.parentMatrixI;
|
|
358
|
+
// vertex: u_ancestor_matrix
|
|
359
|
+
highp[12] = grid.ancestorMatrixA;
|
|
360
|
+
highp[13] = grid.ancestorMatrixB;
|
|
361
|
+
highp[14] = grid.ancestorMatrixC;
|
|
362
|
+
highp[16] = grid.ancestorMatrixD;
|
|
363
|
+
highp[17] = grid.ancestorMatrixE;
|
|
364
|
+
highp[18] = grid.ancestorMatrixF;
|
|
365
|
+
highp[20] = grid.ancestorMatrixG;
|
|
366
|
+
highp[21] = grid.ancestorMatrixH;
|
|
367
|
+
highp[22] = grid.ancestorMatrixI;
|
|
368
|
+
// vertex: u_viewport
|
|
369
|
+
highp[3] = viewport_width;
|
|
370
|
+
highp[7] = viewport_height;
|
|
371
|
+
// vertex: u_parent_viewport
|
|
372
|
+
highp[11] = grid.parentViewportX;
|
|
373
|
+
highp[15] = grid.parentViewportY;
|
|
374
|
+
highp[19] = grid.parentViewportW;
|
|
375
|
+
highp[23] = grid.parentViewportH;
|
|
376
|
+
// vertex: u_grid_min
|
|
377
|
+
highp[24] = grid.minXST;
|
|
378
|
+
highp[25] = grid.minYST;
|
|
379
|
+
highp[26] = grid.minXPQ;
|
|
380
|
+
highp[27] = grid.minYPQ;
|
|
381
|
+
// vertex: u_grid_max
|
|
382
|
+
highp[28] = grid.maxXST;
|
|
383
|
+
highp[29] = grid.maxYST;
|
|
384
|
+
highp[30] = grid.maxXPQ;
|
|
385
|
+
highp[31] = grid.maxYPQ;
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
// vertex: u_matrix
|
|
389
|
+
highp[0] = matrix_a;
|
|
390
|
+
highp[1] = matrix_b;
|
|
391
|
+
highp[2] = matrix_c;
|
|
392
|
+
highp[4] = matrix_d;
|
|
393
|
+
highp[5] = matrix_e;
|
|
394
|
+
highp[6] = matrix_f;
|
|
395
|
+
highp[8] = matrix_g;
|
|
396
|
+
highp[9] = matrix_h;
|
|
397
|
+
highp[10] = matrix_i;
|
|
398
|
+
// vertex: u_viewport
|
|
399
|
+
highp[3] = viewport_width;
|
|
400
|
+
highp[7] = viewport_height;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* @param {WebGLShaderUniform} uniform
|
|
405
|
+
* @param {number} width
|
|
406
|
+
* @param {number} height
|
|
407
|
+
* @return {void}
|
|
408
|
+
* @method
|
|
409
|
+
* @public
|
|
410
|
+
*/
|
|
411
|
+
setMaskShapeUniformIdentity(uniform, width, height) {
|
|
412
|
+
const highp = uniform.highp;
|
|
413
|
+
// vertex: u_matrix
|
|
414
|
+
highp[0] = 1;
|
|
415
|
+
highp[1] = 0;
|
|
416
|
+
highp[2] = 0;
|
|
417
|
+
highp[4] = 0;
|
|
418
|
+
highp[5] = 1;
|
|
419
|
+
highp[6] = 0;
|
|
420
|
+
highp[8] = 0;
|
|
421
|
+
highp[9] = 0;
|
|
422
|
+
highp[10] = 1;
|
|
423
|
+
// vertex: u_viewport
|
|
424
|
+
highp[3] = width;
|
|
425
|
+
highp[7] = height;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export declare class VertexShaderLibrary {
|
|
5
|
+
/**
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @method
|
|
8
|
+
* @static
|
|
9
|
+
*/
|
|
10
|
+
static FUNCTION_GRID_OFF(): string;
|
|
11
|
+
/**
|
|
12
|
+
* @param {number} index
|
|
13
|
+
* @return {string}
|
|
14
|
+
* @method
|
|
15
|
+
* @static
|
|
16
|
+
*/
|
|
17
|
+
static FUNCTION_GRID_ON(index: number): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export class VertexShaderLibrary {
|
|
5
|
+
/**
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @method
|
|
8
|
+
* @static
|
|
9
|
+
*/
|
|
10
|
+
static FUNCTION_GRID_OFF() {
|
|
11
|
+
return `
|
|
12
|
+
|
|
13
|
+
vec2 applyMatrix(in vec2 vertex) {
|
|
14
|
+
mat3 matrix = mat3(
|
|
15
|
+
u_highp[0].xyz,
|
|
16
|
+
u_highp[1].xyz,
|
|
17
|
+
u_highp[2].xyz
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
vec2 position = (matrix * vec3(vertex, 1.0)).xy;
|
|
21
|
+
|
|
22
|
+
return position;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @param {number} index
|
|
29
|
+
* @return {string}
|
|
30
|
+
* @method
|
|
31
|
+
* @static
|
|
32
|
+
*/
|
|
33
|
+
static FUNCTION_GRID_ON(index) {
|
|
34
|
+
return `
|
|
35
|
+
|
|
36
|
+
vec2 applyMatrix(in vec2 vertex) {
|
|
37
|
+
mat3 parent_matrix = mat3(
|
|
38
|
+
u_highp[${index}].xyz,
|
|
39
|
+
u_highp[${index + 1}].xyz,
|
|
40
|
+
u_highp[${index + 2}].xyz
|
|
41
|
+
);
|
|
42
|
+
mat3 ancestor_matrix = mat3(
|
|
43
|
+
u_highp[${index + 3}].xyz,
|
|
44
|
+
u_highp[${index + 4}].xyz,
|
|
45
|
+
u_highp[${index + 5}].xyz
|
|
46
|
+
);
|
|
47
|
+
vec2 parent_offset = vec2(u_highp[${index + 2}].w, u_highp[${index + 3}].w);
|
|
48
|
+
vec2 parent_size = vec2(u_highp[${index + 4}].w, u_highp[${index + 5}].w);
|
|
49
|
+
vec4 grid_min = u_highp[${index + 6}];
|
|
50
|
+
vec4 grid_max = u_highp[${index + 7}];
|
|
51
|
+
|
|
52
|
+
vec2 position = (parent_matrix * vec3(vertex, 1.0)).xy;
|
|
53
|
+
position = (position - parent_offset) / parent_size;
|
|
54
|
+
|
|
55
|
+
vec4 ga = grid_min;
|
|
56
|
+
vec4 gb = grid_max - grid_min;
|
|
57
|
+
vec4 gc = vec4(1.0) - grid_max;
|
|
58
|
+
|
|
59
|
+
vec2 pa = position;
|
|
60
|
+
vec2 pb = position - grid_min.st;
|
|
61
|
+
vec2 pc = position - grid_max.st;
|
|
62
|
+
|
|
63
|
+
position = (ga.pq / ga.st) * min(pa, ga.st)
|
|
64
|
+
+ (gb.pq / gb.st) * clamp(pb, vec2(0.0), gb.st)
|
|
65
|
+
+ (gc.pq / gc.st) * max(vec2(0.0), pc);
|
|
66
|
+
|
|
67
|
+
position = position * parent_size + parent_offset;
|
|
68
|
+
position = (ancestor_matrix * vec3(position, 1.0)).xy;
|
|
69
|
+
|
|
70
|
+
return position;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export declare class VertexShaderSource {
|
|
5
|
+
/**
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @method
|
|
8
|
+
* @static
|
|
9
|
+
*/
|
|
10
|
+
static TEXTURE(): string;
|
|
11
|
+
/**
|
|
12
|
+
* @return {string}
|
|
13
|
+
* @method
|
|
14
|
+
* @static
|
|
15
|
+
*/
|
|
16
|
+
static BLEND(): string;
|
|
17
|
+
/**
|
|
18
|
+
* @return {string}
|
|
19
|
+
* @method
|
|
20
|
+
* @static
|
|
21
|
+
*/
|
|
22
|
+
static BLEND_CLIP(): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export class VertexShaderSource {
|
|
5
|
+
/**
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @method
|
|
8
|
+
* @static
|
|
9
|
+
*/
|
|
10
|
+
static TEXTURE() {
|
|
11
|
+
return `#version 300 es
|
|
12
|
+
|
|
13
|
+
layout (location = 0) in vec2 a_vertex;
|
|
14
|
+
|
|
15
|
+
out vec2 v_coord;
|
|
16
|
+
|
|
17
|
+
void main() {
|
|
18
|
+
v_coord = a_vertex;
|
|
19
|
+
|
|
20
|
+
vec2 position = a_vertex * 2.0 - 1.0;
|
|
21
|
+
gl_Position = vec4(position, 0.0, 1.0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @return {string}
|
|
28
|
+
* @method
|
|
29
|
+
* @static
|
|
30
|
+
*/
|
|
31
|
+
static BLEND() {
|
|
32
|
+
return `#version 300 es
|
|
33
|
+
|
|
34
|
+
layout (location = 0) in vec2 a_vertex;
|
|
35
|
+
|
|
36
|
+
uniform vec4 u_highp[4];
|
|
37
|
+
|
|
38
|
+
out vec2 v_coord;
|
|
39
|
+
|
|
40
|
+
void main() {
|
|
41
|
+
v_coord = a_vertex;
|
|
42
|
+
|
|
43
|
+
vec2 offset = u_highp[0].xy;
|
|
44
|
+
vec2 size = u_highp[0].zw;
|
|
45
|
+
mat3 matrix = mat3(u_highp[1].xyz, u_highp[2].xyz, u_highp[3].xyz);
|
|
46
|
+
vec2 viewport = vec2(u_highp[1].w, u_highp[2].w);
|
|
47
|
+
|
|
48
|
+
vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);
|
|
49
|
+
position = position * size + offset;
|
|
50
|
+
position = (matrix * vec3(position, 1.0)).xy;
|
|
51
|
+
position /= viewport;
|
|
52
|
+
|
|
53
|
+
position = position * 2.0 - 1.0;
|
|
54
|
+
gl_Position = vec4(position.x, -position.y, 0.0, 1.0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @return {string}
|
|
61
|
+
* @method
|
|
62
|
+
* @static
|
|
63
|
+
*/
|
|
64
|
+
static BLEND_CLIP() {
|
|
65
|
+
return `#version 300 es
|
|
66
|
+
|
|
67
|
+
layout (location = 0) in vec2 a_vertex;
|
|
68
|
+
|
|
69
|
+
uniform vec4 u_highp[4];
|
|
70
|
+
|
|
71
|
+
out vec2 v_coord;
|
|
72
|
+
|
|
73
|
+
void main() {
|
|
74
|
+
v_coord = a_vertex;
|
|
75
|
+
|
|
76
|
+
vec2 offset = u_highp[0].xy;
|
|
77
|
+
vec2 size = u_highp[0].zw;
|
|
78
|
+
mat3 inv_matrix = mat3(u_highp[1].xyz, u_highp[2].xyz, u_highp[3].xyz);
|
|
79
|
+
vec2 viewport = vec2(u_highp[1].w, u_highp[2].w);
|
|
80
|
+
|
|
81
|
+
vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);
|
|
82
|
+
position *= viewport;
|
|
83
|
+
position = (inv_matrix * vec3(position, 1.0)).xy;
|
|
84
|
+
position = (position - offset) / size;
|
|
85
|
+
|
|
86
|
+
position = position * 2.0 - 1.0;
|
|
87
|
+
gl_Position = vec4(position.x, -position.y, 0.0, 1.0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export declare class VertexShaderSourceFill {
|
|
5
|
+
/**
|
|
6
|
+
* @param {number} highp_length
|
|
7
|
+
* @param {boolean} with_uv
|
|
8
|
+
* @param {boolean} for_mask
|
|
9
|
+
* @param {boolean} has_grid
|
|
10
|
+
* @return {string}
|
|
11
|
+
* @method
|
|
12
|
+
* @static
|
|
13
|
+
*/
|
|
14
|
+
static TEMPLATE(highp_length: number, with_uv: boolean, for_mask: boolean, has_grid: boolean): string;
|
|
15
|
+
/**
|
|
16
|
+
* @return {string}
|
|
17
|
+
* @method
|
|
18
|
+
* @static
|
|
19
|
+
*/
|
|
20
|
+
static ATTRIBUTE_BEZIER_ON(): string;
|
|
21
|
+
/**
|
|
22
|
+
* @return {string}
|
|
23
|
+
* @method
|
|
24
|
+
* @static
|
|
25
|
+
*/
|
|
26
|
+
static VARYING_UV_ON(): string;
|
|
27
|
+
/**
|
|
28
|
+
* @return {string}
|
|
29
|
+
* @method
|
|
30
|
+
* @static
|
|
31
|
+
*/
|
|
32
|
+
static VARYING_BEZIER_ON(): string;
|
|
33
|
+
/**
|
|
34
|
+
* @return {string}
|
|
35
|
+
* @method
|
|
36
|
+
* @static
|
|
37
|
+
*/
|
|
38
|
+
static STATEMENT_UV_ON(): string;
|
|
39
|
+
/**
|
|
40
|
+
* @return {string}
|
|
41
|
+
* @method
|
|
42
|
+
* @static
|
|
43
|
+
*/
|
|
44
|
+
static STATEMENT_BEZIER_ON(): string;
|
|
45
|
+
}
|