@next2d/webgl 1.15.0 → 1.17.0
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/dist/CanvasPatternToWebGL.d.ts +0 -6
- package/dist/CanvasPatternToWebGL.js +0 -11
- package/dist/CanvasToWebGLContext.d.ts +90 -31
- package/dist/CanvasToWebGLContext.js +244 -71
- package/dist/CanvasToWebGLContextBlend.d.ts +79 -1
- package/dist/CanvasToWebGLContextBlend.js +197 -13
- package/dist/CanvasToWebGLContextMask.d.ts +0 -6
- package/dist/CanvasToWebGLContextMask.js +1 -26
- package/dist/CanvasToWebGLContextStyle.js +0 -2
- package/dist/Const.d.ts +12 -0
- package/dist/Const.js +14 -0
- package/dist/FrameBufferManager.d.ts +42 -3
- package/dist/FrameBufferManager.js +109 -0
- package/dist/TextureManager.d.ts +54 -4
- package/dist/TextureManager.js +239 -4
- package/dist/VertexArrayObjectManager.d.ts +19 -0
- package/dist/VertexArrayObjectManager.js +69 -18
- package/dist/interface/BlendModeImpl.d.ts +1 -0
- package/dist/interface/BlendModeImpl.js +1 -0
- package/dist/interface/CachePositionImpl.d.ts +11 -0
- package/dist/interface/CachePositionImpl.js +1 -0
- package/dist/interface/PointImpl.d.ts +4 -0
- package/dist/interface/PointImpl.js +1 -0
- package/dist/shader/CanvasToWebGLShader.d.ts +18 -4
- package/dist/shader/CanvasToWebGLShader.js +36 -15
- package/dist/shader/GradientLUTGenerator.js +7 -0
- package/dist/shader/WebGLShaderInstance.d.ts +30 -0
- package/dist/shader/WebGLShaderInstance.js +48 -0
- package/dist/shader/WebGLShaderUniform.js +0 -6
- package/dist/shader/fragment/FragmentShaderLibrary.d.ts +6 -0
- package/dist/shader/fragment/FragmentShaderLibrary.js +13 -4
- package/dist/shader/fragment/FragmentShaderSourceBlend.d.ts +8 -0
- package/dist/shader/fragment/FragmentShaderSourceBlend.js +65 -0
- package/dist/shader/fragment/FragmentShaderSourceTexture.d.ts +6 -0
- package/dist/shader/fragment/FragmentShaderSourceTexture.js +32 -0
- package/dist/shader/variants/BlendShaderVariantCollection.d.ts +60 -0
- package/dist/shader/variants/BlendShaderVariantCollection.js +137 -0
- package/dist/shader/vertex/VertexShaderSource.d.ts +12 -0
- package/dist/shader/vertex/VertexShaderSource.js +72 -0
- package/dist/shader/vertex/VertexShaderSourceFill.js +8 -4
- package/package.json +2 -2
|
@@ -12,12 +12,6 @@ export declare class CanvasPatternToWebGL {
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
constructor(context: CanvasToWebGLContext, texture: WebGLTexture, repeat: boolean, color_transform: Float32Array);
|
|
15
|
-
/**
|
|
16
|
-
* @return {void}
|
|
17
|
-
* @method
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
dispose(): void;
|
|
21
15
|
/**
|
|
22
16
|
* @member {WebGLTexture}
|
|
23
17
|
* @readonly
|
|
@@ -28,17 +28,6 @@ export class CanvasPatternToWebGL {
|
|
|
28
28
|
*/
|
|
29
29
|
this._$colorTransform = color_transform;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* @return {void}
|
|
33
|
-
* @method
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
dispose() {
|
|
37
|
-
this
|
|
38
|
-
._$context
|
|
39
|
-
.frameBuffer
|
|
40
|
-
.releaseTexture(this._$texture);
|
|
41
|
-
}
|
|
42
31
|
/**
|
|
43
32
|
* @member {WebGLTexture}
|
|
44
33
|
* @readonly
|
|
@@ -6,18 +6,25 @@ import { VertexArrayObjectManager } from "./VertexArrayObjectManager";
|
|
|
6
6
|
import { CanvasToWebGLContextBlend } from "./CanvasToWebGLContextBlend";
|
|
7
7
|
import { CanvasPatternToWebGL } from "./CanvasPatternToWebGL";
|
|
8
8
|
import { CanvasGradientToWebGL } from "./CanvasGradientToWebGL";
|
|
9
|
-
import { AttachmentImpl
|
|
9
|
+
import type { AttachmentImpl } from "./interface/AttachmentImpl";
|
|
10
|
+
import type { BoundsImpl } from "./interface/BoundsImpl";
|
|
11
|
+
import type { BlendModeImpl } from "./interface/BlendModeImpl";
|
|
12
|
+
import type { PointImpl } from "./interface/PointImpl";
|
|
13
|
+
import type { InterpolationMethodImpl } from "./interface/InterpolationMethodImpl";
|
|
14
|
+
import type { SpreadMethodImpl } from "./interface/SpreadMethodImpl";
|
|
15
|
+
import type { CapsStyleImpl } from "./interface/CapsStyleImpl";
|
|
16
|
+
import type { JointStyleImpl } from "./interface/JointStyleImpl";
|
|
17
|
+
import type { CachePositionImpl } from "./interface/CachePositionImpl";
|
|
10
18
|
/**
|
|
11
19
|
* @class
|
|
12
20
|
*/
|
|
13
21
|
export declare class CanvasToWebGLContext {
|
|
22
|
+
_$offsetX: number;
|
|
23
|
+
_$offsetY: number;
|
|
14
24
|
readonly _$gl: WebGL2RenderingContext;
|
|
15
|
-
private readonly _$maxTextureSize;
|
|
16
|
-
private readonly _$contextStyle;
|
|
17
25
|
private _$cacheBounds;
|
|
18
26
|
private _$matrix;
|
|
19
27
|
private _$cacheAttachment;
|
|
20
|
-
private readonly _$stack;
|
|
21
28
|
private _$globalAlpha;
|
|
22
29
|
private _$imageSmoothingEnabled;
|
|
23
30
|
private _$globalCompositeOperation;
|
|
@@ -27,21 +34,22 @@ export declare class CanvasToWebGLContext {
|
|
|
27
34
|
private _$clearColorA;
|
|
28
35
|
private _$viewportWidth;
|
|
29
36
|
private _$viewportHeight;
|
|
37
|
+
private _$cachePosition;
|
|
38
|
+
private _$isLayer;
|
|
39
|
+
private readonly _$maxTextureSize;
|
|
40
|
+
private readonly _$contextStyle;
|
|
41
|
+
private readonly _$stack;
|
|
42
|
+
private readonly _$blends;
|
|
43
|
+
private readonly _$positions;
|
|
30
44
|
private readonly _$frameBufferManager;
|
|
31
45
|
private readonly _$path;
|
|
32
46
|
private readonly _$grid;
|
|
33
|
-
_$offsetX: number;
|
|
34
|
-
_$offsetY: number;
|
|
35
|
-
private readonly _$blends;
|
|
36
|
-
private readonly _$positions;
|
|
37
|
-
private _$isLayer;
|
|
38
47
|
private readonly _$shaderList;
|
|
39
48
|
private readonly _$gradientLUT;
|
|
40
49
|
private readonly _$vao;
|
|
41
50
|
private readonly _$mask;
|
|
42
51
|
private readonly _$blend;
|
|
43
|
-
private readonly _$
|
|
44
|
-
private readonly _$maskBoundsArray;
|
|
52
|
+
private readonly _$maskBounds;
|
|
45
53
|
private readonly _$attachmentArray;
|
|
46
54
|
/**
|
|
47
55
|
* @param {WebGL2RenderingContext} gl
|
|
@@ -50,6 +58,12 @@ export declare class CanvasToWebGLContext {
|
|
|
50
58
|
* @public
|
|
51
59
|
*/
|
|
52
60
|
constructor(gl: WebGL2RenderingContext, sample: number);
|
|
61
|
+
/**
|
|
62
|
+
* @member {object}
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
get cachePosition(): CachePositionImpl | null;
|
|
66
|
+
set cachePosition(cache_position: CachePositionImpl | null);
|
|
53
67
|
/**
|
|
54
68
|
* @return {void}
|
|
55
69
|
* @method
|
|
@@ -185,6 +199,55 @@ export declare class CanvasToWebGLContext {
|
|
|
185
199
|
* @public
|
|
186
200
|
*/
|
|
187
201
|
_$getTextureScale(width: number, height: number): number;
|
|
202
|
+
/**
|
|
203
|
+
* @description 描画用のbufferをbind
|
|
204
|
+
*
|
|
205
|
+
* @return {void}
|
|
206
|
+
* @method
|
|
207
|
+
* @public
|
|
208
|
+
*/
|
|
209
|
+
drawInstacedArray(): void;
|
|
210
|
+
/**
|
|
211
|
+
* @return {void}
|
|
212
|
+
* @method
|
|
213
|
+
* @public
|
|
214
|
+
*/
|
|
215
|
+
clearInstacedArray(): void;
|
|
216
|
+
/**
|
|
217
|
+
* @description 描画用のbufferをbind
|
|
218
|
+
*
|
|
219
|
+
* @param {object} position
|
|
220
|
+
* @return {void}
|
|
221
|
+
* @method
|
|
222
|
+
* @public
|
|
223
|
+
*/
|
|
224
|
+
bindRenderBuffer(position: CachePositionImpl): void;
|
|
225
|
+
/**
|
|
226
|
+
* @param {object} position
|
|
227
|
+
* @return {WebGLTexture}
|
|
228
|
+
* @method
|
|
229
|
+
* @public
|
|
230
|
+
*/
|
|
231
|
+
getTextureFromRect(position: CachePositionImpl): WebGLTexture;
|
|
232
|
+
/**
|
|
233
|
+
* @param {WebGLTexture} texture
|
|
234
|
+
* @return {void}
|
|
235
|
+
* @method
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
drawBitmap(texture: WebGLTexture): void;
|
|
239
|
+
/**
|
|
240
|
+
* @return {void}
|
|
241
|
+
* @method
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
drawTextureFromRect(texture: WebGLTexture, position: CachePositionImpl): void;
|
|
245
|
+
/**
|
|
246
|
+
* @return {void}
|
|
247
|
+
* @method
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
stopStencil(): void;
|
|
188
251
|
/**
|
|
189
252
|
* @param {object} [attachment = null]
|
|
190
253
|
* @return {void}
|
|
@@ -224,6 +287,18 @@ export declare class CanvasToWebGLContext {
|
|
|
224
287
|
* @public
|
|
225
288
|
*/
|
|
226
289
|
transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
290
|
+
debug(index?: number): void;
|
|
291
|
+
/**
|
|
292
|
+
* @param {number} x_min
|
|
293
|
+
* @param {number} y_min
|
|
294
|
+
* @param {number} x_max
|
|
295
|
+
* @param {number} y_max
|
|
296
|
+
* @param {Float32Array} color_transform
|
|
297
|
+
* @return {void}
|
|
298
|
+
* @method
|
|
299
|
+
* @public
|
|
300
|
+
*/
|
|
301
|
+
drawInstance(x_min: number, y_min: number, x_max: number, y_max: number, color_transform: Float32Array): void;
|
|
227
302
|
/**
|
|
228
303
|
* @param {WebGLTexture} image
|
|
229
304
|
* @param {number} x
|
|
@@ -257,15 +332,11 @@ export declare class CanvasToWebGLContext {
|
|
|
257
332
|
*/
|
|
258
333
|
clearRect(x: number, y: number, w: number, h: number): void;
|
|
259
334
|
/**
|
|
260
|
-
* @param {number} x
|
|
261
|
-
* @param {number} y
|
|
262
|
-
* @param {number} w
|
|
263
|
-
* @param {number} h
|
|
264
335
|
* @return {void}
|
|
265
336
|
* @method
|
|
266
337
|
* @public
|
|
267
338
|
*/
|
|
268
|
-
_$clearRectStencil(
|
|
339
|
+
_$clearRectStencil(): void;
|
|
269
340
|
/**
|
|
270
341
|
* @param {number} x
|
|
271
342
|
* @param {number} y
|
|
@@ -346,13 +417,12 @@ export declare class CanvasToWebGLContext {
|
|
|
346
417
|
* @description マスク処理の開始関数
|
|
347
418
|
* Mask processing start function
|
|
348
419
|
*
|
|
349
|
-
* @param {Float32Array} matrix
|
|
350
420
|
* @param {object} bounds
|
|
351
|
-
* @return {
|
|
421
|
+
* @return {void}
|
|
352
422
|
* @method
|
|
353
423
|
* @public
|
|
354
424
|
*/
|
|
355
|
-
_$startClip(
|
|
425
|
+
_$startClip(bounds: BoundsImpl): boolean;
|
|
356
426
|
/**
|
|
357
427
|
* @return {void}
|
|
358
428
|
* @method
|
|
@@ -546,12 +616,6 @@ export declare class CanvasToWebGLContext {
|
|
|
546
616
|
* @private
|
|
547
617
|
*/
|
|
548
618
|
_$endLayer(): void;
|
|
549
|
-
/**
|
|
550
|
-
* @return {void}
|
|
551
|
-
* @method
|
|
552
|
-
* @private
|
|
553
|
-
*/
|
|
554
|
-
_$saveCurrentMask(): void;
|
|
555
619
|
/**
|
|
556
620
|
* @param {number} width
|
|
557
621
|
* @param {number} height
|
|
@@ -562,17 +626,12 @@ export declare class CanvasToWebGLContext {
|
|
|
562
626
|
*/
|
|
563
627
|
_$saveAttachment(width: number, height: number, multisample?: boolean): void;
|
|
564
628
|
/**
|
|
629
|
+
* @param {boolean} [release_texture = false]
|
|
565
630
|
* @return {void}
|
|
566
631
|
* @method
|
|
567
632
|
* @private
|
|
568
633
|
*/
|
|
569
634
|
_$restoreAttachment(release_texture?: boolean): void;
|
|
570
|
-
/**
|
|
571
|
-
* @return {void}
|
|
572
|
-
* @method
|
|
573
|
-
* @private
|
|
574
|
-
*/
|
|
575
|
-
_$restoreCurrentMask(): void;
|
|
576
635
|
/**
|
|
577
636
|
* @return {object}
|
|
578
637
|
* @method
|
|
@@ -10,7 +10,8 @@ import { CanvasToWebGLContextBlend } from "./CanvasToWebGLContextBlend";
|
|
|
10
10
|
import { CanvasPatternToWebGL } from "./CanvasPatternToWebGL";
|
|
11
11
|
import { CanvasGradientToWebGL } from "./CanvasGradientToWebGL";
|
|
12
12
|
import { WebGLFillMeshGenerator } from "./WebGLFillMeshGenerator";
|
|
13
|
-
import { $
|
|
13
|
+
import { $setRenderSize } from "./Const";
|
|
14
|
+
import { $Math, $getFloat32Array9, $getArray, $clamp, $poolArray, $inverseMatrix, $poolFloat32Array9, $poolBoundsObject, $getBoundsObject } from "@next2d/share";
|
|
14
15
|
/**
|
|
15
16
|
* @class
|
|
16
17
|
*/
|
|
@@ -22,6 +23,7 @@ export class CanvasToWebGLContext {
|
|
|
22
23
|
* @public
|
|
23
24
|
*/
|
|
24
25
|
constructor(gl, sample) {
|
|
26
|
+
$setRenderSize(gl.getParameter(gl.MAX_TEXTURE_SIZE));
|
|
25
27
|
/**
|
|
26
28
|
* @type {WebGL2RenderingContext}
|
|
27
29
|
* @private
|
|
@@ -189,17 +191,28 @@ export class CanvasToWebGLContext {
|
|
|
189
191
|
* @type {array}
|
|
190
192
|
* @private
|
|
191
193
|
*/
|
|
192
|
-
this._$
|
|
194
|
+
this._$attachmentArray = [];
|
|
193
195
|
/**
|
|
194
|
-
* @type {
|
|
196
|
+
* @type {object}
|
|
195
197
|
* @private
|
|
196
198
|
*/
|
|
197
|
-
this._$
|
|
199
|
+
this._$maskBounds = $getBoundsObject(0, 0, 0, 0);
|
|
198
200
|
/**
|
|
199
|
-
* @type {
|
|
201
|
+
* @type {object}
|
|
202
|
+
* @default null
|
|
200
203
|
* @private
|
|
201
204
|
*/
|
|
202
|
-
this._$
|
|
205
|
+
this._$cachePosition = null;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* @member {object}
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
get cachePosition() {
|
|
212
|
+
return this._$cachePosition;
|
|
213
|
+
}
|
|
214
|
+
set cachePosition(cache_position) {
|
|
215
|
+
this._$cachePosition = cache_position;
|
|
203
216
|
}
|
|
204
217
|
/**
|
|
205
218
|
* @return {void}
|
|
@@ -409,6 +422,130 @@ export class CanvasToWebGLContext {
|
|
|
409
422
|
}
|
|
410
423
|
return 1;
|
|
411
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* @description 描画用のbufferをbind
|
|
427
|
+
*
|
|
428
|
+
* @return {void}
|
|
429
|
+
* @method
|
|
430
|
+
* @public
|
|
431
|
+
*/
|
|
432
|
+
drawInstacedArray() {
|
|
433
|
+
this.blend.drawInstacedArray();
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* @return {void}
|
|
437
|
+
* @method
|
|
438
|
+
* @public
|
|
439
|
+
*/
|
|
440
|
+
clearInstacedArray() {
|
|
441
|
+
this.blend.clearInstacedArray();
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* @description 描画用のbufferをbind
|
|
445
|
+
*
|
|
446
|
+
* @param {object} position
|
|
447
|
+
* @return {void}
|
|
448
|
+
* @method
|
|
449
|
+
* @public
|
|
450
|
+
*/
|
|
451
|
+
bindRenderBuffer(position) {
|
|
452
|
+
this
|
|
453
|
+
._$frameBufferManager
|
|
454
|
+
.bindRenderBuffer();
|
|
455
|
+
// 初期化
|
|
456
|
+
this._$gl.clearColor(0, 0, 0, 0);
|
|
457
|
+
this._$gl.clear(this._$gl.COLOR_BUFFER_BIT | this._$gl.STENCIL_BUFFER_BIT);
|
|
458
|
+
// 描画領域をあらためて設定
|
|
459
|
+
this._$viewportWidth = position.w;
|
|
460
|
+
this._$viewportHeight = position.h;
|
|
461
|
+
this._$gl.viewport(position.x, position.y, position.w, position.h);
|
|
462
|
+
this._$gl.enable(this._$gl.SCISSOR_TEST);
|
|
463
|
+
this._$gl.scissor(position.x, position.y, position.w, position.h);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* @param {object} position
|
|
467
|
+
* @return {WebGLTexture}
|
|
468
|
+
* @method
|
|
469
|
+
* @public
|
|
470
|
+
*/
|
|
471
|
+
getTextureFromRect(position) {
|
|
472
|
+
const manager = this._$frameBufferManager;
|
|
473
|
+
const atlasTexture = manager
|
|
474
|
+
.textureManager
|
|
475
|
+
.getAtlasTexture(position.index);
|
|
476
|
+
const currentAttachment = manager.currentAttachment;
|
|
477
|
+
const attachment = manager
|
|
478
|
+
.createTextureAttachment(position.w, position.h);
|
|
479
|
+
this._$bind(attachment);
|
|
480
|
+
this.save();
|
|
481
|
+
this.setTransform(1, 0, 0, 1, 0, 0);
|
|
482
|
+
this.reset();
|
|
483
|
+
this.drawImage(atlasTexture, -position.x, -atlasTexture.height + position.h + position.y, atlasTexture.width, atlasTexture.height);
|
|
484
|
+
this.restore();
|
|
485
|
+
const texture = attachment.texture;
|
|
486
|
+
manager.releaseAttachment(attachment);
|
|
487
|
+
// reset
|
|
488
|
+
this._$bind(currentAttachment);
|
|
489
|
+
return texture;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* @param {WebGLTexture} texture
|
|
493
|
+
* @return {void}
|
|
494
|
+
* @method
|
|
495
|
+
* @public
|
|
496
|
+
*/
|
|
497
|
+
drawBitmap(texture) {
|
|
498
|
+
const variants = this
|
|
499
|
+
._$shaderList
|
|
500
|
+
.blendShaderVariants;
|
|
501
|
+
const shader = variants
|
|
502
|
+
.getNormalBlendShader(false);
|
|
503
|
+
variants.setNormalBlendUniform(shader.uniform, 0, 0, texture.width, texture.height, this._$matrix, this._$viewportWidth, this._$viewportHeight, false, 1, 1, 1, 1, 0, 0, 0, 0);
|
|
504
|
+
this
|
|
505
|
+
._$frameBufferManager
|
|
506
|
+
.textureManager
|
|
507
|
+
.bind0(texture, this._$imageSmoothingEnabled);
|
|
508
|
+
this.blend.toOperation("normal");
|
|
509
|
+
shader._$drawImage();
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* @return {void}
|
|
513
|
+
* @method
|
|
514
|
+
* @public
|
|
515
|
+
*/
|
|
516
|
+
drawTextureFromRect(texture, position) {
|
|
517
|
+
const manager = this._$frameBufferManager;
|
|
518
|
+
const currentAttachment = manager.currentAttachment;
|
|
519
|
+
this.bindRenderBuffer(position);
|
|
520
|
+
manager.transferTexture(position);
|
|
521
|
+
const atlasTexture = manager
|
|
522
|
+
.textureManager
|
|
523
|
+
.getAtlasTexture(position.index);
|
|
524
|
+
const attachment = manager
|
|
525
|
+
.createTextureAttachmentFrom(atlasTexture);
|
|
526
|
+
this._$bind(attachment);
|
|
527
|
+
this._$gl.enable(this._$gl.SCISSOR_TEST);
|
|
528
|
+
this._$gl.scissor(position.x, position.y, position.w, position.h);
|
|
529
|
+
this._$gl.clearColor(0, 0, 0, 0);
|
|
530
|
+
this._$gl.disable(this._$gl.SCISSOR_TEST);
|
|
531
|
+
this.save();
|
|
532
|
+
this.setTransform(1, 0, 0, 1, 0, 0);
|
|
533
|
+
this.reset();
|
|
534
|
+
this.drawImage(texture, position.x, atlasTexture.height - position.h - position.y, texture.width, texture.height);
|
|
535
|
+
this.restore();
|
|
536
|
+
manager.releaseAttachment(attachment);
|
|
537
|
+
// reset
|
|
538
|
+
this._$bind(currentAttachment);
|
|
539
|
+
manager.textureManager.release(texture);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* @return {void}
|
|
543
|
+
* @method
|
|
544
|
+
* @public
|
|
545
|
+
*/
|
|
546
|
+
stopStencil() {
|
|
547
|
+
this._$mask._$onClearRect();
|
|
548
|
+
}
|
|
412
549
|
/**
|
|
413
550
|
* @param {object} [attachment = null]
|
|
414
551
|
* @return {void}
|
|
@@ -499,6 +636,80 @@ export class CanvasToWebGLContext {
|
|
|
499
636
|
this._$matrix[6] = e * a00 + f * a10 + a20;
|
|
500
637
|
this._$matrix[7] = e * a01 + f * a11 + a21;
|
|
501
638
|
}
|
|
639
|
+
debug(index = 0) {
|
|
640
|
+
const manager = this._$frameBufferManager;
|
|
641
|
+
const atlasTexture = manager
|
|
642
|
+
.textureManager
|
|
643
|
+
.getAtlasTexture(index);
|
|
644
|
+
const currentAttachment = manager.currentAttachment;
|
|
645
|
+
const attachment = manager.createTextureAttachmentFrom(atlasTexture);
|
|
646
|
+
this._$bind(attachment);
|
|
647
|
+
const pixels = new Uint8Array(atlasTexture.width * atlasTexture.height * 4);
|
|
648
|
+
this._$gl.readPixels(0, 0, atlasTexture.width, atlasTexture.height, this._$gl.RGBA, this._$gl.UNSIGNED_BYTE, pixels);
|
|
649
|
+
const canvas = document.createElement("canvas");
|
|
650
|
+
canvas.width = atlasTexture.width;
|
|
651
|
+
canvas.height = atlasTexture.height;
|
|
652
|
+
const ctx = canvas.getContext("2d");
|
|
653
|
+
const imageData = new ImageData(atlasTexture.width, atlasTexture.height);
|
|
654
|
+
for (let idx = 0; idx < pixels.length; ++idx) {
|
|
655
|
+
imageData.data[idx] = pixels[idx];
|
|
656
|
+
}
|
|
657
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.putImageData(imageData, 0, 0);
|
|
658
|
+
console.log(canvas.toDataURL());
|
|
659
|
+
this._$bind(currentAttachment);
|
|
660
|
+
manager.releaseAttachment(attachment);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* @param {number} x_min
|
|
664
|
+
* @param {number} y_min
|
|
665
|
+
* @param {number} x_max
|
|
666
|
+
* @param {number} y_max
|
|
667
|
+
* @param {Float32Array} color_transform
|
|
668
|
+
* @return {void}
|
|
669
|
+
* @method
|
|
670
|
+
* @public
|
|
671
|
+
*/
|
|
672
|
+
drawInstance(x_min, y_min, x_max, y_max, color_transform) {
|
|
673
|
+
let ct0 = 1;
|
|
674
|
+
let ct1 = 1;
|
|
675
|
+
let ct2 = 1;
|
|
676
|
+
let ct4 = 0;
|
|
677
|
+
let ct5 = 0;
|
|
678
|
+
let ct6 = 0;
|
|
679
|
+
const ct3 = this._$globalAlpha;
|
|
680
|
+
const ct7 = 0;
|
|
681
|
+
if (color_transform) {
|
|
682
|
+
ct0 = color_transform[0];
|
|
683
|
+
ct1 = color_transform[1];
|
|
684
|
+
ct2 = color_transform[2];
|
|
685
|
+
ct4 = color_transform[4] / 255;
|
|
686
|
+
ct5 = color_transform[5] / 255;
|
|
687
|
+
ct6 = color_transform[6] / 255;
|
|
688
|
+
}
|
|
689
|
+
const position = this._$cachePosition;
|
|
690
|
+
if (position) {
|
|
691
|
+
switch (this._$globalCompositeOperation) {
|
|
692
|
+
case "normal":
|
|
693
|
+
case "layer":
|
|
694
|
+
case "add":
|
|
695
|
+
case "screen":
|
|
696
|
+
case "alpha":
|
|
697
|
+
case "erase":
|
|
698
|
+
case "copy":
|
|
699
|
+
this.blend.drawInstance(position, ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7, this._$globalCompositeOperation, this._$viewportWidth, this._$viewportHeight, this._$matrix, this._$imageSmoothingEnabled);
|
|
700
|
+
break;
|
|
701
|
+
default:
|
|
702
|
+
{
|
|
703
|
+
const atlasTexture = this
|
|
704
|
+
._$frameBufferManager
|
|
705
|
+
.textureManager
|
|
706
|
+
.getAtlasTexture(position.index);
|
|
707
|
+
this.blend.drawInstanceBlend(atlasTexture, x_min, y_min, x_max, y_max, ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7, position, this._$globalCompositeOperation, this._$viewportWidth, this._$viewportHeight, this._$matrix, this._$imageSmoothingEnabled);
|
|
708
|
+
}
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
502
713
|
/**
|
|
503
714
|
* @param {WebGLTexture} image
|
|
504
715
|
* @param {number} x
|
|
@@ -562,18 +773,16 @@ export class CanvasToWebGLContext {
|
|
|
562
773
|
this._$gl.disable(this._$gl.SCISSOR_TEST);
|
|
563
774
|
}
|
|
564
775
|
/**
|
|
565
|
-
* @param {number} x
|
|
566
|
-
* @param {number} y
|
|
567
|
-
* @param {number} w
|
|
568
|
-
* @param {number} h
|
|
569
776
|
* @return {void}
|
|
570
777
|
* @method
|
|
571
778
|
* @public
|
|
572
779
|
*/
|
|
573
|
-
_$clearRectStencil(
|
|
780
|
+
_$clearRectStencil() {
|
|
781
|
+
// stencilを終了
|
|
574
782
|
this._$mask._$onClearRect();
|
|
783
|
+
// マスクの描画領域に限定してstencil情報をクリア
|
|
575
784
|
this._$gl.enable(this._$gl.SCISSOR_TEST);
|
|
576
|
-
this._$gl.scissor(
|
|
785
|
+
this._$gl.scissor(this._$maskBounds.xMin, this._$maskBounds.yMin, this._$maskBounds.xMax, this._$maskBounds.yMax);
|
|
577
786
|
this._$gl.clear(this._$gl.STENCIL_BUFFER_BIT);
|
|
578
787
|
this._$gl.disable(this._$gl.SCISSOR_TEST);
|
|
579
788
|
}
|
|
@@ -671,6 +880,9 @@ export class CanvasToWebGLContext {
|
|
|
671
880
|
._$frameBufferManager
|
|
672
881
|
.textureManager
|
|
673
882
|
.bind0(texture, true);
|
|
883
|
+
this
|
|
884
|
+
._$frameBufferManager
|
|
885
|
+
.bindRenderBuffer();
|
|
674
886
|
variants = this
|
|
675
887
|
._$shaderList
|
|
676
888
|
.gradientShapeShaderVariants;
|
|
@@ -787,59 +999,37 @@ export class CanvasToWebGLContext {
|
|
|
787
999
|
* @description マスク処理の開始関数
|
|
788
1000
|
* Mask processing start function
|
|
789
1001
|
*
|
|
790
|
-
* @param {Float32Array} matrix
|
|
791
1002
|
* @param {object} bounds
|
|
792
|
-
* @return {
|
|
1003
|
+
* @return {void}
|
|
793
1004
|
* @method
|
|
794
1005
|
* @public
|
|
795
1006
|
*/
|
|
796
|
-
_$startClip(
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
1007
|
+
_$startClip(bounds) {
|
|
1008
|
+
const x = bounds.xMin;
|
|
1009
|
+
const y = bounds.yMin;
|
|
1010
|
+
const width = Math.abs(bounds.xMax - bounds.xMin);
|
|
1011
|
+
const height = Math.abs(bounds.yMax - bounds.yMin);
|
|
801
1012
|
// resize
|
|
802
1013
|
const manager = this._$frameBufferManager;
|
|
803
1014
|
const currentAttachment = manager.currentAttachment;
|
|
804
|
-
if (!currentAttachment
|
|
1015
|
+
if (!currentAttachment) {
|
|
805
1016
|
throw new Error("the current Attachment is null.");
|
|
806
1017
|
}
|
|
807
1018
|
if (x > currentAttachment.width
|
|
808
1019
|
|| y > currentAttachment.height) {
|
|
809
|
-
return
|
|
810
|
-
}
|
|
811
|
-
if (width + x > currentAttachment.width) {
|
|
812
|
-
width = currentAttachment.width - x;
|
|
1020
|
+
return false;
|
|
813
1021
|
}
|
|
814
|
-
if (
|
|
815
|
-
|
|
1022
|
+
if (0 > x && 0 >= width + x) {
|
|
1023
|
+
return false;
|
|
816
1024
|
}
|
|
817
|
-
if (0 >
|
|
818
|
-
|
|
819
|
-
x = 0;
|
|
1025
|
+
if (0 > y && 0 >= height + y) {
|
|
1026
|
+
return false;
|
|
820
1027
|
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
return null;
|
|
827
|
-
}
|
|
828
|
-
width = $Math.ceil(width);
|
|
829
|
-
height = $Math.ceil(height);
|
|
830
|
-
this._$cacheBounds.xMin = x;
|
|
831
|
-
this._$cacheBounds.yMin = y;
|
|
832
|
-
this._$cacheBounds.xMax = width;
|
|
833
|
-
this._$cacheBounds.yMax = height;
|
|
834
|
-
this._$cacheAttachment = currentAttachment;
|
|
835
|
-
// create new buffer
|
|
836
|
-
this._$bind(manager.createCacheAttachment(width, height, true));
|
|
837
|
-
// draw background
|
|
838
|
-
const texture = currentAttachment.texture;
|
|
839
|
-
this.reset();
|
|
840
|
-
this.setTransform(1, 0, 0, 1, 0, 0);
|
|
841
|
-
this.drawImage(texture, -x, -y, texture.width, texture.height);
|
|
842
|
-
return $getFloat32Array6(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4] - bounds.xMin, matrix[5] - bounds.yMin);
|
|
1028
|
+
this._$maskBounds.xMin = $Math.max(0, $Math.min(this._$maskBounds.xMin, x));
|
|
1029
|
+
this._$maskBounds.yMin = $Math.max(0, $Math.min(this._$maskBounds.yMin, y));
|
|
1030
|
+
this._$maskBounds.xMax = $Math.min(currentAttachment.width, $Math.min(this._$maskBounds.xMax, width));
|
|
1031
|
+
this._$maskBounds.yMax = $Math.min(currentAttachment.height, $Math.min(this._$maskBounds.yMax, height));
|
|
1032
|
+
return true;
|
|
843
1033
|
}
|
|
844
1034
|
/**
|
|
845
1035
|
* @return {void}
|
|
@@ -855,6 +1045,7 @@ export class CanvasToWebGLContext {
|
|
|
855
1045
|
* @public
|
|
856
1046
|
*/
|
|
857
1047
|
_$leaveClip() {
|
|
1048
|
+
this.drawInstacedArray();
|
|
858
1049
|
this._$mask._$leaveClip();
|
|
859
1050
|
}
|
|
860
1051
|
/**
|
|
@@ -1356,17 +1547,6 @@ export class CanvasToWebGLContext {
|
|
|
1356
1547
|
}
|
|
1357
1548
|
this._$isLayer = !!this._$blends.pop();
|
|
1358
1549
|
}
|
|
1359
|
-
/**
|
|
1360
|
-
* @return {void}
|
|
1361
|
-
* @method
|
|
1362
|
-
* @private
|
|
1363
|
-
*/
|
|
1364
|
-
_$saveCurrentMask() {
|
|
1365
|
-
this._$maskBufferArray.push(this._$cacheAttachment);
|
|
1366
|
-
this._$cacheAttachment = null;
|
|
1367
|
-
const bounds = this._$cacheBounds;
|
|
1368
|
-
this._$maskBoundsArray.push($getBoundsObject(bounds.xMin, bounds.xMax, bounds.yMin, bounds.yMax));
|
|
1369
|
-
}
|
|
1370
1550
|
/**
|
|
1371
1551
|
* @param {number} width
|
|
1372
1552
|
* @param {number} height
|
|
@@ -1376,6 +1556,7 @@ export class CanvasToWebGLContext {
|
|
|
1376
1556
|
* @private
|
|
1377
1557
|
*/
|
|
1378
1558
|
_$saveAttachment(width, height, multisample = false) {
|
|
1559
|
+
this.drawInstacedArray();
|
|
1379
1560
|
const manager = this._$frameBufferManager;
|
|
1380
1561
|
this
|
|
1381
1562
|
._$attachmentArray
|
|
@@ -1383,6 +1564,7 @@ export class CanvasToWebGLContext {
|
|
|
1383
1564
|
this._$bind(manager.createCacheAttachment(width, height, multisample));
|
|
1384
1565
|
}
|
|
1385
1566
|
/**
|
|
1567
|
+
* @param {boolean} [release_texture = false]
|
|
1386
1568
|
* @return {void}
|
|
1387
1569
|
* @method
|
|
1388
1570
|
* @private
|
|
@@ -1392,15 +1574,6 @@ export class CanvasToWebGLContext {
|
|
|
1392
1574
|
manager.releaseAttachment(manager.currentAttachment, release_texture);
|
|
1393
1575
|
this._$bind(this._$attachmentArray.pop());
|
|
1394
1576
|
}
|
|
1395
|
-
/**
|
|
1396
|
-
* @return {void}
|
|
1397
|
-
* @method
|
|
1398
|
-
* @private
|
|
1399
|
-
*/
|
|
1400
|
-
_$restoreCurrentMask() {
|
|
1401
|
-
this._$cacheAttachment = this._$maskBufferArray.pop() || null;
|
|
1402
|
-
this._$cacheBounds = this._$maskBoundsArray.pop() || $getBoundsObject();
|
|
1403
|
-
}
|
|
1404
1577
|
/**
|
|
1405
1578
|
* @return {object}
|
|
1406
1579
|
* @method
|