Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 62 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next2d/player",
"version": "2.12.0",
"version": "2.13.0",
"description": "Experience the fast and beautiful anti-aliased rendering of WebGL. You can create rich, interactive graphics, cross-platform applications and games without worrying about browser or device compatibility.",
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
"license": "MIT",
Expand Down Expand Up @@ -54,7 +54,7 @@
"@types/node": "^24.10.1",
"@typescript-eslint/eslint-plugin": "^8.48.0",
"@typescript-eslint/parser": "^8.48.0",
"@vitest/web-worker": "^4.0.13",
"@vitest/web-worker": "^4.0.14",
"eslint": "^9.39.1",
"eslint-plugin-unused-imports": "^4.3.0",
"globals": "^16.5.0",
Expand All @@ -63,7 +63,7 @@
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"vite": "^7.2.4",
"vitest": "^4.0.13",
"vitest": "^4.0.14",
"vitest-webgl-canvas-mock": "^1.1.0",
"xml2js": "^0.6.2"
},
Expand All @@ -83,4 +83,4 @@
"@next2d/ui": "file:packages/ui",
"@next2d/webgl": "file:packages/webgl"
}
}
}
51 changes: 48 additions & 3 deletions packages/texture-packer/src/Node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { execute as nodeInsertService } from "./Node/service/NodeInsertService";
import { execute as nodeDisposeService } from "./Node/service/NodeDisposeService";

/**
* @description ノードオブジェクトプール(パフォーマンス最適化)
* Node object pool (performance optimization)
*
* @type {Node[]}
* @private
*/
const $nodePool: Node[] = [];

/**
* @description テクスチャパッキングのノードクラス
* Node class for texture
Expand Down Expand Up @@ -132,8 +141,8 @@ export class Node
}

/**
* @description 新規ノードを生成
* Create a new node
* @description 新規ノードを生成(プールから取得または新規作成)
* Create a new node (get from pool or create new)
*
* @param {number} index
* @param {number} x
Expand All @@ -146,6 +155,42 @@ export class Node
*/
create (index: number, x: number, y: number, w: number, h: number): Node
{
return new Node(index, x, y, w, h);
let node: Node;
if ($nodePool.length > 0) {
node = $nodePool.pop() as Node;
node.index = index;
node.x = x;
node.y = y;
node.w = w;
node.h = h;
node.left = null;
node.right = null;
node.used = false;
} else {
node = new Node(index, x, y, w, h);
}
return node;
}

/**
* @description ノードをプールに返却(メモリ再利用)
* Return node to pool (memory reuse)
*
* @return {void}
* @method
* @public
*/
release (): void
{
if (this.left) {
this.left.release();
this.left = null;
}
if (this.right) {
this.right.release();
this.right = null;
}
this.used = false;
$nodePool.push(this);
}
}
14 changes: 14 additions & 0 deletions packages/texture-packer/src/Node/service/NodeDisposeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export const execute = (

if (node.left?.dispose(x, y, width, height)) {
if (!node.left.used && !node.right?.used) {
// 子ノードをプールに返却
if (node.left) {
node.left.release();
}
if (node.right) {
node.right.release();
}
node.left = node.right = null;
node.used = false;
}
Expand All @@ -31,6 +38,13 @@ export const execute = (

if (node.right?.dispose(x, y, width, height)) {
if (!node.right.used && !node.left?.used) {
// 子ノードをプールに返却
if (node.left) {
node.left.release();
}
if (node.right) {
node.right.release();
}
node.left = node.right = null;
node.used = false;
}
Expand Down
Loading