@next2d/webgl 3.8.1 → 3.9.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/package.json +4 -3
- package/src/AtlasManager.d.ts +46 -0
- package/src/AtlasManager.js +95 -2
- package/src/Blend/usecase/BlnedDrawDisplayObjectUseCase.js +10 -10
- package/src/Context/service/ContextBeginNodeRenderingService.js +3 -3
- package/src/Context/usecase/ContextBindUseCase.js +6 -1
- package/src/Context/usecase/ContextClearRectUseCase.js +2 -2
- package/src/Context/usecase/ContextClipUseCase.js +2 -2
- package/src/Context.js +5 -2
- package/src/FrameBufferManager/service/FrameBufferManagerTransferAtlasTextureService.d.ts +7 -2
- package/src/FrameBufferManager/service/FrameBufferManagerTransferAtlasTextureService.js +45 -12
- package/src/FrameBufferManager/usecase/FrameBufferManagerGetTextureFromNodeUseCase.js +2 -1
- package/src/FrameBufferManager.d.ts +1 -2
- package/src/FrameBufferManager.js +3 -4
- package/src/Mask/service/MaskSetMaskBoundsService.js +2 -2
- package/src/Mask/usecase/MaskLeaveMaskUseCase.js +2 -2
- package/src/Shader/Fragment/FragmentShaderSourceTexture.js +6 -3
- package/src/Shader/GradientLUTGenerator/usecase/GradientLUTGenerateFilterTextureUseCase.js +4 -1
- package/src/Shader/GradientLUTGenerator/usecase/GradientLUTGenerateShapeTextureUseCase.js +11 -4
- package/src/Shader/ShaderManager/service/ShaderManagerInitializeUniformService.js +4 -1
- package/src/TextureManager/service/TextureManagerCreateTextureObjectService.js +3 -1
- package/src/TextureManager/service/TextureManagerReuseBindService.d.ts +15 -0
- package/src/TextureManager/service/TextureManagerReuseBindService.js +29 -0
- package/src/TextureManager/usecase/TextureManagerCreateAtlasTextureUseCase.d.ts +10 -3
- package/src/TextureManager/usecase/TextureManagerCreateAtlasTextureUseCase.js +16 -9
- package/src/TextureManager/usecase/TextureManagerGetMainTextureFromBoundsUseCase.js +2 -2
- package/src/TextureManager/usecase/TextureManagerGetTextureUseCase.d.ts +7 -1
- package/src/TextureManager/usecase/TextureManagerGetTextureUseCase.js +16 -1
- package/src/TextureManager/usecase/TextureManagerReleaseTextureObjectUseCase.js +4 -2
- package/src/TextureManager.d.ts +43 -0
- package/src/TextureManager.js +100 -0
- package/src/VertexArrayObject/usecase/VertexArrayObjectBindAttributeUseCase.js +8 -4
- package/src/VertexArrayObject/usecase/VertexArrayObjectGetGradientObjectUseCase.js +4 -0
- package/src/WebGLUtil.d.ts +22 -0
- package/src/WebGLUtil.js +37 -0
- package/src/interface/ITextureObject.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/webgl",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "Next2D Webgl Package",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
"type": "git",
|
|
24
24
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
25
25
|
},
|
|
26
|
+
"sideEffects": false,
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@next2d/texture-packer": "3.
|
|
28
|
-
"@next2d/render-queue": "3.
|
|
28
|
+
"@next2d/texture-packer": "3.9.0",
|
|
29
|
+
"@next2d/render-queue": "3.9.0"
|
|
29
30
|
}
|
|
30
31
|
}
|
package/src/AtlasManager.d.ts
CHANGED
|
@@ -9,7 +9,53 @@ export declare const $getAtlasAttachmentObject: () => IAttachmentObject;
|
|
|
9
9
|
export declare const $hasAtlasAttachmentObject: () => boolean;
|
|
10
10
|
export declare const $rootNodes: TexturePacker[];
|
|
11
11
|
export declare let $atlasTexture: ITextureObject | null;
|
|
12
|
+
/**
|
|
13
|
+
* @description 指定ページを未解決(dirty)としてマークする
|
|
14
|
+
* Mark the given page as dirty (has unresolved drawing)
|
|
15
|
+
*
|
|
16
|
+
* @param {number} index
|
|
17
|
+
* @return {void}
|
|
18
|
+
* @method
|
|
19
|
+
* @protected
|
|
20
|
+
*/
|
|
21
|
+
export declare const $setAtlasPageDirty: (index: number) => void;
|
|
22
|
+
/**
|
|
23
|
+
* @description 指定ページのdirtyフラグを取得
|
|
24
|
+
* Get the dirty flag of the given page
|
|
25
|
+
*
|
|
26
|
+
* @param {number} index
|
|
27
|
+
* @return {boolean}
|
|
28
|
+
* @method
|
|
29
|
+
* @protected
|
|
30
|
+
*/
|
|
31
|
+
export declare const $isAtlasPageDirty: (index: number) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @description 指定ページのdirtyフラグをクリア
|
|
34
|
+
* Clear the dirty flag of the given page
|
|
35
|
+
*
|
|
36
|
+
* @param {number} index
|
|
37
|
+
* @return {void}
|
|
38
|
+
* @method
|
|
39
|
+
* @protected
|
|
40
|
+
*/
|
|
41
|
+
export declare const $clearAtlasPageDirty: (index: number) => void;
|
|
12
42
|
export declare const $getAtlasTextureObject: () => ITextureObject;
|
|
43
|
+
/**
|
|
44
|
+
* @description アトラス配列テクスチャのレイヤー数を必要数まで拡張する。
|
|
45
|
+
* texStorage3Dはimmutableのため、拡張時は作り直して全ページを
|
|
46
|
+
* dirty(全域)にし、次回の解決で各ページのMSAAバッファから再転写する。
|
|
47
|
+
* (ページの内容は各ページのMSAAアタッチメントが保持している)
|
|
48
|
+
* Grow the atlas array texture to the required layer count.
|
|
49
|
+
* texStorage3D is immutable, so the texture is recreated and all
|
|
50
|
+
* pages are marked fully dirty; the next resolve re-blits each
|
|
51
|
+
* page from its MSAA attachment (which owns the page contents).
|
|
52
|
+
*
|
|
53
|
+
* @param {number} layers
|
|
54
|
+
* @return {void}
|
|
55
|
+
* @method
|
|
56
|
+
* @protected
|
|
57
|
+
*/
|
|
58
|
+
export declare const $ensureAtlasTextureLayers: (layers: number) => void;
|
|
13
59
|
export declare const $getActiveTransferBounds: (index: number) => Float32Array;
|
|
14
60
|
export declare const $clearTransferBounds: () => void;
|
|
15
61
|
export declare let $currentAtlasIndex: number;
|
package/src/AtlasManager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execute as textureManagerCreateAtlasTextureUseCase } from "./TextureManager/usecase/TextureManagerCreateAtlasTextureUseCase";
|
|
2
2
|
import { execute as frameBufferManagerGetAttachmentObjectUseCase } from "./FrameBufferManager/usecase/FrameBufferManagerGetAttachmentObjectUseCase";
|
|
3
|
-
import { $RENDER_MAX_SIZE } from "./WebGLUtil";
|
|
3
|
+
import { $RENDER_MAX_SIZE, $gl } from "./WebGLUtil";
|
|
4
4
|
const $MAX_VALUE = Number.MAX_VALUE;
|
|
5
5
|
const $MIN_VALUE = -Number.MAX_VALUE;
|
|
6
6
|
export let $activeAtlasIndex = 0;
|
|
@@ -27,12 +27,105 @@ export const $hasAtlasAttachmentObject = () => {
|
|
|
27
27
|
};
|
|
28
28
|
export const $rootNodes = [];
|
|
29
29
|
export let $atlasTexture = null;
|
|
30
|
+
/**
|
|
31
|
+
* @description 現在のアトラス配列テクスチャのレイヤー数
|
|
32
|
+
* Current number of layers in the atlas array texture
|
|
33
|
+
*
|
|
34
|
+
* @type {number}
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
let $atlasTextureLayers = 0;
|
|
38
|
+
/**
|
|
39
|
+
* @description ページ毎の「未解決の描き込みがあるか」フラグ
|
|
40
|
+
* Per-page flag indicating unresolved drawing into the page
|
|
41
|
+
*
|
|
42
|
+
* @type {boolean[]}
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
const $atlasDirtyPages = [];
|
|
46
|
+
/**
|
|
47
|
+
* @description 指定ページを未解決(dirty)としてマークする
|
|
48
|
+
* Mark the given page as dirty (has unresolved drawing)
|
|
49
|
+
*
|
|
50
|
+
* @param {number} index
|
|
51
|
+
* @return {void}
|
|
52
|
+
* @method
|
|
53
|
+
* @protected
|
|
54
|
+
*/
|
|
55
|
+
export const $setAtlasPageDirty = (index) => {
|
|
56
|
+
$atlasDirtyPages[index] = true;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* @description 指定ページのdirtyフラグを取得
|
|
60
|
+
* Get the dirty flag of the given page
|
|
61
|
+
*
|
|
62
|
+
* @param {number} index
|
|
63
|
+
* @return {boolean}
|
|
64
|
+
* @method
|
|
65
|
+
* @protected
|
|
66
|
+
*/
|
|
67
|
+
export const $isAtlasPageDirty = (index) => {
|
|
68
|
+
return !!$atlasDirtyPages[index];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* @description 指定ページのdirtyフラグをクリア
|
|
72
|
+
* Clear the dirty flag of the given page
|
|
73
|
+
*
|
|
74
|
+
* @param {number} index
|
|
75
|
+
* @return {void}
|
|
76
|
+
* @method
|
|
77
|
+
* @protected
|
|
78
|
+
*/
|
|
79
|
+
export const $clearAtlasPageDirty = (index) => {
|
|
80
|
+
$atlasDirtyPages[index] = false;
|
|
81
|
+
};
|
|
30
82
|
export const $getAtlasTextureObject = () => {
|
|
31
83
|
if (!$atlasTexture) {
|
|
32
|
-
$atlasTexture = textureManagerCreateAtlasTextureUseCase();
|
|
84
|
+
$atlasTexture = textureManagerCreateAtlasTextureUseCase(1);
|
|
85
|
+
$atlasTextureLayers = 1;
|
|
33
86
|
}
|
|
34
87
|
return $atlasTexture;
|
|
35
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* @description アトラス配列テクスチャのレイヤー数を必要数まで拡張する。
|
|
91
|
+
* texStorage3Dはimmutableのため、拡張時は作り直して全ページを
|
|
92
|
+
* dirty(全域)にし、次回の解決で各ページのMSAAバッファから再転写する。
|
|
93
|
+
* (ページの内容は各ページのMSAAアタッチメントが保持している)
|
|
94
|
+
* Grow the atlas array texture to the required layer count.
|
|
95
|
+
* texStorage3D is immutable, so the texture is recreated and all
|
|
96
|
+
* pages are marked fully dirty; the next resolve re-blits each
|
|
97
|
+
* page from its MSAA attachment (which owns the page contents).
|
|
98
|
+
*
|
|
99
|
+
* @param {number} layers
|
|
100
|
+
* @return {void}
|
|
101
|
+
* @method
|
|
102
|
+
* @protected
|
|
103
|
+
*/
|
|
104
|
+
export const $ensureAtlasTextureLayers = (layers) => {
|
|
105
|
+
if (!$atlasTexture) {
|
|
106
|
+
$atlasTextureLayers = Math.max(1, layers);
|
|
107
|
+
$atlasTexture = textureManagerCreateAtlasTextureUseCase($atlasTextureLayers);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (layers <= $atlasTextureLayers) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
$gl.deleteTexture($atlasTexture.resource);
|
|
114
|
+
$atlasTexture = textureManagerCreateAtlasTextureUseCase(layers);
|
|
115
|
+
$atlasTextureLayers = layers;
|
|
116
|
+
// 全ページを全域dirtyにして次回の解決で再転写させる
|
|
117
|
+
for (let idx = 0; idx < $atlasAttachmentObjects.length; ++idx) {
|
|
118
|
+
if (!$atlasAttachmentObjects[idx]) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
$atlasDirtyPages[idx] = true;
|
|
122
|
+
const bounds = $getActiveTransferBounds(idx);
|
|
123
|
+
bounds[0] = 0;
|
|
124
|
+
bounds[1] = 0;
|
|
125
|
+
bounds[2] = $RENDER_MAX_SIZE;
|
|
126
|
+
bounds[3] = $RENDER_MAX_SIZE;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
36
129
|
const $transferBounds = [];
|
|
37
130
|
export const $getActiveTransferBounds = (index) => {
|
|
38
131
|
let bounds = $transferBounds[index];
|
|
@@ -40,7 +40,6 @@ export const execute = (node, x_min, y_min, x_max, y_max, color_transform) => {
|
|
|
40
40
|
const ct4 = color_transform[4] / 255;
|
|
41
41
|
const ct5 = color_transform[5] / 255;
|
|
42
42
|
const ct6 = color_transform[6] / 255;
|
|
43
|
-
const ct7 = 0;
|
|
44
43
|
const matrix = $context.$matrix;
|
|
45
44
|
switch ($context.globalCompositeOperation) {
|
|
46
45
|
case "normal":
|
|
@@ -51,25 +50,26 @@ export const execute = (node, x_min, y_min, x_max, y_max, color_transform) => {
|
|
|
51
50
|
case "erase":
|
|
52
51
|
case "copy":
|
|
53
52
|
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
$setActiveAtlasIndex($currentAtlasIndex);
|
|
53
|
+
// アトラスはTEXTURE_2D_ARRAY化され、レイヤー番号をインスタンス属性で
|
|
54
|
+
// 渡すため、ページ切替ではバッチを分断しない。ブレンドモード変更時のみflushする。
|
|
55
|
+
if ($currentBlendMode !== $context.globalCompositeOperation) {
|
|
58
56
|
const currentOperation = $context.globalCompositeOperation;
|
|
59
57
|
$context.globalCompositeOperation = $currentBlendMode;
|
|
60
|
-
$context.newDrawState = true;
|
|
61
58
|
$context.drawArraysInstanced();
|
|
62
|
-
$context.newDrawState = true;
|
|
63
59
|
// ブレンドモードをセット
|
|
64
60
|
$context.globalCompositeOperation = currentOperation;
|
|
65
61
|
$setCurrentBlendMode($context.globalCompositeOperation);
|
|
66
|
-
|
|
62
|
+
}
|
|
63
|
+
// indexをセット(他経路のアタッチメント参照用に維持)
|
|
64
|
+
if ($currentAtlasIndex !== node.index) {
|
|
67
65
|
$setCurrentAtlasIndex(node.index);
|
|
68
66
|
$setActiveAtlasIndex(node.index);
|
|
69
67
|
}
|
|
70
68
|
// 描画するまで配列に変数を保持
|
|
71
69
|
const shaderInstancedManager = variantsBlendInstanceShaderService();
|
|
72
|
-
|
|
70
|
+
// a_add.w(旧ct7、常に0)をアトラスのレイヤー番号として使用する。
|
|
71
|
+
// シェーダー側はカラー加算のw成分を0として扱うため出力は不変。
|
|
72
|
+
renderQueue.pushDisplayObjectBuffer((node.x + 0.5) / $RENDER_MAX_SIZE, (node.y + 0.5) / $RENDER_MAX_SIZE, (node.w - 1.0) / $RENDER_MAX_SIZE, (node.h - 1.0) / $RENDER_MAX_SIZE, node.w, node.h, $viewportWidth, $viewportHeight, matrix[6], matrix[7], matrix[0], matrix[1], matrix[3], matrix[4], ct0, ct1, ct2, ct3, ct4, ct5, ct6, node.index);
|
|
73
73
|
shaderInstancedManager.count++;
|
|
74
74
|
}
|
|
75
75
|
break;
|
|
@@ -121,7 +121,7 @@ export const execute = (node, x_min, y_min, x_max, y_max, color_transform) => {
|
|
|
121
121
|
textureManagerBind01UseCase(dstTextureObject, srcTextureObject);
|
|
122
122
|
// blend用のシェーダーを取得
|
|
123
123
|
const shaderManager = variantsBlendDrawShaderService($context.globalCompositeOperation, true);
|
|
124
|
-
shaderManagerSetBlendWithColorTransformUniformService(shaderManager, ct0, ct1, ct2, ct3, ct4, ct5, ct6,
|
|
124
|
+
shaderManagerSetBlendWithColorTransformUniformService(shaderManager, ct0, ct1, ct2, ct3, ct4, ct5, ct6, 0);
|
|
125
125
|
shaderManagerDrawTextureUseCase(shaderManager);
|
|
126
126
|
if (currentAttachmentObject) {
|
|
127
127
|
$context.bind(currentAttachmentObject);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $gl, $enableScissorTest } from "../../WebGLUtil";
|
|
1
|
+
import { $gl, $enableScissorTest, $setScissorBox } from "../../WebGLUtil";
|
|
2
2
|
/**
|
|
3
3
|
* @description 描画範囲を設定
|
|
4
4
|
* Set the drawing range.
|
|
@@ -14,9 +14,9 @@ import { $gl, $enableScissorTest } from "../../WebGLUtil";
|
|
|
14
14
|
export const execute = (x, y, w, h) => {
|
|
15
15
|
// 初期化範囲を設定
|
|
16
16
|
$enableScissorTest();
|
|
17
|
-
$
|
|
17
|
+
$setScissorBox(x, y, w + 1, h + 1);
|
|
18
18
|
// 初期化(clearColorは初期化時に(0,0,0,0)設定済み)
|
|
19
19
|
$gl.clear($gl.COLOR_BUFFER_BIT | $gl.STENCIL_BUFFER_BIT);
|
|
20
20
|
// 描画領域をあらためて設定
|
|
21
|
-
$
|
|
21
|
+
$setScissorBox(x, y, w, h);
|
|
22
22
|
};
|
|
@@ -32,9 +32,14 @@ export const execute = (context, attachment_object) => {
|
|
|
32
32
|
? attachment_object.color
|
|
33
33
|
: attachment_object.stencil;
|
|
34
34
|
// 再利用のオブジェクトの場合は、描画情報をクリアする
|
|
35
|
+
// テクスチャプールから再利用されたテクスチャ(dirty)もステイル内容を含むためクリア対象
|
|
35
36
|
// clearColorは初期化時に(0,0,0,0)で固定済みのためそのまま使用
|
|
36
|
-
|
|
37
|
+
const texture = attachment_object.texture;
|
|
38
|
+
if (object.dirty || texture && texture.dirty) {
|
|
37
39
|
object.dirty = false;
|
|
40
|
+
if (texture) {
|
|
41
|
+
texture.dirty = false;
|
|
42
|
+
}
|
|
38
43
|
context.clearRect(0, 0, attachment_object.width, attachment_object.height);
|
|
39
44
|
}
|
|
40
45
|
// mask bind
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $gl, $enableScissorTest, $disableScissorTest } from "../../WebGLUtil";
|
|
1
|
+
import { $gl, $enableScissorTest, $disableScissorTest, $setScissorBox } from "../../WebGLUtil";
|
|
2
2
|
/**
|
|
3
3
|
* @description 指定範囲をクリアする
|
|
4
4
|
* Clear the specified range
|
|
@@ -14,7 +14,7 @@ import { $gl, $enableScissorTest, $disableScissorTest } from "../../WebGLUtil";
|
|
|
14
14
|
export const execute = (x, y, w, h) => {
|
|
15
15
|
// 指定範囲をクリア
|
|
16
16
|
$enableScissorTest();
|
|
17
|
-
$
|
|
17
|
+
$setScissorBox(x, y, w, h);
|
|
18
18
|
$gl.clear($gl.COLOR_BUFFER_BIT | $gl.STENCIL_BUFFER_BIT);
|
|
19
19
|
$disableScissorTest();
|
|
20
20
|
};
|
|
@@ -5,7 +5,7 @@ import { execute as shaderManagerSetMaskUniformService } from "../../Shader/Shad
|
|
|
5
5
|
import { execute as shaderManagerFillUseCase } from "../../Shader/ShaderManager/usecase/ShaderManagerFillUseCase";
|
|
6
6
|
import { execute as maskUnionMaskService } from "../../Mask/service/MaskUnionMaskService";
|
|
7
7
|
import { $clipLevels, $clipBounds } from "../../Mask";
|
|
8
|
-
import { $gl, $context, $enableScissorTest, $disableScissorTest } from "../../WebGLUtil";
|
|
8
|
+
import { $gl, $context, $enableScissorTest, $disableScissorTest, $setScissorBox } from "../../WebGLUtil";
|
|
9
9
|
import { $fillBufferIndexes, $clearFillBufferSetting } from "../../Mesh";
|
|
10
10
|
import { $terminateGrid, $gridDataMap } from "../../Grid";
|
|
11
11
|
/**
|
|
@@ -30,7 +30,7 @@ export const execute = () => {
|
|
|
30
30
|
const width = Math.ceil(Math.abs(xMax - xMin));
|
|
31
31
|
const height = Math.ceil(Math.abs(yMax - yMin));
|
|
32
32
|
$enableScissorTest();
|
|
33
|
-
$
|
|
33
|
+
$setScissorBox(xMin, currentAttachmentObject.height - yMin - height, width, height);
|
|
34
34
|
const vertexArrayObject = vertexArrayObjectCreateFillObjectUseCase();
|
|
35
35
|
let level = $clipLevels.get(currentAttachmentObject.clipLevel);
|
|
36
36
|
let offset = 0;
|
package/src/Context.js
CHANGED
|
@@ -50,7 +50,7 @@ import { execute as contextUpdateTransferBoundsService } from "./Context/service
|
|
|
50
50
|
import { execute as contextDrawFillUseCase } from "./Context/usecase/ContextDrawFillUseCase";
|
|
51
51
|
import { execute as contextCreateImageBitmapService } from "./Context/service/ContextCreateImageBitmapService";
|
|
52
52
|
import { $setGradientLUTGeneratorMaxLength } from "./Shader/GradientLUTGenerator";
|
|
53
|
-
import { $getAtlasAttachmentObject, $clearTransferBounds, $getAtlasTextureObject } from "./AtlasManager";
|
|
53
|
+
import { $getAtlasAttachmentObject, $clearTransferBounds, $getAtlasTextureObject, $setAtlasPageDirty } from "./AtlasManager";
|
|
54
54
|
import { $setReadFrameBuffer, $setDrawFrameBuffer, $currentAttachment, $setAtlasFrameBuffer, $setBitmapFrameBuffer } from "./FrameBufferManager";
|
|
55
55
|
import { $setRenderMaxSize, $setWebGL2RenderingContext, $setSamples, $getFloat32Array9, $getArray, $setContext, $setDevicePixelRatio } from "./WebGLUtil";
|
|
56
56
|
export class Context {
|
|
@@ -217,7 +217,8 @@ export class Context {
|
|
|
217
217
|
// FrameBufferManagerの初期起動
|
|
218
218
|
$setReadFrameBuffer(gl);
|
|
219
219
|
$setDrawFrameBuffer(gl);
|
|
220
|
-
$
|
|
220
|
+
$getAtlasTextureObject();
|
|
221
|
+
$setAtlasFrameBuffer(gl);
|
|
221
222
|
$setBitmapFrameBuffer(gl);
|
|
222
223
|
// VertexArrayObjectの初期起動
|
|
223
224
|
vertexArrayObjectBootUseCase(gl);
|
|
@@ -355,6 +356,8 @@ export class Context {
|
|
|
355
356
|
}
|
|
356
357
|
beginNodeRendering(node) {
|
|
357
358
|
this.newDrawState = true;
|
|
359
|
+
// このページには未解決の描き込みがある(次回の解決対象)
|
|
360
|
+
$setAtlasPageDirty(node.index);
|
|
358
361
|
contextUpdateTransferBoundsService(node);
|
|
359
362
|
contextBeginNodeRenderingService(node.x, node.y, node.w, node.h);
|
|
360
363
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @description
|
|
3
|
-
*
|
|
2
|
+
* @description 未解決(dirty)の全アトラスページを、配列テクスチャの各レイヤーへ解決します。
|
|
3
|
+
* ページ毎に専用レイヤーを持つため、解決は「ページ切替のたび」ではなく
|
|
4
|
+
* 「描き込みがあったページのみ」行えばよい。
|
|
5
|
+
* Resolve all dirty atlas pages into their own layers of the
|
|
6
|
+
* atlas array texture. Each page owns a dedicated layer, so a
|
|
7
|
+
* resolve is needed only for pages that received drawing,
|
|
8
|
+
* not on every page switch.
|
|
4
9
|
*
|
|
5
10
|
* @return {void}
|
|
6
11
|
* @method
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import { $getActiveTransferBounds, $
|
|
2
|
-
import { $gl, $context, $enableScissorTest, $disableScissorTest } from "../../WebGLUtil";
|
|
1
|
+
import { $getActiveTransferBounds, $getAtlasAttachmentObjects, $getAtlasTextureObject, $ensureAtlasTextureLayers, $isAtlasPageDirty, $clearAtlasPageDirty } from "../../AtlasManager";
|
|
2
|
+
import { $gl, $context, $RENDER_MAX_SIZE, $enableScissorTest, $disableScissorTest, $setScissorBox } from "../../WebGLUtil";
|
|
3
3
|
import { $atlasFrameBuffer, $setFramebufferBound } from "../../FrameBufferManager";
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
5
|
+
* @type {number}
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
const $MAX_VALUE = Number.MAX_VALUE;
|
|
9
|
+
/**
|
|
10
|
+
* @description 未解決(dirty)の全アトラスページを、配列テクスチャの各レイヤーへ解決します。
|
|
11
|
+
* ページ毎に専用レイヤーを持つため、解決は「ページ切替のたび」ではなく
|
|
12
|
+
* 「描き込みがあったページのみ」行えばよい。
|
|
13
|
+
* Resolve all dirty atlas pages into their own layers of the
|
|
14
|
+
* atlas array texture. Each page owns a dedicated layer, so a
|
|
15
|
+
* resolve is needed only for pages that received drawing,
|
|
16
|
+
* not on every page switch.
|
|
7
17
|
*
|
|
8
18
|
* @return {void}
|
|
9
19
|
* @method
|
|
@@ -14,15 +24,38 @@ export const execute = () => {
|
|
|
14
24
|
return;
|
|
15
25
|
}
|
|
16
26
|
const currentAttachmentObject = $context.currentAttachmentObject;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
$
|
|
21
|
-
const
|
|
22
|
-
const bounds = $getActiveTransferBounds(atlasIdx);
|
|
27
|
+
const atlasAttachmentObjects = $getAtlasAttachmentObjects();
|
|
28
|
+
// ページ数に合わせて配列テクスチャのレイヤーを確保
|
|
29
|
+
// (拡張時は全ページが全域dirtyになり、このループで再転写される)
|
|
30
|
+
$ensureAtlasTextureLayers(atlasAttachmentObjects.length);
|
|
31
|
+
const atlasTextureObject = $getAtlasTextureObject();
|
|
23
32
|
$enableScissorTest();
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
for (let idx = 0; idx < atlasAttachmentObjects.length; ++idx) {
|
|
34
|
+
if (!$isAtlasPageDirty(idx)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const atlasAttachmentObject = atlasAttachmentObjects[idx];
|
|
38
|
+
if (!atlasAttachmentObject) {
|
|
39
|
+
$clearAtlasPageDirty(idx);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
// ページのMSAAアタッチメントをREADにバインド
|
|
43
|
+
$context.bind(atlasAttachmentObject);
|
|
44
|
+
// 対象レイヤーをDRAWにアタッチ
|
|
45
|
+
$gl.bindFramebuffer($gl.DRAW_FRAMEBUFFER, $atlasFrameBuffer);
|
|
46
|
+
$gl.framebufferTextureLayer($gl.DRAW_FRAMEBUFFER, $gl.COLOR_ATTACHMENT0, atlasTextureObject.resource, 0, idx);
|
|
47
|
+
$setFramebufferBound(false);
|
|
48
|
+
const bounds = $getActiveTransferBounds(idx);
|
|
49
|
+
if (bounds[0] === $MAX_VALUE) {
|
|
50
|
+
// dirtyだが範囲が未記録の場合は全域を転写(安全側)
|
|
51
|
+
$setScissorBox(0, 0, $RENDER_MAX_SIZE, $RENDER_MAX_SIZE);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
$setScissorBox(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
55
|
+
}
|
|
56
|
+
$gl.blitFramebuffer(0, 0, atlasAttachmentObject.width, atlasAttachmentObject.height, 0, 0, atlasAttachmentObject.width, atlasAttachmentObject.height, $gl.COLOR_BUFFER_BIT, $gl.NEAREST);
|
|
57
|
+
$clearAtlasPageDirty(idx);
|
|
58
|
+
}
|
|
26
59
|
$disableScissorTest();
|
|
27
60
|
if (currentAttachmentObject) {
|
|
28
61
|
$context.bind(currentAttachmentObject);
|
|
@@ -18,8 +18,9 @@ export const execute = (node) => {
|
|
|
18
18
|
$setActiveAtlasIndex(node.index);
|
|
19
19
|
frameBufferManagerTransferAtlasTextureService();
|
|
20
20
|
$gl.bindFramebuffer($gl.FRAMEBUFFER, $readBitmapFramebuffer);
|
|
21
|
+
// アトラスはTEXTURE_2D_ARRAYのため、ノードが属するページのレイヤーをアタッチする
|
|
21
22
|
const atlasTextureObject = $getAtlasTextureObject();
|
|
22
|
-
$gl.
|
|
23
|
+
$gl.framebufferTextureLayer($gl.FRAMEBUFFER, $gl.COLOR_ATTACHMENT0, atlasTextureObject.resource, 0, node.index);
|
|
23
24
|
$gl.bindFramebuffer($gl.FRAMEBUFFER, $drawBitmapFramebuffer);
|
|
24
25
|
const textureObject = textureManagerGetTextureUseCase(node.w, node.h);
|
|
25
26
|
$gl.framebufferTexture2D($gl.FRAMEBUFFER, $gl.COLOR_ATTACHMENT0, $gl.TEXTURE_2D, textureObject.resource, 0);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { IAttachmentObject } from "./interface/IAttachmentObject";
|
|
2
|
-
import type { ITextureObject } from "./interface/ITextureObject";
|
|
3
2
|
export declare const $objectPool: IAttachmentObject[];
|
|
4
3
|
export declare let $readFrameBuffer: WebGLFramebuffer;
|
|
5
4
|
export declare const $setReadFrameBuffer: (gl: WebGL2RenderingContext) => void;
|
|
6
5
|
export declare let $drawFrameBuffer: WebGLFramebuffer | null;
|
|
7
6
|
export declare const $setDrawFrameBuffer: (gl: WebGL2RenderingContext) => void;
|
|
8
7
|
export declare let $atlasFrameBuffer: WebGLFramebuffer | null;
|
|
9
|
-
export declare const $setAtlasFrameBuffer: (gl: WebGL2RenderingContext
|
|
8
|
+
export declare const $setAtlasFrameBuffer: (gl: WebGL2RenderingContext) => void;
|
|
10
9
|
export declare let $currentAttachment: IAttachmentObject | null;
|
|
11
10
|
export declare const $setCurrentAttachment: (attachment_object: IAttachmentObject | null) => void;
|
|
12
11
|
export declare let $isFramebufferBound: boolean;
|
|
@@ -8,11 +8,10 @@ export const $setDrawFrameBuffer = (gl) => {
|
|
|
8
8
|
$drawFrameBuffer = gl.createFramebuffer();
|
|
9
9
|
};
|
|
10
10
|
export let $atlasFrameBuffer = null;
|
|
11
|
-
export const $setAtlasFrameBuffer = (gl
|
|
11
|
+
export const $setAtlasFrameBuffer = (gl) => {
|
|
12
|
+
// アトラスはTEXTURE_2D_ARRAYになったため、カラーアタッチメントは
|
|
13
|
+
// 解決(blit)時に framebufferTextureLayer で対象レイヤーを都度アタッチする
|
|
12
14
|
$atlasFrameBuffer = gl.createFramebuffer();
|
|
13
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, $atlasFrameBuffer);
|
|
14
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture_object.resource, 0);
|
|
15
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
16
15
|
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, $atlasFrameBuffer);
|
|
17
16
|
};
|
|
18
17
|
export let $currentAttachment = null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $clipBounds } from "../../Mask";
|
|
2
|
-
import { $
|
|
2
|
+
import { $context, $getFloat32Array4, $enableScissorTest, $setScissorBox } from "../../WebGLUtil";
|
|
3
3
|
/**
|
|
4
4
|
* @description マスクの描画範囲をセット
|
|
5
5
|
* Set the drawing range of the mask.
|
|
@@ -22,5 +22,5 @@ export const execute = (x_min, y_min, x_max, y_max) => {
|
|
|
22
22
|
const width = Math.ceil(Math.abs(x_max - x_min));
|
|
23
23
|
const height = Math.ceil(Math.abs(y_max - y_min));
|
|
24
24
|
$enableScissorTest();
|
|
25
|
-
$
|
|
25
|
+
$setScissorBox(x_min, currentAttachmentObject.height - y_min - height, width, height);
|
|
26
26
|
};
|
|
@@ -3,7 +3,7 @@ import { execute as shaderManagerFillUseCase } from "../../Shader/ShaderManager/
|
|
|
3
3
|
import { execute as variantsShapeRectShaderService } from "../../Shader/Variants/Shape/service/VariantsShapeRectShaderService";
|
|
4
4
|
import { $getRectVertexArrayObject } from "../../VertexArrayObject";
|
|
5
5
|
import { $setMaskDrawing, $clipBounds, $clipLevels } from "../../Mask";
|
|
6
|
-
import { $gl, $context, $poolFloat32Array4, $enableScissorTest, $disableScissorTest, $disableStencilTest } from "../../WebGLUtil";
|
|
6
|
+
import { $gl, $context, $poolFloat32Array4, $enableScissorTest, $disableScissorTest, $disableStencilTest, $setScissorBox } from "../../WebGLUtil";
|
|
7
7
|
/**
|
|
8
8
|
* @description マスクの終了処理
|
|
9
9
|
* End mask processing
|
|
@@ -30,7 +30,7 @@ export const execute = () => {
|
|
|
30
30
|
const width = Math.ceil(Math.abs(xMax - xMin));
|
|
31
31
|
const height = Math.ceil(Math.abs(yMax - yMin));
|
|
32
32
|
$enableScissorTest();
|
|
33
|
-
$
|
|
33
|
+
$setScissorBox(xMin, currentAttachmentObject.height - yMin - height, width, height);
|
|
34
34
|
// 単体のマスクであれば終了
|
|
35
35
|
--currentAttachmentObject.clipLevel;
|
|
36
36
|
if (!currentAttachmentObject.clipLevel) {
|
|
@@ -39,10 +39,13 @@ void main() {
|
|
|
39
39
|
}`;
|
|
40
40
|
};
|
|
41
41
|
export const INSTANCE_TEXTURE = () => {
|
|
42
|
+
// アトラスはTEXTURE_2D_ARRAY。v_add.wはカラー加算値ではなく
|
|
43
|
+
// アトラスのレイヤー番号(旧実装では常に0だったct7のスロットを転用)。
|
|
44
|
+
// カラー変換ではw成分を0として扱うため出力は旧実装と同一。
|
|
42
45
|
return `#version 300 es
|
|
43
46
|
precision mediump float;
|
|
44
47
|
|
|
45
|
-
uniform
|
|
48
|
+
uniform mediump sampler2DArray u_texture;
|
|
46
49
|
|
|
47
50
|
in vec4 v_mul;
|
|
48
51
|
in vec4 v_add;
|
|
@@ -50,13 +53,13 @@ in vec2 v_coord;
|
|
|
50
53
|
out vec4 o_color;
|
|
51
54
|
|
|
52
55
|
void main() {
|
|
53
|
-
vec4 src = texture(u_texture, v_coord);
|
|
56
|
+
vec4 src = texture(u_texture, vec3(v_coord, v_add.w));
|
|
54
57
|
|
|
55
58
|
if (v_mul.x != 1.0 || v_mul.y != 1.0 || v_mul.z != 1.0 || v_mul.w != 1.0
|
|
56
59
|
|| v_add.x != 0.0 || v_add.y != 0.0 || v_add.z != 0.0
|
|
57
60
|
) {
|
|
58
61
|
src.rgb /= max(0.0001, src.a);
|
|
59
|
-
src = clamp(src * v_mul + v_add, 0.0, 1.0);
|
|
62
|
+
src = clamp(src * v_mul + vec4(v_add.xyz, 0.0), 0.0, 1.0);
|
|
60
63
|
src.rgb *= src.a;
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -27,7 +27,10 @@ export const execute = (ratios, colors, alphas) => {
|
|
|
27
27
|
const end = Math.min(begin + maxLength, stopsLength);
|
|
28
28
|
const shaderManager = variantsGradientLUTShaderService(end - begin, false);
|
|
29
29
|
gradientLUTSetFilterUniformService(shaderManager, ratios, colors, alphas, begin, end);
|
|
30
|
-
|
|
30
|
+
// 先頭チャンクは0、末尾チャンクは1まで矩形を拡張して描画する。
|
|
31
|
+
// シェーダー側が最初/最後のストップ色でパディングするため、
|
|
32
|
+
// ストップ範囲外のtexelが未描画(前回内容のまま)になるのを防ぐ。
|
|
33
|
+
gradientLUTGeneratorFillTextureUseCase(shaderManager, begin === 0 ? 0 : ratios[begin] / 255, end === stopsLength ? 1 : ratios[end - 1] / 255);
|
|
31
34
|
}
|
|
32
35
|
blendResetService();
|
|
33
36
|
if (currentAttachment) {
|
|
@@ -3,7 +3,7 @@ import { execute as blendOneZeroService } from "../../../Blend/service/BlendOneZ
|
|
|
3
3
|
import { execute as blendResetService } from "../../../Blend/service/BlendResetService";
|
|
4
4
|
import { execute as gradientLUTSetUniformService } from "../service/GradientLUTSetUniformService";
|
|
5
5
|
import { execute as gradientLUTGeneratorFillTextureUseCase } from "./GradientLUTGeneratorFillTextureUseCase";
|
|
6
|
-
import { $
|
|
6
|
+
import { $context, $enableScissorTest, $disableScissorTest, $scissorBox, $setScissorBox } from "../../../WebGLUtil";
|
|
7
7
|
import { $getGradientAttachmentObjectWithResolution, $getAdaptiveResolution, $getGradientLUTGeneratorMaxLength, $rgbIdentityTable, $rgbToLinearTable } from "../../GradientLUTGenerator";
|
|
8
8
|
/**
|
|
9
9
|
* @description グラデーションのテクスチャを生成します。
|
|
@@ -21,7 +21,11 @@ import { $getGradientAttachmentObjectWithResolution, $getAdaptiveResolution, $ge
|
|
|
21
21
|
*/
|
|
22
22
|
export const execute = (stops, interpolation) => {
|
|
23
23
|
const currentAttachment = $context.currentAttachmentObject;
|
|
24
|
-
|
|
24
|
+
// JS側で追跡しているscissor矩形を退避(getParameterの同期クエリを回避)
|
|
25
|
+
const scissorX = $scissorBox[0];
|
|
26
|
+
const scissorY = $scissorBox[1];
|
|
27
|
+
const scissorW = $scissorBox[2];
|
|
28
|
+
const scissorH = $scissorBox[3];
|
|
25
29
|
$disableScissorTest();
|
|
26
30
|
const isLinearSpace = interpolation === 0;
|
|
27
31
|
const stopsLength = stops.length / 5;
|
|
@@ -38,7 +42,10 @@ export const execute = (stops, interpolation) => {
|
|
|
38
42
|
const end = Math.min(begin + maxLength, stopsLength);
|
|
39
43
|
const shaderManager = variantsGradientLUTShaderService(end - begin, isLinearSpace);
|
|
40
44
|
gradientLUTSetUniformService(shaderManager, stops, begin, end, table);
|
|
41
|
-
|
|
45
|
+
// 先頭チャンクは0、末尾チャンクは1まで矩形を拡張して描画する。
|
|
46
|
+
// シェーダー側が最初/最後のストップ色でパディングするため、
|
|
47
|
+
// ストップ範囲外のtexelが未描画(前回内容のまま)になるのを防ぐ。
|
|
48
|
+
gradientLUTGeneratorFillTextureUseCase(shaderManager, begin === 0 ? 0 : stops[begin * 5], end === stopsLength ? 1 : stops[(end - 1) * 5]);
|
|
42
49
|
}
|
|
43
50
|
blendResetService();
|
|
44
51
|
if (currentAttachment) {
|
|
@@ -46,6 +53,6 @@ export const execute = (stops, interpolation) => {
|
|
|
46
53
|
}
|
|
47
54
|
// bugfix: @see https://github.com/Next2D/player/issues/234
|
|
48
55
|
$enableScissorTest();
|
|
49
|
-
$
|
|
56
|
+
$setScissorBox(scissorX, scissorY, scissorW, scissorH);
|
|
50
57
|
return gradientAttachmentObject.texture;
|
|
51
58
|
};
|
|
@@ -19,7 +19,8 @@ export const execute = (program, map, atlas = false) => {
|
|
|
19
19
|
const location = $gl.getUniformLocation(program, name);
|
|
20
20
|
// WebGLの仕様でuniformのint型のデフォルト値は0に設定されるため、
|
|
21
21
|
// sampler2D(size=1)の値の更新は不要
|
|
22
|
-
if (info.type === $gl.SAMPLER_2D
|
|
22
|
+
if ((info.type === $gl.SAMPLER_2D || info.type === $gl.SAMPLER_2D_ARRAY)
|
|
23
|
+
&& info.size === 1 && !atlas) {
|
|
23
24
|
continue;
|
|
24
25
|
}
|
|
25
26
|
const data = {};
|
|
@@ -38,7 +39,9 @@ export const execute = (program, map, atlas = false) => {
|
|
|
38
39
|
break;
|
|
39
40
|
// uniformの値の設定は、programに保持されるため、
|
|
40
41
|
// sampler2Dは一度だけ設定するようにする
|
|
42
|
+
// アトラスはTEXTURE_2D_ARRAY(テクスチャユニット3固定)としてサンプリング
|
|
41
43
|
case $gl.SAMPLER_2D:
|
|
44
|
+
case $gl.SAMPLER_2D_ARRAY:
|
|
42
45
|
data.method = atlas
|
|
43
46
|
? $gl.uniform1i.bind($gl, location, 3)
|
|
44
47
|
: $gl.uniform1iv.bind($gl, location);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ITextureObject } from "../../interface/ITextureObject";
|
|
2
|
+
/**
|
|
3
|
+
* @description プールから再利用したテクスチャをTEXTURE0にバインドします。
|
|
4
|
+
* texStorage2D は確保済みのため、フィルター設定の差分のみ反映します。
|
|
5
|
+
* Bind a texture reused from the pool to TEXTURE0.
|
|
6
|
+
* Storage is already allocated by texStorage2D, so only the
|
|
7
|
+
* filter settings are updated when they differ.
|
|
8
|
+
*
|
|
9
|
+
* @param {ITextureObject} textrue_object
|
|
10
|
+
* @param {boolean} [smooth=false]
|
|
11
|
+
* @return {void}
|
|
12
|
+
* @method
|
|
13
|
+
* @protected
|
|
14
|
+
*/
|
|
15
|
+
export declare const execute: (textrue_object: ITextureObject, smooth?: boolean) => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { $gl } from "../../WebGLUtil";
|
|
2
|
+
import { $activeTextureUnit, $boundTextures, $setActiveTextureUnit } from "../../TextureManager";
|
|
3
|
+
/**
|
|
4
|
+
* @description プールから再利用したテクスチャをTEXTURE0にバインドします。
|
|
5
|
+
* texStorage2D は確保済みのため、フィルター設定の差分のみ反映します。
|
|
6
|
+
* Bind a texture reused from the pool to TEXTURE0.
|
|
7
|
+
* Storage is already allocated by texStorage2D, so only the
|
|
8
|
+
* filter settings are updated when they differ.
|
|
9
|
+
*
|
|
10
|
+
* @param {ITextureObject} textrue_object
|
|
11
|
+
* @param {boolean} [smooth=false]
|
|
12
|
+
* @return {void}
|
|
13
|
+
* @method
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
16
|
+
export const execute = (textrue_object, smooth = false) => {
|
|
17
|
+
if ($activeTextureUnit !== $gl.TEXTURE0) {
|
|
18
|
+
$setActiveTextureUnit($gl.TEXTURE0);
|
|
19
|
+
$gl.activeTexture($gl.TEXTURE0);
|
|
20
|
+
}
|
|
21
|
+
$boundTextures[0] = textrue_object;
|
|
22
|
+
$gl.bindTexture($gl.TEXTURE_2D, textrue_object.resource);
|
|
23
|
+
if (textrue_object.smooth !== smooth) {
|
|
24
|
+
textrue_object.smooth = smooth;
|
|
25
|
+
const filter = smooth ? $gl.LINEAR : $gl.NEAREST;
|
|
26
|
+
$gl.texParameteri($gl.TEXTURE_2D, $gl.TEXTURE_MIN_FILTER, filter);
|
|
27
|
+
$gl.texParameteri($gl.TEXTURE_2D, $gl.TEXTURE_MAG_FILTER, filter);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { ITextureObject } from "../../interface/ITextureObject";
|
|
2
2
|
/**
|
|
3
|
-
* @description
|
|
4
|
-
*
|
|
3
|
+
* @description アトラス専用のテクスチャ(TEXTURE_2D_ARRAY)を作成します。
|
|
4
|
+
* 1ページ=1レイヤーとして解決することで、複数ページを1バッチで
|
|
5
|
+
* サンプリングでき、ページ切替によるバッチ分断が発生しない。
|
|
6
|
+
* テクスチャユニット3に常時バインドされる。
|
|
7
|
+
* Create the atlas texture (TEXTURE_2D_ARRAY). Each page resolves
|
|
8
|
+
* into its own layer so a single batch can sample multiple pages
|
|
9
|
+
* without breaking on page switches. Permanently bound to
|
|
10
|
+
* texture unit 3.
|
|
5
11
|
*
|
|
12
|
+
* @param {number} [layers=1]
|
|
6
13
|
* @return {ITextureObject}
|
|
7
14
|
* @method
|
|
8
15
|
* @protected
|
|
9
16
|
*/
|
|
10
|
-
export declare const execute: () => ITextureObject;
|
|
17
|
+
export declare const execute: (layers?: number) => ITextureObject;
|
|
@@ -2,22 +2,29 @@ import { execute as textureManagerCreateTextureObjectService } from "../service/
|
|
|
2
2
|
import { $activeTextureUnit } from "../../TextureManager";
|
|
3
3
|
import { $RENDER_MAX_SIZE, $gl } from "../../WebGLUtil";
|
|
4
4
|
/**
|
|
5
|
-
* @description
|
|
6
|
-
*
|
|
5
|
+
* @description アトラス専用のテクスチャ(TEXTURE_2D_ARRAY)を作成します。
|
|
6
|
+
* 1ページ=1レイヤーとして解決することで、複数ページを1バッチで
|
|
7
|
+
* サンプリングでき、ページ切替によるバッチ分断が発生しない。
|
|
8
|
+
* テクスチャユニット3に常時バインドされる。
|
|
9
|
+
* Create the atlas texture (TEXTURE_2D_ARRAY). Each page resolves
|
|
10
|
+
* into its own layer so a single batch can sample multiple pages
|
|
11
|
+
* without breaking on page switches. Permanently bound to
|
|
12
|
+
* texture unit 3.
|
|
7
13
|
*
|
|
14
|
+
* @param {number} [layers=1]
|
|
8
15
|
* @return {ITextureObject}
|
|
9
16
|
* @method
|
|
10
17
|
* @protected
|
|
11
18
|
*/
|
|
12
|
-
export const execute = () => {
|
|
19
|
+
export const execute = (layers = 1) => {
|
|
13
20
|
const textureObject = textureManagerCreateTextureObjectService($RENDER_MAX_SIZE, $RENDER_MAX_SIZE);
|
|
14
21
|
$gl.activeTexture($gl.TEXTURE3);
|
|
15
|
-
$gl.bindTexture($gl.
|
|
16
|
-
$gl.texParameteri($gl.
|
|
17
|
-
$gl.texParameteri($gl.
|
|
18
|
-
$gl.texParameteri($gl.
|
|
19
|
-
$gl.texParameteri($gl.
|
|
20
|
-
$gl.
|
|
22
|
+
$gl.bindTexture($gl.TEXTURE_2D_ARRAY, textureObject.resource);
|
|
23
|
+
$gl.texParameteri($gl.TEXTURE_2D_ARRAY, $gl.TEXTURE_WRAP_S, $gl.CLAMP_TO_EDGE);
|
|
24
|
+
$gl.texParameteri($gl.TEXTURE_2D_ARRAY, $gl.TEXTURE_WRAP_T, $gl.CLAMP_TO_EDGE);
|
|
25
|
+
$gl.texParameteri($gl.TEXTURE_2D_ARRAY, $gl.TEXTURE_MIN_FILTER, $gl.LINEAR);
|
|
26
|
+
$gl.texParameteri($gl.TEXTURE_2D_ARRAY, $gl.TEXTURE_MAG_FILTER, $gl.NEAREST);
|
|
27
|
+
$gl.texStorage3D($gl.TEXTURE_2D_ARRAY, 1, $gl.RGBA8, textureObject.width, textureObject.height, layers);
|
|
21
28
|
$gl.activeTexture($activeTextureUnit !== -1
|
|
22
29
|
? $activeTextureUnit
|
|
23
30
|
: $gl.TEXTURE0);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execute as textureManagerGetTextureUseCase } from "./TextureManagerGetTextureUseCase";
|
|
2
2
|
import { execute as textureManagerBind0UseCase } from "./TextureManagerBind0UseCase";
|
|
3
|
-
import { $context, $gl, $enableScissorTest, $disableScissorTest } from "../../WebGLUtil";
|
|
3
|
+
import { $context, $gl, $enableScissorTest, $disableScissorTest, $setScissorBox } from "../../WebGLUtil";
|
|
4
4
|
import { $drawBitmapFramebuffer, $readFrameBuffer } from "../../FrameBufferManager";
|
|
5
5
|
/**
|
|
6
6
|
* @type {ITextureObject}
|
|
@@ -37,7 +37,7 @@ export const execute = (x, y, width, height) => {
|
|
|
37
37
|
$gl.bindFramebuffer($gl.READ_FRAMEBUFFER, $readFrameBuffer);
|
|
38
38
|
$gl.bindFramebuffer($gl.DRAW_FRAMEBUFFER, $drawBitmapFramebuffer);
|
|
39
39
|
$enableScissorTest();
|
|
40
|
-
$
|
|
40
|
+
$setScissorBox(x, mainAttachmentObject.height - y - height, width + 1, height + 1);
|
|
41
41
|
// execute
|
|
42
42
|
$gl.blitFramebuffer(0, 0, mainAttachmentObject.width, mainAttachmentObject.height, 0, 0, mainAttachmentObject.width, mainAttachmentObject.height, $gl.COLOR_BUFFER_BIT, $gl.NEAREST);
|
|
43
43
|
$disableScissorTest();
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import type { ITextureObject } from "../../interface/ITextureObject";
|
|
2
2
|
/**
|
|
3
3
|
* @description オブジェクトプールにTextureObjectがあれば再利用、なければ新規作成して返却します。
|
|
4
|
+
* 再利用テクスチャは dirty=true のまま返却されるため、内容のゼロ初期化を
|
|
5
|
+
* 前提とする呼び出し元(部分コピー等)は use_pool=false で新規テクスチャを取得すること。
|
|
4
6
|
* If there is a TextureObject in the object pool, it will be reused,
|
|
5
7
|
* otherwise it will be created and returned.
|
|
8
|
+
* Reused textures are returned with dirty=true. Callers that rely on
|
|
9
|
+
* zero-initialized contents (e.g. partial copies) must pass
|
|
10
|
+
* use_pool=false to get a freshly created texture.
|
|
6
11
|
*
|
|
7
12
|
* @param {number} width
|
|
8
13
|
* @param {number} height
|
|
9
14
|
* @param {boolean} [smooth=false]
|
|
15
|
+
* @param {boolean} [use_pool=true]
|
|
10
16
|
* @return {ITextureObject}
|
|
11
17
|
* @method
|
|
12
18
|
* @protected
|
|
13
19
|
*/
|
|
14
|
-
export declare const execute: (width: number, height: number, smooth?: boolean) => ITextureObject;
|
|
20
|
+
export declare const execute: (width: number, height: number, smooth?: boolean, use_pool?: boolean) => ITextureObject;
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import { execute as textureManagerCreateTextureObjectService } from "../service/TextureManagerCreateTextureObjectService";
|
|
2
2
|
import { execute as textureManagerInitializeBindService } from "../service/TextureManagerInitializeBindService";
|
|
3
|
+
import { execute as textureManagerReuseBindService } from "../service/TextureManagerReuseBindService";
|
|
4
|
+
import { $acquirePooledTexture } from "../../TextureManager";
|
|
3
5
|
/**
|
|
4
6
|
* @description オブジェクトプールにTextureObjectがあれば再利用、なければ新規作成して返却します。
|
|
7
|
+
* 再利用テクスチャは dirty=true のまま返却されるため、内容のゼロ初期化を
|
|
8
|
+
* 前提とする呼び出し元(部分コピー等)は use_pool=false で新規テクスチャを取得すること。
|
|
5
9
|
* If there is a TextureObject in the object pool, it will be reused,
|
|
6
10
|
* otherwise it will be created and returned.
|
|
11
|
+
* Reused textures are returned with dirty=true. Callers that rely on
|
|
12
|
+
* zero-initialized contents (e.g. partial copies) must pass
|
|
13
|
+
* use_pool=false to get a freshly created texture.
|
|
7
14
|
*
|
|
8
15
|
* @param {number} width
|
|
9
16
|
* @param {number} height
|
|
10
17
|
* @param {boolean} [smooth=false]
|
|
18
|
+
* @param {boolean} [use_pool=true]
|
|
11
19
|
* @return {ITextureObject}
|
|
12
20
|
* @method
|
|
13
21
|
* @protected
|
|
14
22
|
*/
|
|
15
|
-
export const execute = (width, height, smooth = false) => {
|
|
23
|
+
export const execute = (width, height, smooth = false, use_pool = true) => {
|
|
24
|
+
if (use_pool) {
|
|
25
|
+
const pooledTextureObject = $acquirePooledTexture(width, height);
|
|
26
|
+
if (pooledTextureObject) {
|
|
27
|
+
textureManagerReuseBindService(pooledTextureObject, smooth);
|
|
28
|
+
return pooledTextureObject;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
16
31
|
const textureObject = textureManagerCreateTextureObjectService(width, height);
|
|
17
32
|
textureManagerInitializeBindService(textureObject, smooth);
|
|
18
33
|
return textureObject;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $gl } from "../../WebGLUtil";
|
|
2
|
-
import { $boundTextures } from "../../TextureManager";
|
|
2
|
+
import { $boundTextures, $releaseTextureToPool } from "../../TextureManager";
|
|
3
3
|
/**
|
|
4
4
|
* @description TextureObjectをオブジェクトプールに保管、サイズオーバー時は削除します。
|
|
5
5
|
* Stores the TextureObject in the object pool and deletes it if it exceeds the size.
|
|
@@ -15,5 +15,7 @@ export const execute = (texture_object) => {
|
|
|
15
15
|
$boundTextures[idx] = null;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
if (!$releaseTextureToPool(texture_object)) {
|
|
19
|
+
$gl.deleteTexture(texture_object.resource);
|
|
20
|
+
}
|
|
19
21
|
};
|
package/src/TextureManager.d.ts
CHANGED
|
@@ -23,3 +23,46 @@ export declare const $setActiveTextureUnit: (unit: number) => void;
|
|
|
23
23
|
* @protected
|
|
24
24
|
*/
|
|
25
25
|
export declare const $boundTextures: Array<ITextureObject | null>;
|
|
26
|
+
/**
|
|
27
|
+
* @description 再利用可能なテクスチャのプール。texStorage2D は immutable のため
|
|
28
|
+
* (width, height) の完全一致キーで管理する。
|
|
29
|
+
* Pool of reusable textures. Keyed by exact (width, height) match
|
|
30
|
+
* because texStorage2D allocates immutable storage.
|
|
31
|
+
*
|
|
32
|
+
* @type {Map<number, ITextureObject[]>}
|
|
33
|
+
* @protected
|
|
34
|
+
*/
|
|
35
|
+
export declare const $texturePool: Map<number, ITextureObject[]>;
|
|
36
|
+
/**
|
|
37
|
+
* @description (width, height) からプールキーを生成
|
|
38
|
+
* Generate a pool key from (width, height)
|
|
39
|
+
*
|
|
40
|
+
* @param {number} width
|
|
41
|
+
* @param {number} height
|
|
42
|
+
* @return {number}
|
|
43
|
+
* @method
|
|
44
|
+
* @protected
|
|
45
|
+
*/
|
|
46
|
+
export declare const $getTexturePoolKey: (width: number, height: number) => number;
|
|
47
|
+
/**
|
|
48
|
+
* @description 完全一致サイズの再利用テクスチャを取得。なければ null。
|
|
49
|
+
* Acquire a pooled texture with the exact size, or null.
|
|
50
|
+
*
|
|
51
|
+
* @param {number} width
|
|
52
|
+
* @param {number} height
|
|
53
|
+
* @return {ITextureObject | null}
|
|
54
|
+
* @method
|
|
55
|
+
* @protected
|
|
56
|
+
*/
|
|
57
|
+
export declare const $acquirePooledTexture: (width: number, height: number) => ITextureObject | null;
|
|
58
|
+
/**
|
|
59
|
+
* @description テクスチャをプールに返却。上限超過なら false を返す(呼び出し側で削除)。
|
|
60
|
+
* Return a texture to the pool. Returns false when the pool is full
|
|
61
|
+
* (the caller should delete the texture).
|
|
62
|
+
*
|
|
63
|
+
* @param {ITextureObject} texture_object
|
|
64
|
+
* @return {boolean}
|
|
65
|
+
* @method
|
|
66
|
+
* @protected
|
|
67
|
+
*/
|
|
68
|
+
export declare const $releaseTextureToPool: (texture_object: ITextureObject) => boolean;
|
package/src/TextureManager.js
CHANGED
|
@@ -24,3 +24,103 @@ export const $setActiveTextureUnit = (unit) => {
|
|
|
24
24
|
* @protected
|
|
25
25
|
*/
|
|
26
26
|
export const $boundTextures = [null, null, null];
|
|
27
|
+
/**
|
|
28
|
+
* @description 再利用可能なテクスチャのプール。texStorage2D は immutable のため
|
|
29
|
+
* (width, height) の完全一致キーで管理する。
|
|
30
|
+
* Pool of reusable textures. Keyed by exact (width, height) match
|
|
31
|
+
* because texStorage2D allocates immutable storage.
|
|
32
|
+
*
|
|
33
|
+
* @type {Map<number, ITextureObject[]>}
|
|
34
|
+
* @protected
|
|
35
|
+
*/
|
|
36
|
+
export const $texturePool = new Map();
|
|
37
|
+
/**
|
|
38
|
+
* @description プール全体の保持数
|
|
39
|
+
* Total number of pooled textures
|
|
40
|
+
*
|
|
41
|
+
* @type {number}
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
let $texturePoolCount = 0;
|
|
45
|
+
/**
|
|
46
|
+
* @description バケット毎の最大保持数
|
|
47
|
+
* Maximum number of pooled textures per size bucket
|
|
48
|
+
*
|
|
49
|
+
* @type {number}
|
|
50
|
+
* @const
|
|
51
|
+
*/
|
|
52
|
+
const $TEXTURE_POOL_BUCKET_MAX = 4;
|
|
53
|
+
/**
|
|
54
|
+
* @description プール全体の最大保持数
|
|
55
|
+
* Maximum total number of pooled textures
|
|
56
|
+
*
|
|
57
|
+
* @type {number}
|
|
58
|
+
* @const
|
|
59
|
+
*/
|
|
60
|
+
const $TEXTURE_POOL_TOTAL_MAX = 32;
|
|
61
|
+
/**
|
|
62
|
+
* @description (width, height) からプールキーを生成
|
|
63
|
+
* Generate a pool key from (width, height)
|
|
64
|
+
*
|
|
65
|
+
* @param {number} width
|
|
66
|
+
* @param {number} height
|
|
67
|
+
* @return {number}
|
|
68
|
+
* @method
|
|
69
|
+
* @protected
|
|
70
|
+
*/
|
|
71
|
+
export const $getTexturePoolKey = (width, height) => {
|
|
72
|
+
return width * 65536 + height;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* @description 完全一致サイズの再利用テクスチャを取得。なければ null。
|
|
76
|
+
* Acquire a pooled texture with the exact size, or null.
|
|
77
|
+
*
|
|
78
|
+
* @param {number} width
|
|
79
|
+
* @param {number} height
|
|
80
|
+
* @return {ITextureObject | null}
|
|
81
|
+
* @method
|
|
82
|
+
* @protected
|
|
83
|
+
*/
|
|
84
|
+
export const $acquirePooledTexture = (width, height) => {
|
|
85
|
+
const bucket = $texturePool.get($getTexturePoolKey(width, height));
|
|
86
|
+
if (!bucket || !bucket.length) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
--$texturePoolCount;
|
|
90
|
+
const textureObject = bucket.pop();
|
|
91
|
+
textureObject.pooled = false;
|
|
92
|
+
return textureObject;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* @description テクスチャをプールに返却。上限超過なら false を返す(呼び出し側で削除)。
|
|
96
|
+
* Return a texture to the pool. Returns false when the pool is full
|
|
97
|
+
* (the caller should delete the texture).
|
|
98
|
+
*
|
|
99
|
+
* @param {ITextureObject} texture_object
|
|
100
|
+
* @return {boolean}
|
|
101
|
+
* @method
|
|
102
|
+
* @protected
|
|
103
|
+
*/
|
|
104
|
+
export const $releaseTextureToPool = (texture_object) => {
|
|
105
|
+
// 二重返却ガード
|
|
106
|
+
if (texture_object.pooled) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if ($texturePoolCount >= $TEXTURE_POOL_TOTAL_MAX) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
const key = $getTexturePoolKey(texture_object.width, texture_object.height);
|
|
113
|
+
let bucket = $texturePool.get(key);
|
|
114
|
+
if (!bucket) {
|
|
115
|
+
bucket = [];
|
|
116
|
+
$texturePool.set(key, bucket);
|
|
117
|
+
}
|
|
118
|
+
if (bucket.length >= $TEXTURE_POOL_BUCKET_MAX) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
texture_object.pooled = true;
|
|
122
|
+
texture_object.dirty = true;
|
|
123
|
+
bucket.push(texture_object);
|
|
124
|
+
++$texturePoolCount;
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
@@ -20,10 +20,14 @@ export const execute = () => {
|
|
|
20
20
|
$gl.bindBuffer($gl.ARRAY_BUFFER, $attributeWebGLBuffer);
|
|
21
21
|
if (renderQueue.buffer.length > $attributeBufferLength) {
|
|
22
22
|
$attributeBufferLength = renderQueue.buffer.length;
|
|
23
|
-
// STREAM_DRAW: 毎フレーム更新されるデータに最適
|
|
24
|
-
// STREAM_DRAW: Optimal for data updated every frame
|
|
25
|
-
$gl.bufferData($gl.ARRAY_BUFFER, $attributeBufferLength * 4, // renderQueue.buffer.byteLength
|
|
26
|
-
$gl.STREAM_DRAW);
|
|
27
23
|
}
|
|
24
|
+
// バッファオーファニング: 直前のdrawArraysInstancedが参照中の可能性がある領域を
|
|
25
|
+
// 上書きするとドライバが暗黙の同期(ストール)を挿入するため、毎回新しいストレージを
|
|
26
|
+
// 確保してから書き込む。STREAM_DRAW: 毎フレーム更新されるデータに最適。
|
|
27
|
+
// Buffer orphaning: overwriting a region that the previous drawArraysInstanced
|
|
28
|
+
// may still be reading can cause an implicit driver sync (stall), so allocate
|
|
29
|
+
// fresh storage before each upload. STREAM_DRAW: optimal for per-frame data.
|
|
30
|
+
$gl.bufferData($gl.ARRAY_BUFFER, $attributeBufferLength * 4, // renderQueue.buffer.byteLength
|
|
31
|
+
$gl.STREAM_DRAW);
|
|
28
32
|
$gl.bufferSubData($gl.ARRAY_BUFFER, 0, renderQueue.buffer, 0, renderQueue.offset);
|
|
29
33
|
};
|
|
@@ -27,6 +27,10 @@ export const execute = (begin, end) => {
|
|
|
27
27
|
$vertexBufferData[2] = begin;
|
|
28
28
|
$vertexBufferData[4] = end;
|
|
29
29
|
$vertexBufferData[6] = end;
|
|
30
|
+
// 必ずグラデーション用のバッファをバインドしてから更新する。
|
|
31
|
+
// バインドせずに bufferSubData を実行すると、直前まで
|
|
32
|
+
// ARRAY_BUFFER にバインドされていた塗りメッシュのバッファを破壊する。
|
|
33
|
+
$gl.bindBuffer($gl.ARRAY_BUFFER, $gradientVertexArrayObject.vertexBuffer);
|
|
30
34
|
$gl.bufferSubData($gl.ARRAY_BUFFER, 0, $vertexBufferData);
|
|
31
35
|
}
|
|
32
36
|
}
|
package/src/WebGLUtil.d.ts
CHANGED
|
@@ -5,6 +5,28 @@ export declare let $samples: number;
|
|
|
5
5
|
export declare const $setSamples: (samples: number) => void;
|
|
6
6
|
export declare let $gl: WebGL2RenderingContext;
|
|
7
7
|
export declare const $setWebGL2RenderingContext: (gl: WebGL2RenderingContext) => void;
|
|
8
|
+
/**
|
|
9
|
+
* @description 最後に設定されたscissor矩形(x, y, w, h)
|
|
10
|
+
* Last scissor rectangle set via $setScissorBox (x, y, w, h)
|
|
11
|
+
*
|
|
12
|
+
* @type {Int32Array}
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
export declare const $scissorBox: Int32Array;
|
|
16
|
+
/**
|
|
17
|
+
* @description gl.scissorのラッパー。矩形をJS側に保持してGLへの同期問い合わせを不要にする。
|
|
18
|
+
* Wrapper for gl.scissor. Tracks the rectangle in JS so that
|
|
19
|
+
* synchronous getParameter(SCISSOR_BOX) queries are unnecessary.
|
|
20
|
+
*
|
|
21
|
+
* @param {number} x
|
|
22
|
+
* @param {number} y
|
|
23
|
+
* @param {number} w
|
|
24
|
+
* @param {number} h
|
|
25
|
+
* @return {void}
|
|
26
|
+
* @method
|
|
27
|
+
* @protected
|
|
28
|
+
*/
|
|
29
|
+
export declare const $setScissorBox: (x: number, y: number, w: number, h: number) => void;
|
|
8
30
|
export declare let $context: Context;
|
|
9
31
|
export declare const $setContext: (context: Context) => void;
|
|
10
32
|
export declare const $enableScissorTest: () => void;
|
package/src/WebGLUtil.js
CHANGED
|
@@ -9,6 +9,43 @@ export const $setSamples = (samples) => {
|
|
|
9
9
|
export let $gl;
|
|
10
10
|
export const $setWebGL2RenderingContext = (gl) => {
|
|
11
11
|
$gl = gl;
|
|
12
|
+
// 現在のscissor矩形をJS側で追跡して同期クエリ(getParameter)を排除する。
|
|
13
|
+
// 初期値のみGLから取得して整合させる。
|
|
14
|
+
const scissorBox = gl.getParameter(gl.SCISSOR_BOX);
|
|
15
|
+
if (scissorBox && scissorBox.length >= 4) {
|
|
16
|
+
$scissorBox[0] = scissorBox[0];
|
|
17
|
+
$scissorBox[1] = scissorBox[1];
|
|
18
|
+
$scissorBox[2] = scissorBox[2];
|
|
19
|
+
$scissorBox[3] = scissorBox[3];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @description 最後に設定されたscissor矩形(x, y, w, h)
|
|
24
|
+
* Last scissor rectangle set via $setScissorBox (x, y, w, h)
|
|
25
|
+
*
|
|
26
|
+
* @type {Int32Array}
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
export const $scissorBox = new Int32Array(4);
|
|
30
|
+
/**
|
|
31
|
+
* @description gl.scissorのラッパー。矩形をJS側に保持してGLへの同期問い合わせを不要にする。
|
|
32
|
+
* Wrapper for gl.scissor. Tracks the rectangle in JS so that
|
|
33
|
+
* synchronous getParameter(SCISSOR_BOX) queries are unnecessary.
|
|
34
|
+
*
|
|
35
|
+
* @param {number} x
|
|
36
|
+
* @param {number} y
|
|
37
|
+
* @param {number} w
|
|
38
|
+
* @param {number} h
|
|
39
|
+
* @return {void}
|
|
40
|
+
* @method
|
|
41
|
+
* @protected
|
|
42
|
+
*/
|
|
43
|
+
export const $setScissorBox = (x, y, w, h) => {
|
|
44
|
+
$scissorBox[0] = x;
|
|
45
|
+
$scissorBox[1] = y;
|
|
46
|
+
$scissorBox[2] = w;
|
|
47
|
+
$scissorBox[3] = h;
|
|
48
|
+
$gl.scissor(x, y, w, h);
|
|
12
49
|
};
|
|
13
50
|
export let $context;
|
|
14
51
|
export const $setContext = (context) => {
|