@next2d/webgl 3.1.0 → 3.2.1
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/AtlasManager.js +11 -7
- package/src/Context/usecase/ContextContainerEndLayerUseCase.d.ts +1 -1
- package/src/Context/usecase/ContextContainerEndLayerUseCase.js +9 -1
- package/src/Context.d.ts +1 -1
- package/src/Context.js +2 -2
- package/src/Mesh.js +3 -1
- package/src/TextureManager/service/TextureManagerBindService.js +12 -7
- package/src/TextureManager/usecase/TextureManagerReleaseTextureObjectUseCase.js +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/webgl",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
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.1
|
|
28
|
-
"@next2d/render-queue": "3.1
|
|
27
|
+
"@next2d/texture-packer": "3.2.1",
|
|
28
|
+
"@next2d/render-queue": "3.2.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/AtlasManager.js
CHANGED
|
@@ -15,13 +15,15 @@ export const $setAtlasAttachmentObject = (attachment_object) => {
|
|
|
15
15
|
$atlasAttachmentObjects[$activeAtlasIndex] = attachment_object;
|
|
16
16
|
};
|
|
17
17
|
export const $getAtlasAttachmentObject = () => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
let attachmentObject = $atlasAttachmentObjects[$activeAtlasIndex];
|
|
19
|
+
if (!attachmentObject) {
|
|
20
|
+
attachmentObject = frameBufferManagerGetAttachmentObjectUseCase($RENDER_MAX_SIZE, $RENDER_MAX_SIZE, true);
|
|
21
|
+
$atlasAttachmentObjects[$activeAtlasIndex] = attachmentObject;
|
|
20
22
|
}
|
|
21
|
-
return
|
|
23
|
+
return attachmentObject;
|
|
22
24
|
};
|
|
23
25
|
export const $hasAtlasAttachmentObject = () => {
|
|
24
|
-
return $activeAtlasIndex
|
|
26
|
+
return !!$atlasAttachmentObjects[$activeAtlasIndex];
|
|
25
27
|
};
|
|
26
28
|
export const $rootNodes = [];
|
|
27
29
|
export let $atlasTexture = null;
|
|
@@ -33,15 +35,17 @@ export const $getAtlasTextureObject = () => {
|
|
|
33
35
|
};
|
|
34
36
|
const $transferBounds = [];
|
|
35
37
|
export const $getActiveTransferBounds = (index) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
let bounds = $transferBounds[index];
|
|
39
|
+
if (!bounds) {
|
|
40
|
+
bounds = new Float32Array([
|
|
38
41
|
$MAX_VALUE,
|
|
39
42
|
$MAX_VALUE,
|
|
40
43
|
$MIN_VALUE,
|
|
41
44
|
$MIN_VALUE
|
|
42
45
|
]);
|
|
46
|
+
$transferBounds[index] = bounds;
|
|
43
47
|
}
|
|
44
|
-
return
|
|
48
|
+
return bounds;
|
|
45
49
|
};
|
|
46
50
|
export const $clearTransferBounds = () => {
|
|
47
51
|
for (let idx = 0; idx < $transferBounds.length; ++idx) {
|
|
@@ -15,4 +15,4 @@ import type { IBlendMode } from "../../interface/IBlendMode";
|
|
|
15
15
|
* @method
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
|
-
export declare const execute: (blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array | null, use_filter: boolean, filter_bounds: Float32Array | null, filter_params: Float32Array | null, unique_key: string, filter_key: string) => void;
|
|
18
|
+
export declare const execute: (blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array | null, use_filter: boolean, filter_bounds: Float32Array | null, filter_params: Float32Array | null, unique_key: string, filter_key: string, _layer_scale_x?: number, _layer_scale_y?: number) => void;
|
|
@@ -39,7 +39,10 @@ const $colorMatrixBuffer = new Float32Array(20);
|
|
|
39
39
|
* @method
|
|
40
40
|
* @public
|
|
41
41
|
*/
|
|
42
|
-
export const execute = (blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key
|
|
42
|
+
export const execute = (blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key,
|
|
43
|
+
// layer_scale は display 側で layer サイズに反映済み。
|
|
44
|
+
// compose時は layer 全体を等倍でmainに貼るので直接は参照しない。
|
|
45
|
+
_layer_scale_x = 1, _layer_scale_y = 1) => {
|
|
43
46
|
// 一時アタッチメントへの描画をフラッシュ
|
|
44
47
|
$context.drawArraysInstanced();
|
|
45
48
|
const layerAttachment = $context.$mainAttachmentObject;
|
|
@@ -133,6 +136,10 @@ export const execute = (blend_mode, matrix, color_transform, use_filter, filter_
|
|
|
133
136
|
break;
|
|
134
137
|
}
|
|
135
138
|
}
|
|
139
|
+
// issue #274: layer は layerScale 倍解像度で確保されており、
|
|
140
|
+
// 子孫のcacheAsBitmap子は既にその倍解像度でlayer内に収まっている。
|
|
141
|
+
// cacheAsBitmap の仕様としてスクリーン上も cacheScale 倍のサイズで
|
|
142
|
+
// 表示されるため、ここでの縮小は行わずそのまま main に合成する。
|
|
136
143
|
// キャッシュに保存
|
|
137
144
|
if (unique_key) {
|
|
138
145
|
$cacheStore.set(unique_key, "fKey", filter_key);
|
|
@@ -160,6 +167,7 @@ export const execute = (blend_mode, matrix, color_transform, use_filter, filter_
|
|
|
160
167
|
// メインのアタッチメントをバインド(currentAttachmentObjectを更新)
|
|
161
168
|
$context.bind($context.$mainAttachmentObject);
|
|
162
169
|
if (textureObject) {
|
|
170
|
+
// cacheAsBitmap と同様、layer は layerScale 倍解像度のままmainに合成する
|
|
163
171
|
$context.reset();
|
|
164
172
|
$context.globalCompositeOperation = blend_mode;
|
|
165
173
|
blendDrawFilterToMainUseCase(textureObject, color_transform, matrix[4], matrix[5]);
|
package/src/Context.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export declare class Context {
|
|
|
71
71
|
useGrid(grid_data: Float32Array | null): void;
|
|
72
72
|
applyFilter(node: Node, unique_key: string, updated: boolean, width: number, height: number, is_bitmap: boolean, matrix: Float32Array, color_transform: Float32Array, blend_mode: IBlendMode, bounds: Float32Array, params: Float32Array): void;
|
|
73
73
|
containerBeginLayer(width: number, height: number): void;
|
|
74
|
-
containerEndLayer(blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array | null, use_filter: boolean, filter_bounds: Float32Array | null, filter_params: Float32Array | null, unique_key: string, filter_key: string): void;
|
|
74
|
+
containerEndLayer(blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array | null, use_filter: boolean, filter_bounds: Float32Array | null, filter_params: Float32Array | null, unique_key: string, filter_key: string, layer_scale_x?: number, layer_scale_y?: number): void;
|
|
75
75
|
containerBeginAtlasNode(width: number, height: number): Node;
|
|
76
76
|
containerEndAtlasNode(): void;
|
|
77
77
|
containerDrawCachedFilter(blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array, filter_bounds: Float32Array, unique_key: string, filter_key: string): void;
|
package/src/Context.js
CHANGED
|
@@ -383,8 +383,8 @@ export class Context {
|
|
|
383
383
|
this.drawArraysInstanced();
|
|
384
384
|
contextContainerBeginLayerUseCase(width, height);
|
|
385
385
|
}
|
|
386
|
-
containerEndLayer(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key) {
|
|
387
|
-
contextContainerEndLayerUseCase(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key);
|
|
386
|
+
containerEndLayer(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, layer_scale_x = 1, layer_scale_y = 1) {
|
|
387
|
+
contextContainerEndLayerUseCase(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, layer_scale_x, layer_scale_y);
|
|
388
388
|
}
|
|
389
389
|
containerBeginAtlasNode(width, height) {
|
|
390
390
|
this.drawArraysInstanced();
|
package/src/Mesh.js
CHANGED
|
@@ -62,7 +62,9 @@ export const $addFillBuffer = (buffer) => {
|
|
|
62
62
|
const length = buffer.length + $fillBufferOffset;
|
|
63
63
|
if (length > $fillBuffer.length) {
|
|
64
64
|
const newBuffer = new Float32Array($upperPowerOfTwo(length));
|
|
65
|
-
|
|
65
|
+
if ($fillBufferOffset > 0) {
|
|
66
|
+
newBuffer.set($fillBuffer.subarray(0, $fillBufferOffset));
|
|
67
|
+
}
|
|
66
68
|
newBuffer.set(buffer, $fillBufferOffset);
|
|
67
69
|
$fillBuffer = newBuffer;
|
|
68
70
|
}
|
|
@@ -13,21 +13,26 @@ import { $activeTextureUnit, $boundTextures, $setActiveTextureUnit } from "../..
|
|
|
13
13
|
* @protected
|
|
14
14
|
*/
|
|
15
15
|
export const execute = (index, unit, texture_object = null, smooth = false) => {
|
|
16
|
-
if ($activeTextureUnit
|
|
16
|
+
if ($activeTextureUnit !== unit) {
|
|
17
17
|
$setActiveTextureUnit(unit);
|
|
18
18
|
$gl.activeTexture(unit);
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const boundTexture = $boundTextures[index];
|
|
21
|
+
if (boundTexture === texture_object) {
|
|
22
|
+
// Same reference, already bound to this unit.
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (boundTexture !== null
|
|
26
|
+
&& texture_object !== null
|
|
27
|
+
&& boundTexture.id === texture_object.id) {
|
|
24
28
|
return;
|
|
25
29
|
}
|
|
26
30
|
$boundTextures[index] = texture_object;
|
|
27
31
|
$gl.bindTexture($gl.TEXTURE_2D, texture_object ? texture_object.resource : null);
|
|
28
32
|
if (texture_object && texture_object.smooth !== smooth) {
|
|
29
33
|
texture_object.smooth = smooth;
|
|
30
|
-
|
|
31
|
-
$gl.texParameteri($gl.TEXTURE_2D, $gl.
|
|
34
|
+
const filter = smooth ? $gl.LINEAR : $gl.NEAREST;
|
|
35
|
+
$gl.texParameteri($gl.TEXTURE_2D, $gl.TEXTURE_MIN_FILTER, filter);
|
|
36
|
+
$gl.texParameteri($gl.TEXTURE_2D, $gl.TEXTURE_MAG_FILTER, filter);
|
|
32
37
|
}
|
|
33
38
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $gl } from "../../WebGLUtil";
|
|
2
|
+
import { $boundTextures } from "../../TextureManager";
|
|
2
3
|
/**
|
|
3
4
|
* @description TextureObjectをオブジェクトプールに保管、サイズオーバー時は削除します。
|
|
4
5
|
* Stores the TextureObject in the object pool and deletes it if it exceeds the size.
|
|
@@ -9,5 +10,10 @@ import { $gl } from "../../WebGLUtil";
|
|
|
9
10
|
* @protected
|
|
10
11
|
*/
|
|
11
12
|
export const execute = (texture_object) => {
|
|
13
|
+
for (let idx = 0; idx < $boundTextures.length; ++idx) {
|
|
14
|
+
if ($boundTextures[idx] === texture_object) {
|
|
15
|
+
$boundTextures[idx] = null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
12
18
|
$gl.deleteTexture(texture_object.resource);
|
|
13
19
|
};
|