@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.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/dist/BezierConverter.d.ts +59 -0
  4. package/dist/BezierConverter.js +106 -0
  5. package/dist/CanvasGradientToWebGL.d.ts +96 -0
  6. package/dist/CanvasGradientToWebGL.js +181 -0
  7. package/dist/CanvasPatternToWebGL.d.ts +39 -0
  8. package/dist/CanvasPatternToWebGL.js +66 -0
  9. package/dist/CanvasToWebGLContext.d.ts +591 -0
  10. package/dist/CanvasToWebGLContext.js +1427 -0
  11. package/dist/CanvasToWebGLContextBlend.d.ts +97 -0
  12. package/dist/CanvasToWebGLContextBlend.js +299 -0
  13. package/dist/CanvasToWebGLContextGrid.d.ts +74 -0
  14. package/dist/CanvasToWebGLContextGrid.js +283 -0
  15. package/dist/CanvasToWebGLContextMask.d.ts +113 -0
  16. package/dist/CanvasToWebGLContextMask.js +436 -0
  17. package/dist/CanvasToWebGLContextPath.d.ts +111 -0
  18. package/dist/CanvasToWebGLContextPath.js +210 -0
  19. package/dist/CanvasToWebGLContextStyle.d.ts +78 -0
  20. package/dist/CanvasToWebGLContextStyle.js +139 -0
  21. package/dist/ColorBufferPool.d.ts +58 -0
  22. package/dist/ColorBufferPool.js +134 -0
  23. package/dist/FrameBufferManager.d.ts +135 -0
  24. package/dist/FrameBufferManager.js +358 -0
  25. package/dist/StencilBufferPool.d.ts +56 -0
  26. package/dist/StencilBufferPool.js +142 -0
  27. package/dist/TextureManager.d.ts +130 -0
  28. package/dist/TextureManager.js +296 -0
  29. package/dist/VertexArrayObjectManager.d.ts +96 -0
  30. package/dist/VertexArrayObjectManager.js +277 -0
  31. package/dist/WebGLFillMeshGenerator.d.ts +31 -0
  32. package/dist/WebGLFillMeshGenerator.js +101 -0
  33. package/dist/WebGLStrokeMeshGenerator.d.ts +183 -0
  34. package/dist/WebGLStrokeMeshGenerator.js +504 -0
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.js +6 -0
  37. package/dist/interface/AttachmentImpl.d.ts +11 -0
  38. package/dist/interface/AttachmentImpl.js +1 -0
  39. package/dist/interface/BoundsImpl.d.ts +6 -0
  40. package/dist/interface/BoundsImpl.js +1 -0
  41. package/dist/interface/CapsStyleImpl.d.ts +1 -0
  42. package/dist/interface/CapsStyleImpl.js +1 -0
  43. package/dist/interface/ClipObjectImpl.d.ts +14 -0
  44. package/dist/interface/ClipObjectImpl.js +1 -0
  45. package/dist/interface/FillMeshImpl.d.ts +5 -0
  46. package/dist/interface/FillMeshImpl.js +1 -0
  47. package/dist/interface/GradientTypeImpl.d.ts +1 -0
  48. package/dist/interface/GradientTypeImpl.js +1 -0
  49. package/dist/interface/GridImpl.d.ts +6 -0
  50. package/dist/interface/GridImpl.js +1 -0
  51. package/dist/interface/IndexRangeImpl.d.ts +4 -0
  52. package/dist/interface/IndexRangeImpl.js +1 -0
  53. package/dist/interface/InterpolationMethodImpl.d.ts +1 -0
  54. package/dist/interface/InterpolationMethodImpl.js +1 -0
  55. package/dist/interface/JointStyleImpl.d.ts +1 -0
  56. package/dist/interface/JointStyleImpl.js +1 -0
  57. package/dist/interface/SpreadMethodImpl.d.ts +1 -0
  58. package/dist/interface/SpreadMethodImpl.js +1 -0
  59. package/dist/interface/StrokeMethImpl.d.ts +4 -0
  60. package/dist/interface/StrokeMethImpl.js +1 -0
  61. package/dist/interface/UniformDataImpl.d.ts +5 -0
  62. package/dist/interface/UniformDataImpl.js +1 -0
  63. package/dist/interface/VerticesImpl.d.ts +1 -0
  64. package/dist/interface/VerticesImpl.js +1 -0
  65. package/dist/shader/CanvasToWebGLShader.d.ts +85 -0
  66. package/dist/shader/CanvasToWebGLShader.js +192 -0
  67. package/dist/shader/CanvasToWebGLShaderList.d.ts +70 -0
  68. package/dist/shader/CanvasToWebGLShaderList.js +109 -0
  69. package/dist/shader/GradientLUTGenerator.d.ts +36 -0
  70. package/dist/shader/GradientLUTGenerator.js +123 -0
  71. package/dist/shader/WebGLShaderUniform.d.ts +52 -0
  72. package/dist/shader/WebGLShaderUniform.js +165 -0
  73. package/dist/shader/fragment/FragmentShaderLibrary.d.ts +18 -0
  74. package/dist/shader/fragment/FragmentShaderLibrary.js +35 -0
  75. package/dist/shader/fragment/FragmentShaderSource.d.ts +29 -0
  76. package/dist/shader/fragment/FragmentShaderSource.js +99 -0
  77. package/dist/shader/fragment/FragmentShaderSourceBlend.d.ts +67 -0
  78. package/dist/shader/fragment/FragmentShaderSourceBlend.js +319 -0
  79. package/dist/shader/fragment/FragmentShaderSourceGradient.d.ts +44 -0
  80. package/dist/shader/fragment/FragmentShaderSourceGradient.js +114 -0
  81. package/dist/shader/fragment/FragmentShaderSourceGradientLUT.d.ts +14 -0
  82. package/dist/shader/fragment/FragmentShaderSourceGradientLUT.js +58 -0
  83. package/dist/shader/fragment/FragmentShaderSourceTexture.d.ts +12 -0
  84. package/dist/shader/fragment/FragmentShaderSourceTexture.js +36 -0
  85. package/dist/shader/fragment/filter/FragmentShaderSourceBlurFilter.d.ts +12 -0
  86. package/dist/shader/fragment/filter/FragmentShaderSourceBlurFilter.js +42 -0
  87. package/dist/shader/fragment/filter/FragmentShaderSourceColorMatrixFilter.d.ts +11 -0
  88. package/dist/shader/fragment/filter/FragmentShaderSourceColorMatrixFilter.js +35 -0
  89. package/dist/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.d.ts +16 -0
  90. package/dist/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.js +80 -0
  91. package/dist/shader/fragment/filter/FragmentShaderSourceDisplacementMapFilter.d.ts +15 -0
  92. package/dist/shader/fragment/filter/FragmentShaderSourceDisplacementMapFilter.js +106 -0
  93. package/dist/shader/fragment/filter/FragmentShaderSourceFilter.d.ts +112 -0
  94. package/dist/shader/fragment/filter/FragmentShaderSourceFilter.js +275 -0
  95. package/dist/shader/variants/BlendShaderVariantCollection.d.ts +99 -0
  96. package/dist/shader/variants/BlendShaderVariantCollection.js +239 -0
  97. package/dist/shader/variants/FilterShaderVariantCollection.d.ts +150 -0
  98. package/dist/shader/variants/FilterShaderVariantCollection.js +395 -0
  99. package/dist/shader/variants/GradientLUTShaderVariantCollection.d.ts +49 -0
  100. package/dist/shader/variants/GradientLUTShaderVariantCollection.js +107 -0
  101. package/dist/shader/variants/GradientShapeShaderVariantCollection.d.ts +61 -0
  102. package/dist/shader/variants/GradientShapeShaderVariantCollection.js +196 -0
  103. package/dist/shader/variants/ShapeShaderVariantCollection.d.ts +117 -0
  104. package/dist/shader/variants/ShapeShaderVariantCollection.js +427 -0
  105. package/dist/shader/vertex/VertexShaderLibrary.d.ts +18 -0
  106. package/dist/shader/vertex/VertexShaderLibrary.js +75 -0
  107. package/dist/shader/vertex/VertexShaderSource.d.ts +23 -0
  108. package/dist/shader/vertex/VertexShaderSource.js +92 -0
  109. package/dist/shader/vertex/VertexShaderSourceFill.d.ts +45 -0
  110. package/dist/shader/vertex/VertexShaderSourceFill.js +112 -0
  111. package/dist/shader/vertex/VertexShaderSourceStroke.d.ts +27 -0
  112. package/dist/shader/vertex/VertexShaderSourceStroke.js +149 -0
  113. package/package.json +37 -0
@@ -0,0 +1,239 @@
1
+ import { CanvasToWebGLShader } from "../CanvasToWebGLShader";
2
+ import { VertexShaderSource } from "../vertex/VertexShaderSource";
3
+ import { FragmentShaderSourceTexture } from "../fragment/FragmentShaderSourceTexture";
4
+ import { FragmentShaderSourceBlend } from "../fragment/FragmentShaderSourceBlend";
5
+ import { $getMap } from "@next2d/share";
6
+ /**
7
+ * @class
8
+ */
9
+ export class BlendShaderVariantCollection {
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} with_color_transform
35
+ * @return {CanvasToWebGLShader}
36
+ * @method
37
+ * @public
38
+ */
39
+ getNormalBlendShader(with_color_transform) {
40
+ const key = `n${with_color_transform ? "y" : "n"}`;
41
+ if (this._$collection.has(key)) {
42
+ const shader = this._$collection.get(key);
43
+ if (shader) {
44
+ return shader;
45
+ }
46
+ }
47
+ const shader = new CanvasToWebGLShader(this._$gl, this._$context, VertexShaderSource.BLEND(), FragmentShaderSourceTexture.TEMPLATE(with_color_transform));
48
+ this._$collection.set(key, shader);
49
+ return shader;
50
+ }
51
+ /**
52
+ * @return {CanvasToWebGLShader}
53
+ * @method
54
+ * @public
55
+ */
56
+ getClipShader() {
57
+ const key = "c";
58
+ if (this._$collection.has(key)) {
59
+ const shader = this._$collection.get(key);
60
+ if (shader) {
61
+ return shader;
62
+ }
63
+ }
64
+ const shader = new CanvasToWebGLShader(this._$gl, this._$context, VertexShaderSource.BLEND_CLIP(), FragmentShaderSourceTexture.TEMPLATE(false));
65
+ this._$collection.set(key, shader);
66
+ return shader;
67
+ }
68
+ /**
69
+ * @param {string} operation
70
+ * @param {boolean} with_color_transform
71
+ * @return {CanvasToWebGLShader}
72
+ * @method
73
+ * @public
74
+ */
75
+ getBlendShader(operation, with_color_transform) {
76
+ const key = `${operation}${with_color_transform ? "y" : "n"}`;
77
+ if (this._$collection.has(key)) {
78
+ const shader = this._$collection.get(key);
79
+ if (shader) {
80
+ return shader;
81
+ }
82
+ }
83
+ const shader = new CanvasToWebGLShader(this._$gl, this._$context, VertexShaderSource.BLEND(), FragmentShaderSourceBlend.TEMPLATE(operation, with_color_transform));
84
+ this._$collection.set(key, shader);
85
+ return shader;
86
+ }
87
+ /**
88
+ * @param {WebGLShaderUniform} uniform
89
+ * @param {number} x
90
+ * @param {number} y
91
+ * @param {number} w
92
+ * @param {number} h
93
+ * @param {Float32Array} matrix
94
+ * @param {number} render_width
95
+ * @param {number} render_height
96
+ * @param {boolean} with_color_transform
97
+ * @param {number} ct0
98
+ * @param {number} ct1
99
+ * @param {number} ct2
100
+ * @param {number} ct3
101
+ * @param {number} ct4
102
+ * @param {number} ct5
103
+ * @param {number} ct6
104
+ * @param {number} ct7
105
+ * @return {void}
106
+ * @method
107
+ * @public
108
+ */
109
+ setNormalBlendUniform(uniform, x, y, w, h, matrix, render_width, render_height, with_color_transform, ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7) {
110
+ const highp = uniform.highp;
111
+ // vertex: u_offset
112
+ highp[0] = x;
113
+ highp[1] = y;
114
+ // vertex: u_size
115
+ highp[2] = w;
116
+ highp[3] = h;
117
+ // vertex: u_matrix
118
+ highp[4] = matrix[0];
119
+ highp[5] = matrix[1];
120
+ highp[6] = matrix[2];
121
+ highp[8] = matrix[3];
122
+ highp[9] = matrix[4];
123
+ highp[10] = matrix[5];
124
+ highp[12] = matrix[6];
125
+ highp[13] = matrix[7];
126
+ highp[14] = matrix[8];
127
+ // vertex: u_viewport
128
+ highp[7] = render_width;
129
+ highp[11] = render_height;
130
+ if (with_color_transform) {
131
+ const mediump = uniform.mediump;
132
+ // fragment: u_color_transform_mul
133
+ mediump[0] = ct0;
134
+ mediump[1] = ct1;
135
+ mediump[2] = ct2;
136
+ mediump[3] = ct3;
137
+ // fragment: u_color_transform_add
138
+ mediump[4] = ct4;
139
+ mediump[5] = ct5;
140
+ mediump[6] = ct6;
141
+ mediump[7] = ct7;
142
+ }
143
+ }
144
+ /**
145
+ * @param {WebGLShaderUniform} uniform
146
+ * @param {number} x
147
+ * @param {number} y
148
+ * @param {number} w
149
+ * @param {number} h
150
+ * @param {Float32Array} inverse_matrix
151
+ * @param {number} render_width
152
+ * @param {number} render_height
153
+ * @return {void}
154
+ * @method
155
+ * @public
156
+ */
157
+ setClipUniform(uniform, x, y, w, h, inverse_matrix, render_width, render_height) {
158
+ const highp = uniform.highp;
159
+ // vertex: u_offset
160
+ highp[0] = x;
161
+ highp[1] = y;
162
+ // vertex: u_size
163
+ highp[2] = w;
164
+ highp[3] = h;
165
+ // vertex: u_inverse_matrix
166
+ highp[4] = inverse_matrix[0];
167
+ highp[5] = inverse_matrix[1];
168
+ highp[6] = inverse_matrix[2];
169
+ highp[8] = inverse_matrix[3];
170
+ highp[9] = inverse_matrix[4];
171
+ highp[10] = inverse_matrix[5];
172
+ highp[12] = inverse_matrix[6];
173
+ highp[13] = inverse_matrix[7];
174
+ highp[14] = inverse_matrix[8];
175
+ // vertex: u_viewport
176
+ highp[7] = render_width;
177
+ highp[11] = render_height;
178
+ }
179
+ /**
180
+ * @param {WebGLShaderUniform} uniform
181
+ * @param {number} x
182
+ * @param {number} y
183
+ * @param {number} w
184
+ * @param {number} h
185
+ * @param {Float32Array} matrix
186
+ * @param {number} render_width
187
+ * @param {number} render_height
188
+ * @param {boolean} with_color_transform
189
+ * @param {number} ct0
190
+ * @param {number} ct1
191
+ * @param {number} ct2
192
+ * @param {number} ct3
193
+ * @param {number} ct4
194
+ * @param {number} ct5
195
+ * @param {number} ct6
196
+ * @param {number} ct7
197
+ * @return {void}
198
+ * @method
199
+ * @public
200
+ */
201
+ setBlendUniform(uniform, x, y, w, h, matrix, render_width, render_height, with_color_transform, ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7) {
202
+ const textures = uniform.textures;
203
+ textures[0] = 0;
204
+ textures[1] = 1;
205
+ const highp = uniform.highp;
206
+ // vertex: u_offset
207
+ highp[0] = x;
208
+ highp[1] = y;
209
+ // vertex: u_size
210
+ highp[2] = w;
211
+ highp[3] = h;
212
+ // vertex: u_matrix
213
+ highp[4] = matrix[0];
214
+ highp[5] = matrix[1];
215
+ highp[6] = matrix[2];
216
+ highp[8] = matrix[3];
217
+ highp[9] = matrix[4];
218
+ highp[10] = matrix[5];
219
+ highp[12] = matrix[6];
220
+ highp[13] = matrix[7];
221
+ highp[14] = matrix[8];
222
+ // vertex: u_viewport
223
+ highp[7] = render_width;
224
+ highp[11] = render_height;
225
+ if (with_color_transform) {
226
+ const mediump = uniform.mediump;
227
+ // fragment: u_color_transform_mul
228
+ mediump[0] = ct0;
229
+ mediump[1] = ct1;
230
+ mediump[2] = ct2;
231
+ mediump[3] = ct3;
232
+ // fragment: u_color_transform_add
233
+ mediump[4] = ct4;
234
+ mediump[5] = ct5;
235
+ mediump[6] = ct6;
236
+ mediump[7] = ct7;
237
+ }
238
+ }
239
+ }
@@ -0,0 +1,150 @@
1
+ import { CanvasToWebGLShader } from "../CanvasToWebGLShader";
2
+ import type { WebGLShaderUniform } from "../WebGLShaderUniform";
3
+ import type { CanvasToWebGLContext } from "../../CanvasToWebGLContext";
4
+ /**
5
+ * @class
6
+ */
7
+ export declare class FilterShaderVariantCollection {
8
+ private readonly _$context;
9
+ private readonly _$gl;
10
+ private readonly _$collection;
11
+ /**
12
+ * @param {CanvasToWebGLContext} context
13
+ * @param {WebGL2RenderingContext} gl
14
+ * @constructor
15
+ * @public
16
+ */
17
+ constructor(context: CanvasToWebGLContext, gl: WebGL2RenderingContext);
18
+ /**
19
+ * @param {number} half_blur
20
+ * @return {CanvasToWebGLShader}
21
+ * @method
22
+ * @public
23
+ */
24
+ getBlurFilterShader(half_blur: number): CanvasToWebGLShader;
25
+ /**
26
+ * @param {boolean} transforms_base
27
+ * @param {boolean} transforms_blur
28
+ * @param {boolean} is_glow
29
+ * @param {string} type
30
+ * @param {boolean} knockout
31
+ * @param {boolean} applies_strength
32
+ * @param {boolean} is_gradient
33
+ * @return {CanvasToWebGLShader}
34
+ * @method
35
+ * @public
36
+ */
37
+ getBitmapFilterShader(transforms_base: boolean, transforms_blur: boolean, is_glow: boolean, type: string, knockout: boolean, applies_strength: boolean, is_gradient: boolean): CanvasToWebGLShader;
38
+ /**
39
+ * @return {CanvasToWebGLShader}
40
+ * @method
41
+ * @public
42
+ */
43
+ getColorMatrixFilterShader(): CanvasToWebGLShader;
44
+ /**
45
+ * @param {number} x
46
+ * @param {number} y
47
+ * @param {boolean} preserve_alpha
48
+ * @param {boolean} clamp
49
+ * @return {CanvasToWebGLShader}
50
+ * @method
51
+ * @public
52
+ */
53
+ getConvolutionFilterShader(x: number, y: number, preserve_alpha: boolean, clamp: boolean): CanvasToWebGLShader;
54
+ /**
55
+ * @param {number} component_x
56
+ * @param {number} component_y
57
+ * @param {string} mode
58
+ * @return {CanvasToWebGLShader}
59
+ * @method
60
+ * @public
61
+ */
62
+ getDisplacementMapFilterShader(component_x: number, component_y: number, mode: string): CanvasToWebGLShader;
63
+ /**
64
+ * @param {WebGLShaderUniform} uniform
65
+ * @param {number} width
66
+ * @param {number} height
67
+ * @param {boolean} is_horizontal
68
+ * @param {number} fraction
69
+ * @param {number} samples
70
+ * @return {void}
71
+ * @method
72
+ * @public
73
+ */
74
+ setBlurFilterUniform(uniform: WebGLShaderUniform, width: number, height: number, is_horizontal: boolean, fraction: number, samples: number): void;
75
+ /**
76
+ * @param {WebGLShaderUniform} uniform
77
+ * @param {number} width
78
+ * @param {number} height
79
+ * @param {number} base_width
80
+ * @param {number} base_height
81
+ * @param {number} base_offset_x
82
+ * @param {number} base_offset_y
83
+ * @param {number} blur_width
84
+ * @param {number} blur_height
85
+ * @param {number} blur_offset_x
86
+ * @param {number} blur_offset_y
87
+ * @param {boolean} is_glow
88
+ * @param {number} strength
89
+ * @param {number} color_r1
90
+ * @param {number} color_g1
91
+ * @param {number} color_b1
92
+ * @param {number} color_a1
93
+ * @param {number} color_r2
94
+ * @param {number} color_g2
95
+ * @param {number} color_b2
96
+ * @param {number} color_a2
97
+ * @param {boolean} transforms_base
98
+ * @param {boolean} transforms_blur
99
+ * @param {boolean} applies_strength
100
+ * @param {boolean} is_gradient
101
+ * @method
102
+ * @public
103
+ */
104
+ setBitmapFilterUniform(uniform: WebGLShaderUniform, width: number, height: number, base_width: number, base_height: number, base_offset_x: number, base_offset_y: number, blur_width: number, blur_height: number, blur_offset_x: number, blur_offset_y: number, is_glow: boolean, strength: number, color_r1: number, color_g1: number, color_b1: number, color_a1: number, color_r2: number, color_g2: number, color_b2: number, color_a2: number, transforms_base: boolean, transforms_blur: boolean, applies_strength: boolean, is_gradient: boolean): void;
105
+ /**
106
+ * @param {WebGLShaderUniform} uniform
107
+ * @param {array} matrix
108
+ * @return {void}
109
+ * @method
110
+ * @public
111
+ */
112
+ setColorMatrixFilterUniform(uniform: WebGLShaderUniform, matrix: number[]): void;
113
+ /**
114
+ * @param {WebGLShaderUniform} uniform
115
+ * @param {number} width
116
+ * @param {number} height
117
+ * @param {Float32Array} matrix
118
+ * @param {number} divisor
119
+ * @param {number} bias
120
+ * @param {boolean} clamp
121
+ * @param {number} color_r
122
+ * @param {number} color_g
123
+ * @param {number} color_b
124
+ * @param {number} color_a
125
+ * @return {void}
126
+ * @method
127
+ * @public
128
+ */
129
+ setConvolutionFilterUniform(uniform: WebGLShaderUniform, width: number, height: number, matrix: number[], divisor: number, bias: number, clamp: boolean, color_r: number, color_g: number, color_b: number, color_a: number): void;
130
+ /**
131
+ * @param {WebGLShaderUniform} uniform
132
+ * @param {number} map_width
133
+ * @param {number} map_height
134
+ * @param {number} base_width
135
+ * @param {number} base_height
136
+ * @param {number} point_x
137
+ * @param {number} point_y
138
+ * @param {number} scale_x
139
+ * @param {number} scale_y
140
+ * @param {string} mode
141
+ * @param {number} color_r
142
+ * @param {number} color_g
143
+ * @param {number} color_b
144
+ * @param {number} color_a
145
+ * @return {void}
146
+ * @method
147
+ * @public
148
+ */
149
+ setDisplacementMapFilterUniform(uniform: WebGLShaderUniform, map_width: number, map_height: number, base_width: number, base_height: number, point_x: number, point_y: number, scale_x: number, scale_y: number, mode: string, color_r: number, color_g: number, color_b: number, color_a: number): void;
150
+ }