@next2d/display 3.2.1 → 3.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/display",
3
- "version": "3.2.1",
3
+ "version": "3.4.0",
4
4
  "description": "Next2D Display Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -24,13 +24,13 @@
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
26
  "dependencies": {
27
- "@next2d/ui": "3.2.1",
28
- "@next2d/text": "3.2.1",
29
- "@next2d/geom": "3.2.1",
30
- "@next2d/media": "3.2.1",
31
- "@next2d/net": "3.2.1",
32
- "@next2d/events": "3.2.1",
33
- "@next2d/filters": "3.2.1",
34
- "@next2d/render-queue": "3.2.1"
27
+ "@next2d/ui": "3.4.0",
28
+ "@next2d/text": "3.4.0",
29
+ "@next2d/geom": "3.4.0",
30
+ "@next2d/media": "3.4.0",
31
+ "@next2d/net": "3.4.0",
32
+ "@next2d/events": "3.4.0",
33
+ "@next2d/filters": "3.4.0",
34
+ "@next2d/render-queue": "3.4.0"
35
35
  }
36
36
  }
@@ -1,5 +1,6 @@
1
1
  import { Event } from "@next2d/events";
2
2
  import { $stageAssignedMap } from "../../DisplayObjectUtil";
3
+ import { $cacheStore } from "@next2d/cache";
3
4
  /**
4
5
  * @description DisplayObjectのADDED_TO_STAGEイベントを実行
5
6
  * Execute the ADDED_TO_STAGE event of DisplayObject
@@ -14,6 +15,13 @@ export const execute = (display_object) => {
14
15
  || !$stageAssignedMap.has(display_object.instanceId)) {
15
16
  return;
16
17
  }
18
+ // 一旦ステージから外れて削除タイマーに乗ったインスタンスがそのまま再復帰した場合、
19
+ // 1秒後の wipe で巻き添えにならないよう trash 登録を取り消す。
20
+ // ナビゲーション(毎回新インスタンス生成)では trash に該当 id がないため no-op。
21
+ if (display_object.uniqueKey) {
22
+ $cacheStore.cancelRemoveTimer(display_object.uniqueKey);
23
+ }
24
+ $cacheStore.cancelRemoveTimer(`${display_object.instanceId}`);
17
25
  display_object.$addedToStage = true;
18
26
  if (display_object.willTrigger(Event.ADDED_TO_STAGE)) {
19
27
  display_object.dispatchEvent(new Event(Event.ADDED_TO_STAGE));
@@ -24,4 +24,16 @@ export const execute = (display_object) => {
24
24
  && $cacheStore.has(display_object.uniqueKey)) {
25
25
  $cacheStore.removeTimer(display_object.uniqueKey);
26
26
  }
27
+ // instanceId ベースキャッシュの cleanup
28
+ // - コンテナの filter/cacheAsBitmap/blend (Main に "filterKey"/"bitmapKey" あり) → removeTimer (1秒猶予で再復帰可)
29
+ // - Shape/Text/Video の filter (ContextApplyFilterUseCase が Worker 側 "fKey"/"fTexture"/"offsetX"/"offsetY" を格納)
30
+ // は Main 側にエントリがないため、$removeIds に直接 push して Worker 側の GPU リソースを解放する。
31
+ // どちらも放置するとナビゲーション繰り返しでアトラス/GPU メモリが枯渇する。
32
+ const instanceIdKey = `${display_object.instanceId}`;
33
+ if ($cacheStore.has(instanceIdKey)) {
34
+ $cacheStore.removeTimer(instanceIdKey);
35
+ }
36
+ else {
37
+ $cacheStore.$removeIds.push(display_object.instanceId);
38
+ }
27
39
  };
@@ -226,7 +226,8 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
226
226
  const filters = display_object_container.filters;
227
227
  if (filters) {
228
228
  const filterKey = $cacheStore.generateFilterKeys(tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3]);
229
- const filterCache = $cacheStore.get(`${display_object_container.instanceId}`, `${filterKey}`);
229
+ const cachedFilterKey = $cacheStore.get(`${display_object_container.instanceId}`, "filterKey");
230
+ const filterCache = cachedFilterKey === filterKey;
230
231
  let updated = false;
231
232
  const params = [];
232
233
  const bounds = $getBoundsArray(0, 0, 0, 0);
@@ -262,23 +263,25 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
262
263
  const layerScaleY = layerScale[1];
263
264
  const layerWidth = Math.ceil(Math.abs(layerBounds[2] - layerBounds[0]) * layerScaleX);
264
265
  const layerHeight = Math.ceil(Math.abs(layerBounds[3] - layerBounds[1]) * layerScaleY);
265
- if (filterCache) {
266
+ if (filterCache && !updated) {
266
267
  // キャッシュがあって、変更がなければキャッシュを使用
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;
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);
278
276
  }
279
- // どこかで変更があったので、キャッシュを削除
280
- $cacheStore.removeById(`${display_object_container.instanceId}`);
277
+ return;
281
278
  }
279
+ // filterCache && updated の場合は MISS パスへフォールスルー。
280
+ // Main は直後の set("filterKey", ...) で上書きされ、Worker 側は
281
+ // ContextContainerEndLayerUseCase 内で旧 fTexture を解放してから
282
+ // 新しいテクスチャを保存するため、ここでの removeById/$removeIds.push は
283
+ // 不要。push してしまうと、Worker が同フレームで作成した新キャッシュを
284
+ // 次フレーム冒頭で wipe してしまい、その次の HIT で無描画になる。
282
285
  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
286
  renderQueue.set(new Float32Array(params));
284
287
  // 子に渡すtMatrixは layerScale 倍で scale して、layer 内の
@@ -299,7 +302,7 @@ export const execute = (display_object_container, image_bitmaps, matrix, color_t
299
302
  }
300
303
  tColorTransform = $getFloat32Array8(1, 1, 1, 1, 0, 0, 0, 0);
301
304
  $poolBoundsArray(layerBounds);
302
- $cacheStore.set(`${display_object_container.instanceId}`, `${filterKey}`, true);
305
+ $cacheStore.set(`${display_object_container.instanceId}`, "filterKey", filterKey);
303
306
  }
304
307
  else {
305
308
  if (blendMode === "normal") {
@@ -81,6 +81,16 @@ export const execute = (movie_clip, children) => {
81
81
  if (displayObject.uniqueKey && $cacheStore.has(displayObject.uniqueKey)) {
82
82
  $cacheStore.removeTimer(displayObject.uniqueKey);
83
83
  }
84
+ // コンテナの instanceId ベースキャッシュ → removeTimer (1秒猶予)
85
+ // Shape/Text/Video の filter キャッシュ (Main にエントリなし) → 直接 $removeIds.push
86
+ // どちらも Worker 側の GPU リソースを解放する。
87
+ const instanceIdKey = `${displayObject.instanceId}`;
88
+ if ($cacheStore.has(instanceIdKey)) {
89
+ $cacheStore.removeTimer(instanceIdKey);
90
+ }
91
+ else {
92
+ $cacheStore.$removeIds.push(displayObject.instanceId);
93
+ }
84
94
  if (displayObject.willTrigger(Event.REMOVED)) {
85
95
  displayObject.dispatchEvent(new Event(Event.REMOVED, true));
86
96
  }
@@ -15,9 +15,12 @@ export const execute = (shape) => {
15
15
  // graphics clear
16
16
  shape.graphics.clear();
17
17
  // cache clear
18
+ // Main 側のみ wipe する。Worker 側は次回 MISS 描画時に
19
+ // 旧 Node を解放してから新 Node を確保するため、ここで $removeIds.push しない。
20
+ // push してしまうと、Worker が同フレームで作成した新キャッシュを次フレーム冒頭で
21
+ // wipe → その次のフレームで Main HIT → Worker null → 永続無描画 になる。
18
22
  if (shape.uniqueKey !== "" && $cacheStore.has(shape.uniqueKey)) {
19
23
  $cacheStore.removeById(shape.uniqueKey);
20
- $cacheStore.$removeIds.push(+shape.uniqueKey);
21
24
  }
22
25
  // apply changes
23
26
  displayObjectApplyChangesService(shape);