@next2d/renderer 3.8.1 → 3.9.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.8.1",
3
+ "version": "3.9.0",
4
4
  "description": "Next2D Renderer Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -23,10 +23,11 @@
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
+ "sideEffects": false,
26
27
  "dependencies": {
27
- "@next2d/webgl": "3.8.1",
28
- "@next2d/webgpu": "3.8.1",
29
- "@next2d/cache": "3.8.1",
30
- "@next2d/texture-packer": "3.8.1"
28
+ "@next2d/webgl": "3.9.0",
29
+ "@next2d/webgpu": "3.9.0",
30
+ "@next2d/cache": "3.9.0",
31
+ "@next2d/texture-packer": "3.9.0"
31
32
  }
32
33
  }
@@ -31,11 +31,12 @@ export const execute = (render_queue, index) => {
31
31
  const isCacheAsBitmap = renderMode === 2;
32
32
  // cache uniqueKey
33
33
  const uniqueKey = `${render_queue[index++]}`;
34
- const cacheKey = render_queue[index++];
34
+ const cacheKey = `${render_queue[index++]}`;
35
35
  const xScale = render_queue[index++];
36
36
  const yScale = render_queue[index++];
37
37
  // フィルターキャッシュ用のユニークキー(instanceId)
38
- const filterKey = `${render_queue[index++]}`;
38
+ // 文字列化はフィルター使用時のみ行う
39
+ const filterKeyNumber = render_queue[index++];
39
40
  let node;
40
41
  const hasCache = render_queue[index++];
41
42
  if (!hasCache) {
@@ -48,19 +49,25 @@ export const execute = (render_queue, index) => {
48
49
  }
49
50
  $context.useGrid(gridData);
50
51
  const length = render_queue[index++];
51
- const commands = render_queue.subarray(index, index + length);
52
+ // ビットマップのピクセルは4バイト/floatでパックされている
53
+ // (ShapeGenerateRenderQueueUseCase参照)。lengthはバイト数。
54
+ // 条件はwriter側の分岐(!(isDrawable || isGridEnabled))と完全一致させる
55
+ const isPackedPixels = !isDrawable && !isGridEnabled;
56
+ const commands = isPackedPixels
57
+ ? null
58
+ : render_queue.subarray(index, index + length);
52
59
  if (isBitmap && !isGridEnabled) {
53
60
  // Bitmapなので、スケールなし
54
61
  const width = Math.ceil(Math.abs(xMax - xMin));
55
62
  const height = Math.ceil(Math.abs(yMax - yMin));
56
63
  // ShapeClearBitmapBufferUseCase 等で Main 側のみ wipe された場合、
57
64
  // Worker には旧 Node が残っているため、新規作成前に解放してアトラスリーク防止
58
- const oldBitmapNode = $cacheStore.get(uniqueKey, `${cacheKey}`);
65
+ const oldBitmapNode = $cacheStore.get(uniqueKey, cacheKey);
59
66
  if (oldBitmapNode) {
60
67
  $context.removeNode(oldBitmapNode);
61
68
  }
62
69
  node = $context.createNode(width, height);
63
- $cacheStore.set(uniqueKey, `${cacheKey}`, node);
70
+ $cacheStore.set(uniqueKey, cacheKey, node);
64
71
  // fixed logic
65
72
  const currentAttachment = $context.currentAttachmentObject;
66
73
  const atlasAttachment = $context.atlasAttachmentObject;
@@ -76,7 +83,8 @@ export const execute = (render_queue, index) => {
76
83
  $context.drawFill();
77
84
  }
78
85
  else {
79
- $context.drawPixels(node, new Uint8Array(commands));
86
+ // パックされたバイト列をビューで復元(GLアップロードは同期のためコピー不要)
87
+ $context.drawPixels(node, new Uint8Array(render_queue.buffer, render_queue.byteOffset + index * 4, length));
80
88
  }
81
89
  $context.endNodeRendering();
82
90
  if (currentAttachment) {
@@ -88,12 +96,12 @@ export const execute = (render_queue, index) => {
88
96
  const height = Math.ceil(Math.abs(yMax - yMin) * yScale);
89
97
  // ShapeClearBitmapBufferUseCase 等で Main 側のみ wipe された場合、
90
98
  // Worker には旧 Node が残っているため、新規作成前に解放してアトラスリーク防止
91
- const oldNode = $cacheStore.get(uniqueKey, `${cacheKey}`);
99
+ const oldNode = $cacheStore.get(uniqueKey, cacheKey);
92
100
  if (oldNode) {
93
101
  $context.removeNode(oldNode);
94
102
  }
95
103
  node = $context.createNode(width, height);
96
- $cacheStore.set(uniqueKey, `${cacheKey}`, node);
104
+ $cacheStore.set(uniqueKey, cacheKey, node);
97
105
  // fixed logic
98
106
  const currentAttachment = $context.currentAttachmentObject;
99
107
  const atlasAttachment = $context.atlasAttachmentObject;
@@ -120,10 +128,10 @@ export const execute = (render_queue, index) => {
120
128
  $context.bind(currentAttachment);
121
129
  }
122
130
  }
123
- index += length;
131
+ index += isPackedPixels ? Math.ceil(length / 4) : length;
124
132
  }
125
133
  else {
126
- node = $cacheStore.get(uniqueKey, `${cacheKey}`);
134
+ node = $cacheStore.get(uniqueKey, cacheKey);
127
135
  if (!node) {
128
136
  return index;
129
137
  }
@@ -139,7 +147,7 @@ export const execute = (render_queue, index) => {
139
147
  const params = render_queue.subarray(index, index + length);
140
148
  const width = Math.ceil(Math.abs(bounds[2] - bounds[0]));
141
149
  const height = Math.ceil(Math.abs(bounds[3] - bounds[1]));
142
- $context.applyFilter(node, filterKey, updated, width, height, isBitmap, matrix, colorTransform, displayObjectGetBlendModeService(blendMode), filterBounds, params);
150
+ $context.applyFilter(node, `${filterKeyNumber}`, updated, width, height, isBitmap, matrix, colorTransform, displayObjectGetBlendModeService(blendMode), filterBounds, params);
143
151
  index += length;
144
152
  return index;
145
153
  }
@@ -31,7 +31,7 @@ export const execute = (render_queue, index) => {
31
31
  const yMax = render_queue[index++];
32
32
  // cache uniqueKey
33
33
  const uniqueKey = `${render_queue[index++]}`;
34
- const cacheKey = render_queue[index++];
34
+ const cacheKey = `${render_queue[index++]}`;
35
35
  // text state (bit 0 = changed, bit 1 = cacheAsBitmap)
36
36
  const changedFlag = render_queue[index++];
37
37
  const changed = Boolean(changedFlag & 1);
@@ -39,7 +39,8 @@ export const execute = (render_queue, index) => {
39
39
  const xScale = render_queue[index++];
40
40
  const yScale = render_queue[index++];
41
41
  // フィルターキャッシュ用のユニークキー(instanceId)
42
- const filterKey = `${render_queue[index++]}`;
42
+ // 文字列化はフィルター使用時のみ行う
43
+ const filterKeyNumber = render_queue[index++];
43
44
  let node;
44
45
  const hasCache = render_queue[index++];
45
46
  if (!hasCache) {
@@ -47,21 +48,23 @@ export const execute = (render_queue, index) => {
47
48
  const height = Math.ceil(Math.abs(yMax - yMin) * yScale);
48
49
  const hasNode = Boolean(render_queue[index++]);
49
50
  if (hasNode) {
50
- node = $cacheStore.get(uniqueKey, `${cacheKey}`);
51
+ node = $cacheStore.get(uniqueKey, cacheKey);
51
52
  }
52
53
  else {
53
54
  // TextFieldResetUseCase 等で Main 側のみ wipe された場合、
54
55
  // Worker には旧 Node が残っているため、新規作成前に解放してアトラスリーク防止
55
- const oldNode = $cacheStore.get(uniqueKey, `${cacheKey}`);
56
+ const oldNode = $cacheStore.get(uniqueKey, cacheKey);
56
57
  if (oldNode) {
57
58
  $context.removeNode(oldNode);
58
59
  }
59
60
  node = $context.createNode(width, height);
60
- $cacheStore.set(uniqueKey, `${cacheKey}`, node);
61
+ $cacheStore.set(uniqueKey, cacheKey, node);
61
62
  }
62
63
  const length = render_queue[index++];
63
- const buffer = new Uint8Array(render_queue.subarray(index, index + length));
64
- index += length;
64
+ // テキストバイト列は4バイト/floatでパックされている
65
+ // (TextFieldGenerateRenderQueueUseCase参照)。lengthはバイト数。
66
+ const buffer = new Uint8Array(render_queue.buffer, render_queue.byteOffset + index * 4, length);
67
+ index += Math.ceil(length / 4);
65
68
  let autoSize = "none";
66
69
  switch (render_queue[index++]) {
67
70
  case 0:
@@ -119,7 +122,7 @@ export const execute = (render_queue, index) => {
119
122
  }
120
123
  }
121
124
  else {
122
- node = $cacheStore.get(uniqueKey, `${cacheKey}`);
125
+ node = $cacheStore.get(uniqueKey, cacheKey);
123
126
  if (!node) {
124
127
  return index;
125
128
  }
@@ -135,7 +138,7 @@ export const execute = (render_queue, index) => {
135
138
  const params = render_queue.subarray(index, index + length);
136
139
  const width = Math.ceil(Math.abs(bounds[2] - bounds[0]));
137
140
  const height = Math.ceil(Math.abs(bounds[3] - bounds[1]));
138
- $context.applyFilter(node, filterKey, Boolean(Math.max(+changed, +updated)), width, height, false, matrix, colorTransform, displayObjectGetBlendModeService(blendMode), filterBounds, params);
141
+ $context.applyFilter(node, `${filterKeyNumber}`, Boolean(Math.max(+changed, +updated)), width, height, false, matrix, colorTransform, displayObjectGetBlendModeService(blendMode), filterBounds, params);
139
142
  index += length;
140
143
  return index;
141
144
  }