@next2d/webgl 3.2.0 → 3.3.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/webgl",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Next2D Webgl Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
26
  "dependencies": {
27
- "@next2d/texture-packer": "3.2.0",
28
- "@next2d/render-queue": "3.2.0"
27
+ "@next2d/texture-packer": "3.3.0",
28
+ "@next2d/render-queue": "3.3.0"
29
29
  }
30
30
  }
@@ -53,16 +53,24 @@ export const execute = (node, unique_key, updated, width, height, is_bitmap, mat
53
53
  const key = $cacheStore.generateFilterKeys(matrix[0], matrix[1], matrix[2], matrix[3]);
54
54
  let useCache = false;
55
55
  const fKey = $cacheStore.get(unique_key, "fKey");
56
- if (fKey === key) {
57
- const cacheTextureObject = $cacheStore.get(unique_key, "fTexture");
56
+ const cacheTextureObject = $cacheStore.get(unique_key, "fTexture");
57
+ if (fKey === key && cacheTextureObject) {
58
58
  if (updated) {
59
+ // 同 filterKey で更新あり: 旧テクスチャを解放して再生成
59
60
  textureManagerReleaseTextureObjectUseCase(cacheTextureObject);
60
61
  }
61
62
  else {
63
+ // 同 filterKey で更新なし: キャッシュをそのまま再利用
62
64
  useCache = true;
63
65
  textureObject = cacheTextureObject;
64
66
  }
65
67
  }
68
+ else if (cacheTextureObject) {
69
+ // filterKey が変わった(matrix 変化等)場合に旧テクスチャを解放してから上書き。
70
+ // これがないと、フィルター付き Shape のスケール/回転アニメーション中に
71
+ // 毎フレーム GPU テクスチャがリークする。
72
+ textureManagerReleaseTextureObjectUseCase(cacheTextureObject);
73
+ }
66
74
  let offsetX = 0;
67
75
  let offsetY = 0;
68
76
  if (!useCache) {
@@ -140,8 +140,12 @@ _layer_scale_x = 1, _layer_scale_y = 1) => {
140
140
  // 子孫のcacheAsBitmap子は既にその倍解像度でlayer内に収まっている。
141
141
  // cacheAsBitmap の仕様としてスクリーン上も cacheScale 倍のサイズで
142
142
  // 表示されるため、ここでの縮小は行わずそのまま main に合成する。
143
- // キャッシュに保存
143
+ // キャッシュに保存(古いfTextureを先に解放してからGPUリーク防止)
144
144
  if (unique_key) {
145
+ const oldTexture = $cacheStore.get(unique_key, "fTexture");
146
+ if (oldTexture) {
147
+ textureManagerReleaseTextureObjectUseCase(oldTexture);
148
+ }
145
149
  $cacheStore.set(unique_key, "fKey", filter_key);
146
150
  $cacheStore.set(unique_key, "fTexture", textureObject);
147
151
  }
package/src/Context.d.ts CHANGED
@@ -55,6 +55,19 @@ export declare class Context {
55
55
  get atlasAttachmentObject(): IAttachmentObject;
56
56
  createNode(width: number, height: number): Node;
57
57
  removeNode(node: Node): void;
58
+ /**
59
+ * @description CacheStore に格納された任意の値を解放する。
60
+ * Release any value stored in CacheStore.
61
+ *
62
+ * CommandRemoveCacheService から instanceId / uniqueKey 単位で呼ばれ、
63
+ * その map に含まれる Node / ITextureObject / プリミティブの全てを
64
+ * 安全に解放できるよう型判定で振り分ける。
65
+ * プリミティブ(fKey の数値など)はスキップする。
66
+ *
67
+ * @param {*} value
68
+ * @return {void}
69
+ */
70
+ releaseTextureCache(value: any): void;
58
71
  beginNodeRendering(node: Node): void;
59
72
  endNodeRendering(): void;
60
73
  drawFill(): void;
package/src/Context.js CHANGED
@@ -25,6 +25,7 @@ import { execute as contextUseGridService } from "./Context/service/ContextUseGr
25
25
  import { execute as contextClipUseCase } from "./Context/usecase/ContextClipUseCase";
26
26
  import { execute as atlasManagerCreateNodeService } from "./AtlasManager/service/AtlasManagerCreateNodeService";
27
27
  import { execute as atlasManagerRemoveNodeService } from "./AtlasManager/service/AtlasManagerRemoveNodeService";
28
+ import { execute as textureManagerReleaseTextureObjectUseCase } from "./TextureManager/usecase/TextureManagerReleaseTextureObjectUseCase";
28
29
  import { execute as blnedDrawDisplayObjectUseCase } from "./Blend/usecase/BlnedDrawDisplayObjectUseCase";
29
30
  import { execute as blnedClearArraysInstancedUseCase } from "./Blend/usecase/BlnedClearArraysInstancedUseCase";
30
31
  import { execute as blnedDrawArraysInstancedUseCase } from "./Blend/usecase/BlnedDrawArraysInstancedUseCase";
@@ -329,6 +330,29 @@ export class Context {
329
330
  removeNode(node) {
330
331
  atlasManagerRemoveNodeService(node);
331
332
  }
333
+ /**
334
+ * @description CacheStore に格納された任意の値を解放する。
335
+ * Release any value stored in CacheStore.
336
+ *
337
+ * CommandRemoveCacheService から instanceId / uniqueKey 単位で呼ばれ、
338
+ * その map に含まれる Node / ITextureObject / プリミティブの全てを
339
+ * 安全に解放できるよう型判定で振り分ける。
340
+ * プリミティブ(fKey の数値など)はスキップする。
341
+ *
342
+ * @param {*} value
343
+ * @return {void}
344
+ */
345
+ releaseTextureCache(value) {
346
+ if (!value || typeof value !== "object") {
347
+ return;
348
+ }
349
+ if ("w" in value) {
350
+ atlasManagerRemoveNodeService(value);
351
+ }
352
+ else if ("resource" in value) {
353
+ textureManagerReleaseTextureObjectUseCase(value);
354
+ }
355
+ }
332
356
  beginNodeRendering(node) {
333
357
  this.newDrawState = true;
334
358
  contextUpdateTransferBoundsService(node);