@next2d/display 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 +10 -9
- package/src/DisplayObject.d.ts +11 -0
- package/src/DisplayObject.js +17 -0
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateClipQueueUseCase.js +1 -1
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateRenderQueueUseCase.js +68 -60
- package/src/DisplayObjectContainer.d.ts +20 -0
- package/src/DisplayObjectContainer.js +32 -0
- package/src/DisplayObjectUtil.d.ts +33 -0
- package/src/DisplayObjectUtil.js +70 -0
- package/src/Shape/usecase/ShapeGenerateClipQueueUseCase.js +1 -1
- package/src/Shape/usecase/ShapeGenerateRenderQueueUseCase.js +28 -39
- package/src/Shape/usecase/ShapeHitTestUseCase.js +23 -0
- package/src/Stage/usecase/StageGenerateRenderQueueUseCase.js +1 -1
- package/src/TextField/usecase/TextFieldGenerateRenderQueueUseCase.js +22 -39
- package/src/Video/usecase/VideoGenerateRenderQueueUseCase.js +14 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/display",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "Next2D Display Package",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,14 +23,15 @@
|
|
|
23
23
|
"type": "git",
|
|
24
24
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
25
25
|
},
|
|
26
|
+
"sideEffects": false,
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@next2d/ui": "3.
|
|
28
|
-
"@next2d/text": "3.
|
|
29
|
-
"@next2d/geom": "3.
|
|
30
|
-
"@next2d/media": "3.
|
|
31
|
-
"@next2d/net": "3.
|
|
32
|
-
"@next2d/events": "3.
|
|
33
|
-
"@next2d/filters": "3.
|
|
34
|
-
"@next2d/render-queue": "3.
|
|
28
|
+
"@next2d/ui": "3.9.0",
|
|
29
|
+
"@next2d/text": "3.9.0",
|
|
30
|
+
"@next2d/geom": "3.9.0",
|
|
31
|
+
"@next2d/media": "3.9.0",
|
|
32
|
+
"@next2d/net": "3.9.0",
|
|
33
|
+
"@next2d/events": "3.9.0",
|
|
34
|
+
"@next2d/filters": "3.9.0",
|
|
35
|
+
"@next2d/render-queue": "3.9.0"
|
|
35
36
|
}
|
|
36
37
|
}
|
package/src/DisplayObject.d.ts
CHANGED
|
@@ -34,6 +34,17 @@ export declare class DisplayObject extends EventDispatcher {
|
|
|
34
34
|
* @public
|
|
35
35
|
*/
|
|
36
36
|
readonly instanceId: number;
|
|
37
|
+
/**
|
|
38
|
+
* @description instanceId の文字列キャッシュ(cacheStoreキー用、遅延生成)。
|
|
39
|
+
* uniqueKey とは別物(uniqueKey はフィルターキャッシュ判定に使われるため流用不可)。
|
|
40
|
+
* Lazily built string cache of instanceId for cacheStore keys.
|
|
41
|
+
* Distinct from uniqueKey (which drives filter-cache decisions).
|
|
42
|
+
*
|
|
43
|
+
* @type {string}
|
|
44
|
+
* @default ""
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
$instanceIdString: string;
|
|
37
48
|
/**
|
|
38
49
|
* @description DisplayObject の生成元ID
|
|
39
50
|
* Source ID of DisplayObject
|
package/src/DisplayObject.js
CHANGED
|
@@ -67,6 +67,22 @@ export class DisplayObject extends EventDispatcher {
|
|
|
67
67
|
writable: true,
|
|
68
68
|
value: void 0
|
|
69
69
|
});
|
|
70
|
+
/**
|
|
71
|
+
* @description instanceId の文字列キャッシュ(cacheStoreキー用、遅延生成)。
|
|
72
|
+
* uniqueKey とは別物(uniqueKey はフィルターキャッシュ判定に使われるため流用不可)。
|
|
73
|
+
* Lazily built string cache of instanceId for cacheStore keys.
|
|
74
|
+
* Distinct from uniqueKey (which drives filter-cache decisions).
|
|
75
|
+
*
|
|
76
|
+
* @type {string}
|
|
77
|
+
* @default ""
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
Object.defineProperty(this, "$instanceIdString", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: void 0
|
|
85
|
+
});
|
|
70
86
|
/**
|
|
71
87
|
* @description DisplayObject の生成元ID
|
|
72
88
|
* Source ID of DisplayObject
|
|
@@ -592,6 +608,7 @@ export class DisplayObject extends EventDispatcher {
|
|
|
592
608
|
this.instanceId = $getInstanceId();
|
|
593
609
|
this.dictionaryId = -1;
|
|
594
610
|
this.uniqueKey = "";
|
|
611
|
+
this.$instanceIdString = "";
|
|
595
612
|
// 各小クラスの機能を所持しているか
|
|
596
613
|
this.isSprite = false;
|
|
597
614
|
this.isContainerEnabled = false;
|
package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateClipQueueUseCase.js
CHANGED
|
@@ -20,7 +20,7 @@ export const execute = (display_object_container, matrix) => {
|
|
|
20
20
|
? Matrix.multiply(matrix, rawMatrix)
|
|
21
21
|
: matrix;
|
|
22
22
|
const children = display_object_container.children;
|
|
23
|
-
renderQueue.
|
|
23
|
+
renderQueue.push2($RENDERER_CONTAINER_TYPE, children.length);
|
|
24
24
|
for (let idx = 0; idx < children.length; idx++) {
|
|
25
25
|
const child = children[idx];
|
|
26
26
|
if (!child) {
|
package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateRenderQueueUseCase.js
CHANGED
|
@@ -13,8 +13,16 @@ import { execute as displayObjectContainerCalcBoundsMatrixUseCase } from "../../
|
|
|
13
13
|
import { stage } from "../../Stage";
|
|
14
14
|
import { renderQueue } from "@next2d/render-queue";
|
|
15
15
|
import { $cacheStore } from "@next2d/cache";
|
|
16
|
-
import { $clamp, $getBoundsArray, $poolBoundsArray, $RENDERER_CONTAINER_TYPE, $getFloat32Array8, $getFloat32Array6, $poolFloat32Array6 } from "../../DisplayObjectUtil";
|
|
16
|
+
import { $clamp, $getBoundsArray, $poolBoundsArray, $RENDERER_CONTAINER_TYPE, $getFloat32Array8, $getFloat32Array6, $poolFloat32Array6, $prepareFilterBuffers, $pushFilterBuffers, $getFilterUpdated } from "../../DisplayObjectUtil";
|
|
17
17
|
import { ColorTransform, Matrix } from "@next2d/geom";
|
|
18
|
+
/**
|
|
19
|
+
* @description filterレイヤーのスケール取得用の再利用バッファ
|
|
20
|
+
* Reusable buffer for filter layer scale retrieval
|
|
21
|
+
*
|
|
22
|
+
* @type {Float32Array}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
const $layerScale = new Float32Array(2);
|
|
18
26
|
/**
|
|
19
27
|
* @description renderer workerに渡すコンテナの描画データを生成
|
|
20
28
|
* Generate rendering data of the container to be passed to the renderer worker
|
|
@@ -31,7 +39,7 @@ import { ColorTransform, Matrix } from "@next2d/geom";
|
|
|
31
39
|
*/
|
|
32
40
|
export const execute = (display_object_container, image_bitmaps, matrix, color_transform, renderer_width, renderer_height, in_filter_layer = false) => {
|
|
33
41
|
if (!display_object_container.visible) {
|
|
34
|
-
renderQueue.
|
|
42
|
+
renderQueue.push1(0);
|
|
35
43
|
return;
|
|
36
44
|
}
|
|
37
45
|
// transformed ColorTransform(tColorTransform)
|
|
@@ -48,7 +56,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
48
56
|
if (tColorTransform !== color_transform) {
|
|
49
57
|
ColorTransform.release(tColorTransform);
|
|
50
58
|
}
|
|
51
|
-
renderQueue.
|
|
59
|
+
renderQueue.push1(0);
|
|
52
60
|
return;
|
|
53
61
|
}
|
|
54
62
|
const children = display_object_container.children;
|
|
@@ -56,7 +64,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
56
64
|
if (tColorTransform !== color_transform) {
|
|
57
65
|
ColorTransform.release(tColorTransform);
|
|
58
66
|
}
|
|
59
|
-
renderQueue.
|
|
67
|
+
renderQueue.push1(0);
|
|
60
68
|
return;
|
|
61
69
|
}
|
|
62
70
|
// transformed matrix(tMatrix)
|
|
@@ -76,13 +84,13 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
76
84
|
if (tMatrix !== matrix) {
|
|
77
85
|
Matrix.release(tMatrix);
|
|
78
86
|
}
|
|
79
|
-
renderQueue.
|
|
87
|
+
renderQueue.push1(0);
|
|
80
88
|
return;
|
|
81
89
|
}
|
|
82
|
-
renderQueue.
|
|
90
|
+
renderQueue.push2(1, $RENDERER_CONTAINER_TYPE);
|
|
83
91
|
// blendMode
|
|
84
92
|
const blendMode = display_object_container.blendMode;
|
|
85
|
-
renderQueue.
|
|
93
|
+
renderQueue.push1(displayObjectBlendToNumberService(blendMode));
|
|
86
94
|
// cacheAsBitmap: フィルターキャッシュ形式でコンテナ全体をビットマップキャッシュ
|
|
87
95
|
// キャッシュテクスチャは親のスケールを含むサイズで描画し、
|
|
88
96
|
// コンポジットは setTransform(1,0,0,1,x,y) で1:1描画されるため正しい画面サイズになる
|
|
@@ -92,6 +100,9 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
92
100
|
// cacheAsBitmap子のテクスチャが親layerに収まる (issue #274 根本対応)。
|
|
93
101
|
const cacheMatrix = display_object_container.cacheAsBitmap;
|
|
94
102
|
if (cacheMatrix) {
|
|
103
|
+
// cacheStoreキー用のinstanceId文字列(遅延メモ化)。uniqueKeyは流用不可
|
|
104
|
+
const idString = display_object_container.$instanceIdString
|
|
105
|
+
|| (display_object_container.$instanceIdString = `${display_object_container.instanceId}`);
|
|
95
106
|
const m = cacheMatrix.rawData;
|
|
96
107
|
const cacheScaleX = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
|
|
97
108
|
const cacheScaleY = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
|
|
@@ -113,7 +124,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
113
124
|
const bitmapCacheKey = $cacheStore.generateKeys(xRounded, yRounded, tColorTransform[7]);
|
|
114
125
|
// 固定プロパティ名で最新のキーのみ保存(古いキーが蓄積されないようにする)
|
|
115
126
|
// レンダラーも最新のfKeyのみ保持するため、キーの一致を保証
|
|
116
|
-
const bitmapCache = $cacheStore.get(
|
|
127
|
+
const bitmapCache = $cacheStore.get(idString, "bitmapKey") === bitmapCacheKey;
|
|
117
128
|
// コンテナ自身のフィルター境界を収集
|
|
118
129
|
const cacheFilters = display_object_container.filters;
|
|
119
130
|
const cacheFilterBounds = $getBoundsArray(0, 0, 0, 0);
|
|
@@ -129,7 +140,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
129
140
|
if (bitmapCache) {
|
|
130
141
|
// cacheAsBitmap cache hit: 子要素走査をスキップして高速パス
|
|
131
142
|
// Shapeと同様に親matrixをレンダラーに渡し、描画時にcacheScaleで補正
|
|
132
|
-
const cachedLocalBounds = $cacheStore.get(
|
|
143
|
+
const cachedLocalBounds = $cacheStore.get(idString, "bLocalBounds");
|
|
133
144
|
if (cachedLocalBounds) {
|
|
134
145
|
// ローカルバウンズ原点のスクリーン座標を計算(Shapeと同じ方式)
|
|
135
146
|
const localOriginX = cachedLocalBounds[0] / (cacheScaleX * rendererScale);
|
|
@@ -142,7 +153,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
142
153
|
// 合成 scale=1 で layer にちょうど収まるようにする。
|
|
143
154
|
const hitMatrixScaleX = in_filter_layer ? 1 : cacheScaleX;
|
|
144
155
|
const hitMatrixScaleY = in_filter_layer ? 1 : cacheScaleY;
|
|
145
|
-
renderQueue.
|
|
156
|
+
renderQueue.push27(1, 0, 0, // layerWidth/Height: HIT時は未使用
|
|
146
157
|
2, 1, display_object_container.instanceId, bitmapCacheKey, cacheFilterBounds[0], cacheFilterBounds[1], cacheFilterBounds[2], cacheFilterBounds[3], renderScaleX, renderScaleY, matrix[0] * hitMatrixScaleX, matrix[1] * hitMatrixScaleX, matrix[2] * hitMatrixScaleY, matrix[3] * hitMatrixScaleY, screenX, screenY, tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7]);
|
|
147
158
|
$poolBoundsArray(cacheFilterBounds);
|
|
148
159
|
if (tColorTransform !== color_transform) {
|
|
@@ -159,17 +170,18 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
159
170
|
// 親matrixのスケール成分のみを含むローカル空間でキャッシュを生成する
|
|
160
171
|
// (親の位置・回転は含まず、スケールのみ反映してテクスチャサイズを画面と一致させる)
|
|
161
172
|
// フィルターパラメータを収集
|
|
162
|
-
|
|
173
|
+
// このパスは $updated を消費しないため、フラグは維持したまま $buffer のみ最新化する
|
|
174
|
+
let cacheFilterParamsLength = 0;
|
|
163
175
|
if (cacheFilters) {
|
|
164
176
|
for (let idx = 0; idx < cacheFilters.length; idx++) {
|
|
165
177
|
const filter = cacheFilters[idx];
|
|
166
178
|
if (!filter || !filter.canApplyFilter()) {
|
|
167
179
|
continue;
|
|
168
180
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
cacheFilterParams.push(...buffer.subarray(idx, idx + 4096));
|
|
181
|
+
if (filter.$updated || !filter.$buffer) {
|
|
182
|
+
filter.$buffer = filter.toNumberArray();
|
|
172
183
|
}
|
|
184
|
+
cacheFilterParamsLength += filter.$buffer.length;
|
|
173
185
|
}
|
|
174
186
|
}
|
|
175
187
|
// キャッシュ描画用の親matrix: cacheScale × rendererScale(対角行列)
|
|
@@ -185,9 +197,9 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
185
197
|
// HITパスと同じ規則: filter layer 内では cacheScale 乗算を省略
|
|
186
198
|
const missMatrixScaleX = in_filter_layer ? 1 : cacheScaleX;
|
|
187
199
|
const missMatrixScaleY = in_filter_layer ? 1 : cacheScaleY;
|
|
188
|
-
renderQueue.
|
|
189
|
-
if (
|
|
190
|
-
|
|
200
|
+
renderQueue.push28(1, localLayerWidth, localLayerHeight, 2, 0, display_object_container.instanceId, bitmapCacheKey, cacheFilterBounds[0], cacheFilterBounds[1], cacheFilterBounds[2], cacheFilterBounds[3], renderScaleX, renderScaleY, matrix[0] * missMatrixScaleX, matrix[1] * missMatrixScaleX, matrix[2] * missMatrixScaleY, matrix[3] * missMatrixScaleY, missScreenX, missScreenY, tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7], cacheFilterParamsLength);
|
|
201
|
+
if (cacheFilterParamsLength > 0 && cacheFilters) {
|
|
202
|
+
$pushFilterBuffers(cacheFilters);
|
|
191
203
|
}
|
|
192
204
|
// 子要素の描画マトリクスをローカル空間に切り替え(親matrixの位置・回転を除外)
|
|
193
205
|
// cacheParentMatrixにrawMatrixを乗算し、layerBoundsオフセットで原点を調整
|
|
@@ -216,38 +228,25 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
216
228
|
}
|
|
217
229
|
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
218
230
|
// HIT時の高速パス用にローカルバウンズをキャッシュ(poolする前に保存)
|
|
219
|
-
$cacheStore.set(
|
|
231
|
+
$cacheStore.set(idString, "bLocalBounds", new Float32Array([localLayerBounds[0], localLayerBounds[1], localLayerBounds[2], localLayerBounds[3]]));
|
|
220
232
|
$poolBoundsArray(localLayerBounds);
|
|
221
233
|
$poolBoundsArray(cacheFilterBounds);
|
|
222
|
-
$cacheStore.set(
|
|
234
|
+
$cacheStore.set(idString, "bitmapKey", bitmapCacheKey);
|
|
223
235
|
}
|
|
224
236
|
else {
|
|
225
237
|
// filters
|
|
226
238
|
const filters = display_object_container.filters;
|
|
227
239
|
if (filters) {
|
|
240
|
+
// cacheStoreキー用のinstanceId文字列(遅延メモ化)。uniqueKeyは流用不可
|
|
241
|
+
const idString = display_object_container.$instanceIdString
|
|
242
|
+
|| (display_object_container.$instanceIdString = `${display_object_container.instanceId}`);
|
|
228
243
|
const filterKey = $cacheStore.generateFilterKeys(tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3]);
|
|
229
|
-
const cachedFilterKey = $cacheStore.get(
|
|
244
|
+
const cachedFilterKey = $cacheStore.get(idString, "filterKey");
|
|
230
245
|
const filterCache = cachedFilterKey === filterKey;
|
|
231
|
-
let updated = false;
|
|
232
|
-
const params = [];
|
|
233
246
|
const bounds = $getBoundsArray(0, 0, 0, 0);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
// フィルターが更新されたかをチェック
|
|
240
|
-
if (filter.$updated) {
|
|
241
|
-
updated = true;
|
|
242
|
-
}
|
|
243
|
-
filter.$updated = false;
|
|
244
|
-
filter.getBounds(bounds);
|
|
245
|
-
const buffer = filter.toNumberArray();
|
|
246
|
-
for (let idx = 0; idx < buffer.length; idx += 4096) {
|
|
247
|
-
params.push(...buffer.subarray(idx, idx + 4096));
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
const useFilfer = params.length > 0;
|
|
247
|
+
const paramsLength = $prepareFilterBuffers(filters, bounds);
|
|
248
|
+
let updated = $getFilterUpdated();
|
|
249
|
+
const useFilfer = paramsLength > 0;
|
|
251
250
|
if (useFilfer) {
|
|
252
251
|
// 子の変更があった場合は親のフラグが立っているので更新
|
|
253
252
|
if (!updated) {
|
|
@@ -257,15 +256,24 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
257
256
|
// 子孫にcacheAsBitmapを持つ要素があれば、そのスケールに合わせて
|
|
258
257
|
// filterレイヤーの解像度を引き上げる。これにより親レイヤー内で
|
|
259
258
|
// 子のcacheScale倍テクスチャが端まで収まる (issue #274 発展対応)。
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
259
|
+
// サブツリーのscale/構造変化は必ずchangedを立てる(=updatedになる)ため、
|
|
260
|
+
// 未更新時は前フレームのキャッシュ値を使い全サブツリー再帰をスキップする。
|
|
261
|
+
let layerScaleX = display_object_container.$layerScaleX;
|
|
262
|
+
let layerScaleY = display_object_container.$layerScaleY;
|
|
263
|
+
if (updated || layerScaleX === -1) {
|
|
264
|
+
$layerScale[0] = 1;
|
|
265
|
+
$layerScale[1] = 1;
|
|
266
|
+
displayObjectContainerGetLayerScaleUseCase(display_object_container, $layerScale);
|
|
267
|
+
layerScaleX = $layerScale[0];
|
|
268
|
+
layerScaleY = $layerScale[1];
|
|
269
|
+
display_object_container.$layerScaleX = layerScaleX;
|
|
270
|
+
display_object_container.$layerScaleY = layerScaleY;
|
|
271
|
+
}
|
|
264
272
|
const layerWidth = Math.ceil(Math.abs(layerBounds[2] - layerBounds[0]) * layerScaleX);
|
|
265
273
|
const layerHeight = Math.ceil(Math.abs(layerBounds[3] - layerBounds[1]) * layerScaleY);
|
|
266
274
|
if (filterCache && !updated) {
|
|
267
275
|
// キャッシュがあって、変更がなければキャッシュを使用
|
|
268
|
-
renderQueue.
|
|
276
|
+
renderQueue.push27(1, layerWidth, layerHeight, 1, 1, display_object_container.instanceId, filterKey, bounds[0], bounds[1], bounds[2], bounds[3], tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], layerBounds[0], layerBounds[1], layerScaleX, layerScaleY, tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7]);
|
|
269
277
|
$poolBoundsArray(layerBounds);
|
|
270
278
|
$poolBoundsArray(bounds);
|
|
271
279
|
if (tColorTransform !== color_transform) {
|
|
@@ -282,8 +290,8 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
282
290
|
// 新しいテクスチャを保存するため、ここでの removeById/$removeIds.push は
|
|
283
291
|
// 不要。push してしまうと、Worker が同フレームで作成した新キャッシュを
|
|
284
292
|
// 次フレーム冒頭で wipe してしまい、その次の HIT で無描画になる。
|
|
285
|
-
renderQueue.
|
|
286
|
-
|
|
293
|
+
renderQueue.push28(1, layerWidth, layerHeight, 1, 0, display_object_container.instanceId, filterKey, bounds[0], bounds[1], bounds[2], bounds[3], tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], layerBounds[0], layerBounds[1], layerScaleX, layerScaleY, tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7], paramsLength);
|
|
294
|
+
$pushFilterBuffers(filters);
|
|
287
295
|
// 子に渡すtMatrixは layerScale 倍で scale して、layer 内の
|
|
288
296
|
// 拡張座標系で描画させる。layer自体は compose時に 1/layerScaleで
|
|
289
297
|
// 縮小合成され最終的に元サイズで表示される。
|
|
@@ -302,18 +310,18 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
302
310
|
}
|
|
303
311
|
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
304
312
|
$poolBoundsArray(layerBounds);
|
|
305
|
-
$cacheStore.set(
|
|
313
|
+
$cacheStore.set(idString, "filterKey", filterKey);
|
|
306
314
|
}
|
|
307
315
|
else {
|
|
308
316
|
if (blendMode === "normal") {
|
|
309
|
-
renderQueue.
|
|
317
|
+
renderQueue.push1(0);
|
|
310
318
|
}
|
|
311
319
|
else {
|
|
312
320
|
// ブレンドモードのみのLayerモード
|
|
313
321
|
const layerBounds = displayObjectContainerCalcBoundsMatrixUseCase(display_object_container, matrix);
|
|
314
322
|
const layerXMin = layerBounds[0];
|
|
315
323
|
const layerYMin = layerBounds[1];
|
|
316
|
-
renderQueue.
|
|
324
|
+
renderQueue.push18(1, Math.ceil(Math.abs(layerBounds[2] - layerXMin)), Math.ceil(Math.abs(layerBounds[3] - layerYMin)), 0, // not use filter,
|
|
317
325
|
tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], layerXMin, layerYMin, tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7]);
|
|
318
326
|
const a0 = tMatrix[0];
|
|
319
327
|
const a1 = tMatrix[1];
|
|
@@ -336,13 +344,13 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
336
344
|
}
|
|
337
345
|
else {
|
|
338
346
|
if (blendMode === "normal") {
|
|
339
|
-
renderQueue.
|
|
347
|
+
renderQueue.push1(0);
|
|
340
348
|
}
|
|
341
349
|
else {
|
|
342
350
|
const layerBounds = displayObjectContainerCalcBoundsMatrixUseCase(display_object_container, matrix);
|
|
343
351
|
const layerXMin2 = layerBounds[0];
|
|
344
352
|
const layerYMin2 = layerBounds[1];
|
|
345
|
-
renderQueue.
|
|
353
|
+
renderQueue.push18(1, Math.ceil(Math.abs(layerBounds[2] - layerXMin2)), Math.ceil(Math.abs(layerBounds[3] - layerYMin2)), 0, // not use filter,
|
|
346
354
|
tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], layerXMin2, layerYMin2, tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7]);
|
|
347
355
|
const b0 = tMatrix[0];
|
|
348
356
|
const b1 = tMatrix[1];
|
|
@@ -367,11 +375,11 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
367
375
|
if (maskDisplayObject) {
|
|
368
376
|
const bounds = displayObjectIsMaskReflectedInDisplayUseCase(maskDisplayObject, tMatrix, renderer_width, renderer_height);
|
|
369
377
|
if (!bounds) {
|
|
370
|
-
renderQueue.
|
|
378
|
+
renderQueue.push1(0);
|
|
371
379
|
}
|
|
372
380
|
else {
|
|
373
381
|
// マスクの描画範囲
|
|
374
|
-
renderQueue.
|
|
382
|
+
renderQueue.push5(1, bounds[0], bounds[1], bounds[2], bounds[3]);
|
|
375
383
|
switch (true) {
|
|
376
384
|
case maskDisplayObject.isContainerEnabled: // 0x00
|
|
377
385
|
displayObjectContainerGenerateClipQueueUseCase(maskDisplayObject, tMatrix);
|
|
@@ -386,18 +394,18 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
386
394
|
maskDisplayObject.changed = false;
|
|
387
395
|
}
|
|
388
396
|
else {
|
|
389
|
-
renderQueue.
|
|
397
|
+
renderQueue.push1(0);
|
|
390
398
|
}
|
|
391
399
|
// children
|
|
392
|
-
renderQueue.
|
|
400
|
+
renderQueue.push1(children.length);
|
|
393
401
|
let clipDepth = 0;
|
|
394
402
|
let canRenderMask = true;
|
|
395
403
|
for (let idx = 0; idx < children.length; ++idx) {
|
|
396
404
|
const child = children[idx];
|
|
397
|
-
renderQueue.
|
|
405
|
+
renderQueue.push2(child.placeId, child.clipDepth);
|
|
398
406
|
// マスクオブジェクトは描画しない(hidden=0)
|
|
399
407
|
if (child.isMask) {
|
|
400
|
-
renderQueue.
|
|
408
|
+
renderQueue.push1(0);
|
|
401
409
|
child.changed = false;
|
|
402
410
|
continue;
|
|
403
411
|
}
|
|
@@ -406,7 +414,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
406
414
|
canRenderMask = true;
|
|
407
415
|
}
|
|
408
416
|
if (!canRenderMask) {
|
|
409
|
-
renderQueue.
|
|
417
|
+
renderQueue.push1(0);
|
|
410
418
|
child.changed = false;
|
|
411
419
|
continue;
|
|
412
420
|
}
|
|
@@ -415,12 +423,12 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
415
423
|
// マスクの描画開始判定
|
|
416
424
|
const bounds = displayObjectIsMaskReflectedInDisplayUseCase(child, tMatrix, renderer_width, renderer_height);
|
|
417
425
|
canRenderMask = bounds ? true : false;
|
|
418
|
-
renderQueue.
|
|
426
|
+
renderQueue.push1(+canRenderMask);
|
|
419
427
|
if (!bounds) {
|
|
420
428
|
child.changed = false;
|
|
421
429
|
continue;
|
|
422
430
|
}
|
|
423
|
-
renderQueue.
|
|
431
|
+
renderQueue.push4(bounds[0], bounds[1], bounds[2], bounds[3]);
|
|
424
432
|
switch (true) {
|
|
425
433
|
case child.isContainerEnabled: // 0x00
|
|
426
434
|
displayObjectContainerGenerateClipQueueUseCase(child, tMatrix);
|
|
@@ -55,6 +55,26 @@ export declare class DisplayObjectContainer extends InteractiveObject {
|
|
|
55
55
|
* @public
|
|
56
56
|
*/
|
|
57
57
|
$container: IParent<any>[] | null;
|
|
58
|
+
/**
|
|
59
|
+
* @description filterレイヤーのサブツリースケールのキャッシュ(x)。-1は未計算。
|
|
60
|
+
* サブツリーのscale/構造変化は必ずchangedを立てるため、
|
|
61
|
+
* フィルターキャッシュHIT時(未更新時)は前フレーム値を再利用できる。
|
|
62
|
+
* Cached filter-layer subtree scale (x). -1 means not computed.
|
|
63
|
+
*
|
|
64
|
+
* @type {number}
|
|
65
|
+
* @default -1
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
$layerScaleX: number;
|
|
69
|
+
/**
|
|
70
|
+
* @description filterレイヤーのサブツリースケールのキャッシュ(y)。-1は未計算。
|
|
71
|
+
* Cached filter-layer subtree scale (y). -1 means not computed.
|
|
72
|
+
*
|
|
73
|
+
* @type {number}
|
|
74
|
+
* @default -1
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
$layerScaleY: number;
|
|
58
78
|
/**
|
|
59
79
|
* @description コンテナの機能を所持しているかを返却
|
|
60
80
|
* Returns whether the display object has container functionality.
|
|
@@ -90,6 +90,36 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
90
90
|
writable: true,
|
|
91
91
|
value: void 0
|
|
92
92
|
});
|
|
93
|
+
/**
|
|
94
|
+
* @description filterレイヤーのサブツリースケールのキャッシュ(x)。-1は未計算。
|
|
95
|
+
* サブツリーのscale/構造変化は必ずchangedを立てるため、
|
|
96
|
+
* フィルターキャッシュHIT時(未更新時)は前フレーム値を再利用できる。
|
|
97
|
+
* Cached filter-layer subtree scale (x). -1 means not computed.
|
|
98
|
+
*
|
|
99
|
+
* @type {number}
|
|
100
|
+
* @default -1
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
Object.defineProperty(this, "$layerScaleX", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: void 0
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* @description filterレイヤーのサブツリースケールのキャッシュ(y)。-1は未計算。
|
|
111
|
+
* Cached filter-layer subtree scale (y). -1 means not computed.
|
|
112
|
+
*
|
|
113
|
+
* @type {number}
|
|
114
|
+
* @default -1
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
Object.defineProperty(this, "$layerScaleY", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
configurable: true,
|
|
120
|
+
writable: true,
|
|
121
|
+
value: void 0
|
|
122
|
+
});
|
|
93
123
|
/**
|
|
94
124
|
* @description コンテナの機能を所持しているかを返却
|
|
95
125
|
* Returns whether the display object has container functionality.
|
|
@@ -112,6 +142,8 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
112
142
|
this._$children = $getArray();
|
|
113
143
|
// protected
|
|
114
144
|
this.$container = null;
|
|
145
|
+
this.$layerScaleX = -1;
|
|
146
|
+
this.$layerScaleY = -1;
|
|
115
147
|
}
|
|
116
148
|
/**
|
|
117
149
|
* @description コンテナのアクティブな子要素を返却
|
|
@@ -2,6 +2,7 @@ import type { IAjaxOption } from "./interface/IAjaxOption";
|
|
|
2
2
|
import type { ISprite } from "./interface/ISprite";
|
|
3
3
|
import type { IDisplayObject } from "./interface/IDisplayObject";
|
|
4
4
|
import type { IURLRequestHeader } from "./interface/IURLRequestHeader";
|
|
5
|
+
import type { IFilterArray } from "./interface/IFilterArray";
|
|
5
6
|
import type { LoaderInfo } from "./LoaderInfo";
|
|
6
7
|
import type { Graphics } from "./Graphics";
|
|
7
8
|
import type { MovieClip } from "./MovieClip";
|
|
@@ -167,6 +168,38 @@ export declare const $getBoundsArray: (x_min: number, y_min: number, x_max: numb
|
|
|
167
168
|
* @protected
|
|
168
169
|
*/
|
|
169
170
|
export declare const $poolBoundsArray: (array: Float32Array) => void;
|
|
171
|
+
/**
|
|
172
|
+
* @description 直近の $prepareFilterBuffers 実行でフィルターの更新があったかどうかを返す
|
|
173
|
+
* Returns whether any filter was updated in the last $prepareFilterBuffers call.
|
|
174
|
+
*
|
|
175
|
+
* @return {boolean}
|
|
176
|
+
* @method
|
|
177
|
+
* @protected
|
|
178
|
+
*/
|
|
179
|
+
export declare const $getFilterUpdated: () => boolean;
|
|
180
|
+
/**
|
|
181
|
+
* @description フィルターのシリアライズ結果($buffer)を$updated連動で最新化し、
|
|
182
|
+
* 適用可能なフィルターのバウンディングボックスと合計パラメータ数を算出。
|
|
183
|
+
* Refresh each filter's serialized $buffer (invalidated by $updated),
|
|
184
|
+
* collect bounds of applicable filters and return the total parameter count.
|
|
185
|
+
*
|
|
186
|
+
* @param {array} filters
|
|
187
|
+
* @param {Float32Array} bounds
|
|
188
|
+
* @return {number}
|
|
189
|
+
* @method
|
|
190
|
+
* @protected
|
|
191
|
+
*/
|
|
192
|
+
export declare const $prepareFilterBuffers: (filters: IFilterArray, bounds: Float32Array) => number;
|
|
193
|
+
/**
|
|
194
|
+
* @description $prepareFilterBuffers で最新化した各フィルターの$bufferをrenderQueueへ書き込む
|
|
195
|
+
* Write each filter's $buffer (refreshed by $prepareFilterBuffers) to the renderQueue.
|
|
196
|
+
*
|
|
197
|
+
* @param {array} filters
|
|
198
|
+
* @return {void}
|
|
199
|
+
* @method
|
|
200
|
+
* @protected
|
|
201
|
+
*/
|
|
202
|
+
export declare const $pushFilterBuffers: (filters: IFilterArray) => void;
|
|
170
203
|
/**
|
|
171
204
|
* @param {object} option
|
|
172
205
|
* @return {void}
|
package/src/DisplayObjectUtil.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Point } from "@next2d/geom";
|
|
2
|
+
import { renderQueue } from "@next2d/render-queue";
|
|
2
3
|
/**
|
|
3
4
|
* @description 現在のマウスの座標情報
|
|
4
5
|
* Current mouse coordinate information
|
|
@@ -258,6 +259,75 @@ export const $getBoundsArray = (x_min, y_min, x_max, y_max) => {
|
|
|
258
259
|
export const $poolBoundsArray = (array) => {
|
|
259
260
|
$boundsArrays.push(array);
|
|
260
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* @description 直近の $prepareFilterBuffers 実行でフィルターの更新があったかどうか
|
|
264
|
+
* Whether any filter was updated in the last $prepareFilterBuffers call.
|
|
265
|
+
*
|
|
266
|
+
* @type {boolean}
|
|
267
|
+
* @private
|
|
268
|
+
*/
|
|
269
|
+
let $filterUpdated = false;
|
|
270
|
+
/**
|
|
271
|
+
* @description 直近の $prepareFilterBuffers 実行でフィルターの更新があったかどうかを返す
|
|
272
|
+
* Returns whether any filter was updated in the last $prepareFilterBuffers call.
|
|
273
|
+
*
|
|
274
|
+
* @return {boolean}
|
|
275
|
+
* @method
|
|
276
|
+
* @protected
|
|
277
|
+
*/
|
|
278
|
+
export const $getFilterUpdated = () => $filterUpdated;
|
|
279
|
+
/**
|
|
280
|
+
* @description フィルターのシリアライズ結果($buffer)を$updated連動で最新化し、
|
|
281
|
+
* 適用可能なフィルターのバウンディングボックスと合計パラメータ数を算出。
|
|
282
|
+
* Refresh each filter's serialized $buffer (invalidated by $updated),
|
|
283
|
+
* collect bounds of applicable filters and return the total parameter count.
|
|
284
|
+
*
|
|
285
|
+
* @param {array} filters
|
|
286
|
+
* @param {Float32Array} bounds
|
|
287
|
+
* @return {number}
|
|
288
|
+
* @method
|
|
289
|
+
* @protected
|
|
290
|
+
*/
|
|
291
|
+
export const $prepareFilterBuffers = (filters, bounds) => {
|
|
292
|
+
$filterUpdated = false;
|
|
293
|
+
let length = 0;
|
|
294
|
+
for (let idx = 0; idx < filters.length; idx++) {
|
|
295
|
+
const filter = filters[idx];
|
|
296
|
+
if (!filter || !filter.canApplyFilter()) {
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
// フィルターが更新されたかをチェック
|
|
300
|
+
if (filter.$updated) {
|
|
301
|
+
$filterUpdated = true;
|
|
302
|
+
filter.$buffer = null;
|
|
303
|
+
}
|
|
304
|
+
filter.$updated = false;
|
|
305
|
+
filter.getBounds(bounds);
|
|
306
|
+
if (!filter.$buffer) {
|
|
307
|
+
filter.$buffer = filter.toNumberArray();
|
|
308
|
+
}
|
|
309
|
+
length += filter.$buffer.length;
|
|
310
|
+
}
|
|
311
|
+
return length;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* @description $prepareFilterBuffers で最新化した各フィルターの$bufferをrenderQueueへ書き込む
|
|
315
|
+
* Write each filter's $buffer (refreshed by $prepareFilterBuffers) to the renderQueue.
|
|
316
|
+
*
|
|
317
|
+
* @param {array} filters
|
|
318
|
+
* @return {void}
|
|
319
|
+
* @method
|
|
320
|
+
* @protected
|
|
321
|
+
*/
|
|
322
|
+
export const $pushFilterBuffers = (filters) => {
|
|
323
|
+
for (let idx = 0; idx < filters.length; idx++) {
|
|
324
|
+
const filter = filters[idx];
|
|
325
|
+
if (!filter || !filter.canApplyFilter() || !filter.$buffer) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
renderQueue.set(filter.$buffer);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
261
331
|
/**
|
|
262
332
|
* @param {object} option
|
|
263
333
|
* @return {void}
|
|
@@ -25,6 +25,6 @@ export const execute = (shape, matrix) => {
|
|
|
25
25
|
? Math.abs(rawMatrix[1]) < 0.001 && Math.abs(rawMatrix[2]) < 0.0001
|
|
26
26
|
: false;
|
|
27
27
|
const buffer = shape.graphics.buffer;
|
|
28
|
-
renderQueue.
|
|
28
|
+
renderQueue.push9($RENDERER_SHAPE_TYPE, tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], tMatrix[4], tMatrix[5], +hasGrid, buffer.length);
|
|
29
29
|
renderQueue.set(buffer);
|
|
30
30
|
};
|
|
@@ -6,7 +6,7 @@ import { execute as displayObjectGenerateHashService } from "../../DisplayObject
|
|
|
6
6
|
import { execute as displayObjectBlendToNumberService } from "../../DisplayObject/service/DisplayObjectBlendToNumberService";
|
|
7
7
|
import { stage } from "../../Stage";
|
|
8
8
|
import { $cacheStore } from "@next2d/cache";
|
|
9
|
-
import { $clamp, $RENDERER_SHAPE_TYPE, $getArray, $poolArray, $poolBoundsArray, $MATRIX_ARRAY_IDENTITY, $getFloat32Array6, $poolFloat32Array6, $getBoundsArray } from "../../DisplayObjectUtil";
|
|
9
|
+
import { $clamp, $RENDERER_SHAPE_TYPE, $getArray, $poolArray, $poolBoundsArray, $MATRIX_ARRAY_IDENTITY, $getFloat32Array6, $poolFloat32Array6, $getBoundsArray, $prepareFilterBuffers, $pushFilterBuffers, $getFilterUpdated } from "../../DisplayObjectUtil";
|
|
10
10
|
import { ColorTransform, Matrix } from "@next2d/geom";
|
|
11
11
|
/**
|
|
12
12
|
* @description renderer workerに渡すShapeの描画データを生成
|
|
@@ -23,13 +23,13 @@ import { ColorTransform, Matrix } from "@next2d/geom";
|
|
|
23
23
|
*/
|
|
24
24
|
export const execute = (shape, matrix, color_transform, renderer_width, renderer_height) => {
|
|
25
25
|
if (!shape.visible) {
|
|
26
|
-
renderQueue.
|
|
26
|
+
renderQueue.push1(0);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const graphics = shape.graphics;
|
|
30
30
|
const isDrawable = graphics.isDrawable;
|
|
31
31
|
if (!isDrawable && !shape.isBitmap) {
|
|
32
|
-
renderQueue.
|
|
32
|
+
renderQueue.push1(0);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
// transformed ColorTransform(tColorTransform)
|
|
@@ -46,7 +46,7 @@ export const execute = (shape, matrix, color_transform, renderer_width, renderer
|
|
|
46
46
|
if (tColorTransform !== color_transform) {
|
|
47
47
|
ColorTransform.release(tColorTransform);
|
|
48
48
|
}
|
|
49
|
-
renderQueue.
|
|
49
|
+
renderQueue.push1(0);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
// transformed matrix(tMatrix)
|
|
@@ -78,7 +78,7 @@ export const execute = (shape, matrix, color_transform, renderer_width, renderer
|
|
|
78
78
|
if (tMatrix !== matrix) {
|
|
79
79
|
Matrix.release(tMatrix);
|
|
80
80
|
}
|
|
81
|
-
renderQueue.
|
|
81
|
+
renderQueue.push1(0);
|
|
82
82
|
return;
|
|
83
83
|
default:
|
|
84
84
|
break;
|
|
@@ -93,7 +93,7 @@ export const execute = (shape, matrix, color_transform, renderer_width, renderer
|
|
|
93
93
|
if (tMatrix !== matrix) {
|
|
94
94
|
Matrix.release(tMatrix);
|
|
95
95
|
}
|
|
96
|
-
renderQueue.
|
|
96
|
+
renderQueue.push1(0);
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
const isGridEnabled = rawMatrix && shape.scale9Grid
|
|
@@ -178,7 +178,7 @@ export const execute = (shape, matrix, color_transform, renderer_width, renderer
|
|
|
178
178
|
? shape.$cache.get(`${cacheKey}`)
|
|
179
179
|
: $cacheStore.get(shape.uniqueKey, `${cacheKey}`);
|
|
180
180
|
if (!cache) {
|
|
181
|
-
renderQueue.
|
|
181
|
+
renderQueue.push1(0);
|
|
182
182
|
if (isGridEnabled) {
|
|
183
183
|
const scale = stage.rendererScale;
|
|
184
184
|
const stageMatrix = $getFloat32Array6(scale, 0, 0, scale, 0, 0);
|
|
@@ -224,15 +224,22 @@ export const execute = (shape, matrix, color_transform, renderer_width, renderer
|
|
|
224
224
|
minYPQ = Math.max(m - 0.00001, 0);
|
|
225
225
|
maxYPQ = Math.min(m + 0.00001, 1);
|
|
226
226
|
}
|
|
227
|
-
renderQueue.
|
|
227
|
+
renderQueue.push24(pMatrix[0], pMatrix[1], pMatrix[2], pMatrix[3], pMatrix[4], pMatrix[5], aMatrix[0], aMatrix[1], aMatrix[2], aMatrix[3], aMatrix[4] - aOffsetX, aMatrix[5] - aOffsetY, parentXMin, parentYMin, parentWidth, parentHeight, minXST, minYST, minXPQ, minYPQ, maxXST, maxYST, maxXPQ, maxYPQ);
|
|
228
228
|
$poolFloat32Array6(aMatrix);
|
|
229
229
|
$poolFloat32Array6(pMatrix);
|
|
230
230
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
231
|
+
if (isDrawable || isGridEnabled) {
|
|
232
|
+
const buffer = graphics.buffer;
|
|
233
|
+
renderQueue.push1(buffer.length);
|
|
234
|
+
renderQueue.set(buffer);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// ビットマップのピクセルは1byte=1floatに展開せず4バイト/floatでパックし、
|
|
238
|
+
// 転送量とキュー常駐メモリを1/4にする(読み出し側はShapeRenderUseCase)
|
|
239
|
+
const buffer = shape.$bitmapBuffer;
|
|
240
|
+
renderQueue.push1(buffer.length);
|
|
241
|
+
renderQueue.setUint8(buffer);
|
|
242
|
+
}
|
|
236
243
|
$cacheStore.set(shape.uniqueKey, `${cacheKey}`, true);
|
|
237
244
|
if (shape.$cache) {
|
|
238
245
|
shape.$cache = null;
|
|
@@ -243,42 +250,24 @@ export const execute = (shape, matrix, color_transform, renderer_width, renderer
|
|
|
243
250
|
shape.$cache = $cacheStore.getById(shape.uniqueKey);
|
|
244
251
|
shape.$cache.set(shape.uniqueKey, true);
|
|
245
252
|
}
|
|
246
|
-
renderQueue.
|
|
253
|
+
renderQueue.push1(1);
|
|
247
254
|
}
|
|
248
|
-
renderQueue.
|
|
255
|
+
renderQueue.push1(displayObjectBlendToNumberService(shape.blendMode));
|
|
249
256
|
const filters = shape.filters;
|
|
250
257
|
if (filters) {
|
|
251
|
-
let updated = false;
|
|
252
|
-
const params = [];
|
|
253
258
|
const bounds = $getBoundsArray(0, 0, 0, 0);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
// フィルターが更新されたかをチェック
|
|
260
|
-
if (filter.$updated) {
|
|
261
|
-
updated = true;
|
|
262
|
-
}
|
|
263
|
-
filter.$updated = false;
|
|
264
|
-
filter.getBounds(bounds);
|
|
265
|
-
const buffer = filter.toNumberArray();
|
|
266
|
-
for (let idx = 0; idx < buffer.length; idx += 4096) {
|
|
267
|
-
params.push(...buffer.subarray(idx, idx + 4096));
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
const useFilfer = params.length > 0;
|
|
271
|
-
if (useFilfer) {
|
|
272
|
-
renderQueue.push(+useFilfer, +updated, bounds[0], bounds[1], bounds[2], bounds[3], params.length);
|
|
273
|
-
renderQueue.set(new Float32Array(params));
|
|
259
|
+
const paramsLength = $prepareFilterBuffers(filters, bounds);
|
|
260
|
+
if (paramsLength > 0) {
|
|
261
|
+
renderQueue.push7(1, +$getFilterUpdated(), bounds[0], bounds[1], bounds[2], bounds[3], paramsLength);
|
|
262
|
+
$pushFilterBuffers(filters);
|
|
274
263
|
}
|
|
275
264
|
else {
|
|
276
|
-
renderQueue.
|
|
265
|
+
renderQueue.push1(0);
|
|
277
266
|
}
|
|
278
267
|
$poolBoundsArray(bounds);
|
|
279
268
|
}
|
|
280
269
|
else {
|
|
281
|
-
renderQueue.
|
|
270
|
+
renderQueue.push1(0);
|
|
282
271
|
}
|
|
283
272
|
if (tColorTransform !== color_transform) {
|
|
284
273
|
ColorTransform.release(tColorTransform);
|
|
@@ -43,6 +43,29 @@ export const execute = (shape, hit_context, matrix, hit_object) => {
|
|
|
43
43
|
if (scaledMatrix) {
|
|
44
44
|
$poolFloat32Array6(scaledMatrix);
|
|
45
45
|
}
|
|
46
|
+
// AABB早期リターン: ポインタをローカル座標へ逆変換し、
|
|
47
|
+
// バウンディングボックスの外ならパス再生とisPointInPathをスキップする。
|
|
48
|
+
// 描画コマンドがある場合はgraphicsのbounds(ストローク幅込み)、
|
|
49
|
+
// 無い場合はフォールバック矩形(0,0)-(width,height)と同じ範囲で判定するため結果は不変。
|
|
50
|
+
const det = tMatrix[0] * tMatrix[3] - tMatrix[1] * tMatrix[2];
|
|
51
|
+
if (det) {
|
|
52
|
+
const dx = hit_object.x - tMatrix[4];
|
|
53
|
+
const dy = hit_object.y - tMatrix[5];
|
|
54
|
+
const localX = (tMatrix[3] * dx - tMatrix[2] * dy) / det;
|
|
55
|
+
const localY = (tMatrix[0] * dy - tMatrix[1] * dx) / det;
|
|
56
|
+
const hasCommands = graphics.buffer.length > 0;
|
|
57
|
+
const boundsXMin = hasCommands ? graphics.xMin : 0;
|
|
58
|
+
const boundsYMin = hasCommands ? graphics.yMin : 0;
|
|
59
|
+
const boundsXMax = hasCommands ? graphics.xMax : width;
|
|
60
|
+
const boundsYMax = hasCommands ? graphics.yMax : height;
|
|
61
|
+
if (localX < boundsXMin || localX > boundsXMax
|
|
62
|
+
|| localY < boundsYMin || localY > boundsYMax) {
|
|
63
|
+
if (tMatrix !== matrix) {
|
|
64
|
+
Matrix.release(tMatrix);
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
46
69
|
hit_context.beginPath();
|
|
47
70
|
hit_context.setTransform(tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], tMatrix[4], tMatrix[5]);
|
|
48
71
|
let hit = false;
|
|
@@ -19,7 +19,7 @@ import { execute as textFieldGenerateRenderQueueUseCase } from "../../TextField/
|
|
|
19
19
|
* @protected
|
|
20
20
|
*/
|
|
21
21
|
export const execute = (display_object, image_bitmaps, matrix, color_transform, renderer_width, renderer_height) => {
|
|
22
|
-
renderQueue.
|
|
22
|
+
renderQueue.push1(stage.backgroundColor);
|
|
23
23
|
switch (true) {
|
|
24
24
|
case display_object.isContainerEnabled: // 0x00
|
|
25
25
|
displayObjectContainerGenerateRenderQueueUseCase(display_object, image_bitmaps, matrix, color_transform, renderer_width, renderer_height);
|
|
@@ -6,7 +6,7 @@ import { execute as displayObjectGenerateHashService } from "../../DisplayObject
|
|
|
6
6
|
import { $cacheStore } from "@next2d/cache";
|
|
7
7
|
import { renderQueue } from "@next2d/render-queue";
|
|
8
8
|
import { stage } from "../../Stage";
|
|
9
|
-
import { $clamp, $RENDERER_TEXT_TYPE, $getArray, $poolArray, $poolBoundsArray, $getBoundsArray, $getFloat32Array6, $poolFloat32Array6 } from "../../DisplayObjectUtil";
|
|
9
|
+
import { $clamp, $RENDERER_TEXT_TYPE, $getArray, $poolArray, $poolBoundsArray, $getBoundsArray, $getFloat32Array6, $poolFloat32Array6, $prepareFilterBuffers, $pushFilterBuffers, $getFilterUpdated } from "../../DisplayObjectUtil";
|
|
10
10
|
import { ColorTransform, Matrix } from "@next2d/geom";
|
|
11
11
|
/**
|
|
12
12
|
* @type {TextEncoder}
|
|
@@ -28,7 +28,7 @@ const $textEncoder = new TextEncoder();
|
|
|
28
28
|
*/
|
|
29
29
|
export const execute = (text_field, matrix, color_transform, renderer_width, renderer_height) => {
|
|
30
30
|
if (!text_field.visible) {
|
|
31
|
-
renderQueue.
|
|
31
|
+
renderQueue.push1(0);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
// transformed ColorTransform(tColorTransform)
|
|
@@ -45,7 +45,7 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
|
|
|
45
45
|
if (tColorTransform !== color_transform) {
|
|
46
46
|
ColorTransform.release(tColorTransform);
|
|
47
47
|
}
|
|
48
|
-
renderQueue.
|
|
48
|
+
renderQueue.push1(0);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
// transformed matrix(tMatrix)
|
|
@@ -77,7 +77,7 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
|
|
|
77
77
|
if (tMatrix !== matrix) {
|
|
78
78
|
Matrix.release(tMatrix);
|
|
79
79
|
}
|
|
80
|
-
renderQueue.
|
|
80
|
+
renderQueue.push1(0);
|
|
81
81
|
return;
|
|
82
82
|
default:
|
|
83
83
|
break;
|
|
@@ -92,7 +92,7 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
|
|
|
92
92
|
if (tMatrix !== matrix) {
|
|
93
93
|
Matrix.release(tMatrix);
|
|
94
94
|
}
|
|
95
|
-
renderQueue.
|
|
95
|
+
renderQueue.push1(0);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
if (!text_field.uniqueKey) {
|
|
@@ -171,26 +171,27 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
|
|
|
171
171
|
: $cacheStore.get(text_field.uniqueKey, `${cacheKey}`);
|
|
172
172
|
if (!cache || text_field.changed) {
|
|
173
173
|
// cache none
|
|
174
|
-
renderQueue.
|
|
174
|
+
renderQueue.push2(0, +cache);
|
|
175
175
|
const buffer = $textEncoder.encode(JSON.stringify(text_field.$textData));
|
|
176
|
-
|
|
177
|
-
renderQueue.
|
|
176
|
+
// バイト数をヘッダに書き、本体は4バイト/floatでパックして転送量を1/4にする
|
|
177
|
+
renderQueue.push1(buffer.length);
|
|
178
|
+
renderQueue.setUint8(buffer);
|
|
178
179
|
// text setting
|
|
179
180
|
switch (text_field.autoSize) {
|
|
180
181
|
case "center":
|
|
181
|
-
renderQueue.
|
|
182
|
+
renderQueue.push1(0);
|
|
182
183
|
break;
|
|
183
184
|
case "left":
|
|
184
|
-
renderQueue.
|
|
185
|
+
renderQueue.push1(1);
|
|
185
186
|
break;
|
|
186
187
|
case "none":
|
|
187
|
-
renderQueue.
|
|
188
|
+
renderQueue.push1(2);
|
|
188
189
|
break;
|
|
189
190
|
case "right":
|
|
190
|
-
renderQueue.
|
|
191
|
+
renderQueue.push1(3);
|
|
191
192
|
break;
|
|
192
193
|
}
|
|
193
|
-
renderQueue.
|
|
194
|
+
renderQueue.push19(text_field.stopIndex, text_field.scrollX, text_field.scrollY, text_field.textWidth, text_field.textHeight, Math.abs(text_field.xMax - text_field.xMin), Math.abs(text_field.yMax - text_field.yMin), text_field.focusIndex, text_field.selectIndex, +text_field.focusVisible, text_field.thickness, text_field.thicknessColor, +text_field.wordWrap, +text_field.border, text_field.borderColor, +text_field.background, text_field.backgroundColor, text_field.defaultTextFormat.color || 0, text_field.defaultTextFormat.size || 0);
|
|
194
195
|
if (!cache) {
|
|
195
196
|
$cacheStore.set(text_field.uniqueKey, `${cacheKey}`, true);
|
|
196
197
|
}
|
|
@@ -203,41 +204,23 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
|
|
|
203
204
|
text_field.$cache = $cacheStore.getById(text_field.uniqueKey);
|
|
204
205
|
text_field.$cache.set(text_field.uniqueKey, true);
|
|
205
206
|
}
|
|
206
|
-
renderQueue.
|
|
207
|
+
renderQueue.push1(1);
|
|
207
208
|
}
|
|
208
|
-
renderQueue.
|
|
209
|
+
renderQueue.push1(displayObjectBlendToNumberService(text_field.blendMode));
|
|
209
210
|
if (text_field.filters?.length) {
|
|
210
|
-
let updated = false;
|
|
211
|
-
const params = [];
|
|
212
211
|
const bounds = $getBoundsArray(0, 0, 0, 0);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
// フィルターが更新されたかをチェック
|
|
219
|
-
if (filter.$updated) {
|
|
220
|
-
updated = true;
|
|
221
|
-
}
|
|
222
|
-
filter.$updated = false;
|
|
223
|
-
filter.getBounds(bounds);
|
|
224
|
-
const buffer = filter.toNumberArray();
|
|
225
|
-
for (let idx = 0; idx < buffer.length; idx += 4096) {
|
|
226
|
-
params.push(...buffer.subarray(idx, idx + 4096));
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
const useFilfer = params.length > 0;
|
|
230
|
-
if (useFilfer) {
|
|
231
|
-
renderQueue.push(+useFilfer, +updated, bounds[0], bounds[1], bounds[2], bounds[3], params.length);
|
|
232
|
-
renderQueue.set(new Float32Array(params));
|
|
212
|
+
const paramsLength = $prepareFilterBuffers(text_field.filters, bounds);
|
|
213
|
+
if (paramsLength > 0) {
|
|
214
|
+
renderQueue.push7(1, +$getFilterUpdated(), bounds[0], bounds[1], bounds[2], bounds[3], paramsLength);
|
|
215
|
+
$pushFilterBuffers(text_field.filters);
|
|
233
216
|
}
|
|
234
217
|
else {
|
|
235
|
-
renderQueue.
|
|
218
|
+
renderQueue.push1(0);
|
|
236
219
|
}
|
|
237
220
|
$poolBoundsArray(bounds);
|
|
238
221
|
}
|
|
239
222
|
else {
|
|
240
|
-
renderQueue.
|
|
223
|
+
renderQueue.push1(0);
|
|
241
224
|
}
|
|
242
225
|
if (tColorTransform !== color_transform) {
|
|
243
226
|
ColorTransform.release(tColorTransform);
|
|
@@ -5,7 +5,7 @@ import { execute as displayObjectBlendToNumberService } from "../../DisplayObjec
|
|
|
5
5
|
import { execute as displayObjectGenerateHashService } from "../../DisplayObject/service/DisplayObjectGenerateHashService";
|
|
6
6
|
import { $cacheStore } from "@next2d/cache";
|
|
7
7
|
import { renderQueue } from "@next2d/render-queue";
|
|
8
|
-
import { $clamp, $RENDERER_VIDEO_TYPE, $getArray, $poolBoundsArray, $poolArray, $getBoundsArray } from "../../DisplayObjectUtil";
|
|
8
|
+
import { $clamp, $RENDERER_VIDEO_TYPE, $getArray, $poolBoundsArray, $poolArray, $getBoundsArray, $prepareFilterBuffers, $pushFilterBuffers, $getFilterUpdated } from "../../DisplayObjectUtil";
|
|
9
9
|
import { ColorTransform, Matrix } from "@next2d/geom";
|
|
10
10
|
/**
|
|
11
11
|
* @description renderer workerに渡すVideoの描画データを生成
|
|
@@ -26,7 +26,7 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
|
|
|
26
26
|
|| !video.$videoElement
|
|
27
27
|
|| !video.$offscreenCanvas
|
|
28
28
|
|| !video.loaded) {
|
|
29
|
-
renderQueue.
|
|
29
|
+
renderQueue.push1(0);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
// transformed ColorTransform(tColorTransform)
|
|
@@ -43,7 +43,7 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
|
|
|
43
43
|
if (tColorTransform !== color_transform) {
|
|
44
44
|
ColorTransform.release(tColorTransform);
|
|
45
45
|
}
|
|
46
|
-
renderQueue.
|
|
46
|
+
renderQueue.push1(0);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
// transformed matrix(tMatrix)
|
|
@@ -76,7 +76,7 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
|
|
|
76
76
|
if (tMatrix !== matrix) {
|
|
77
77
|
Matrix.release(tMatrix);
|
|
78
78
|
}
|
|
79
|
-
renderQueue.
|
|
79
|
+
renderQueue.push1(0);
|
|
80
80
|
return;
|
|
81
81
|
default:
|
|
82
82
|
break;
|
|
@@ -91,7 +91,7 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
|
|
|
91
91
|
if (tMatrix !== matrix) {
|
|
92
92
|
Matrix.release(tMatrix);
|
|
93
93
|
}
|
|
94
|
-
renderQueue.
|
|
94
|
+
renderQueue.push1(0);
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
if (!video.uniqueKey) {
|
|
@@ -115,7 +115,7 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
|
|
|
115
115
|
: $cacheStore.get(video.uniqueKey, "0");
|
|
116
116
|
if (!cache || video.changed) {
|
|
117
117
|
// cache, node
|
|
118
|
-
renderQueue.
|
|
118
|
+
renderQueue.push2(0, +cache);
|
|
119
119
|
const context = video.$context;
|
|
120
120
|
if (context) {
|
|
121
121
|
const x = video.videoWidth / 2;
|
|
@@ -141,41 +141,23 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
|
|
|
141
141
|
video.$cache = $cacheStore.getById(video.uniqueKey);
|
|
142
142
|
video.$cache.set(video.uniqueKey, true);
|
|
143
143
|
}
|
|
144
|
-
renderQueue.
|
|
144
|
+
renderQueue.push1(1);
|
|
145
145
|
}
|
|
146
|
-
renderQueue.
|
|
146
|
+
renderQueue.push1(displayObjectBlendToNumberService(video.blendMode));
|
|
147
147
|
if (video.filters?.length) {
|
|
148
|
-
let updated = false;
|
|
149
|
-
const params = [];
|
|
150
148
|
const bounds = $getBoundsArray(0, 0, 0, 0);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
// フィルターが更新されたかをチェック
|
|
157
|
-
if (filter.$updated) {
|
|
158
|
-
updated = true;
|
|
159
|
-
}
|
|
160
|
-
filter.$updated = false;
|
|
161
|
-
filter.getBounds(bounds);
|
|
162
|
-
const buffer = filter.toNumberArray();
|
|
163
|
-
for (let idx = 0; idx < buffer.length; idx += 4096) {
|
|
164
|
-
params.push(...buffer.subarray(idx, idx + 4096));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const useFilfer = params.length > 0;
|
|
168
|
-
if (useFilfer) {
|
|
169
|
-
renderQueue.push(+useFilfer, +updated, bounds[0], bounds[1], bounds[2], bounds[3], params.length);
|
|
170
|
-
renderQueue.set(new Float32Array(params));
|
|
149
|
+
const paramsLength = $prepareFilterBuffers(video.filters, bounds);
|
|
150
|
+
if (paramsLength > 0) {
|
|
151
|
+
renderQueue.push7(1, +$getFilterUpdated(), bounds[0], bounds[1], bounds[2], bounds[3], paramsLength);
|
|
152
|
+
$pushFilterBuffers(video.filters);
|
|
171
153
|
}
|
|
172
154
|
else {
|
|
173
|
-
renderQueue.
|
|
155
|
+
renderQueue.push1(0);
|
|
174
156
|
}
|
|
175
157
|
$poolBoundsArray(bounds);
|
|
176
158
|
}
|
|
177
159
|
else {
|
|
178
|
-
renderQueue.
|
|
160
|
+
renderQueue.push1(0);
|
|
179
161
|
}
|
|
180
162
|
if (tColorTransform !== color_transform) {
|
|
181
163
|
ColorTransform.release(tColorTransform);
|