@next2d/display 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/display",
3
- "version": "3.0.5",
3
+ "version": "3.1.0",
4
4
  "description": "Next2D Display Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -24,13 +24,13 @@
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
26
  "dependencies": {
27
- "@next2d/ui": "3.0.5",
28
- "@next2d/text": "3.0.5",
29
- "@next2d/geom": "3.0.5",
30
- "@next2d/media": "3.0.5",
31
- "@next2d/net": "3.0.5",
32
- "@next2d/events": "3.0.5",
33
- "@next2d/filters": "3.0.5",
34
- "@next2d/render-queue": "3.0.5"
27
+ "@next2d/ui": "3.1.0",
28
+ "@next2d/text": "3.1.0",
29
+ "@next2d/geom": "3.1.0",
30
+ "@next2d/media": "3.1.0",
31
+ "@next2d/net": "3.1.0",
32
+ "@next2d/events": "3.1.0",
33
+ "@next2d/filters": "3.1.0",
34
+ "@next2d/render-queue": "3.1.0"
35
35
  }
36
36
  }
@@ -6,7 +6,7 @@ import { execute as shapeHitTestUseCase } from "../../Shape/usecase/ShapeHitTest
6
6
  import { execute as textFieldHitTestUseCase } from "../../TextField/usecase/TextFieldHitTestUseCase";
7
7
  import { execute as videoHitTestUseCase } from "../../Video/usecase/VideoHitTestUseCase";
8
8
  import { Rectangle, Point } from "@next2d/geom";
9
- import { $MATRIX_ARRAY_IDENTITY, $poolBoundsArray, $colorContext } from "../../DisplayObjectUtil";
9
+ import { $MATRIX_ARRAY_IDENTITY, $poolBoundsArray, $colorContext, $getFloat32Array6, $poolFloat32Array6 } from "../../DisplayObjectUtil";
10
10
  /**
11
11
  * @type {IPlayerHitObject}
12
12
  * @private
@@ -55,9 +55,23 @@ export const execute = (display_object, x, y, shape_flag = false) => {
55
55
  }
56
56
  const rawBounds = displayObjectGetRawBoundsUseCase(display_object);
57
57
  const martix = displayObjectGetRawMatrixUseCase(display_object);
58
- const bounds = displayObjectCalcBoundsMatrixService(rawBounds[0], rawBounds[1], rawBounds[2], rawBounds[3], martix ? martix : $MATRIX_ARRAY_IDENTITY);
58
+ // cacheAsBitmap倍率をhitTest用のmatrixに適用
59
+ const cacheMatrix = display_object.cacheAsBitmap;
60
+ let hitMatrix = martix ? martix : $MATRIX_ARRAY_IDENTITY;
61
+ let scaledMatrix = null;
62
+ if (cacheMatrix && hitMatrix) {
63
+ const m = cacheMatrix.rawData;
64
+ const csx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
65
+ const csy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
66
+ scaledMatrix = $getFloat32Array6(hitMatrix[0] * csx, hitMatrix[1] * csx, hitMatrix[2] * csy, hitMatrix[3] * csy, hitMatrix[4], hitMatrix[5]);
67
+ hitMatrix = scaledMatrix;
68
+ }
69
+ const bounds = displayObjectCalcBoundsMatrixService(rawBounds[0], rawBounds[1], rawBounds[2], rawBounds[3], hitMatrix);
59
70
  // pool
60
71
  $poolBoundsArray(rawBounds);
72
+ if (scaledMatrix) {
73
+ $poolFloat32Array6(scaledMatrix);
74
+ }
61
75
  const rectangle = new Rectangle(bounds[0], bounds[1], Math.abs(bounds[2] - bounds[0]), Math.abs(bounds[3] - bounds[1]));
62
76
  // pool
63
77
  $poolBoundsArray(bounds);
@@ -6,7 +6,8 @@ import type { IBlendMode } from "./interface/IBlendMode";
6
6
  import type { IFilterArray } from "./interface/IFilterArray";
7
7
  import type { MovieClip } from "./MovieClip";
8
8
  import type { ISprite } from "./interface/ISprite";
9
- import type { ColorTransform, Matrix, Rectangle, Point } from "@next2d/geom";
9
+ import type { ColorTransform, Rectangle, Point } from "@next2d/geom";
10
+ import { Matrix } from "@next2d/geom";
10
11
  import { EventDispatcher } from "@next2d/events";
11
12
  /**
12
13
  * @description DisplayObject クラスは、表示リストに含めることのできるすべてのオブジェクトに関する基本クラスです。
@@ -319,6 +320,20 @@ export declare class DisplayObject extends EventDispatcher {
319
320
  * @private
320
321
  */
321
322
  private _$visible;
323
+ /**
324
+ * @description ビットマップキャッシュ用のMatrix。nullでない場合、指定Matrix × stageのrendererScaleで
325
+ * Shape/TextFieldのベクター描画をキャッシュし、ステージのリサイズがあるまで再利用します。
326
+ * 先祖のMatrixの影響を受けず、キャッシュの品質は指定Matrixとstageスケールのみで決定されます。
327
+ * Matrix for bitmap caching. When not null, caches Shape/TextField vector rendering
328
+ * at the specified Matrix × stage rendererScale, reusing until stage resize.
329
+ * Cache quality is determined only by the specified Matrix and stage scale,
330
+ * independent of ancestor transforms.
331
+ *
332
+ * @type {Matrix | null}
333
+ * @default null
334
+ * @private
335
+ */
336
+ private _$cacheAsBitmap;
322
337
  /**
323
338
  * @description 表示オブジェクト単位の変数を保持するマップ
324
339
  * Map that holds variables for display objects
@@ -347,6 +362,15 @@ export declare class DisplayObject extends EventDispatcher {
347
362
  * @public
348
363
  */
349
364
  parent: ISprite<any> | null;
365
+ /**
366
+ * @description キャッシュする際の指定Matrix、nullの場合は通常のMatrixで描画
367
+ * Specified Matrix for caching, if null, draw with the normal Matrix
368
+ *
369
+ * @member {Matrix | null}
370
+ * @default null
371
+ * @public
372
+ */
373
+ cacheTransform: Matrix | null;
350
374
  /**
351
375
  * @constructor
352
376
  * @public
@@ -520,6 +544,21 @@ export declare class DisplayObject extends EventDispatcher {
520
544
  */
521
545
  get visible(): boolean;
522
546
  set visible(visible: boolean);
547
+ /**
548
+ * @description ビットマップキャッシュ用のMatrix。nullでない場合、指定Matrix × stageのrendererScaleで
549
+ * Shape/TextFieldのベクター描画をキャッシュし、ステージのリサイズがあるまで再利用します。
550
+ * 先祖のMatrixの影響を受けず、キャッシュの品質は指定Matrixとstageスケールのみで決定されます。
551
+ * Matrix for bitmap caching. When not null, caches Shape/TextField vector rendering
552
+ * at the specified Matrix × stage rendererScale, reusing until stage resize.
553
+ * Cache quality is determined only by the specified Matrix and stage scale,
554
+ * independent of ancestor transforms.
555
+ *
556
+ * @member {Matrix | null}
557
+ * @default null
558
+ * @public
559
+ */
560
+ get cacheAsBitmap(): Matrix | null;
561
+ set cacheAsBitmap(cache_as_bitmap: Matrix | null);
523
562
  /**
524
563
  * @description 表示オブジェクトの幅を示します(ピクセル単位)。
525
564
  * Indicates the width of the display object, in pixels.
@@ -1,3 +1,4 @@
1
+ import { Matrix } from "@next2d/geom";
1
2
  import { EventDispatcher } from "@next2d/events";
2
3
  import { execute as displayObjectApplyChangesService } from "./DisplayObject/service/DisplayObjectApplyChangesService";
3
4
  import { execute as displayObjectConcatenatedMatrixUseCase } from "./DisplayObject/usecase/DisplayObjectConcatenatedMatrixUseCase";
@@ -512,6 +513,25 @@ export class DisplayObject extends EventDispatcher {
512
513
  writable: true,
513
514
  value: void 0
514
515
  });
516
+ /**
517
+ * @description ビットマップキャッシュ用のMatrix。nullでない場合、指定Matrix × stageのrendererScaleで
518
+ * Shape/TextFieldのベクター描画をキャッシュし、ステージのリサイズがあるまで再利用します。
519
+ * 先祖のMatrixの影響を受けず、キャッシュの品質は指定Matrixとstageスケールのみで決定されます。
520
+ * Matrix for bitmap caching. When not null, caches Shape/TextField vector rendering
521
+ * at the specified Matrix × stage rendererScale, reusing until stage resize.
522
+ * Cache quality is determined only by the specified Matrix and stage scale,
523
+ * independent of ancestor transforms.
524
+ *
525
+ * @type {Matrix | null}
526
+ * @default null
527
+ * @private
528
+ */
529
+ Object.defineProperty(this, "_$cacheAsBitmap", {
530
+ enumerable: true,
531
+ configurable: true,
532
+ writable: true,
533
+ value: void 0
534
+ });
515
535
  /**
516
536
  * @description 表示オブジェクト単位の変数を保持するマップ
517
537
  * Map that holds variables for display objects
@@ -555,6 +575,20 @@ export class DisplayObject extends EventDispatcher {
555
575
  writable: true,
556
576
  value: void 0
557
577
  });
578
+ /**
579
+ * @description キャッシュする際の指定Matrix、nullの場合は通常のMatrixで描画
580
+ * Specified Matrix for caching, if null, draw with the normal Matrix
581
+ *
582
+ * @member {Matrix | null}
583
+ * @default null
584
+ * @public
585
+ */
586
+ Object.defineProperty(this, "cacheTransform", {
587
+ enumerable: true,
588
+ configurable: true,
589
+ writable: true,
590
+ value: null
591
+ });
558
592
  this.instanceId = $getInstanceId();
559
593
  this.dictionaryId = -1;
560
594
  this.uniqueKey = "";
@@ -587,6 +621,7 @@ export class DisplayObject extends EventDispatcher {
587
621
  this.$filters = null;
588
622
  this.$blendMode = null;
589
623
  this._$visible = true;
624
+ this._$cacheAsBitmap = null;
590
625
  this._$scale9Grid = null;
591
626
  this._$variables = null;
592
627
  // キャッシュ
@@ -800,9 +835,14 @@ export class DisplayObject extends EventDispatcher {
800
835
  * @public
801
836
  */
802
837
  get scaleX() {
803
- return this.$scaleX === null
838
+ const base = this.$scaleX === null
804
839
  ? displayObjectGetScaleXUseCase(this)
805
840
  : this.$scaleX;
841
+ if (this._$cacheAsBitmap) {
842
+ const m = this._$cacheAsBitmap.rawData;
843
+ return base * Math.sqrt(m[0] * m[0] + m[1] * m[1]);
844
+ }
845
+ return base;
806
846
  }
807
847
  set scaleX(scale_x) {
808
848
  displayObjectSetScaleXUseCase(this, scale_x);
@@ -816,9 +856,14 @@ export class DisplayObject extends EventDispatcher {
816
856
  * @public
817
857
  */
818
858
  get scaleY() {
819
- return this.$scaleY === null
859
+ const base = this.$scaleY === null
820
860
  ? displayObjectGetScaleYUseCase(this)
821
861
  : this.$scaleY;
862
+ if (this._$cacheAsBitmap) {
863
+ const m = this._$cacheAsBitmap.rawData;
864
+ return base * Math.sqrt(m[2] * m[2] + m[3] * m[3]);
865
+ }
866
+ return base;
822
867
  }
823
868
  set scaleY(scale_y) {
824
869
  displayObjectSetScaleYUseCase(this, scale_y);
@@ -841,6 +886,32 @@ export class DisplayObject extends EventDispatcher {
841
886
  this._$visible = visible;
842
887
  displayObjectApplyChangesService(this);
843
888
  }
889
+ /**
890
+ * @description ビットマップキャッシュ用のMatrix。nullでない場合、指定Matrix × stageのrendererScaleで
891
+ * Shape/TextFieldのベクター描画をキャッシュし、ステージのリサイズがあるまで再利用します。
892
+ * 先祖のMatrixの影響を受けず、キャッシュの品質は指定Matrixとstageスケールのみで決定されます。
893
+ * Matrix for bitmap caching. When not null, caches Shape/TextField vector rendering
894
+ * at the specified Matrix × stage rendererScale, reusing until stage resize.
895
+ * Cache quality is determined only by the specified Matrix and stage scale,
896
+ * independent of ancestor transforms.
897
+ *
898
+ * @member {Matrix | null}
899
+ * @default null
900
+ * @public
901
+ */
902
+ get cacheAsBitmap() {
903
+ return this._$cacheAsBitmap;
904
+ }
905
+ set cacheAsBitmap(cache_as_bitmap) {
906
+ if (cache_as_bitmap !== null && !(cache_as_bitmap instanceof Matrix)) {
907
+ return;
908
+ }
909
+ if (this._$cacheAsBitmap === cache_as_bitmap) {
910
+ return;
911
+ }
912
+ this._$cacheAsBitmap = cache_as_bitmap;
913
+ displayObjectApplyChangesService(this);
914
+ }
844
915
  /**
845
916
  * @description 表示オブジェクトの幅を示します(ピクセル単位)。
846
917
  * Indicates the width of the display object, in pixels.
@@ -3,7 +3,7 @@ import { execute as displayObjectGetRawMatrixUseCase } from "../../DisplayObject
3
3
  import { execute as shapeCalcBoundsMatrixUseCase } from "../../Shape/usecase/ShapeCalcBoundsMatrixUseCase";
4
4
  import { execute as videoCalcBoundsMatrixUseCase } from "../../Video/usecase/VideoCalcBoundsMatrixUseCase";
5
5
  import { execute as textFieldCalcBoundsMatrixUseCase } from "../../TextField/usecase/TextFieldCalcBoundsMatrixUseCase";
6
- import { $getBoundsArray, $poolBoundsArray } from "../../DisplayObjectUtil";
6
+ import { $getBoundsArray, $poolBoundsArray, $getFloat32Array6, $poolFloat32Array6 } from "../../DisplayObjectUtil";
7
7
  /**
8
8
  * @description DisplayObjectContainerのバウンディングボックスを計算
9
9
  * Calculate the bounding box of the DisplayObjectContainer
@@ -18,7 +18,22 @@ export const execute = (display_object_container, matrix = null) => {
18
18
  if (!children.length) {
19
19
  return $getBoundsArray(0, 0, 0, 0);
20
20
  }
21
- const rawMatrix = displayObjectGetRawMatrixUseCase(display_object_container);
21
+ let rawMatrix = displayObjectGetRawMatrixUseCase(display_object_container);
22
+ // cacheAsBitmap倍率をrawMatrixに適用(ShapeCalcBoundsMatrixUseCaseと同様)
23
+ const cacheMatrix = display_object_container.cacheAsBitmap;
24
+ let scaledMatrix = null;
25
+ if (cacheMatrix) {
26
+ const m = cacheMatrix.rawData;
27
+ const csx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
28
+ const csy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
29
+ if (rawMatrix) {
30
+ scaledMatrix = $getFloat32Array6(rawMatrix[0] * csx, rawMatrix[1] * csx, rawMatrix[2] * csy, rawMatrix[3] * csy, rawMatrix[4], rawMatrix[5]);
31
+ }
32
+ else {
33
+ scaledMatrix = $getFloat32Array6(csx, 0, 0, csy, 0, 0);
34
+ }
35
+ rawMatrix = scaledMatrix;
36
+ }
22
37
  const tMatrix = rawMatrix
23
38
  ? matrix
24
39
  ? Matrix.multiply(matrix, rawMatrix)
@@ -58,5 +73,8 @@ export const execute = (display_object_container, matrix = null) => {
58
73
  yMax = Math.max(yMax, bounds[3]);
59
74
  $poolBoundsArray(bounds);
60
75
  }
76
+ if (scaledMatrix) {
77
+ $poolFloat32Array6(scaledMatrix);
78
+ }
61
79
  return $getBoundsArray(xMin, yMin, xMax, yMax);
62
80
  };