@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,97 @@
|
|
|
1
|
+
import type { CanvasToWebGLContext } from "./CanvasToWebGLContext";
|
|
2
|
+
import { BlendModeImpl } from "@next2d/interface";
|
|
3
|
+
/**
|
|
4
|
+
* @class
|
|
5
|
+
*/
|
|
6
|
+
export declare class CanvasToWebGLContextBlend {
|
|
7
|
+
private readonly _$context;
|
|
8
|
+
private readonly _$gl;
|
|
9
|
+
private _$enabled;
|
|
10
|
+
private _$funcCode;
|
|
11
|
+
/**
|
|
12
|
+
* @param {CanvasToWebGLContext} context
|
|
13
|
+
* @param {WebGL2RenderingContext} gl
|
|
14
|
+
* @constructor
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
constructor(context: CanvasToWebGLContext, gl: WebGL2RenderingContext);
|
|
18
|
+
/**
|
|
19
|
+
* @return {void}
|
|
20
|
+
* @method
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
enable(): void;
|
|
24
|
+
/**
|
|
25
|
+
* @return {void}
|
|
26
|
+
* @method
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
disable(): void;
|
|
30
|
+
/**
|
|
31
|
+
* @return {void}
|
|
32
|
+
* @method
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
reset(): void;
|
|
36
|
+
/**
|
|
37
|
+
* @return {void}
|
|
38
|
+
* @method
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
toOneZero(): void;
|
|
42
|
+
/**
|
|
43
|
+
* @return {void}
|
|
44
|
+
* @method
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
toZeroOne(): void;
|
|
48
|
+
/**
|
|
49
|
+
* @return {void}
|
|
50
|
+
* @method
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
toAdd(): void;
|
|
54
|
+
/**
|
|
55
|
+
* @return {void}
|
|
56
|
+
* @method
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
toScreen(): void;
|
|
60
|
+
/**
|
|
61
|
+
* @return {void}
|
|
62
|
+
* @method
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
toAlpha(): void;
|
|
66
|
+
/**
|
|
67
|
+
* @return {void}
|
|
68
|
+
* @method
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
toErase(): void;
|
|
72
|
+
/**
|
|
73
|
+
* @return {void}
|
|
74
|
+
* @method
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
toSourceAtop(): void;
|
|
78
|
+
/**
|
|
79
|
+
* @return {void}
|
|
80
|
+
* @method
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
toSourceIn(): void;
|
|
84
|
+
/**
|
|
85
|
+
* @param {string} operation
|
|
86
|
+
* @return {void}
|
|
87
|
+
* @method
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
toOperation(operation: BlendModeImpl): void;
|
|
91
|
+
/**
|
|
92
|
+
* @return {void}
|
|
93
|
+
* @method
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
drawImage(image: WebGLTexture, x: number, y: number, w: number, h: number, ct0: number, ct1: number, ct2: number, ct3: number, ct4: number, ct5: number, ct6: number, ct7: number, operation: BlendModeImpl, renderWidth: number, renderHeight: number, matrix: Float32Array, imageSmoothingEnabled: boolean): void;
|
|
97
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { $Math, $Number, $inverseMatrix } from "@next2d/share";
|
|
2
|
+
/**
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
export class CanvasToWebGLContextBlend {
|
|
6
|
+
/**
|
|
7
|
+
* @param {CanvasToWebGLContext} context
|
|
8
|
+
* @param {WebGL2RenderingContext} gl
|
|
9
|
+
* @constructor
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
constructor(context, gl) {
|
|
13
|
+
/**
|
|
14
|
+
* @type {CanvasToWebGLContext}
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
this._$context = context;
|
|
18
|
+
/**
|
|
19
|
+
* @type {WebGL2RenderingContext}
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
this._$gl = gl;
|
|
23
|
+
/**
|
|
24
|
+
* @type {boolean}
|
|
25
|
+
* @default false
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
this._$enabled = false;
|
|
29
|
+
/**
|
|
30
|
+
* @type {number}
|
|
31
|
+
* @default 600
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
this._$funcCode = 600;
|
|
35
|
+
// start
|
|
36
|
+
this.enable();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @return {void}
|
|
40
|
+
* @method
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
enable() {
|
|
44
|
+
if (!this._$enabled) {
|
|
45
|
+
this._$enabled = true;
|
|
46
|
+
this._$gl.enable(this._$gl.BLEND);
|
|
47
|
+
}
|
|
48
|
+
this.reset();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @return {void}
|
|
52
|
+
* @method
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
disable() {
|
|
56
|
+
if (this._$enabled) {
|
|
57
|
+
this._$enabled = false;
|
|
58
|
+
this._$gl.disable(this._$gl.BLEND);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @return {void}
|
|
63
|
+
* @method
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
reset() {
|
|
67
|
+
if (this._$funcCode !== 613) {
|
|
68
|
+
this._$funcCode = 613;
|
|
69
|
+
this._$gl.blendFunc(this._$gl.ONE, this._$gl.ONE_MINUS_SRC_ALPHA);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @return {void}
|
|
74
|
+
* @method
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
toOneZero() {
|
|
78
|
+
if (this._$funcCode !== 610) {
|
|
79
|
+
this._$funcCode = 610;
|
|
80
|
+
this._$gl.blendFunc(this._$gl.ONE, this._$gl.ZERO);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @return {void}
|
|
85
|
+
* @method
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
toZeroOne() {
|
|
89
|
+
if (this._$funcCode !== 601) {
|
|
90
|
+
this._$funcCode = 601;
|
|
91
|
+
this._$gl.blendFuncSeparate(this._$gl.ZERO, this._$gl.ONE, this._$gl.ONE, this._$gl.ZERO);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @return {void}
|
|
96
|
+
* @method
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
toAdd() {
|
|
100
|
+
if (this._$funcCode !== 611) {
|
|
101
|
+
this._$funcCode = 611;
|
|
102
|
+
this._$gl.blendFunc(this._$gl.ONE, this._$gl.ONE);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @return {void}
|
|
107
|
+
* @method
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
toScreen() {
|
|
111
|
+
if (this._$funcCode !== 641) {
|
|
112
|
+
this._$funcCode = 641;
|
|
113
|
+
this._$gl.blendFunc(this._$gl.ONE_MINUS_DST_COLOR, this._$gl.ONE);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @return {void}
|
|
118
|
+
* @method
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
toAlpha() {
|
|
122
|
+
if (this._$funcCode !== 606) {
|
|
123
|
+
this._$funcCode = 606;
|
|
124
|
+
this._$gl.blendFunc(this._$gl.ZERO, this._$gl.SRC_ALPHA);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @return {void}
|
|
129
|
+
* @method
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
toErase() {
|
|
133
|
+
if (this._$funcCode !== 603) {
|
|
134
|
+
this._$funcCode = 603;
|
|
135
|
+
this._$gl.blendFunc(this._$gl.ZERO, this._$gl.ONE_MINUS_SRC_ALPHA);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @return {void}
|
|
140
|
+
* @method
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
toSourceAtop() {
|
|
144
|
+
if (this._$funcCode !== 673) {
|
|
145
|
+
this._$funcCode = 673;
|
|
146
|
+
this._$gl.blendFunc(this._$gl.DST_ALPHA, this._$gl.ONE_MINUS_SRC_ALPHA);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @return {void}
|
|
151
|
+
* @method
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
toSourceIn() {
|
|
155
|
+
if (this._$funcCode !== 670) {
|
|
156
|
+
this._$funcCode = 670;
|
|
157
|
+
this._$gl.blendFunc(this._$gl.DST_ALPHA, this._$gl.ZERO);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @param {string} operation
|
|
162
|
+
* @return {void}
|
|
163
|
+
* @method
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
toOperation(operation) {
|
|
167
|
+
switch (operation) {
|
|
168
|
+
case "add":
|
|
169
|
+
this.toAdd();
|
|
170
|
+
break;
|
|
171
|
+
case "screen":
|
|
172
|
+
this.toScreen();
|
|
173
|
+
break;
|
|
174
|
+
case "alpha":
|
|
175
|
+
this.toAlpha();
|
|
176
|
+
break;
|
|
177
|
+
case "erase":
|
|
178
|
+
this.toErase();
|
|
179
|
+
break;
|
|
180
|
+
case "copy":
|
|
181
|
+
this.toOneZero();
|
|
182
|
+
break;
|
|
183
|
+
default:
|
|
184
|
+
this.reset();
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @return {void}
|
|
190
|
+
* @method
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
193
|
+
drawImage(image, x, y, w, h, ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7, operation, renderWidth, renderHeight, matrix, imageSmoothingEnabled) {
|
|
194
|
+
const manager = this._$context.frameBuffer;
|
|
195
|
+
const currentBuffer = manager.currentAttachment;
|
|
196
|
+
const withCT = ct0 !== 1 || ct1 !== 1 || ct2 !== 1 || ct3 !== 1 ||
|
|
197
|
+
ct4 !== 0 || ct5 !== 0 || ct6 !== 0 || ct7 !== 0;
|
|
198
|
+
const variants = this._$context.shaderList.blendShaderVariants;
|
|
199
|
+
switch (operation) {
|
|
200
|
+
case "normal":
|
|
201
|
+
case "layer":
|
|
202
|
+
case "add":
|
|
203
|
+
case "screen":
|
|
204
|
+
case "alpha":
|
|
205
|
+
case "erase":
|
|
206
|
+
case "copy":
|
|
207
|
+
{
|
|
208
|
+
manager.textureManager.bind0(image, imageSmoothingEnabled);
|
|
209
|
+
const shader = variants.getNormalBlendShader(withCT);
|
|
210
|
+
variants.setNormalBlendUniform(shader.uniform, x, y, w, h, matrix, renderWidth, renderHeight, withCT, ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7);
|
|
211
|
+
const a = matrix[0];
|
|
212
|
+
const b = matrix[1];
|
|
213
|
+
const c = matrix[3];
|
|
214
|
+
const d = matrix[4];
|
|
215
|
+
const tx = matrix[6];
|
|
216
|
+
const ty = matrix[7];
|
|
217
|
+
if (a !== 1 || b !== 0 || c !== 0 || d !== 1) {
|
|
218
|
+
const left = x;
|
|
219
|
+
const right = x + w;
|
|
220
|
+
const top = y;
|
|
221
|
+
const bottom = y + h;
|
|
222
|
+
const x0 = +(right * a + bottom * c + tx);
|
|
223
|
+
const x1 = +(right * a + top * c + tx);
|
|
224
|
+
const x2 = +(left * a + bottom * c + tx);
|
|
225
|
+
const x3 = +(left * a + top * c + tx);
|
|
226
|
+
const y0 = +(right * b + bottom * d + ty);
|
|
227
|
+
const y1 = +(right * b + top * d + ty);
|
|
228
|
+
const y2 = +(left * b + bottom * d + ty);
|
|
229
|
+
const y3 = +(left * b + top * d + ty);
|
|
230
|
+
const no = $Number.MAX_VALUE;
|
|
231
|
+
const xMin = +$Math.min($Math.min($Math.min($Math.min(no, x0), x1), x2), x3);
|
|
232
|
+
const xMax = +$Math.max($Math.max($Math.max($Math.max(-no, x0), x1), x2), x3);
|
|
233
|
+
const yMin = +$Math.min($Math.min($Math.min($Math.min(no, y0), y1), y2), y3);
|
|
234
|
+
const yMax = +$Math.max($Math.max($Math.max($Math.max(-no, y0), y1), y2), y3);
|
|
235
|
+
const sx = $Math.max(0, xMin);
|
|
236
|
+
const sy = $Math.max(0, yMin);
|
|
237
|
+
const sw = $Math.min($Math.max(0, renderWidth - sx), $Math.ceil($Math.abs(xMax - xMin)));
|
|
238
|
+
const sh = $Math.min($Math.max(0, renderHeight - sy), $Math.ceil($Math.abs(yMax - yMin)));
|
|
239
|
+
if (!sw || !sh) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
this._$gl.enable(this._$gl.SCISSOR_TEST);
|
|
243
|
+
this._$gl.scissor(sx, $Math.max(0, renderHeight - (sy + sh)), sw + 1, sh + 1);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
const sx = $Math.max(0, x + tx);
|
|
247
|
+
const sy = $Math.max(0, y + ty);
|
|
248
|
+
const sw = $Math.min($Math.max(0, renderWidth - sx), w);
|
|
249
|
+
const sh = $Math.min($Math.max(0, renderHeight - sy), h);
|
|
250
|
+
if (!sw || !sh) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
this._$gl.enable(this._$gl.SCISSOR_TEST);
|
|
254
|
+
this._$gl.scissor(sx, Math.max(0, renderHeight - (sy + sh)), sw + 1, sh + 1);
|
|
255
|
+
}
|
|
256
|
+
this.toOperation(operation);
|
|
257
|
+
shader._$drawImage();
|
|
258
|
+
this._$gl.disable(this._$gl.SCISSOR_TEST);
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
261
|
+
default:
|
|
262
|
+
{
|
|
263
|
+
const sx = Math.max(0, x + matrix[6]);
|
|
264
|
+
const sy = Math.max(0, y + matrix[7]);
|
|
265
|
+
const sw = Math.min(Math.max(0, renderWidth - sx), w);
|
|
266
|
+
const sh = Math.min(Math.max(0, renderHeight - sy), h);
|
|
267
|
+
if (!sw || !sh) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const texture = manager.getTextureFromCurrentAttachment();
|
|
271
|
+
const backTextureAttachment = this
|
|
272
|
+
._$context
|
|
273
|
+
.frameBuffer
|
|
274
|
+
.createTextureAttachment(w, h);
|
|
275
|
+
this._$context._$bind(backTextureAttachment);
|
|
276
|
+
manager.textureManager.bind0(texture);
|
|
277
|
+
const clipShader = variants.getClipShader();
|
|
278
|
+
const clipUniform = clipShader.uniform;
|
|
279
|
+
variants.setClipUniform(clipUniform, x, y, w, h, $inverseMatrix(matrix), renderWidth, renderHeight);
|
|
280
|
+
this.reset();
|
|
281
|
+
clipShader._$drawImage();
|
|
282
|
+
const backTexture = manager
|
|
283
|
+
.getTextureFromCurrentAttachment();
|
|
284
|
+
this._$context._$bind(currentBuffer);
|
|
285
|
+
manager.textureManager.bind01(backTexture, image, imageSmoothingEnabled);
|
|
286
|
+
const shader = variants
|
|
287
|
+
.getBlendShader(operation, withCT);
|
|
288
|
+
variants.setBlendUniform(shader.uniform, x, y, w, h, matrix, renderWidth, renderHeight, withCT, ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7);
|
|
289
|
+
this._$gl.enable(this._$gl.SCISSOR_TEST);
|
|
290
|
+
this._$gl.scissor(sx, Math.max(0, renderHeight - (sy + sh)), sw, sh);
|
|
291
|
+
this.toOneZero();
|
|
292
|
+
shader._$drawImage();
|
|
293
|
+
this._$gl.disable(this._$gl.SCISSOR_TEST);
|
|
294
|
+
manager.releaseAttachment(backTextureAttachment, true);
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { BoundsImpl } from "./interface/BoundsImpl";
|
|
2
|
+
import type { GridImpl } from "./interface/GridImpl";
|
|
3
|
+
/**
|
|
4
|
+
* @class
|
|
5
|
+
*/
|
|
6
|
+
export declare class CanvasToWebGLContextGrid {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
parentMatrixA: number;
|
|
9
|
+
parentMatrixB: number;
|
|
10
|
+
parentMatrixC: number;
|
|
11
|
+
parentMatrixD: number;
|
|
12
|
+
parentMatrixE: number;
|
|
13
|
+
parentMatrixF: number;
|
|
14
|
+
parentMatrixG: number;
|
|
15
|
+
parentMatrixH: number;
|
|
16
|
+
parentMatrixI: number;
|
|
17
|
+
ancestorMatrixA: number;
|
|
18
|
+
ancestorMatrixB: number;
|
|
19
|
+
ancestorMatrixC: number;
|
|
20
|
+
ancestorMatrixD: number;
|
|
21
|
+
ancestorMatrixE: number;
|
|
22
|
+
ancestorMatrixF: number;
|
|
23
|
+
ancestorMatrixG: number;
|
|
24
|
+
ancestorMatrixH: number;
|
|
25
|
+
ancestorMatrixI: number;
|
|
26
|
+
parentViewportX: number;
|
|
27
|
+
parentViewportY: number;
|
|
28
|
+
parentViewportW: number;
|
|
29
|
+
parentViewportH: number;
|
|
30
|
+
minXST: number;
|
|
31
|
+
minYST: number;
|
|
32
|
+
minXPQ: number;
|
|
33
|
+
minYPQ: number;
|
|
34
|
+
maxXST: number;
|
|
35
|
+
maxYST: number;
|
|
36
|
+
maxXPQ: number;
|
|
37
|
+
maxYPQ: number;
|
|
38
|
+
/**
|
|
39
|
+
* @constructor
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
constructor();
|
|
43
|
+
/**
|
|
44
|
+
* @param {number} x
|
|
45
|
+
* @param {number} y
|
|
46
|
+
* @param {number} width
|
|
47
|
+
* @param {number} height
|
|
48
|
+
* @param {object} bounds
|
|
49
|
+
* @param {object} grid
|
|
50
|
+
* @param {number} same_scale
|
|
51
|
+
* @param {number} parentA
|
|
52
|
+
* @param {number} parentB
|
|
53
|
+
* @param {number} parentC
|
|
54
|
+
* @param {number} parentD
|
|
55
|
+
* @param {number} parentE
|
|
56
|
+
* @param {number} parentF
|
|
57
|
+
* @param {number} ancestorA
|
|
58
|
+
* @param {number} ancestorB
|
|
59
|
+
* @param {number} ancestorC
|
|
60
|
+
* @param {number} ancestorD
|
|
61
|
+
* @param {number} ancestorE
|
|
62
|
+
* @param {number} ancestorF
|
|
63
|
+
* @return {void}
|
|
64
|
+
* @method
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
enable(x: number, y: number, width: number, height: number, bounds: BoundsImpl, grid: GridImpl, same_scale: number, parentA: number, parentB: number, parentC: number, parentD: number, parentE: number, parentF: number, ancestorA: number, ancestorB: number, ancestorC: number, ancestorD: number, ancestorE: number, ancestorF: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* @return void
|
|
70
|
+
* @method
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
disable(): void;
|
|
74
|
+
}
|