@next2d/display 2.13.1 → 3.0.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.
Files changed (27) hide show
  1. package/README.md +388 -5
  2. package/package.json +9 -9
  3. package/src/BitmapData.d.ts +1 -1
  4. package/src/BitmapData.js +1 -16
  5. package/src/DisplayObject/service/DisplayObjectApplyChangesService.js +4 -3
  6. package/src/DisplayObject/service/DisplayObjectGenerateHashService.js +57 -11
  7. package/src/DisplayObject.js +2 -1
  8. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateRenderQueueUseCase.js +147 -4
  9. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGetLayerBoundsUseCase.d.ts +14 -0
  10. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGetLayerBoundsUseCase.js +65 -0
  11. package/src/Graphics/service/GraphicsToNumberArrayService.js +25 -1
  12. package/src/Shape/usecase/ShapeCalcLayerBoundsUseCase.d.ts +12 -0
  13. package/src/Shape/usecase/ShapeCalcLayerBoundsUseCase.js +32 -0
  14. package/src/Shape/usecase/ShapeGenerateRenderQueueUseCase.js +28 -16
  15. package/src/Shape/usecase/ShapeLoadAsyncUseCase.d.ts +12 -0
  16. package/src/Shape/usecase/ShapeLoadAsyncUseCase.js +21 -0
  17. package/src/Shape.d.ts +10 -0
  18. package/src/Shape.js +13 -0
  19. package/src/Sprite.d.ts +2 -5
  20. package/src/Sprite.js +2 -5
  21. package/src/Stage.js +3 -0
  22. package/src/TextField/usecase/TextFieldCalcLayerBoundsUseCase.d.ts +12 -0
  23. package/src/TextField/usecase/TextFieldCalcLayerBoundsUseCase.js +32 -0
  24. package/src/TextField/usecase/TextFieldGenerateRenderQueueUseCase.js +23 -12
  25. package/src/Video/usecase/VideoCalcLayerBoundsUseCase.d.ts +12 -0
  26. package/src/Video/usecase/VideoCalcLayerBoundsUseCase.js +32 -0
  27. package/src/Video/usecase/VideoGenerateRenderQueueUseCase.js +12 -1
@@ -0,0 +1,32 @@
1
+ import { execute as textFieldCalcBoundsMatrixUseCase } from "./TextFieldCalcBoundsMatrixUseCase";
2
+ import { $getBoundsArray, $poolBoundsArray } from "../../DisplayObjectUtil";
3
+ /**
4
+ * @description TextFieldのフィルター適用後の描画範囲を計算します。
5
+ * Calculate the drawing area of TextField after applying filters.
6
+ *
7
+ * @param {TextField} text_field
8
+ * @param {Float32Array | null} [matrix=null]
9
+ * @return {Float32Array}
10
+ * @method
11
+ * @protected
12
+ */
13
+ export const execute = (text_field, matrix = null) => {
14
+ const bounds = textFieldCalcBoundsMatrixUseCase(text_field, matrix);
15
+ const filters = text_field.filters;
16
+ if (filters) {
17
+ const filterBounds = $getBoundsArray(0, 0, 0, 0);
18
+ for (let idx = 0; idx < filters.length; idx++) {
19
+ const filter = filters[idx];
20
+ if (!filter || !filter.canApplyFilter()) {
21
+ continue;
22
+ }
23
+ filter.getBounds(filterBounds);
24
+ }
25
+ bounds[0] += filterBounds[0];
26
+ bounds[1] += filterBounds[1];
27
+ bounds[2] += filterBounds[2];
28
+ bounds[3] += filterBounds[3];
29
+ $poolBoundsArray(filterBounds);
30
+ }
31
+ return bounds;
32
+ };
@@ -33,6 +33,10 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
33
33
  // transformed ColorTransform(tColorTransform)
34
34
  const rawColor = displayObjectGetRawColorTransformUseCase(text_field);
35
35
  const tColorTransform = rawColor
36
+ && (rawColor[0] !== 1 || rawColor[1] !== 1
37
+ || rawColor[2] !== 1 || rawColor[3] !== 1
38
+ || rawColor[4] !== 0 || rawColor[5] !== 0
39
+ || rawColor[6] !== 0 || rawColor[7] !== 0)
36
40
  ? ColorTransform.multiply(color_transform, rawColor)
37
41
  : color_transform;
38
42
  const alpha = $clamp(tColorTransform[3] + tColorTransform[7] / 255, 0, 1, 0);
@@ -46,6 +50,9 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
46
50
  // transformed matrix(tMatrix)
47
51
  const rawMatrix = displayObjectGetRawMatrixUseCase(text_field);
48
52
  const tMatrix = rawMatrix
53
+ && (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
54
+ || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
55
+ || rawMatrix[4] !== 0 || rawMatrix[5] !== 0)
49
56
  ? Matrix.multiply(matrix, rawMatrix)
50
57
  : matrix;
51
58
  const bounds = displayObjectCalcBoundsMatrixService(text_field.xMin, text_field.yMin, text_field.xMax, text_field.yMax, tMatrix);
@@ -69,7 +76,6 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
69
76
  if (tMatrix !== matrix) {
70
77
  Matrix.release(tMatrix);
71
78
  }
72
- $poolBoundsArray(bounds);
73
79
  renderQueue.push(0);
74
80
  return;
75
81
  default:
@@ -85,7 +91,6 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
85
91
  if (tMatrix !== matrix) {
86
92
  Matrix.release(tMatrix);
87
93
  }
88
- $poolBoundsArray(bounds);
89
94
  renderQueue.push(0);
90
95
  return;
91
96
  }
@@ -99,23 +104,26 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
99
104
  text_field.uniqueKey = `${text_field.instanceId}`;
100
105
  }
101
106
  }
102
- const xScale = Math.round(Math.sqrt(tMatrix[0] * tMatrix[0]
103
- + tMatrix[1] * tMatrix[1]) * 100) / 100;
104
- const yScale = Math.round(Math.sqrt(tMatrix[2] * tMatrix[2]
105
- + tMatrix[3] * tMatrix[3]) * 100) / 100;
107
+ const xScale = Math.sqrt(tMatrix[0] * tMatrix[0]
108
+ + tMatrix[1] * tMatrix[1]);
109
+ const yScale = Math.sqrt(tMatrix[2] * tMatrix[2]
110
+ + tMatrix[3] * tMatrix[3]);
111
+ const xScaleRounded = Math.round(xScale * 100) / 100;
112
+ const yScaleRounded = Math.round(yScale * 100) / 100;
106
113
  if (text_field.changed
107
114
  && !text_field.cacheKey
108
- || text_field.cacheParams[0] !== xScale
109
- || text_field.cacheParams[1] !== yScale
115
+ || text_field.cacheParams[0] !== xScaleRounded
116
+ || text_field.cacheParams[1] !== yScaleRounded
110
117
  || text_field.cacheParams[2] !== tColorTransform[7]) {
111
- text_field.cacheKey = $cacheStore.generateKeys(xScale, yScale, tColorTransform[7]);
112
- text_field.cacheParams[0] = xScale;
113
- text_field.cacheParams[1] = yScale;
118
+ text_field.cacheKey = $cacheStore.generateKeys(xScaleRounded, yScaleRounded, tColorTransform[7]);
119
+ text_field.cacheParams[0] = xScaleRounded;
120
+ text_field.cacheParams[1] = yScaleRounded;
114
121
  text_field.cacheParams[2] = tColorTransform[7];
115
122
  }
116
123
  const cacheKey = text_field.cacheKey;
117
124
  // rennder on
118
- renderQueue.push(1, $RENDERER_TEXT_TYPE, tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], tMatrix[4], tMatrix[5], tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7], xMin, yMin, xMax, yMax, text_field.xMin, text_field.yMin, text_field.xMax, text_field.yMax, +text_field.uniqueKey, cacheKey, +text_field.changed);
125
+ renderQueue.pushTextFieldBuffer(1, $RENDERER_TEXT_TYPE, tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], tMatrix[4], tMatrix[5], tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7], xMin, yMin, xMax, yMax, text_field.xMin, text_field.yMin, text_field.xMax, text_field.yMax, +text_field.uniqueKey, cacheKey, +text_field.changed, xScale, yScale, text_field.instanceId // フィルターキャッシュ用のユニークキー
126
+ );
119
127
  if (text_field.$cache && !text_field.$cache.has(text_field.uniqueKey)) {
120
128
  text_field.$cache = null;
121
129
  }
@@ -184,6 +192,9 @@ export const execute = (text_field, matrix, color_transform, renderer_width, ren
184
192
  renderQueue.push(+useFilfer, +updated, bounds[0], bounds[1], bounds[2], bounds[3], params.length);
185
193
  renderQueue.set(new Float32Array(params));
186
194
  }
195
+ else {
196
+ renderQueue.push(0);
197
+ }
187
198
  $poolBoundsArray(bounds);
188
199
  }
189
200
  else {
@@ -0,0 +1,12 @@
1
+ import type { Video } from "@next2d/media";
2
+ /**
3
+ * @description Videoのフィルター適用後の描画範囲を計算します。
4
+ * Calculate the drawing area of Video after applying filters.
5
+ *
6
+ * @param {Video} video
7
+ * @param {Float32Array | null} [matrix=null]
8
+ * @return {Float32Array}
9
+ * @method
10
+ * @protected
11
+ */
12
+ export declare const execute: (video: Video, matrix?: Float32Array | null) => Float32Array;
@@ -0,0 +1,32 @@
1
+ import { execute as videoCalcBoundsMatrixUseCase } from "./VideoCalcBoundsMatrixUseCase";
2
+ import { $getBoundsArray, $poolBoundsArray } from "../../DisplayObjectUtil";
3
+ /**
4
+ * @description Videoのフィルター適用後の描画範囲を計算します。
5
+ * Calculate the drawing area of Video after applying filters.
6
+ *
7
+ * @param {Video} video
8
+ * @param {Float32Array | null} [matrix=null]
9
+ * @return {Float32Array}
10
+ * @method
11
+ * @protected
12
+ */
13
+ export const execute = (video, matrix = null) => {
14
+ const bounds = videoCalcBoundsMatrixUseCase(video, matrix);
15
+ const filters = video.filters;
16
+ if (filters) {
17
+ const filterBounds = $getBoundsArray(0, 0, 0, 0);
18
+ for (let idx = 0; idx < filters.length; idx++) {
19
+ const filter = filters[idx];
20
+ if (!filter || !filter.canApplyFilter()) {
21
+ continue;
22
+ }
23
+ filter.getBounds(filterBounds);
24
+ }
25
+ bounds[0] += filterBounds[0];
26
+ bounds[1] += filterBounds[1];
27
+ bounds[2] += filterBounds[2];
28
+ bounds[3] += filterBounds[3];
29
+ $poolBoundsArray(filterBounds);
30
+ }
31
+ return bounds;
32
+ };
@@ -32,6 +32,10 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
32
32
  // transformed ColorTransform(tColorTransform)
33
33
  const rawColor = displayObjectGetRawColorTransformUseCase(video);
34
34
  const tColorTransform = rawColor
35
+ && (rawColor[0] !== 1 || rawColor[1] !== 1
36
+ || rawColor[2] !== 1 || rawColor[3] !== 1
37
+ || rawColor[4] !== 0 || rawColor[5] !== 0
38
+ || rawColor[6] !== 0 || rawColor[7] !== 0)
35
39
  ? ColorTransform.multiply(color_transform, rawColor)
36
40
  : color_transform;
37
41
  const alpha = $clamp(tColorTransform[3] + tColorTransform[7] / 255, 0, 1, 0);
@@ -45,6 +49,9 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
45
49
  // transformed matrix(tMatrix)
46
50
  const rawMatrix = displayObjectGetRawMatrixUseCase(video);
47
51
  const tMatrix = rawMatrix
52
+ && (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
53
+ || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
54
+ || rawMatrix[4] !== 0 || rawMatrix[5] !== 0)
48
55
  ? Matrix.multiply(matrix, rawMatrix)
49
56
  : matrix;
50
57
  // draw text
@@ -98,7 +105,8 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
98
105
  }
99
106
  }
100
107
  // rennder on
101
- renderQueue.push(1, $RENDERER_VIDEO_TYPE, tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], tMatrix[4], tMatrix[5], tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7], xMin, yMin, xMax, yMax, 0, 0, video.videoWidth, video.videoHeight, +video.uniqueKey, +video.changed);
108
+ renderQueue.pushVideoBuffer(1, $RENDERER_VIDEO_TYPE, tMatrix[0], tMatrix[1], tMatrix[2], tMatrix[3], tMatrix[4], tMatrix[5], tColorTransform[0], tColorTransform[1], tColorTransform[2], tColorTransform[3], tColorTransform[4], tColorTransform[5], tColorTransform[6], tColorTransform[7], xMin, yMin, xMax, yMax, 0, 0, video.videoWidth, video.videoHeight, +video.uniqueKey, +video.changed, video.instanceId // フィルターキャッシュ用のユニークキー
109
+ );
102
110
  if (video.$cache && !video.$cache.has(video.uniqueKey)) {
103
111
  video.$cache = null;
104
112
  }
@@ -161,6 +169,9 @@ export const execute = (video, image_bitmaps, matrix, color_transform, renderer_
161
169
  renderQueue.push(+useFilfer, +updated, bounds[0], bounds[1], bounds[2], bounds[3], params.length);
162
170
  renderQueue.set(new Float32Array(params));
163
171
  }
172
+ else {
173
+ renderQueue.push(0);
174
+ }
164
175
  $poolBoundsArray(bounds);
165
176
  }
166
177
  else {