@next2d/display 3.0.5 → 3.2.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 +9 -9
- package/src/DisplayObject/usecase/DisplayObjectHitTestPointUseCase.js +16 -2
- package/src/DisplayObject/usecase/DisplayObjectSetRotationUseCase.js +12 -14
- package/src/DisplayObject.d.ts +40 -1
- package/src/DisplayObject.js +73 -2
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerCalcBoundsMatrixUseCase.js +20 -2
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateRenderQueueUseCase.d.ts +1 -1
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateRenderQueueUseCase.js +256 -98
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGetLayerScaleUseCase.d.ts +17 -0
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGetLayerScaleUseCase.js +41 -0
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerMouseHitUseCase.js +20 -2
- package/src/Graphics/service/GraphicsToNumberArrayService.js +6 -2
- package/src/Loader/usecase/LoaderLoadJsonUseCase.js +8 -1
- package/src/Loader/worker/ZlibInflateWorker.js +378 -9
- package/src/Loader/worker/unzip.worker.inline.js +1 -1
- package/src/Shape/usecase/ShapeCalcBoundsMatrixUseCase.js +20 -2
- package/src/Shape/usecase/ShapeGenerateRenderQueueUseCase.js +50 -12
- package/src/Shape/usecase/ShapeHitTestUseCase.js +20 -1
- package/src/TextField/usecase/TextFieldCalcBoundsMatrixUseCase.js +20 -2
- package/src/TextField/usecase/TextFieldGenerateRenderQueueUseCase.js +52 -13
- package/src/TextField/usecase/TextFieldHitTestUseCase.js +20 -1
package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateRenderQueueUseCase.js
CHANGED
|
@@ -8,10 +8,12 @@ import { execute as displayObjectIsMaskReflectedInDisplayUseCase } from "../../D
|
|
|
8
8
|
import { execute as displayObjectContainerGenerateClipQueueUseCase } from "../../DisplayObjectContainer/usecase/DisplayObjectContainerGenerateClipQueueUseCase";
|
|
9
9
|
import { execute as displayObjectBlendToNumberService } from "../../DisplayObject/service/DisplayObjectBlendToNumberService";
|
|
10
10
|
import { execute as displayObjectContainerGetLayerBoundsUseCase } from "./DisplayObjectContainerGetLayerBoundsUseCase";
|
|
11
|
+
import { execute as displayObjectContainerGetLayerScaleUseCase } from "./DisplayObjectContainerGetLayerScaleUseCase";
|
|
11
12
|
import { execute as displayObjectContainerCalcBoundsMatrixUseCase } from "../../DisplayObjectContainer/usecase/DisplayObjectContainerCalcBoundsMatrixUseCase";
|
|
13
|
+
import { stage } from "../../Stage";
|
|
12
14
|
import { renderQueue } from "@next2d/render-queue";
|
|
13
15
|
import { $cacheStore } from "@next2d/cache";
|
|
14
|
-
import { $clamp, $getBoundsArray, $poolBoundsArray, $RENDERER_CONTAINER_TYPE, $getFloat32Array8, $getFloat32Array6 } from "../../DisplayObjectUtil";
|
|
16
|
+
import { $clamp, $getBoundsArray, $poolBoundsArray, $RENDERER_CONTAINER_TYPE, $getFloat32Array8, $getFloat32Array6, $poolFloat32Array6 } from "../../DisplayObjectUtil";
|
|
15
17
|
import { ColorTransform, Matrix } from "@next2d/geom";
|
|
16
18
|
/**
|
|
17
19
|
* @description renderer workerに渡すコンテナの描画データを生成
|
|
@@ -27,7 +29,7 @@ import { ColorTransform, Matrix } from "@next2d/geom";
|
|
|
27
29
|
* @method
|
|
28
30
|
* @private
|
|
29
31
|
*/
|
|
30
|
-
export const execute = (display_object_container, image_bitmaps, matrix, color_transform, renderer_width, renderer_height) => {
|
|
32
|
+
export const execute = (display_object_container, image_bitmaps, matrix, color_transform, renderer_width, renderer_height, in_filter_layer = false) => {
|
|
31
33
|
if (!display_object_container.visible) {
|
|
32
34
|
renderQueue.push(0);
|
|
33
35
|
return;
|
|
@@ -81,94 +83,274 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
81
83
|
// blendMode
|
|
82
84
|
const blendMode = display_object_container.blendMode;
|
|
83
85
|
renderQueue.push(displayObjectBlendToNumberService(blendMode));
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
// cacheAsBitmap: フィルターキャッシュ形式でコンテナ全体をビットマップキャッシュ
|
|
87
|
+
// キャッシュテクスチャは親のスケールを含むサイズで描画し、
|
|
88
|
+
// コンポジットは setTransform(1,0,0,1,x,y) で1:1描画されるため正しい画面サイズになる
|
|
89
|
+
// 親の移動はキャッシュヒット(位置だけ更新)、スケール変更はキャッシュミス(再描画)
|
|
90
|
+
// 親がfilter等の中間レイヤー内にいる場合、filter layer 側で layerScale倍の
|
|
91
|
+
// 解像度を確保してから最終compose時に 1/layerScale で縮小合成する仕組みによって
|
|
92
|
+
// cacheAsBitmap子のテクスチャが親layerに収まる (issue #274 根本対応)。
|
|
93
|
+
const cacheMatrix = display_object_container.cacheAsBitmap;
|
|
94
|
+
if (cacheMatrix) {
|
|
95
|
+
const m = cacheMatrix.rawData;
|
|
96
|
+
const cacheScaleX = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
|
|
97
|
+
const cacheScaleY = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
|
|
98
|
+
const ownScaleX = rawMatrix
|
|
99
|
+
? Math.sqrt(rawMatrix[0] * rawMatrix[0] + rawMatrix[1] * rawMatrix[1])
|
|
100
|
+
: 1;
|
|
101
|
+
const ownScaleY = rawMatrix
|
|
102
|
+
? Math.sqrt(rawMatrix[2] * rawMatrix[2] + rawMatrix[3] * rawMatrix[3])
|
|
103
|
+
: 1;
|
|
104
|
+
// Shape/TextFieldと同様にstage.rendererScaleを使用
|
|
105
|
+
// matrixから抽出すると親のアニメーション(スケール変動)でキーが揺れて
|
|
106
|
+
// 毎フレームcache MISSが発生する原因になる
|
|
107
|
+
const rendererScale = stage.rendererScale;
|
|
108
|
+
// コンポジットスケール = cacheScale × ownScale × rendererScale
|
|
109
|
+
const renderScaleX = cacheScaleX * ownScaleX * rendererScale;
|
|
110
|
+
const renderScaleY = cacheScaleY * ownScaleY * rendererScale;
|
|
111
|
+
const xRounded = Math.round(renderScaleX * 100) / 100;
|
|
112
|
+
const yRounded = Math.round(renderScaleY * 100) / 100;
|
|
113
|
+
const bitmapCacheKey = $cacheStore.generateKeys(xRounded, yRounded, tColorTransform[7]);
|
|
114
|
+
// 固定プロパティ名で最新のキーのみ保存(古いキーが蓄積されないようにする)
|
|
115
|
+
// レンダラーも最新のfKeyのみ保持するため、キーの一致を保証
|
|
116
|
+
const bitmapCache = $cacheStore.get(`${display_object_container.instanceId}`, "bitmapKey") === bitmapCacheKey;
|
|
117
|
+
// コンテナ自身のフィルター境界を収集
|
|
118
|
+
const cacheFilters = display_object_container.filters;
|
|
119
|
+
const cacheFilterBounds = $getBoundsArray(0, 0, 0, 0);
|
|
120
|
+
if (cacheFilters) {
|
|
121
|
+
for (let idx = 0; idx < cacheFilters.length; idx++) {
|
|
122
|
+
const filter = cacheFilters[idx];
|
|
123
|
+
if (!filter || !filter.canApplyFilter()) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
filter.getBounds(cacheFilterBounds);
|
|
96
127
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
128
|
+
}
|
|
129
|
+
if (bitmapCache) {
|
|
130
|
+
// cacheAsBitmap cache hit: 子要素走査をスキップして高速パス
|
|
131
|
+
// Shapeと同様に親matrixをレンダラーに渡し、描画時にcacheScaleで補正
|
|
132
|
+
const cachedLocalBounds = $cacheStore.get(`${display_object_container.instanceId}`, "bLocalBounds");
|
|
133
|
+
if (cachedLocalBounds) {
|
|
134
|
+
// ローカルバウンズ原点のスクリーン座標を計算(Shapeと同じ方式)
|
|
135
|
+
const localOriginX = cachedLocalBounds[0] / (cacheScaleX * rendererScale);
|
|
136
|
+
const localOriginY = cachedLocalBounds[1] / (cacheScaleY * rendererScale);
|
|
137
|
+
const screenX = matrix[0] * localOriginX + matrix[2] * localOriginY + matrix[4];
|
|
138
|
+
const screenY = matrix[1] * localOriginX + matrix[3] * localOriginY + matrix[5];
|
|
139
|
+
// 通常: matrixにcacheScaleを乗算。レンダラで matrix/renderScale → cacheScale成分が反映される。
|
|
140
|
+
// issue #274: 親がfilter layer を持ち、layer を cacheScale 倍解像度で確保している場合は、
|
|
141
|
+
// 親のtMatrix に既に layerScale (=cacheScale) が掛かっているため、cacheScale 乗算を省略して
|
|
142
|
+
// 合成 scale=1 で layer にちょうど収まるようにする。
|
|
143
|
+
const hitMatrixScaleX = in_filter_layer ? 1 : cacheScaleX;
|
|
144
|
+
const hitMatrixScaleY = in_filter_layer ? 1 : cacheScaleY;
|
|
145
|
+
renderQueue.push(1, 0, 0, // layerWidth/Height: HIT時は未使用
|
|
146
|
+
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
|
+
$poolBoundsArray(cacheFilterBounds);
|
|
148
|
+
if (tColorTransform !== color_transform) {
|
|
149
|
+
ColorTransform.release(tColorTransform);
|
|
150
|
+
}
|
|
151
|
+
if (tMatrix !== matrix) {
|
|
152
|
+
Matrix.release(tMatrix);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
100
155
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
156
|
+
// cachedLocalBoundsがない場合はMISSにフォールスルー
|
|
157
|
+
}
|
|
158
|
+
// cacheAsBitmap cache miss: 初回描画
|
|
159
|
+
// 親matrixのスケール成分のみを含むローカル空間でキャッシュを生成する
|
|
160
|
+
// (親の位置・回転は含まず、スケールのみ反映してテクスチャサイズを画面と一致させる)
|
|
161
|
+
// フィルターパラメータを収集
|
|
162
|
+
const cacheFilterParams = [];
|
|
163
|
+
if (cacheFilters) {
|
|
164
|
+
for (let idx = 0; idx < cacheFilters.length; idx++) {
|
|
165
|
+
const filter = cacheFilters[idx];
|
|
166
|
+
if (!filter || !filter.canApplyFilter()) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const buffer = filter.toNumberArray();
|
|
170
|
+
for (let idx = 0; idx < buffer.length; idx += 4096) {
|
|
171
|
+
cacheFilterParams.push(...buffer.subarray(idx, idx + 4096));
|
|
172
|
+
}
|
|
106
173
|
}
|
|
107
174
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
175
|
+
// キャッシュ描画用の親matrix: cacheScale × rendererScale(対角行列)
|
|
176
|
+
const cacheParentMatrix = $getFloat32Array6(cacheScaleX * rendererScale, 0, 0, cacheScaleY * rendererScale, 0, 0);
|
|
177
|
+
const localLayerBounds = displayObjectContainerGetLayerBoundsUseCase(display_object_container, cacheParentMatrix);
|
|
178
|
+
const localLayerWidth = Math.ceil(Math.abs(localLayerBounds[2] - localLayerBounds[0]));
|
|
179
|
+
const localLayerHeight = Math.ceil(Math.abs(localLayerBounds[3] - localLayerBounds[1]));
|
|
180
|
+
// Shapeと同じ方式でスクリーン座標を計算
|
|
181
|
+
const localOriginX = localLayerBounds[0] / (cacheScaleX * rendererScale);
|
|
182
|
+
const localOriginY = localLayerBounds[1] / (cacheScaleY * rendererScale);
|
|
183
|
+
const missScreenX = matrix[0] * localOriginX + matrix[2] * localOriginY + matrix[4];
|
|
184
|
+
const missScreenY = matrix[1] * localOriginX + matrix[3] * localOriginY + matrix[5];
|
|
185
|
+
// HITパスと同じ規則: filter layer 内では cacheScale 乗算を省略
|
|
186
|
+
const missMatrixScaleX = in_filter_layer ? 1 : cacheScaleX;
|
|
187
|
+
const missMatrixScaleY = in_filter_layer ? 1 : cacheScaleY;
|
|
188
|
+
renderQueue.push(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], cacheFilterParams.length);
|
|
189
|
+
if (cacheFilterParams.length > 0) {
|
|
190
|
+
renderQueue.set(new Float32Array(cacheFilterParams));
|
|
191
|
+
}
|
|
192
|
+
// 子要素の描画マトリクスをローカル空間に切り替え(親matrixの位置・回転を除外)
|
|
193
|
+
// cacheParentMatrixにrawMatrixを乗算し、layerBoundsオフセットで原点を調整
|
|
194
|
+
let localMatrix;
|
|
195
|
+
if (rawMatrix) {
|
|
196
|
+
localMatrix = Matrix.multiply(cacheParentMatrix, rawMatrix);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
localMatrix = $getFloat32Array6(cacheParentMatrix[0], 0, 0, cacheParentMatrix[3], 0, 0);
|
|
200
|
+
}
|
|
201
|
+
const localTx = localMatrix[4] - localLayerBounds[0];
|
|
202
|
+
const localTy = localMatrix[5] - localLayerBounds[1];
|
|
203
|
+
if (tMatrix !== matrix) {
|
|
204
|
+
Matrix.release(tMatrix);
|
|
205
|
+
}
|
|
206
|
+
tMatrix = $getFloat32Array6(localMatrix[0], localMatrix[1], localMatrix[2], localMatrix[3], localTx, localTy);
|
|
207
|
+
if (rawMatrix) {
|
|
208
|
+
Matrix.release(localMatrix);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
$poolFloat32Array6(localMatrix);
|
|
212
|
+
}
|
|
213
|
+
Matrix.release(cacheParentMatrix);
|
|
214
|
+
if (tColorTransform !== color_transform) {
|
|
215
|
+
ColorTransform.release(tColorTransform);
|
|
216
|
+
}
|
|
217
|
+
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
218
|
+
// HIT時の高速パス用にローカルバウンズをキャッシュ(poolする前に保存)
|
|
219
|
+
$cacheStore.set(`${display_object_container.instanceId}`, "bLocalBounds", new Float32Array([localLayerBounds[0], localLayerBounds[1], localLayerBounds[2], localLayerBounds[3]]));
|
|
220
|
+
$poolBoundsArray(localLayerBounds);
|
|
221
|
+
$poolBoundsArray(cacheFilterBounds);
|
|
222
|
+
$cacheStore.set(`${display_object_container.instanceId}`, "bitmapKey", bitmapCacheKey);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
// filters
|
|
226
|
+
const filters = display_object_container.filters;
|
|
227
|
+
if (filters) {
|
|
228
|
+
const filterKey = $cacheStore.generateFilterKeys(tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3]);
|
|
229
|
+
const filterCache = $cacheStore.get(`${display_object_container.instanceId}`, `${filterKey}`);
|
|
230
|
+
let updated = false;
|
|
231
|
+
const params = [];
|
|
232
|
+
const bounds = $getBoundsArray(0, 0, 0, 0);
|
|
233
|
+
for (let idx = 0; idx < filters.length; idx++) {
|
|
234
|
+
const filter = filters[idx];
|
|
235
|
+
if (!filter || !filter.canApplyFilter()) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
// フィルターが更新されたかをチェック
|
|
239
|
+
if (filter.$updated) {
|
|
240
|
+
updated = true;
|
|
241
|
+
}
|
|
242
|
+
filter.$updated = false;
|
|
243
|
+
filter.getBounds(bounds);
|
|
244
|
+
const buffer = filter.toNumberArray();
|
|
245
|
+
for (let idx = 0; idx < buffer.length; idx += 4096) {
|
|
246
|
+
params.push(...buffer.subarray(idx, idx + 4096));
|
|
247
|
+
}
|
|
113
248
|
}
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
//
|
|
249
|
+
const useFilfer = params.length > 0;
|
|
250
|
+
if (useFilfer) {
|
|
251
|
+
// 子の変更があった場合は親のフラグが立っているので更新
|
|
117
252
|
if (!updated) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
253
|
+
updated = display_object_container.changed;
|
|
254
|
+
}
|
|
255
|
+
const layerBounds = displayObjectContainerGetLayerBoundsUseCase(display_object_container, matrix);
|
|
256
|
+
// 子孫にcacheAsBitmapを持つ要素があれば、そのスケールに合わせて
|
|
257
|
+
// filterレイヤーの解像度を引き上げる。これにより親レイヤー内で
|
|
258
|
+
// 子のcacheScale倍テクスチャが端まで収まる (issue #274 発展対応)。
|
|
259
|
+
const layerScale = new Float32Array([1, 1]);
|
|
260
|
+
displayObjectContainerGetLayerScaleUseCase(display_object_container, layerScale);
|
|
261
|
+
const layerScaleX = layerScale[0];
|
|
262
|
+
const layerScaleY = layerScale[1];
|
|
263
|
+
const layerWidth = Math.ceil(Math.abs(layerBounds[2] - layerBounds[0]) * layerScaleX);
|
|
264
|
+
const layerHeight = Math.ceil(Math.abs(layerBounds[3] - layerBounds[1]) * layerScaleY);
|
|
265
|
+
if (filterCache) {
|
|
266
|
+
// キャッシュがあって、変更がなければキャッシュを使用
|
|
267
|
+
if (!updated) {
|
|
268
|
+
renderQueue.push(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
|
+
$poolBoundsArray(layerBounds);
|
|
270
|
+
$poolBoundsArray(bounds);
|
|
271
|
+
if (tColorTransform !== color_transform) {
|
|
272
|
+
ColorTransform.release(tColorTransform);
|
|
273
|
+
}
|
|
274
|
+
if (tMatrix !== matrix) {
|
|
275
|
+
Matrix.release(tMatrix);
|
|
276
|
+
}
|
|
277
|
+
return;
|
|
123
278
|
}
|
|
279
|
+
// どこかで変更があったので、キャッシュを削除
|
|
280
|
+
$cacheStore.removeById(`${display_object_container.instanceId}`);
|
|
281
|
+
}
|
|
282
|
+
renderQueue.push(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], params.length);
|
|
283
|
+
renderQueue.set(new Float32Array(params));
|
|
284
|
+
// 子に渡すtMatrixは layerScale 倍で scale して、layer 内の
|
|
285
|
+
// 拡張座標系で描画させる。layer自体は compose時に 1/layerScaleで
|
|
286
|
+
// 縮小合成され最終的に元サイズで表示される。
|
|
287
|
+
const fa0 = tMatrix[0] * layerScaleX;
|
|
288
|
+
const fa1 = tMatrix[1] * layerScaleX;
|
|
289
|
+
const fa2 = tMatrix[2] * layerScaleY;
|
|
290
|
+
const fa3 = tMatrix[3] * layerScaleY;
|
|
291
|
+
const faTx = (tMatrix[4] - layerBounds[0]) * layerScaleX;
|
|
292
|
+
const faTy = (tMatrix[5] - layerBounds[1]) * layerScaleY;
|
|
293
|
+
if (tMatrix !== matrix) {
|
|
294
|
+
Matrix.release(tMatrix);
|
|
295
|
+
}
|
|
296
|
+
tMatrix = $getFloat32Array6(fa0, fa1, fa2, fa3, faTx, faTy);
|
|
297
|
+
if (tColorTransform !== color_transform) {
|
|
298
|
+
ColorTransform.release(tColorTransform);
|
|
299
|
+
}
|
|
300
|
+
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
301
|
+
$poolBoundsArray(layerBounds);
|
|
302
|
+
$cacheStore.set(`${display_object_container.instanceId}`, `${filterKey}`, true);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
if (blendMode === "normal") {
|
|
306
|
+
renderQueue.push(0);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
// ブレンドモードのみのLayerモード
|
|
310
|
+
const layerBounds = displayObjectContainerCalcBoundsMatrixUseCase(display_object_container, matrix);
|
|
311
|
+
const layerXMin = layerBounds[0];
|
|
312
|
+
const layerYMin = layerBounds[1];
|
|
313
|
+
renderQueue.push(1, Math.ceil(Math.abs(layerBounds[2] - layerXMin)), Math.ceil(Math.abs(layerBounds[3] - layerYMin)), 0, // not use filter,
|
|
314
|
+
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]);
|
|
315
|
+
const a0 = tMatrix[0];
|
|
316
|
+
const a1 = tMatrix[1];
|
|
317
|
+
const a2 = tMatrix[2];
|
|
318
|
+
const a3 = tMatrix[3];
|
|
319
|
+
const adjustedTx1 = tMatrix[4] - layerXMin;
|
|
320
|
+
const adjustedTy1 = tMatrix[5] - layerYMin;
|
|
124
321
|
if (tMatrix !== matrix) {
|
|
125
322
|
Matrix.release(tMatrix);
|
|
126
323
|
}
|
|
127
|
-
|
|
324
|
+
tMatrix = $getFloat32Array6(a0, a1, a2, a3, adjustedTx1, adjustedTy1);
|
|
325
|
+
$poolBoundsArray(layerBounds);
|
|
326
|
+
if (tColorTransform !== color_transform) {
|
|
327
|
+
ColorTransform.release(tColorTransform);
|
|
328
|
+
}
|
|
329
|
+
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
128
330
|
}
|
|
129
|
-
// どこかで変更があったので、キャッシュを削除
|
|
130
|
-
$cacheStore.removeById(`${display_object_container.instanceId}`);
|
|
131
331
|
}
|
|
132
|
-
|
|
133
|
-
renderQueue.set(new Float32Array(params));
|
|
134
|
-
const fa0 = tMatrix[0];
|
|
135
|
-
const fa1 = tMatrix[1];
|
|
136
|
-
const fa2 = tMatrix[2];
|
|
137
|
-
const fa3 = tMatrix[3];
|
|
138
|
-
const faTx = tMatrix[4] - layerBounds[0];
|
|
139
|
-
const faTy = tMatrix[5] - layerBounds[1];
|
|
140
|
-
if (tMatrix !== matrix) {
|
|
141
|
-
Matrix.release(tMatrix);
|
|
142
|
-
}
|
|
143
|
-
tMatrix = $getFloat32Array6(fa0, fa1, fa2, fa3, faTx, faTy);
|
|
144
|
-
if (tColorTransform !== color_transform) {
|
|
145
|
-
ColorTransform.release(tColorTransform);
|
|
146
|
-
}
|
|
147
|
-
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
148
|
-
$poolBoundsArray(layerBounds);
|
|
149
|
-
$cacheStore.set(`${display_object_container.instanceId}`, `${filterKey}`, true);
|
|
332
|
+
$poolBoundsArray(bounds);
|
|
150
333
|
}
|
|
151
334
|
else {
|
|
152
335
|
if (blendMode === "normal") {
|
|
153
336
|
renderQueue.push(0);
|
|
154
337
|
}
|
|
155
338
|
else {
|
|
156
|
-
// ブレンドモードのみのLayerモード
|
|
157
339
|
const layerBounds = displayObjectContainerCalcBoundsMatrixUseCase(display_object_container, matrix);
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
renderQueue.push(1, Math.ceil(Math.abs(layerBounds[2] -
|
|
161
|
-
tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3],
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
const
|
|
340
|
+
const layerXMin2 = layerBounds[0];
|
|
341
|
+
const layerYMin2 = layerBounds[1];
|
|
342
|
+
renderQueue.push(1, Math.ceil(Math.abs(layerBounds[2] - layerXMin2)), Math.ceil(Math.abs(layerBounds[3] - layerYMin2)), 0, // not use filter,
|
|
343
|
+
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]);
|
|
344
|
+
const b0 = tMatrix[0];
|
|
345
|
+
const b1 = tMatrix[1];
|
|
346
|
+
const b2 = tMatrix[2];
|
|
347
|
+
const b3 = tMatrix[3];
|
|
348
|
+
const adjustedTx2 = tMatrix[4] - layerXMin2;
|
|
349
|
+
const adjustedTy2 = tMatrix[5] - layerYMin2;
|
|
168
350
|
if (tMatrix !== matrix) {
|
|
169
351
|
Matrix.release(tMatrix);
|
|
170
352
|
}
|
|
171
|
-
tMatrix = $getFloat32Array6(
|
|
353
|
+
tMatrix = $getFloat32Array6(b0, b1, b2, b3, adjustedTx2, adjustedTy2);
|
|
172
354
|
$poolBoundsArray(layerBounds);
|
|
173
355
|
if (tColorTransform !== color_transform) {
|
|
174
356
|
ColorTransform.release(tColorTransform);
|
|
@@ -176,35 +358,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
176
358
|
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
177
359
|
}
|
|
178
360
|
}
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
if (blendMode === "normal") {
|
|
183
|
-
renderQueue.push(0);
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
const layerBounds = displayObjectContainerCalcBoundsMatrixUseCase(display_object_container, matrix);
|
|
187
|
-
const layerXMin2 = layerBounds[0];
|
|
188
|
-
const layerYMin2 = layerBounds[1];
|
|
189
|
-
renderQueue.push(1, Math.ceil(Math.abs(layerBounds[2] - layerXMin2)), Math.ceil(Math.abs(layerBounds[3] - layerYMin2)), 0, // not use filter,
|
|
190
|
-
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]);
|
|
191
|
-
const b0 = tMatrix[0];
|
|
192
|
-
const b1 = tMatrix[1];
|
|
193
|
-
const b2 = tMatrix[2];
|
|
194
|
-
const b3 = tMatrix[3];
|
|
195
|
-
const adjustedTx2 = tMatrix[4] - layerXMin2;
|
|
196
|
-
const adjustedTy2 = tMatrix[5] - layerYMin2;
|
|
197
|
-
if (tMatrix !== matrix) {
|
|
198
|
-
Matrix.release(tMatrix);
|
|
199
|
-
}
|
|
200
|
-
tMatrix = $getFloat32Array6(b0, b1, b2, b3, adjustedTx2, adjustedTy2);
|
|
201
|
-
$poolBoundsArray(layerBounds);
|
|
202
|
-
if (tColorTransform !== color_transform) {
|
|
203
|
-
ColorTransform.release(tColorTransform);
|
|
204
|
-
}
|
|
205
|
-
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
361
|
+
} // end cacheAsBitmap else
|
|
208
362
|
// mask
|
|
209
363
|
const maskDisplayObject = display_object_container.mask;
|
|
210
364
|
if (maskDisplayObject) {
|
|
@@ -277,9 +431,13 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
277
431
|
child.changed = false;
|
|
278
432
|
continue;
|
|
279
433
|
}
|
|
434
|
+
// 自身が filter を発動した、または既に filter layer 内にいる場合は、
|
|
435
|
+
// 子コンテナに伝播して cacheAsBitmap 合成scaleの二重適用を防ぐ
|
|
436
|
+
const childInFilterLayer = in_filter_layer
|
|
437
|
+
|| Boolean(display_object_container.filters && display_object_container.filters.length);
|
|
280
438
|
switch (true) {
|
|
281
439
|
case child.isContainerEnabled: // 0x00
|
|
282
|
-
execute(child, image_bitmaps, tMatrix, tColorTransform, renderer_width, renderer_height);
|
|
440
|
+
execute(child, image_bitmaps, tMatrix, tColorTransform, renderer_width, renderer_height, childInFilterLayer);
|
|
283
441
|
break;
|
|
284
442
|
case child.isShape: // 0x01
|
|
285
443
|
shapeGenerateRenderQueueUseCase(child, tMatrix, tColorTransform, renderer_width, renderer_height);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DisplayObjectContainer } from "../../DisplayObjectContainer";
|
|
2
|
+
/**
|
|
3
|
+
* @description コンテナ内部の子孫が描画時に必要とする最大cacheAsBitmapスケールを返却します。
|
|
4
|
+
* 親がfilter/cacheAsBitmap等のレイヤーを作成する際、そのテクスチャの解像度を
|
|
5
|
+
* 子孫のcacheScaleに合わせて拡張しないと、描画時にテクスチャ不足で端が欠ける。
|
|
6
|
+
* 戻り値は [scaleX, scaleY] の2要素で、いずれも1以上。
|
|
7
|
+
* Return the maximum cacheAsBitmap scale required by descendants.
|
|
8
|
+
* The parent layer texture must reserve this much resolution to avoid
|
|
9
|
+
* cropping descendants that render at cacheScale resolution.
|
|
10
|
+
*
|
|
11
|
+
* @param {DisplayObjectContainer} display_object_container
|
|
12
|
+
* @param {Float32Array} out [scaleX, scaleY] を格納するバッファ
|
|
13
|
+
* @return {void}
|
|
14
|
+
* @method
|
|
15
|
+
* @protected
|
|
16
|
+
*/
|
|
17
|
+
export declare const execute: <P extends DisplayObjectContainer>(display_object_container: P, out: Float32Array) => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description コンテナ内部の子孫が描画時に必要とする最大cacheAsBitmapスケールを返却します。
|
|
3
|
+
* 親がfilter/cacheAsBitmap等のレイヤーを作成する際、そのテクスチャの解像度を
|
|
4
|
+
* 子孫のcacheScaleに合わせて拡張しないと、描画時にテクスチャ不足で端が欠ける。
|
|
5
|
+
* 戻り値は [scaleX, scaleY] の2要素で、いずれも1以上。
|
|
6
|
+
* Return the maximum cacheAsBitmap scale required by descendants.
|
|
7
|
+
* The parent layer texture must reserve this much resolution to avoid
|
|
8
|
+
* cropping descendants that render at cacheScale resolution.
|
|
9
|
+
*
|
|
10
|
+
* @param {DisplayObjectContainer} display_object_container
|
|
11
|
+
* @param {Float32Array} out [scaleX, scaleY] を格納するバッファ
|
|
12
|
+
* @return {void}
|
|
13
|
+
* @method
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
16
|
+
export const execute = (display_object_container, out) => {
|
|
17
|
+
const children = display_object_container.children;
|
|
18
|
+
for (let idx = 0; idx < children.length; idx++) {
|
|
19
|
+
const child = children[idx];
|
|
20
|
+
if (!child || !child.visible) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (child.isContainerEnabled) {
|
|
24
|
+
const container = child;
|
|
25
|
+
const cache = container.cacheAsBitmap;
|
|
26
|
+
if (cache) {
|
|
27
|
+
const m = cache.rawData;
|
|
28
|
+
const csx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
|
|
29
|
+
const csy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
|
|
30
|
+
if (csx > out[0]) {
|
|
31
|
+
out[0] = csx;
|
|
32
|
+
}
|
|
33
|
+
if (csy > out[1]) {
|
|
34
|
+
out[1] = csy;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// 孫以下にも cacheAsBitmap がある可能性があるため再帰
|
|
38
|
+
execute(container, out);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -3,7 +3,7 @@ import { execute as displayObjectGetRawMatrixUseCase } from "../../DisplayObject
|
|
|
3
3
|
import { execute as shapeHitTestUseCase } from "../../Shape/usecase/ShapeHitTestUseCase";
|
|
4
4
|
import { execute as textFieldHitTestUseCase } from "../../TextField/usecase/TextFieldHitTestUseCase";
|
|
5
5
|
import { execute as videoHitTestUseCase } from "../../Video/usecase/VideoHitTestUseCase";
|
|
6
|
-
import { $getArray, $poolArray, $getMap, $poolMap } from "../../DisplayObjectUtil";
|
|
6
|
+
import { $getArray, $poolArray, $getMap, $poolMap, $getFloat32Array6, $poolFloat32Array6 } from "../../DisplayObjectUtil";
|
|
7
7
|
/**
|
|
8
8
|
* @description コンテナ内のヒット判定
|
|
9
9
|
* Hit judgment in the container
|
|
@@ -22,10 +22,28 @@ export const execute = (display_object_container, hit_context, matrix, hit_objec
|
|
|
22
22
|
if (!children.length) {
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
let rawMatrix = displayObjectGetRawMatrixUseCase(display_object_container);
|
|
26
|
+
// cacheAsBitmap倍率をrawMatrixに適用(Shapeと同じ方式)
|
|
27
|
+
const cacheMatrix = display_object_container.cacheAsBitmap;
|
|
28
|
+
let scaledMatrix = null;
|
|
29
|
+
if (cacheMatrix) {
|
|
30
|
+
const cm = cacheMatrix.rawData;
|
|
31
|
+
const csx = Math.sqrt(cm[0] * cm[0] + cm[1] * cm[1]);
|
|
32
|
+
const csy = Math.sqrt(cm[2] * cm[2] + cm[3] * cm[3]);
|
|
33
|
+
if (rawMatrix) {
|
|
34
|
+
scaledMatrix = $getFloat32Array6(rawMatrix[0] * csx, rawMatrix[1] * csx, rawMatrix[2] * csy, rawMatrix[3] * csy, rawMatrix[4], rawMatrix[5]);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
scaledMatrix = $getFloat32Array6(csx, 0, 0, csy, 0, 0);
|
|
38
|
+
}
|
|
39
|
+
rawMatrix = scaledMatrix;
|
|
40
|
+
}
|
|
26
41
|
const tMatrix = rawMatrix
|
|
27
42
|
? Matrix.multiply(matrix, rawMatrix)
|
|
28
43
|
: matrix;
|
|
44
|
+
if (scaledMatrix) {
|
|
45
|
+
$poolFloat32Array6(scaledMatrix);
|
|
46
|
+
}
|
|
29
47
|
// mask set
|
|
30
48
|
const clips = $getArray();
|
|
31
49
|
const targets = $getArray();
|
|
@@ -92,7 +92,9 @@ export const execute = (recodes) => {
|
|
|
92
92
|
const color = sortStops[idx];
|
|
93
93
|
array.push(color.ratio, color.R, color.G, color.B, color.A);
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
// JSON由来のデシリアライズではFloat32Arrayがkeyed object
|
|
96
|
+
// ({0:v,...,5:v})になるためspreadではなくindexアクセスで読む
|
|
97
|
+
array.push(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
96
98
|
switch (spread) {
|
|
97
99
|
case "reflect":
|
|
98
100
|
array.push(0);
|
|
@@ -157,7 +159,9 @@ export const execute = (recodes) => {
|
|
|
157
159
|
const color = stops[idx];
|
|
158
160
|
array.push(color.ratio, color.R, color.G, color.B, color.A);
|
|
159
161
|
}
|
|
160
|
-
|
|
162
|
+
// JSON由来のデシリアライズではFloat32Arrayがkeyed object
|
|
163
|
+
// ({0:v,...,5:v})になるためspreadではなくindexアクセスで読む
|
|
164
|
+
array.push(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
161
165
|
switch (spread) {
|
|
162
166
|
case "reflect":
|
|
163
167
|
array.push(0);
|
|
@@ -12,11 +12,18 @@ import { $unzipWorker } from "../worker/UnzipWorker";
|
|
|
12
12
|
*/
|
|
13
13
|
export const execute = async (loader, object) => {
|
|
14
14
|
if (object.type === "zlib") {
|
|
15
|
-
await new Promise((resolve) => {
|
|
15
|
+
await new Promise((resolve, reject) => {
|
|
16
16
|
$unzipWorker.onmessage = (event) => {
|
|
17
|
+
if (event.data && event.data.error) {
|
|
18
|
+
reject(new Error(event.data.error));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
17
21
|
loaderBuildService(loader, event.data);
|
|
18
22
|
resolve();
|
|
19
23
|
};
|
|
24
|
+
$unzipWorker.onerror = (event) => {
|
|
25
|
+
reject(new Error(event.message));
|
|
26
|
+
};
|
|
20
27
|
const buffer = new Uint8Array(object.buffer);
|
|
21
28
|
$unzipWorker.postMessage(buffer, [buffer.buffer]);
|
|
22
29
|
});
|