@next2d/renderer 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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/renderer",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Next2D Renderer Package",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@next2d/webgl": "3.0
|
|
28
|
-
"@next2d/webgpu": "3.0
|
|
29
|
-
"@next2d/cache": "3.0
|
|
30
|
-
"@next2d/texture-packer": "3.0
|
|
27
|
+
"@next2d/webgl": "3.1.0",
|
|
28
|
+
"@next2d/webgpu": "3.1.0",
|
|
29
|
+
"@next2d/cache": "3.1.0",
|
|
30
|
+
"@next2d/texture-packer": "3.1.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $context } from "../../RendererUtil";
|
|
2
|
+
import { $cacheStore } from "@next2d/cache";
|
|
2
3
|
import { execute as shapeRenderUseCase } from "../../Shape/usecase/ShapeRenderUseCase";
|
|
3
4
|
import { execute as shapeClipRenderUseCase } from "../../Shape/usecase/ShapeClipRenderUseCase";
|
|
4
5
|
import { execute as textFieldRenderUseCase } from "../../TextField/usecase/TextFieldRenderUseCase";
|
|
@@ -26,8 +27,11 @@ export const execute = (render_queue, index, image_bitmaps) => {
|
|
|
26
27
|
let layerWidth = 0;
|
|
27
28
|
let layerHeight = 0;
|
|
28
29
|
let useFilter = false;
|
|
30
|
+
let useCacheAsBitmap = false;
|
|
29
31
|
let uniqueKey = "";
|
|
30
32
|
let filterKey = "";
|
|
33
|
+
let cacheRenderScaleX = 1;
|
|
34
|
+
let cacheRenderScaleY = 1;
|
|
31
35
|
let filterBounds = null;
|
|
32
36
|
let filterParams = null;
|
|
33
37
|
let matrix = null;
|
|
@@ -35,8 +39,40 @@ export const execute = (render_queue, index, image_bitmaps) => {
|
|
|
35
39
|
if (useLayer) {
|
|
36
40
|
layerWidth = render_queue[index++];
|
|
37
41
|
layerHeight = render_queue[index++];
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
const layerType = render_queue[index++]; // 0=blend, 1=filter, 2=cacheAsBitmap
|
|
43
|
+
useFilter = layerType === 1;
|
|
44
|
+
useCacheAsBitmap = layerType === 2;
|
|
45
|
+
if (useCacheAsBitmap) {
|
|
46
|
+
// cacheAsBitmapパス
|
|
47
|
+
const cacheHit = Boolean(render_queue[index++]);
|
|
48
|
+
uniqueKey = `${render_queue[index++]}`;
|
|
49
|
+
filterKey = `${render_queue[index++]}`;
|
|
50
|
+
// フィルター境界を読み取り
|
|
51
|
+
filterBounds = render_queue.subarray(index, index + 4);
|
|
52
|
+
index += 4;
|
|
53
|
+
// renderScale(キャッシュ描画時のスケール)
|
|
54
|
+
cacheRenderScaleX = render_queue[index++];
|
|
55
|
+
cacheRenderScaleY = render_queue[index++];
|
|
56
|
+
// 親matrix + スクリーン座標 (a, b, c, d, screenX, screenY)
|
|
57
|
+
matrix = render_queue.subarray(index, index + 6);
|
|
58
|
+
index += 6;
|
|
59
|
+
colorTransform = render_queue.subarray(index, index + 8);
|
|
60
|
+
index += 8;
|
|
61
|
+
if (cacheHit) {
|
|
62
|
+
// キャッシュ済み: Shapeと同様にmatrix/renderScaleで描画
|
|
63
|
+
const cachedNode = $cacheStore.get(uniqueKey, "bNode");
|
|
64
|
+
if (cachedNode) {
|
|
65
|
+
$context.globalAlpha = Math.min(Math.max(0, colorTransform[3] + colorTransform[7] / 255), 1);
|
|
66
|
+
$context.globalCompositeOperation = blendMode;
|
|
67
|
+
$context.setTransform(matrix[0] / cacheRenderScaleX, matrix[1] / cacheRenderScaleX, matrix[2] / cacheRenderScaleY, matrix[3] / cacheRenderScaleY, matrix[4], matrix[5]);
|
|
68
|
+
$context.drawDisplayObject(cachedNode, filterBounds[0], filterBounds[1], filterBounds[2], filterBounds[3], colorTransform);
|
|
69
|
+
}
|
|
70
|
+
return index;
|
|
71
|
+
}
|
|
72
|
+
// 初回描画: フィルターパラメータをスキップ(アトラスパスでは不使用)
|
|
73
|
+
index += render_queue[index] + 1;
|
|
74
|
+
}
|
|
75
|
+
else if (useFilter) {
|
|
40
76
|
// フィルターパス: filterCache/uniqueKey/filterKey を読む
|
|
41
77
|
const filterCache = Boolean(render_queue[index++]);
|
|
42
78
|
uniqueKey = `${render_queue[index++]}`;
|
|
@@ -71,7 +107,12 @@ export const execute = (render_queue, index, image_bitmaps) => {
|
|
|
71
107
|
}
|
|
72
108
|
}
|
|
73
109
|
// コンテナのフィルター/ブレンド用にレイヤーを開始
|
|
74
|
-
|
|
110
|
+
let cacheNode = null;
|
|
111
|
+
if (useCacheAsBitmap) {
|
|
112
|
+
// cacheAsBitmap: temp FBO作成→子要素描画→アトラスノードへコピー
|
|
113
|
+
cacheNode = $context.containerBeginAtlasNode(layerWidth, layerHeight);
|
|
114
|
+
}
|
|
115
|
+
else if (useLayer) {
|
|
75
116
|
$context.containerBeginLayer(layerWidth, layerHeight);
|
|
76
117
|
}
|
|
77
118
|
const useMaskDisplayObject = Boolean(render_queue[index++]);
|
|
@@ -173,7 +214,23 @@ export const execute = (render_queue, index, image_bitmaps) => {
|
|
|
173
214
|
$context.leaveMask();
|
|
174
215
|
}
|
|
175
216
|
// コンテナのフィルター/ブレンド結果をメインに合成
|
|
176
|
-
if (
|
|
217
|
+
if (cacheNode) {
|
|
218
|
+
// cacheAsBitmap: アトラス描画終了→キャッシュ→インスタンス描画
|
|
219
|
+
$context.containerEndAtlasNode();
|
|
220
|
+
// 古いノードを解放
|
|
221
|
+
const oldNode = $cacheStore.get(uniqueKey, "bNode");
|
|
222
|
+
if (oldNode) {
|
|
223
|
+
$context.removeNode(oldNode);
|
|
224
|
+
}
|
|
225
|
+
$cacheStore.set(uniqueKey, "bNode", cacheNode);
|
|
226
|
+
$cacheStore.set(uniqueKey, "bKey", filterKey);
|
|
227
|
+
// アトラスからインスタンス描画(Shapeと同様にmatrix/renderScaleで描画)
|
|
228
|
+
$context.globalAlpha = Math.min(Math.max(0, colorTransform[3] + colorTransform[7] / 255), 1);
|
|
229
|
+
$context.globalCompositeOperation = blendMode;
|
|
230
|
+
$context.setTransform(matrix[0] / cacheRenderScaleX, matrix[1] / cacheRenderScaleX, matrix[2] / cacheRenderScaleY, matrix[3] / cacheRenderScaleY, matrix[4], matrix[5]);
|
|
231
|
+
$context.drawDisplayObject(cacheNode, filterBounds[0], filterBounds[1], filterBounds[2], filterBounds[3], colorTransform);
|
|
232
|
+
}
|
|
233
|
+
else if (useLayer) {
|
|
177
234
|
$context.containerEndLayer(blendMode, matrix, colorTransform, useFilter, filterBounds, filterParams, uniqueKey, filterKey);
|
|
178
235
|
}
|
|
179
236
|
return index;
|
|
@@ -26,7 +26,9 @@ export const execute = (render_queue, index) => {
|
|
|
26
26
|
const yMax = render_queue[index++];
|
|
27
27
|
const isGridEnabled = Boolean(render_queue[index++]);
|
|
28
28
|
const isDrawable = Boolean(render_queue[index++]);
|
|
29
|
-
const
|
|
29
|
+
const renderMode = render_queue[index++]; // 0=vector, 1=bitmap, 2=cacheAsBitmap
|
|
30
|
+
const isBitmap = renderMode === 1;
|
|
31
|
+
const isCacheAsBitmap = renderMode === 2;
|
|
30
32
|
// cache uniqueKey
|
|
31
33
|
const uniqueKey = `${render_queue[index++]}`;
|
|
32
34
|
const cacheKey = render_queue[index++];
|
|
@@ -138,6 +140,14 @@ export const execute = (render_queue, index) => {
|
|
|
138
140
|
$context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
139
141
|
$context.drawDisplayObject(node, bounds[0], bounds[1], bounds[2], bounds[3], colorTransform);
|
|
140
142
|
}
|
|
143
|
+
else if (isCacheAsBitmap) {
|
|
144
|
+
// cacheAsBitmap: Bitmapと同様の描画パスで、cacheScaleを補正
|
|
145
|
+
// baseBounds原点(xMin,yMin)のスクリーン座標をtranslationに反映
|
|
146
|
+
const screenX = matrix[0] * xMin + matrix[2] * yMin + matrix[4];
|
|
147
|
+
const screenY = matrix[1] * xMin + matrix[3] * yMin + matrix[5];
|
|
148
|
+
$context.setTransform(matrix[0] / xScale, matrix[1] / xScale, matrix[2] / yScale, matrix[3] / yScale, screenX, screenY);
|
|
149
|
+
$context.drawDisplayObject(node, bounds[0], bounds[1], bounds[2], bounds[3], colorTransform);
|
|
150
|
+
}
|
|
141
151
|
else {
|
|
142
152
|
const radianX = Math.atan2(matrix[1], matrix[0]);
|
|
143
153
|
const radianY = Math.atan2(-matrix[2], matrix[3]);
|
|
@@ -32,8 +32,10 @@ export const execute = (render_queue, index) => {
|
|
|
32
32
|
// cache uniqueKey
|
|
33
33
|
const uniqueKey = `${render_queue[index++]}`;
|
|
34
34
|
const cacheKey = render_queue[index++];
|
|
35
|
-
// text state
|
|
36
|
-
const
|
|
35
|
+
// text state (bit 0 = changed, bit 1 = cacheAsBitmap)
|
|
36
|
+
const changedFlag = render_queue[index++];
|
|
37
|
+
const changed = Boolean(changedFlag & 1);
|
|
38
|
+
const isCacheAsBitmap = Boolean(changedFlag & 2);
|
|
37
39
|
const xScale = render_queue[index++];
|
|
38
40
|
const yScale = render_queue[index++];
|
|
39
41
|
// フィルターキャッシュ用のユニークキー(instanceId)
|
|
@@ -133,19 +135,28 @@ export const execute = (render_queue, index) => {
|
|
|
133
135
|
$context.globalAlpha = Math.min(Math.max(0, colorTransform[3] + colorTransform[7] / 255), 1);
|
|
134
136
|
$context.imageSmoothingEnabled = true;
|
|
135
137
|
$context.globalCompositeOperation = displayObjectGetBlendModeService(blendMode);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
const sinX = Math.sin(radianX);
|
|
143
|
-
const cosY = Math.cos(radianY);
|
|
144
|
-
const sinY = Math.sin(radianY);
|
|
145
|
-
$context.setTransform(cosX, sinX, -sinY, cosY, tx * cosX - ty * sinY + matrix[4], tx * sinX + ty * cosY + matrix[5]);
|
|
138
|
+
if (isCacheAsBitmap) {
|
|
139
|
+
// cacheAsBitmap: Bitmapと同様の描画パスで、cacheScaleを補正
|
|
140
|
+
// baseBounds原点(xMin,yMin)のスクリーン座標をtranslationに反映
|
|
141
|
+
const screenX = matrix[0] * xMin + matrix[2] * yMin + matrix[4];
|
|
142
|
+
const screenY = matrix[1] * xMin + matrix[3] * yMin + matrix[5];
|
|
143
|
+
$context.setTransform(matrix[0] / xScale, matrix[1] / xScale, matrix[2] / yScale, matrix[3] / yScale, screenX, screenY);
|
|
146
144
|
}
|
|
147
145
|
else {
|
|
148
|
-
|
|
146
|
+
const radianX = Math.atan2(matrix[1], matrix[0]);
|
|
147
|
+
const radianY = Math.atan2(-matrix[2], matrix[3]);
|
|
148
|
+
if (radianX || radianY) {
|
|
149
|
+
const tx = xMin * xScale;
|
|
150
|
+
const ty = yMin * yScale;
|
|
151
|
+
const cosX = Math.cos(radianX);
|
|
152
|
+
const sinX = Math.sin(radianX);
|
|
153
|
+
const cosY = Math.cos(radianY);
|
|
154
|
+
const sinY = Math.sin(radianY);
|
|
155
|
+
$context.setTransform(cosX, sinX, -sinY, cosY, tx * cosX - ty * sinY + matrix[4], tx * sinX + ty * cosY + matrix[5]);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
$context.setTransform(1, 0, 0, 1, bounds[0], bounds[1]);
|
|
159
|
+
}
|
|
149
160
|
}
|
|
150
161
|
// 描画範囲をinstanced arrayに設定
|
|
151
162
|
$context.drawDisplayObject(node, bounds[0], bounds[1], bounds[2], bounds[3], colorTransform);
|