@next2d/display 3.0.5 → 3.1.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.d.ts +40 -1
- package/src/DisplayObject.js +73 -2
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerCalcBoundsMatrixUseCase.js +20 -2
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateRenderQueueUseCase.js +227 -96
- package/src/DisplayObjectContainer/usecase/DisplayObjectContainerMouseHitUseCase.js +20 -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
|
@@ -9,9 +9,10 @@ import { execute as displayObjectContainerGenerateClipQueueUseCase } from "../..
|
|
|
9
9
|
import { execute as displayObjectBlendToNumberService } from "../../DisplayObject/service/DisplayObjectBlendToNumberService";
|
|
10
10
|
import { execute as displayObjectContainerGetLayerBoundsUseCase } from "./DisplayObjectContainerGetLayerBoundsUseCase";
|
|
11
11
|
import { execute as displayObjectContainerCalcBoundsMatrixUseCase } from "../../DisplayObjectContainer/usecase/DisplayObjectContainerCalcBoundsMatrixUseCase";
|
|
12
|
+
import { stage } from "../../Stage";
|
|
12
13
|
import { renderQueue } from "@next2d/render-queue";
|
|
13
14
|
import { $cacheStore } from "@next2d/cache";
|
|
14
|
-
import { $clamp, $getBoundsArray, $poolBoundsArray, $RENDERER_CONTAINER_TYPE, $getFloat32Array8, $getFloat32Array6 } from "../../DisplayObjectUtil";
|
|
15
|
+
import { $clamp, $getBoundsArray, $poolBoundsArray, $RENDERER_CONTAINER_TYPE, $getFloat32Array8, $getFloat32Array6, $poolFloat32Array6 } from "../../DisplayObjectUtil";
|
|
15
16
|
import { ColorTransform, Matrix } from "@next2d/geom";
|
|
16
17
|
/**
|
|
17
18
|
* @description renderer workerに渡すコンテナの描画データを生成
|
|
@@ -81,94 +82,252 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
81
82
|
// blendMode
|
|
82
83
|
const blendMode = display_object_container.blendMode;
|
|
83
84
|
renderQueue.push(displayObjectBlendToNumberService(blendMode));
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
// cacheAsBitmap: フィルターキャッシュ形式でコンテナ全体をビットマップキャッシュ
|
|
86
|
+
// キャッシュテクスチャは親のスケールを含むサイズで描画し、
|
|
87
|
+
// コンポジットは setTransform(1,0,0,1,x,y) で1:1描画されるため正しい画面サイズになる
|
|
88
|
+
// 親の移動はキャッシュヒット(位置だけ更新)、スケール変更はキャッシュミス(再描画)
|
|
89
|
+
const cacheMatrix = display_object_container.cacheAsBitmap;
|
|
90
|
+
if (cacheMatrix) {
|
|
91
|
+
const m = cacheMatrix.rawData;
|
|
92
|
+
const cacheScaleX = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
|
|
93
|
+
const cacheScaleY = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
|
|
94
|
+
const ownScaleX = rawMatrix
|
|
95
|
+
? Math.sqrt(rawMatrix[0] * rawMatrix[0] + rawMatrix[1] * rawMatrix[1])
|
|
96
|
+
: 1;
|
|
97
|
+
const ownScaleY = rawMatrix
|
|
98
|
+
? Math.sqrt(rawMatrix[2] * rawMatrix[2] + rawMatrix[3] * rawMatrix[3])
|
|
99
|
+
: 1;
|
|
100
|
+
// Shape/TextFieldと同様にstage.rendererScaleを使用
|
|
101
|
+
// matrixから抽出すると親のアニメーション(スケール変動)でキーが揺れて
|
|
102
|
+
// 毎フレームcache MISSが発生する原因になる
|
|
103
|
+
const rendererScale = stage.rendererScale;
|
|
104
|
+
// コンポジットスケール = cacheScale × ownScale × rendererScale
|
|
105
|
+
const renderScaleX = cacheScaleX * ownScaleX * rendererScale;
|
|
106
|
+
const renderScaleY = cacheScaleY * ownScaleY * rendererScale;
|
|
107
|
+
const xRounded = Math.round(renderScaleX * 100) / 100;
|
|
108
|
+
const yRounded = Math.round(renderScaleY * 100) / 100;
|
|
109
|
+
const bitmapCacheKey = $cacheStore.generateKeys(xRounded, yRounded, tColorTransform[7]);
|
|
110
|
+
// 固定プロパティ名で最新のキーのみ保存(古いキーが蓄積されないようにする)
|
|
111
|
+
// レンダラーも最新のfKeyのみ保持するため、キーの一致を保証
|
|
112
|
+
const bitmapCache = $cacheStore.get(`${display_object_container.instanceId}`, "bitmapKey") === bitmapCacheKey;
|
|
113
|
+
// コンテナ自身のフィルター境界を収集
|
|
114
|
+
const cacheFilters = display_object_container.filters;
|
|
115
|
+
const cacheFilterBounds = $getBoundsArray(0, 0, 0, 0);
|
|
116
|
+
if (cacheFilters) {
|
|
117
|
+
for (let idx = 0; idx < cacheFilters.length; idx++) {
|
|
118
|
+
const filter = cacheFilters[idx];
|
|
119
|
+
if (!filter || !filter.canApplyFilter()) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
filter.getBounds(cacheFilterBounds);
|
|
96
123
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
124
|
+
}
|
|
125
|
+
if (bitmapCache) {
|
|
126
|
+
// cacheAsBitmap cache hit: 子要素走査をスキップして高速パス
|
|
127
|
+
// Shapeと同様に親matrixをレンダラーに渡し、描画時にcacheScaleで補正
|
|
128
|
+
const cachedLocalBounds = $cacheStore.get(`${display_object_container.instanceId}`, "bLocalBounds");
|
|
129
|
+
if (cachedLocalBounds) {
|
|
130
|
+
// ローカルバウンズ原点のスクリーン座標を計算(Shapeと同じ方式)
|
|
131
|
+
const localOriginX = cachedLocalBounds[0] / (cacheScaleX * rendererScale);
|
|
132
|
+
const localOriginY = cachedLocalBounds[1] / (cacheScaleY * rendererScale);
|
|
133
|
+
const screenX = matrix[0] * localOriginX + matrix[2] * localOriginY + matrix[4];
|
|
134
|
+
const screenY = matrix[1] * localOriginX + matrix[3] * localOriginY + matrix[5];
|
|
135
|
+
// Shapeと同様にmatrixにcacheScaleを乗算して送る
|
|
136
|
+
// レンダラーで matrix/renderScale → cacheScale成分が反映される
|
|
137
|
+
renderQueue.push(1, 0, 0, // layerWidth/Height: HIT時は未使用
|
|
138
|
+
2, 1, display_object_container.instanceId, bitmapCacheKey, cacheFilterBounds[0], cacheFilterBounds[1], cacheFilterBounds[2], cacheFilterBounds[3], renderScaleX, renderScaleY, matrix[0] * cacheScaleX, matrix[1] * cacheScaleX, matrix[2] * cacheScaleY, matrix[3] * cacheScaleY, screenX, screenY, tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7]);
|
|
139
|
+
$poolBoundsArray(cacheFilterBounds);
|
|
140
|
+
if (tColorTransform !== color_transform) {
|
|
141
|
+
ColorTransform.release(tColorTransform);
|
|
142
|
+
}
|
|
143
|
+
if (tMatrix !== matrix) {
|
|
144
|
+
Matrix.release(tMatrix);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
100
147
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
148
|
+
// cachedLocalBoundsがない場合はMISSにフォールスルー
|
|
149
|
+
}
|
|
150
|
+
// cacheAsBitmap cache miss: 初回描画
|
|
151
|
+
// 親matrixのスケール成分のみを含むローカル空間でキャッシュを生成する
|
|
152
|
+
// (親の位置・回転は含まず、スケールのみ反映してテクスチャサイズを画面と一致させる)
|
|
153
|
+
// フィルターパラメータを収集
|
|
154
|
+
const cacheFilterParams = [];
|
|
155
|
+
if (cacheFilters) {
|
|
156
|
+
for (let idx = 0; idx < cacheFilters.length; idx++) {
|
|
157
|
+
const filter = cacheFilters[idx];
|
|
158
|
+
if (!filter || !filter.canApplyFilter()) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const buffer = filter.toNumberArray();
|
|
162
|
+
for (let idx = 0; idx < buffer.length; idx += 4096) {
|
|
163
|
+
cacheFilterParams.push(...buffer.subarray(idx, idx + 4096));
|
|
164
|
+
}
|
|
106
165
|
}
|
|
107
166
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
167
|
+
// キャッシュ描画用の親matrix: cacheScale × rendererScale(対角行列)
|
|
168
|
+
const cacheParentMatrix = $getFloat32Array6(cacheScaleX * rendererScale, 0, 0, cacheScaleY * rendererScale, 0, 0);
|
|
169
|
+
const localLayerBounds = displayObjectContainerGetLayerBoundsUseCase(display_object_container, cacheParentMatrix);
|
|
170
|
+
const localLayerWidth = Math.ceil(Math.abs(localLayerBounds[2] - localLayerBounds[0]));
|
|
171
|
+
const localLayerHeight = Math.ceil(Math.abs(localLayerBounds[3] - localLayerBounds[1]));
|
|
172
|
+
// Shapeと同じ方式でスクリーン座標を計算
|
|
173
|
+
const localOriginX = localLayerBounds[0] / (cacheScaleX * rendererScale);
|
|
174
|
+
const localOriginY = localLayerBounds[1] / (cacheScaleY * rendererScale);
|
|
175
|
+
const missScreenX = matrix[0] * localOriginX + matrix[2] * localOriginY + matrix[4];
|
|
176
|
+
const missScreenY = matrix[1] * localOriginX + matrix[3] * localOriginY + matrix[5];
|
|
177
|
+
renderQueue.push(1, localLayerWidth, localLayerHeight, 2, 0, display_object_container.instanceId, bitmapCacheKey, cacheFilterBounds[0], cacheFilterBounds[1], cacheFilterBounds[2], cacheFilterBounds[3], renderScaleX, renderScaleY, matrix[0] * cacheScaleX, matrix[1] * cacheScaleX, matrix[2] * cacheScaleY, matrix[3] * cacheScaleY, missScreenX, missScreenY, tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7], cacheFilterParams.length);
|
|
178
|
+
if (cacheFilterParams.length > 0) {
|
|
179
|
+
renderQueue.set(new Float32Array(cacheFilterParams));
|
|
180
|
+
}
|
|
181
|
+
// 子要素の描画マトリクスをローカル空間に切り替え(親matrixの位置・回転を除外)
|
|
182
|
+
// cacheParentMatrixにrawMatrixを乗算し、layerBoundsオフセットで原点を調整
|
|
183
|
+
let localMatrix;
|
|
184
|
+
if (rawMatrix) {
|
|
185
|
+
localMatrix = Matrix.multiply(cacheParentMatrix, rawMatrix);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
localMatrix = $getFloat32Array6(cacheParentMatrix[0], 0, 0, cacheParentMatrix[3], 0, 0);
|
|
189
|
+
}
|
|
190
|
+
const localTx = localMatrix[4] - localLayerBounds[0];
|
|
191
|
+
const localTy = localMatrix[5] - localLayerBounds[1];
|
|
192
|
+
if (tMatrix !== matrix) {
|
|
193
|
+
Matrix.release(tMatrix);
|
|
194
|
+
}
|
|
195
|
+
tMatrix = $getFloat32Array6(localMatrix[0], localMatrix[1], localMatrix[2], localMatrix[3], localTx, localTy);
|
|
196
|
+
if (rawMatrix) {
|
|
197
|
+
Matrix.release(localMatrix);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
$poolFloat32Array6(localMatrix);
|
|
201
|
+
}
|
|
202
|
+
Matrix.release(cacheParentMatrix);
|
|
203
|
+
if (tColorTransform !== color_transform) {
|
|
204
|
+
ColorTransform.release(tColorTransform);
|
|
205
|
+
}
|
|
206
|
+
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
207
|
+
// HIT時の高速パス用にローカルバウンズをキャッシュ(poolする前に保存)
|
|
208
|
+
$cacheStore.set(`${display_object_container.instanceId}`, "bLocalBounds", new Float32Array([localLayerBounds[0], localLayerBounds[1], localLayerBounds[2], localLayerBounds[3]]));
|
|
209
|
+
$poolBoundsArray(localLayerBounds);
|
|
210
|
+
$poolBoundsArray(cacheFilterBounds);
|
|
211
|
+
$cacheStore.set(`${display_object_container.instanceId}`, "bitmapKey", bitmapCacheKey);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
// filters
|
|
215
|
+
const filters = display_object_container.filters;
|
|
216
|
+
if (filters) {
|
|
217
|
+
const filterKey = $cacheStore.generateFilterKeys(tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3]);
|
|
218
|
+
const filterCache = $cacheStore.get(`${display_object_container.instanceId}`, `${filterKey}`);
|
|
219
|
+
let updated = false;
|
|
220
|
+
const params = [];
|
|
221
|
+
const bounds = $getBoundsArray(0, 0, 0, 0);
|
|
222
|
+
for (let idx = 0; idx < filters.length; idx++) {
|
|
223
|
+
const filter = filters[idx];
|
|
224
|
+
if (!filter || !filter.canApplyFilter()) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
// フィルターが更新されたかをチェック
|
|
228
|
+
if (filter.$updated) {
|
|
229
|
+
updated = true;
|
|
230
|
+
}
|
|
231
|
+
filter.$updated = false;
|
|
232
|
+
filter.getBounds(bounds);
|
|
233
|
+
const buffer = filter.toNumberArray();
|
|
234
|
+
for (let idx = 0; idx < buffer.length; idx += 4096) {
|
|
235
|
+
params.push(...buffer.subarray(idx, idx + 4096));
|
|
236
|
+
}
|
|
113
237
|
}
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
//
|
|
238
|
+
const useFilfer = params.length > 0;
|
|
239
|
+
if (useFilfer) {
|
|
240
|
+
// 子の変更があった場合は親のフラグが立っているので更新
|
|
117
241
|
if (!updated) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
242
|
+
updated = display_object_container.changed;
|
|
243
|
+
}
|
|
244
|
+
const layerBounds = displayObjectContainerGetLayerBoundsUseCase(display_object_container, matrix);
|
|
245
|
+
if (filterCache) {
|
|
246
|
+
// キャッシュがあって、変更がなければキャッシュを使用
|
|
247
|
+
if (!updated) {
|
|
248
|
+
renderQueue.push(1, Math.ceil(Math.abs(layerBounds[2] - layerBounds[0])), Math.ceil(Math.abs(layerBounds[3] - layerBounds[1])), 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], tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7]);
|
|
249
|
+
$poolBoundsArray(layerBounds);
|
|
250
|
+
$poolBoundsArray(bounds);
|
|
251
|
+
if (tColorTransform !== color_transform) {
|
|
252
|
+
ColorTransform.release(tColorTransform);
|
|
253
|
+
}
|
|
254
|
+
if (tMatrix !== matrix) {
|
|
255
|
+
Matrix.release(tMatrix);
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
123
258
|
}
|
|
259
|
+
// どこかで変更があったので、キャッシュを削除
|
|
260
|
+
$cacheStore.removeById(`${display_object_container.instanceId}`);
|
|
261
|
+
}
|
|
262
|
+
renderQueue.push(1, Math.ceil(Math.abs(layerBounds[2] - layerBounds[0])), Math.ceil(Math.abs(layerBounds[3] - layerBounds[1])), 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], tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7], params.length);
|
|
263
|
+
renderQueue.set(new Float32Array(params));
|
|
264
|
+
const fa0 = tMatrix[0];
|
|
265
|
+
const fa1 = tMatrix[1];
|
|
266
|
+
const fa2 = tMatrix[2];
|
|
267
|
+
const fa3 = tMatrix[3];
|
|
268
|
+
const faTx = tMatrix[4] - layerBounds[0];
|
|
269
|
+
const faTy = tMatrix[5] - layerBounds[1];
|
|
270
|
+
if (tMatrix !== matrix) {
|
|
271
|
+
Matrix.release(tMatrix);
|
|
272
|
+
}
|
|
273
|
+
tMatrix = $getFloat32Array6(fa0, fa1, fa2, fa3, faTx, faTy);
|
|
274
|
+
if (tColorTransform !== color_transform) {
|
|
275
|
+
ColorTransform.release(tColorTransform);
|
|
276
|
+
}
|
|
277
|
+
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
278
|
+
$poolBoundsArray(layerBounds);
|
|
279
|
+
$cacheStore.set(`${display_object_container.instanceId}`, `${filterKey}`, true);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
if (blendMode === "normal") {
|
|
283
|
+
renderQueue.push(0);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
// ブレンドモードのみのLayerモード
|
|
287
|
+
const layerBounds = displayObjectContainerCalcBoundsMatrixUseCase(display_object_container, matrix);
|
|
288
|
+
const layerXMin = layerBounds[0];
|
|
289
|
+
const layerYMin = layerBounds[1];
|
|
290
|
+
renderQueue.push(1, Math.ceil(Math.abs(layerBounds[2] - layerXMin)), Math.ceil(Math.abs(layerBounds[3] - layerYMin)), 0, // not use filter,
|
|
291
|
+
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]);
|
|
292
|
+
const a0 = tMatrix[0];
|
|
293
|
+
const a1 = tMatrix[1];
|
|
294
|
+
const a2 = tMatrix[2];
|
|
295
|
+
const a3 = tMatrix[3];
|
|
296
|
+
const adjustedTx1 = tMatrix[4] - layerXMin;
|
|
297
|
+
const adjustedTy1 = tMatrix[5] - layerYMin;
|
|
124
298
|
if (tMatrix !== matrix) {
|
|
125
299
|
Matrix.release(tMatrix);
|
|
126
300
|
}
|
|
127
|
-
|
|
301
|
+
tMatrix = $getFloat32Array6(a0, a1, a2, a3, adjustedTx1, adjustedTy1);
|
|
302
|
+
$poolBoundsArray(layerBounds);
|
|
303
|
+
if (tColorTransform !== color_transform) {
|
|
304
|
+
ColorTransform.release(tColorTransform);
|
|
305
|
+
}
|
|
306
|
+
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
128
307
|
}
|
|
129
|
-
// どこかで変更があったので、キャッシュを削除
|
|
130
|
-
$cacheStore.removeById(`${display_object_container.instanceId}`);
|
|
131
308
|
}
|
|
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);
|
|
309
|
+
$poolBoundsArray(bounds);
|
|
150
310
|
}
|
|
151
311
|
else {
|
|
152
312
|
if (blendMode === "normal") {
|
|
153
313
|
renderQueue.push(0);
|
|
154
314
|
}
|
|
155
315
|
else {
|
|
156
|
-
// ブレンドモードのみのLayerモード
|
|
157
316
|
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
|
|
317
|
+
const layerXMin2 = layerBounds[0];
|
|
318
|
+
const layerYMin2 = layerBounds[1];
|
|
319
|
+
renderQueue.push(1, Math.ceil(Math.abs(layerBounds[2] - layerXMin2)), Math.ceil(Math.abs(layerBounds[3] - layerYMin2)), 0, // not use filter,
|
|
320
|
+
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]);
|
|
321
|
+
const b0 = tMatrix[0];
|
|
322
|
+
const b1 = tMatrix[1];
|
|
323
|
+
const b2 = tMatrix[2];
|
|
324
|
+
const b3 = tMatrix[3];
|
|
325
|
+
const adjustedTx2 = tMatrix[4] - layerXMin2;
|
|
326
|
+
const adjustedTy2 = tMatrix[5] - layerYMin2;
|
|
168
327
|
if (tMatrix !== matrix) {
|
|
169
328
|
Matrix.release(tMatrix);
|
|
170
329
|
}
|
|
171
|
-
tMatrix = $getFloat32Array6(
|
|
330
|
+
tMatrix = $getFloat32Array6(b0, b1, b2, b3, adjustedTx2, adjustedTy2);
|
|
172
331
|
$poolBoundsArray(layerBounds);
|
|
173
332
|
if (tColorTransform !== color_transform) {
|
|
174
333
|
ColorTransform.release(tColorTransform);
|
|
@@ -176,35 +335,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
|
|
|
176
335
|
tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
|
|
177
336
|
}
|
|
178
337
|
}
|
|
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
|
-
}
|
|
338
|
+
} // end cacheAsBitmap else
|
|
208
339
|
// mask
|
|
209
340
|
const maskDisplayObject = display_object_container.mask;
|
|
210
341
|
if (maskDisplayObject) {
|
|
@@ -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();
|
|
@@ -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
|
});
|