@next2d/webgl 3.18.0 → 3.19.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 +3 -3
- package/src/Context/usecase/ContextBindUseCase.d.ts +12 -0
- package/src/Context/usecase/ContextBindUseCase.js +44 -14
- package/src/Context/usecase/ContextDeferBindUseCase.d.ts +18 -0
- package/src/Context/usecase/ContextDeferBindUseCase.js +28 -0
- package/src/Context/usecase/ContextSyncAttachmentUseCase.d.ts +13 -0
- package/src/Context/usecase/ContextSyncAttachmentUseCase.js +21 -0
- package/src/Context.d.ts +15 -0
- package/src/Context.js +98 -1
- package/src/FrameBufferManager/service/FrameBufferManagerBindAttachmentObjectService.js +3 -1
- package/src/FrameBufferManager/service/FrameBufferManagerUnBindAttachmentObjectService.js +3 -1
- package/src/FrameBufferManager.d.ts +37 -0
- package/src/FrameBufferManager.js +41 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/webgl",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"description": "Next2D Webgl Package",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@next2d/texture-packer": "3.
|
|
28
|
-
"@next2d/render-queue": "3.
|
|
27
|
+
"@next2d/texture-packer": "3.19.0",
|
|
28
|
+
"@next2d/render-queue": "3.19.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { IAttachmentObject } from "../../interface/IAttachmentObject";
|
|
2
2
|
import type { Context } from "../../Context";
|
|
3
|
+
/**
|
|
4
|
+
* @description GL のフレームバッファを attachment_object に切り替える
|
|
5
|
+
* Switch the GL framebuffer to attachment_object
|
|
6
|
+
*
|
|
7
|
+
* @param {Context} context
|
|
8
|
+
* @param {IAttachmentObject} attachment_object
|
|
9
|
+
* @param {IAttachmentObject | null} previous 直前まで GL に付いていたアタッチメントオブジェクト
|
|
10
|
+
* @return {void}
|
|
11
|
+
* @method
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
export declare const $bindPhysical: (context: Context, attachment_object: IAttachmentObject, previous: IAttachmentObject | null) => void;
|
|
3
15
|
/**
|
|
4
16
|
* @description アタッチメントオブジェクトのサイズに変更・初期化し、フレームバッファにアタッチメントオブジェクトをバインドする
|
|
5
17
|
* Change and initialize to the size of the attachment object and bind the attachment object to the frame buffer
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { $currentAttachment } from "../../FrameBufferManager";
|
|
1
|
+
import { $currentAttachment, $setCurrentAttachment, $physicalAttachment, $attachmentDeferred, $setAttachmentDeferred, $isFramebufferBound } from "../../FrameBufferManager";
|
|
2
2
|
import { execute as frameBufferManagerBindAttachmentObjectService } from "../../FrameBufferManager/service/FrameBufferManagerBindAttachmentObjectService";
|
|
3
3
|
import { execute as maskBindUseCase } from "../../Mask/usecase/MaskBindUseCase";
|
|
4
4
|
import { $gl, $setViewportSize } from "../../WebGLUtil";
|
|
5
5
|
/**
|
|
6
|
-
* @description
|
|
7
|
-
*
|
|
6
|
+
* @description GL のフレームバッファを attachment_object に切り替える
|
|
7
|
+
* Switch the GL framebuffer to attachment_object
|
|
8
8
|
*
|
|
9
9
|
* @param {Context} context
|
|
10
10
|
* @param {IAttachmentObject} attachment_object
|
|
11
|
+
* @param {IAttachmentObject | null} previous 直前まで GL に付いていたアタッチメントオブジェクト
|
|
11
12
|
* @return {void}
|
|
12
13
|
* @method
|
|
13
14
|
* @protected
|
|
14
15
|
*/
|
|
15
|
-
export const
|
|
16
|
-
// fixed logic
|
|
17
|
-
const currentAttachment = $currentAttachment;
|
|
18
|
-
if (currentAttachment
|
|
19
|
-
&& attachment_object.id === currentAttachment.id) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
16
|
+
export const $bindPhysical = (context, attachment_object, previous) => {
|
|
22
17
|
// フレームバッファにアタッチメントオブジェクトをバインドする
|
|
23
18
|
frameBufferManagerBindAttachmentObjectService(attachment_object);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
// ビューポートの大きさは、切り替えを保留している間に書き換わっていることがあるので必ず合わせる
|
|
20
|
+
$setViewportSize(attachment_object.width, attachment_object.height);
|
|
21
|
+
if (!previous
|
|
22
|
+
|| previous.width !== attachment_object.width
|
|
23
|
+
|| previous.height !== attachment_object.height) {
|
|
28
24
|
$gl.viewport(0, 0, attachment_object.width, attachment_object.height);
|
|
29
25
|
}
|
|
30
26
|
// カラーバッファorステンシルバッファが、未初期化の場合はクリアする
|
|
@@ -45,3 +41,37 @@ export const execute = (context, attachment_object) => {
|
|
|
45
41
|
// mask bind
|
|
46
42
|
maskBindUseCase(attachment_object.mask);
|
|
47
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* @description アタッチメントオブジェクトのサイズに変更・初期化し、フレームバッファにアタッチメントオブジェクトをバインドする
|
|
46
|
+
* Change and initialize to the size of the attachment object and bind the attachment object to the frame buffer
|
|
47
|
+
*
|
|
48
|
+
* @param {Context} context
|
|
49
|
+
* @param {IAttachmentObject} attachment_object
|
|
50
|
+
* @return {void}
|
|
51
|
+
* @method
|
|
52
|
+
* @protected
|
|
53
|
+
*/
|
|
54
|
+
export const execute = (context, attachment_object) => {
|
|
55
|
+
// 描画先の切り替えを保留している間 (ContextDeferBindUseCase): GL にはまだ前の描画先が付いている
|
|
56
|
+
if ($attachmentDeferred) {
|
|
57
|
+
$setAttachmentDeferred(false);
|
|
58
|
+
const physical = $physicalAttachment;
|
|
59
|
+
if (physical
|
|
60
|
+
&& physical.id === attachment_object.id
|
|
61
|
+
&& $isFramebufferBound) {
|
|
62
|
+
// GL に付いたままの描画先へ戻るだけ: 何も切り替えずに済む
|
|
63
|
+
$setCurrentAttachment(attachment_object);
|
|
64
|
+
$setViewportSize(attachment_object.width, attachment_object.height);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
$bindPhysical(context, attachment_object, physical);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// fixed logic
|
|
71
|
+
const currentAttachment = $currentAttachment;
|
|
72
|
+
if (currentAttachment
|
|
73
|
+
&& attachment_object.id === currentAttachment.id) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
$bindPhysical(context, attachment_object, currentAttachment);
|
|
77
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IAttachmentObject } from "../../interface/IAttachmentObject";
|
|
2
|
+
/**
|
|
3
|
+
* @description 描画先を attachment_object に切り替えるが、GL のフレームバッファの切り替えは、実際に GL で
|
|
4
|
+
* 描く時点まで保留する。アトラスへ図形を描いた後に元の描画先へ戻す処理で使う: 未キャッシュの
|
|
5
|
+
* 図形が続くと、次の図形がすぐにアトラスへ切り替え直すので、戻す切り替えは無駄になる。
|
|
6
|
+
* 現在の描画先とビューポートの大きさ (どちらも JavaScript の値) は、ここで切り替え後の値にする。
|
|
7
|
+
* Switch the render target to attachment_object, but postpone switching the GL framebuffer
|
|
8
|
+
* until something is actually drawn with GL. Used to go back to the previous target after
|
|
9
|
+
* drawing a shape into the atlas: when uncached shapes follow one another, the next one
|
|
10
|
+
* switches straight back to the atlas, so switching back in between is wasted. The current
|
|
11
|
+
* attachment and the viewport size (both JavaScript values) take their new values here.
|
|
12
|
+
*
|
|
13
|
+
* @param {IAttachmentObject} attachment_object
|
|
14
|
+
* @return {void}
|
|
15
|
+
* @method
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
export declare const execute: (attachment_object: IAttachmentObject) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { $currentAttachment, $setCurrentAttachment, $setAttachmentDeferred } from "../../FrameBufferManager";
|
|
2
|
+
import { $setViewportSize } from "../../WebGLUtil";
|
|
3
|
+
/**
|
|
4
|
+
* @description 描画先を attachment_object に切り替えるが、GL のフレームバッファの切り替えは、実際に GL で
|
|
5
|
+
* 描く時点まで保留する。アトラスへ図形を描いた後に元の描画先へ戻す処理で使う: 未キャッシュの
|
|
6
|
+
* 図形が続くと、次の図形がすぐにアトラスへ切り替え直すので、戻す切り替えは無駄になる。
|
|
7
|
+
* 現在の描画先とビューポートの大きさ (どちらも JavaScript の値) は、ここで切り替え後の値にする。
|
|
8
|
+
* Switch the render target to attachment_object, but postpone switching the GL framebuffer
|
|
9
|
+
* until something is actually drawn with GL. Used to go back to the previous target after
|
|
10
|
+
* drawing a shape into the atlas: when uncached shapes follow one another, the next one
|
|
11
|
+
* switches straight back to the atlas, so switching back in between is wasted. The current
|
|
12
|
+
* attachment and the viewport size (both JavaScript values) take their new values here.
|
|
13
|
+
*
|
|
14
|
+
* @param {IAttachmentObject} attachment_object
|
|
15
|
+
* @return {void}
|
|
16
|
+
* @method
|
|
17
|
+
* @protected
|
|
18
|
+
*/
|
|
19
|
+
export const execute = (attachment_object) => {
|
|
20
|
+
const currentAttachment = $currentAttachment;
|
|
21
|
+
if (currentAttachment
|
|
22
|
+
&& attachment_object.id === currentAttachment.id) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
$setCurrentAttachment(attachment_object);
|
|
26
|
+
$setViewportSize(attachment_object.width, attachment_object.height);
|
|
27
|
+
$setAttachmentDeferred(true);
|
|
28
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Context } from "../../Context";
|
|
2
|
+
/**
|
|
3
|
+
* @description 保留していた描画先の切り替え (ContextDeferBindUseCase) を、GL のフレームバッファに反映する。
|
|
4
|
+
* GL で描く処理の先頭で、$attachmentDeferred が true のときに呼ぶ。
|
|
5
|
+
* Apply the postponed render target switch (ContextDeferBindUseCase) to the GL framebuffer.
|
|
6
|
+
* Called at the start of anything that draws with GL, when $attachmentDeferred is true.
|
|
7
|
+
*
|
|
8
|
+
* @param {Context} context
|
|
9
|
+
* @return {void}
|
|
10
|
+
* @method
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
export declare const execute: (context: Context) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { $currentAttachment, $physicalAttachment, $setAttachmentDeferred } from "../../FrameBufferManager";
|
|
2
|
+
import { $bindPhysical } from "./ContextBindUseCase";
|
|
3
|
+
/**
|
|
4
|
+
* @description 保留していた描画先の切り替え (ContextDeferBindUseCase) を、GL のフレームバッファに反映する。
|
|
5
|
+
* GL で描く処理の先頭で、$attachmentDeferred が true のときに呼ぶ。
|
|
6
|
+
* Apply the postponed render target switch (ContextDeferBindUseCase) to the GL framebuffer.
|
|
7
|
+
* Called at the start of anything that draws with GL, when $attachmentDeferred is true.
|
|
8
|
+
*
|
|
9
|
+
* @param {Context} context
|
|
10
|
+
* @return {void}
|
|
11
|
+
* @method
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
export const execute = (context) => {
|
|
15
|
+
$setAttachmentDeferred(false);
|
|
16
|
+
const attachment = $currentAttachment;
|
|
17
|
+
if (!attachment) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
$bindPhysical(context, attachment, $physicalAttachment);
|
|
21
|
+
};
|
package/src/Context.d.ts
CHANGED
|
@@ -31,6 +31,21 @@ export declare class Context {
|
|
|
31
31
|
resize(width: number, height: number, cache_clear?: boolean): void;
|
|
32
32
|
clearRect(x: number, y: number, w: number, h: number): void;
|
|
33
33
|
bind(attachment_object: IAttachmentObject): void;
|
|
34
|
+
/**
|
|
35
|
+
* @description 描画先を attachment_object に戻す。GL のフレームバッファの切り替えは、次に GL で描く時点まで
|
|
36
|
+
* 保留する (すぐ次の処理が同じ描画先へ切り替え直す場合、切り替えそのものを省ける)。
|
|
37
|
+
* アトラスへ描いた後に、元の描画先へ戻すときに使う。
|
|
38
|
+
* Go back to attachment_object as the render target. Switching the GL framebuffer is
|
|
39
|
+
* postponed until the next GL draw (and skipped altogether when the next operation
|
|
40
|
+
* switches straight back). Use it to return to the previous target after drawing
|
|
41
|
+
* into the atlas.
|
|
42
|
+
*
|
|
43
|
+
* @param {IAttachmentObject} attachment_object
|
|
44
|
+
* @return {void}
|
|
45
|
+
* @method
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
deferBind(attachment_object: IAttachmentObject): void;
|
|
34
49
|
queueTextElement(node: Node, canvas: OffscreenCanvas): boolean;
|
|
35
50
|
save(): void;
|
|
36
51
|
restore(): void;
|
package/src/Context.js
CHANGED
|
@@ -14,6 +14,8 @@ import { execute as contextFillBackgroundColorService } from "./Context/service/
|
|
|
14
14
|
import { execute as contextResizeUseCase } from "./Context/usecase/ContextResizeUseCase";
|
|
15
15
|
import { execute as contextClearRectUseCase } from "./Context/usecase/ContextClearRectUseCase";
|
|
16
16
|
import { execute as contextBindUseCase } from "./Context/usecase/ContextBindUseCase";
|
|
17
|
+
import { execute as contextDeferBindUseCase } from "./Context/usecase/ContextDeferBindUseCase";
|
|
18
|
+
import { execute as contextSyncAttachmentUseCase } from "./Context/usecase/ContextSyncAttachmentUseCase";
|
|
17
19
|
import { execute as contextSaveService } from "./Context/service/ContextSaveService";
|
|
18
20
|
import { execute as contextRestoreService } from "./Context/service/ContextRestoreService";
|
|
19
21
|
import { execute as contextSetTransformService } from "./Context/service/ContextSetTransformService";
|
|
@@ -55,7 +57,7 @@ import { execute as contextDrawFillUseCase } from "./Context/usecase/ContextDraw
|
|
|
55
57
|
import { execute as contextCreateImageBitmapService } from "./Context/service/ContextCreateImageBitmapService";
|
|
56
58
|
import { $setGradientLUTGeneratorMaxLength } from "./Shader/GradientLUTGenerator";
|
|
57
59
|
import { $getAtlasAttachmentObject, $clearTransferBounds, $getAtlasTextureObject, $setAtlasPageDirty, $rootNodes, $setActiveAtlasIndex } from "./AtlasManager";
|
|
58
|
-
import { $setReadFrameBuffer, $setDrawFrameBuffer, $currentAttachment, $setAtlasFrameBuffer, $setBitmapFrameBuffer } from "./FrameBufferManager";
|
|
60
|
+
import { $setReadFrameBuffer, $setDrawFrameBuffer, $currentAttachment, $attachmentDeferred, $setAtlasFrameBuffer, $setBitmapFrameBuffer } from "./FrameBufferManager";
|
|
59
61
|
import { $setRenderMaxSize, $setWebGL2RenderingContext, $setSamples, $getFloat32Array9, $getArray, $setContext, $setDevicePixelRatio } from "./WebGLUtil";
|
|
60
62
|
export class Context {
|
|
61
63
|
constructor(gl, samples, device_pixel_ratio = 1) {
|
|
@@ -124,14 +126,23 @@ export class Context {
|
|
|
124
126
|
contextUpdateBackgroundColorService(this, red, green, blue, alpha);
|
|
125
127
|
}
|
|
126
128
|
fillBackgroundColor() {
|
|
129
|
+
if ($attachmentDeferred) {
|
|
130
|
+
contextSyncAttachmentUseCase(this);
|
|
131
|
+
}
|
|
127
132
|
flushTextUploads();
|
|
128
133
|
contextFillBackgroundColorService(this.$clearColorR, this.$clearColorG, this.$clearColorB, this.$clearColorA);
|
|
129
134
|
}
|
|
130
135
|
resize(width, height, cache_clear = true) {
|
|
136
|
+
if ($attachmentDeferred) {
|
|
137
|
+
contextSyncAttachmentUseCase(this);
|
|
138
|
+
}
|
|
131
139
|
disposeTextUploads();
|
|
132
140
|
contextResizeUseCase(this, width, height, cache_clear);
|
|
133
141
|
}
|
|
134
142
|
clearRect(x, y, w, h) {
|
|
143
|
+
if ($attachmentDeferred) {
|
|
144
|
+
contextSyncAttachmentUseCase(this);
|
|
145
|
+
}
|
|
135
146
|
flushTextUploads();
|
|
136
147
|
contextClearRectUseCase(x, y, w, h);
|
|
137
148
|
}
|
|
@@ -139,6 +150,23 @@ export class Context {
|
|
|
139
150
|
flushTextUploads();
|
|
140
151
|
contextBindUseCase(this, attachment_object);
|
|
141
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* @description 描画先を attachment_object に戻す。GL のフレームバッファの切り替えは、次に GL で描く時点まで
|
|
155
|
+
* 保留する (すぐ次の処理が同じ描画先へ切り替え直す場合、切り替えそのものを省ける)。
|
|
156
|
+
* アトラスへ描いた後に、元の描画先へ戻すときに使う。
|
|
157
|
+
* Go back to attachment_object as the render target. Switching the GL framebuffer is
|
|
158
|
+
* postponed until the next GL draw (and skipped altogether when the next operation
|
|
159
|
+
* switches straight back). Use it to return to the previous target after drawing
|
|
160
|
+
* into the atlas.
|
|
161
|
+
*
|
|
162
|
+
* @param {IAttachmentObject} attachment_object
|
|
163
|
+
* @return {void}
|
|
164
|
+
* @method
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
deferBind(attachment_object) {
|
|
168
|
+
contextDeferBindUseCase(attachment_object);
|
|
169
|
+
}
|
|
142
170
|
queueTextElement(node, canvas) {
|
|
143
171
|
return queueTextUpload(node, canvas);
|
|
144
172
|
}
|
|
@@ -155,6 +183,9 @@ export class Context {
|
|
|
155
183
|
contextTransformService(this, a, b, c, d, e, f);
|
|
156
184
|
}
|
|
157
185
|
reset() {
|
|
186
|
+
if ($attachmentDeferred) {
|
|
187
|
+
contextSyncAttachmentUseCase(this);
|
|
188
|
+
}
|
|
158
189
|
flushTextUploads();
|
|
159
190
|
contextResetService(this);
|
|
160
191
|
}
|
|
@@ -219,30 +250,51 @@ export class Context {
|
|
|
219
250
|
bezierCurveTo(cx1, cy1, cx2, cy2, x, y);
|
|
220
251
|
}
|
|
221
252
|
fill() {
|
|
253
|
+
if ($attachmentDeferred) {
|
|
254
|
+
contextSyncAttachmentUseCase(this);
|
|
255
|
+
}
|
|
222
256
|
flushTextUploads();
|
|
223
257
|
contextFillUseCase("fill");
|
|
224
258
|
}
|
|
225
259
|
gradientFill(type, stops, matrix, spread, interpolation, focal) {
|
|
260
|
+
if ($attachmentDeferred) {
|
|
261
|
+
contextSyncAttachmentUseCase(this);
|
|
262
|
+
}
|
|
226
263
|
flushTextUploads();
|
|
227
264
|
contextGradientFillUseCase(type, stops, matrix, spread, interpolation, focal);
|
|
228
265
|
}
|
|
229
266
|
bitmapFill(pixels, matrix, width, height, repeat, smooth) {
|
|
267
|
+
if ($attachmentDeferred) {
|
|
268
|
+
contextSyncAttachmentUseCase(this);
|
|
269
|
+
}
|
|
230
270
|
flushTextUploads();
|
|
231
271
|
contextBitmapFillUseCase(pixels, matrix, width, height, repeat, smooth);
|
|
232
272
|
}
|
|
233
273
|
stroke() {
|
|
274
|
+
if ($attachmentDeferred) {
|
|
275
|
+
contextSyncAttachmentUseCase(this);
|
|
276
|
+
}
|
|
234
277
|
flushTextUploads();
|
|
235
278
|
contextStrokeUseCase();
|
|
236
279
|
}
|
|
237
280
|
gradientStroke(type, stops, matrix, spread, interpolation, focal) {
|
|
281
|
+
if ($attachmentDeferred) {
|
|
282
|
+
contextSyncAttachmentUseCase(this);
|
|
283
|
+
}
|
|
238
284
|
flushTextUploads();
|
|
239
285
|
contextGradientStrokeUseCase(type, stops, matrix, spread, interpolation, focal);
|
|
240
286
|
}
|
|
241
287
|
bitmapStroke(pixels, matrix, width, height, repeat, smooth) {
|
|
288
|
+
if ($attachmentDeferred) {
|
|
289
|
+
contextSyncAttachmentUseCase(this);
|
|
290
|
+
}
|
|
242
291
|
flushTextUploads();
|
|
243
292
|
contextBitmapStrokeUseCase(pixels, matrix, width, height, repeat, smooth);
|
|
244
293
|
}
|
|
245
294
|
clip() {
|
|
295
|
+
if ($attachmentDeferred) {
|
|
296
|
+
contextSyncAttachmentUseCase(this);
|
|
297
|
+
}
|
|
246
298
|
flushTextUploads();
|
|
247
299
|
contextClipUseCase();
|
|
248
300
|
}
|
|
@@ -298,6 +350,9 @@ export class Context {
|
|
|
298
350
|
}
|
|
299
351
|
}
|
|
300
352
|
beginNodeRendering(node) {
|
|
353
|
+
if ($attachmentDeferred) {
|
|
354
|
+
contextSyncAttachmentUseCase(this);
|
|
355
|
+
}
|
|
301
356
|
flushTextUploads();
|
|
302
357
|
this.newDrawState = true;
|
|
303
358
|
// このページには未解決の描き込みがある(次回の解決対象)
|
|
@@ -306,10 +361,16 @@ export class Context {
|
|
|
306
361
|
contextBeginNodeRenderingService(node.x, node.y, node.w, node.h);
|
|
307
362
|
}
|
|
308
363
|
endNodeRendering() {
|
|
364
|
+
if ($attachmentDeferred) {
|
|
365
|
+
contextSyncAttachmentUseCase(this);
|
|
366
|
+
}
|
|
309
367
|
flushTextUploads();
|
|
310
368
|
contextEndNodeRenderingService();
|
|
311
369
|
}
|
|
312
370
|
drawFill() {
|
|
371
|
+
if ($attachmentDeferred) {
|
|
372
|
+
contextSyncAttachmentUseCase(this);
|
|
373
|
+
}
|
|
313
374
|
flushTextUploads();
|
|
314
375
|
contextDrawFillUseCase();
|
|
315
376
|
}
|
|
@@ -318,6 +379,9 @@ export class Context {
|
|
|
318
379
|
blnedDrawDisplayObjectUseCase(node, x_min, y_min, x_max, y_max, color_transform, color_transform_offset);
|
|
319
380
|
}
|
|
320
381
|
drawArraysInstanced() {
|
|
382
|
+
if ($attachmentDeferred) {
|
|
383
|
+
contextSyncAttachmentUseCase(this);
|
|
384
|
+
}
|
|
321
385
|
flushTextUploads();
|
|
322
386
|
blnedDrawArraysInstancedUseCase();
|
|
323
387
|
}
|
|
@@ -325,26 +389,44 @@ export class Context {
|
|
|
325
389
|
blnedClearArraysInstancedUseCase();
|
|
326
390
|
}
|
|
327
391
|
transferMainCanvas() {
|
|
392
|
+
if ($attachmentDeferred) {
|
|
393
|
+
contextSyncAttachmentUseCase(this);
|
|
394
|
+
}
|
|
328
395
|
flushTextUploads();
|
|
329
396
|
frameBufferManagerTransferMainCanvasService();
|
|
330
397
|
}
|
|
331
398
|
drawPixels(node, pixels) {
|
|
399
|
+
if ($attachmentDeferred) {
|
|
400
|
+
contextSyncAttachmentUseCase(this);
|
|
401
|
+
}
|
|
332
402
|
flushTextUploads();
|
|
333
403
|
contextDrawPixelsUseCase(node, pixels);
|
|
334
404
|
}
|
|
335
405
|
drawElement(node, element, _flipY = false) {
|
|
406
|
+
if ($attachmentDeferred) {
|
|
407
|
+
contextSyncAttachmentUseCase(this);
|
|
408
|
+
}
|
|
336
409
|
flushTextUploads();
|
|
337
410
|
contextDrawElementUseCase(node, element);
|
|
338
411
|
}
|
|
339
412
|
beginMask() {
|
|
413
|
+
if ($attachmentDeferred) {
|
|
414
|
+
contextSyncAttachmentUseCase(this);
|
|
415
|
+
}
|
|
340
416
|
flushTextUploads();
|
|
341
417
|
maskBeginMaskService();
|
|
342
418
|
}
|
|
343
419
|
setMaskBounds(x_min, y_min, x_max, y_max) {
|
|
420
|
+
if ($attachmentDeferred) {
|
|
421
|
+
contextSyncAttachmentUseCase(this);
|
|
422
|
+
}
|
|
344
423
|
flushTextUploads();
|
|
345
424
|
maskSetMaskBoundsService(x_min, y_min, x_max, y_max);
|
|
346
425
|
}
|
|
347
426
|
endMask() {
|
|
427
|
+
if ($attachmentDeferred) {
|
|
428
|
+
contextSyncAttachmentUseCase(this);
|
|
429
|
+
}
|
|
348
430
|
flushTextUploads();
|
|
349
431
|
maskEndMaskService();
|
|
350
432
|
}
|
|
@@ -364,6 +446,9 @@ export class Context {
|
|
|
364
446
|
contextContainerBeginLayerUseCase(width, height);
|
|
365
447
|
}
|
|
366
448
|
containerEndLayer(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, layer_scale_x = 1, layer_scale_y = 1) {
|
|
449
|
+
if ($attachmentDeferred) {
|
|
450
|
+
contextSyncAttachmentUseCase(this);
|
|
451
|
+
}
|
|
367
452
|
contextContainerEndLayerUseCase(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, layer_scale_x, layer_scale_y);
|
|
368
453
|
}
|
|
369
454
|
containerBeginAtlasNode(width, height) {
|
|
@@ -376,17 +461,29 @@ export class Context {
|
|
|
376
461
|
return node;
|
|
377
462
|
}
|
|
378
463
|
containerEndAtlasNode() {
|
|
464
|
+
if ($attachmentDeferred) {
|
|
465
|
+
contextSyncAttachmentUseCase(this);
|
|
466
|
+
}
|
|
379
467
|
const node = this._pendingAtlasNodes.pop();
|
|
380
468
|
contextContainerEndAtlasNodeUseCase(node);
|
|
381
469
|
}
|
|
382
470
|
containerDrawCachedFilter(blend_mode, matrix, color_transform, filter_bounds, unique_key, filter_key) {
|
|
471
|
+
if ($attachmentDeferred) {
|
|
472
|
+
contextSyncAttachmentUseCase(this);
|
|
473
|
+
}
|
|
383
474
|
contextContainerDrawCachedFilterUseCase(blend_mode, matrix, color_transform, filter_bounds, unique_key, filter_key);
|
|
384
475
|
}
|
|
385
476
|
async createImageBitmap(width, height) {
|
|
477
|
+
if ($attachmentDeferred) {
|
|
478
|
+
contextSyncAttachmentUseCase(this);
|
|
479
|
+
}
|
|
386
480
|
flushTextUploads();
|
|
387
481
|
return await contextCreateImageBitmapService(width, height);
|
|
388
482
|
}
|
|
389
483
|
getRenderCompletion() {
|
|
484
|
+
if ($attachmentDeferred) {
|
|
485
|
+
contextSyncAttachmentUseCase(this);
|
|
486
|
+
}
|
|
390
487
|
flushTextUploads();
|
|
391
488
|
return contextGetRenderCompletionService();
|
|
392
489
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $gl } from "../../WebGLUtil";
|
|
2
2
|
import { execute as textureManagerBind0UseCase } from "../../TextureManager/usecase/TextureManagerBind0UseCase";
|
|
3
3
|
import { execute as textureManagerBindService } from "../../TextureManager/service/TextureManagerBindService";
|
|
4
|
-
import { $setFramebufferBound, $setCurrentAttachment, $readFrameBuffer, $isFramebufferBound, $attachedColor, $setAttachedColor, $attachedStencil, $setAttachedStencil } from "../../FrameBufferManager";
|
|
4
|
+
import { $setFramebufferBound, $setCurrentAttachment, $setPhysicalAttachment, $setAttachmentDeferred, $readFrameBuffer, $isFramebufferBound, $attachedColor, $setAttachedColor, $attachedStencil, $setAttachedStencil } from "../../FrameBufferManager";
|
|
5
5
|
/**
|
|
6
6
|
* @description フレームバッファにアタッチメントオブジェクトをバインドする
|
|
7
7
|
* Bind the attachment object to the frame buffer
|
|
@@ -13,6 +13,8 @@ import { $setFramebufferBound, $setCurrentAttachment, $readFrameBuffer, $isFrame
|
|
|
13
13
|
*/
|
|
14
14
|
export const execute = (attachment_object) => {
|
|
15
15
|
$setCurrentAttachment(attachment_object);
|
|
16
|
+
$setPhysicalAttachment(attachment_object);
|
|
17
|
+
$setAttachmentDeferred(false);
|
|
16
18
|
if (!$isFramebufferBound) {
|
|
17
19
|
$setFramebufferBound(true);
|
|
18
20
|
$gl.bindFramebuffer($gl.FRAMEBUFFER, $readFrameBuffer);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $gl } from "../../WebGLUtil";
|
|
2
|
-
import { $setCurrentAttachment, $isFramebufferBound, $setFramebufferBound } from "../../FrameBufferManager";
|
|
2
|
+
import { $setCurrentAttachment, $setPhysicalAttachment, $setAttachmentDeferred, $isFramebufferBound, $setFramebufferBound } from "../../FrameBufferManager";
|
|
3
3
|
/**
|
|
4
4
|
* @description 現在アタッチされているFramebufferのバインド解除
|
|
5
5
|
* Unbind the currently attached Framebuffer
|
|
@@ -10,6 +10,8 @@ import { $setCurrentAttachment, $isFramebufferBound, $setFramebufferBound } from
|
|
|
10
10
|
*/
|
|
11
11
|
export const execute = () => {
|
|
12
12
|
$setCurrentAttachment(null);
|
|
13
|
+
$setPhysicalAttachment(null);
|
|
14
|
+
$setAttachmentDeferred(false);
|
|
13
15
|
if ($isFramebufferBound) {
|
|
14
16
|
$setFramebufferBound(false);
|
|
15
17
|
$gl.bindFramebuffer($gl.FRAMEBUFFER, null);
|
|
@@ -48,6 +48,43 @@ export declare let $atlasFrameBuffer: WebGLFramebuffer | null;
|
|
|
48
48
|
export declare const $setAtlasFrameBuffer: (gl: WebGL2RenderingContext) => void;
|
|
49
49
|
export declare let $currentAttachment: IAttachmentObject | null;
|
|
50
50
|
export declare const $setCurrentAttachment: (attachment_object: IAttachmentObject | null) => void;
|
|
51
|
+
/**
|
|
52
|
+
* @description GL のフレームバッファに実際に付いているアタッチメントオブジェクト。
|
|
53
|
+
* 通常は $currentAttachment と同じ。$attachmentDeferred が true の間だけ違う。
|
|
54
|
+
* The attachment object actually attached to the GL framebuffer. Normally the same as
|
|
55
|
+
* $currentAttachment; they differ only while $attachmentDeferred is true.
|
|
56
|
+
*
|
|
57
|
+
* @type {IAttachmentObject | null}
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare let $physicalAttachment: IAttachmentObject | null;
|
|
61
|
+
/**
|
|
62
|
+
* @param {IAttachmentObject | null} attachment_object
|
|
63
|
+
* @return {void}
|
|
64
|
+
* @method
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export declare const $setPhysicalAttachment: (attachment_object: IAttachmentObject | null) => void;
|
|
68
|
+
/**
|
|
69
|
+
* @description 描画先の切り替えを保留しているかどうか。true の間、$currentAttachment (とビューポートの
|
|
70
|
+
* 大きさ) は切り替え後の値だが、GL のフレームバッファは $physicalAttachment のまま。
|
|
71
|
+
* GL で描く前に ContextSyncAttachmentUseCase で実際に切り替える。
|
|
72
|
+
* Whether a render target switch is pending. While true, $currentAttachment (and the
|
|
73
|
+
* viewport size) already hold the new target but the GL framebuffer still has
|
|
74
|
+
* $physicalAttachment. ContextSyncAttachmentUseCase performs the switch before
|
|
75
|
+
* anything is drawn with GL.
|
|
76
|
+
*
|
|
77
|
+
* @type {boolean}
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare let $attachmentDeferred: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* @param {boolean} state
|
|
83
|
+
* @return {void}
|
|
84
|
+
* @method
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export declare const $setAttachmentDeferred: (state: boolean) => void;
|
|
51
88
|
export declare let $isFramebufferBound: boolean;
|
|
52
89
|
export declare const $setFramebufferBound: (state: boolean) => void;
|
|
53
90
|
export declare let $readBitmapFramebuffer: WebGLFramebuffer | null;
|
|
@@ -64,6 +64,47 @@ export let $currentAttachment = null;
|
|
|
64
64
|
export const $setCurrentAttachment = (attachment_object) => {
|
|
65
65
|
$currentAttachment = attachment_object;
|
|
66
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* @description GL のフレームバッファに実際に付いているアタッチメントオブジェクト。
|
|
69
|
+
* 通常は $currentAttachment と同じ。$attachmentDeferred が true の間だけ違う。
|
|
70
|
+
* The attachment object actually attached to the GL framebuffer. Normally the same as
|
|
71
|
+
* $currentAttachment; they differ only while $attachmentDeferred is true.
|
|
72
|
+
*
|
|
73
|
+
* @type {IAttachmentObject | null}
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export let $physicalAttachment = null;
|
|
77
|
+
/**
|
|
78
|
+
* @param {IAttachmentObject | null} attachment_object
|
|
79
|
+
* @return {void}
|
|
80
|
+
* @method
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
export const $setPhysicalAttachment = (attachment_object) => {
|
|
84
|
+
$physicalAttachment = attachment_object;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* @description 描画先の切り替えを保留しているかどうか。true の間、$currentAttachment (とビューポートの
|
|
88
|
+
* 大きさ) は切り替え後の値だが、GL のフレームバッファは $physicalAttachment のまま。
|
|
89
|
+
* GL で描く前に ContextSyncAttachmentUseCase で実際に切り替える。
|
|
90
|
+
* Whether a render target switch is pending. While true, $currentAttachment (and the
|
|
91
|
+
* viewport size) already hold the new target but the GL framebuffer still has
|
|
92
|
+
* $physicalAttachment. ContextSyncAttachmentUseCase performs the switch before
|
|
93
|
+
* anything is drawn with GL.
|
|
94
|
+
*
|
|
95
|
+
* @type {boolean}
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export let $attachmentDeferred = false;
|
|
99
|
+
/**
|
|
100
|
+
* @param {boolean} state
|
|
101
|
+
* @return {void}
|
|
102
|
+
* @method
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export const $setAttachmentDeferred = (state) => {
|
|
106
|
+
$attachmentDeferred = state;
|
|
107
|
+
};
|
|
67
108
|
export let $isFramebufferBound = false;
|
|
68
109
|
export const $setFramebufferBound = (state) => {
|
|
69
110
|
$isFramebufferBound = state;
|