@next2d/display 1.15.0 → 1.17.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/dist/BitmapData.d.ts +10 -1
- package/dist/BitmapData.js +55 -25
- package/dist/DisplayObject.d.ts +18 -11
- package/dist/DisplayObject.js +245 -125
- package/dist/DisplayObjectContainer.d.ts +3 -3
- package/dist/DisplayObjectContainer.js +192 -359
- package/dist/Graphics.d.ts +19 -1
- package/dist/Graphics.js +249 -109
- package/dist/Loader.d.ts +11 -1
- package/dist/Loader.js +33 -32
- package/dist/MovieClip.js +1 -1
- package/dist/Shape.d.ts +6 -8
- package/dist/Shape.js +75 -67
- package/dist/Sprite.d.ts +0 -12
- package/dist/Sprite.js +0 -22
- package/dist/Stage.js +3 -2
- package/dist/TextField.d.ts +555 -0
- package/dist/TextField.js +2031 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +12 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InteractiveObject } from "./InteractiveObject";
|
|
2
2
|
import { Event as Next2DEvent } from "@next2d/events";
|
|
3
|
-
import { $createInstance, $currentPlayer, $hitContext, $isTouch, $MATRIX_HIT_ARRAY_IDENTITY, $rendererWorker } from "@next2d/util";
|
|
4
|
-
import { $doUpdated, $boundsMatrix, $clamp, $getArray, $getBoundsObject, $getFloat32Array6, $getFloat32Array8, $getMap, $getPreObject, $Math, $COLOR_ARRAY_IDENTITY, $MATRIX_ARRAY_IDENTITY, $multiplicationColor, $multiplicationMatrix, $Number, $poolArray, $poolBoundsObject, $poolFloat32Array6, $poolFloat32Array8, $poolMap, $poolPreObject } from "@next2d/share";
|
|
3
|
+
import { $createInstance, $currentPlayer, $getRenderBufferArray, $getRenderMessageObject, $hitContext, $isTouch, $MATRIX_HIT_ARRAY_IDENTITY, $poolRenderMessageObject, $rendererWorker } from "@next2d/util";
|
|
4
|
+
import { $cacheStore, $doUpdated, $boundsMatrix, $clamp, $getArray, $getBoundsObject, $getFloat32Array6, $getFloat32Array8, $getMap, $getPreObject, $Math, $COLOR_ARRAY_IDENTITY, $MATRIX_ARRAY_IDENTITY, $multiplicationColor, $multiplicationMatrix, $Number, $poolArray, $poolBoundsObject, $poolFloat32Array6, $poolFloat32Array8, $poolMap, $poolPreObject, $devicePixelRatio } from "@next2d/share";
|
|
5
5
|
/**
|
|
6
6
|
* DisplayObjectContainer クラスは、表示リストで表示オブジェクトコンテナとして機能するすべてのオブジェクトの基本クラスです。
|
|
7
7
|
* このクラス自体は、画面上でのコンテンツの描画のための API を含みません。
|
|
@@ -384,14 +384,11 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
384
384
|
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
-
const graphics = "_$graphics" in this
|
|
388
|
-
? this._$graphics
|
|
389
|
-
: null;
|
|
390
387
|
const children = this._$needsChildren
|
|
391
388
|
? this._$getChildren()
|
|
392
389
|
: this._$children;
|
|
393
390
|
// size zero
|
|
394
|
-
if (!children.length
|
|
391
|
+
if (!children.length) {
|
|
395
392
|
const bounds = $getBoundsObject(multiMatrix[4], -multiMatrix[4], multiMatrix[5], -multiMatrix[5]);
|
|
396
393
|
if (matrix && multiMatrix !== matrix) {
|
|
397
394
|
$poolFloat32Array6(multiMatrix);
|
|
@@ -404,16 +401,6 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
404
401
|
let xMax = -no;
|
|
405
402
|
let yMin = no;
|
|
406
403
|
let yMax = -no;
|
|
407
|
-
if (graphics) {
|
|
408
|
-
const baseBounds = graphics._$getBounds();
|
|
409
|
-
const bounds = $boundsMatrix(baseBounds, multiMatrix);
|
|
410
|
-
$poolBoundsObject(baseBounds);
|
|
411
|
-
xMin = bounds.xMin;
|
|
412
|
-
xMax = bounds.xMax;
|
|
413
|
-
yMin = bounds.yMin;
|
|
414
|
-
yMax = bounds.yMax;
|
|
415
|
-
$poolBoundsObject(bounds);
|
|
416
|
-
}
|
|
417
404
|
for (let idx = 0; idx < children.length; ++idx) {
|
|
418
405
|
const bounds = children[idx]._$getBounds(multiMatrix);
|
|
419
406
|
xMin = $Math.min(xMin, bounds.xMin);
|
|
@@ -429,32 +416,17 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
429
416
|
return $getBoundsObject(xMin, xMax, yMin, yMax);
|
|
430
417
|
}
|
|
431
418
|
/**
|
|
432
|
-
* @param {
|
|
419
|
+
* @param {Float32Array} multi_matrix
|
|
433
420
|
* @return {object}
|
|
434
421
|
* @private
|
|
435
422
|
*/
|
|
436
|
-
_$getLayerBounds(
|
|
437
|
-
let multiMatrix = $MATRIX_ARRAY_IDENTITY;
|
|
438
|
-
if (matrix) {
|
|
439
|
-
multiMatrix = matrix;
|
|
440
|
-
const rawMatrix = this._$transform._$rawMatrix();
|
|
441
|
-
if (rawMatrix !== $MATRIX_ARRAY_IDENTITY) {
|
|
442
|
-
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
const graphics = "_$graphics" in this
|
|
446
|
-
? this._$graphics
|
|
447
|
-
: null;
|
|
423
|
+
_$getLayerBounds(multi_matrix) {
|
|
448
424
|
const children = this._$needsChildren
|
|
449
425
|
? this._$getChildren()
|
|
450
426
|
: this._$children;
|
|
451
427
|
// size zero
|
|
452
|
-
if (!children.length
|
|
453
|
-
|
|
454
|
-
if (matrix && multiMatrix !== matrix) {
|
|
455
|
-
$poolFloat32Array6(multiMatrix);
|
|
456
|
-
}
|
|
457
|
-
return bounds;
|
|
428
|
+
if (!children.length) {
|
|
429
|
+
return $getBoundsObject(0, 0, 0, 0);
|
|
458
430
|
}
|
|
459
431
|
// data init
|
|
460
432
|
const no = $Number.MAX_VALUE;
|
|
@@ -462,45 +434,46 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
462
434
|
let xMax = -no;
|
|
463
435
|
let yMin = no;
|
|
464
436
|
let yMax = -no;
|
|
465
|
-
if (graphics) {
|
|
466
|
-
const baseBounds = graphics._$getBounds();
|
|
467
|
-
const bounds = $boundsMatrix(baseBounds, multiMatrix);
|
|
468
|
-
$poolBoundsObject(baseBounds);
|
|
469
|
-
xMin = +bounds.xMin;
|
|
470
|
-
xMax = +bounds.xMax;
|
|
471
|
-
yMin = +bounds.yMin;
|
|
472
|
-
yMax = +bounds.yMax;
|
|
473
|
-
$poolBoundsObject(bounds);
|
|
474
|
-
}
|
|
475
437
|
for (let idx = 0; idx < children.length; ++idx) {
|
|
476
|
-
const
|
|
477
|
-
|
|
438
|
+
const instance = children[idx];
|
|
439
|
+
let multiMatrix = multi_matrix;
|
|
440
|
+
const rawMatrix = instance._$transform._$rawMatrix();
|
|
441
|
+
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
442
|
+
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
443
|
+
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
444
|
+
multiMatrix = $multiplicationMatrix(multi_matrix, rawMatrix);
|
|
445
|
+
}
|
|
446
|
+
const bounds = instance._$getLayerBounds(multiMatrix);
|
|
478
447
|
xMin = $Math.min(xMin, bounds.xMin);
|
|
479
448
|
xMax = $Math.max(xMax, bounds.xMax);
|
|
480
449
|
yMin = $Math.min(yMin, bounds.yMin);
|
|
481
450
|
yMax = $Math.max(yMax, bounds.yMax);
|
|
482
451
|
$poolBoundsObject(bounds);
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
// end
|
|
488
|
-
if (!matrix) {
|
|
489
|
-
return $getBoundsObject(xMin, xMax, yMin, yMax);
|
|
452
|
+
if (multiMatrix !== multi_matrix) {
|
|
453
|
+
$poolFloat32Array6(multiMatrix);
|
|
454
|
+
}
|
|
490
455
|
}
|
|
491
456
|
const filters = this._$filters || this.filters;
|
|
492
457
|
if (!filters.length) {
|
|
493
458
|
return $getBoundsObject(xMin, xMax, yMin, yMax);
|
|
494
459
|
}
|
|
495
|
-
let filterBounds = $getBoundsObject(
|
|
460
|
+
let filterBounds = $getBoundsObject(0, xMax - xMin, 0, yMax - yMin);
|
|
461
|
+
let xScale = +$Math.sqrt(multi_matrix[0] * multi_matrix[0]
|
|
462
|
+
+ multi_matrix[1] * multi_matrix[1]);
|
|
463
|
+
let yScale = +$Math.sqrt(multi_matrix[2] * multi_matrix[2]
|
|
464
|
+
+ multi_matrix[3] * multi_matrix[3]);
|
|
465
|
+
xScale /= $devicePixelRatio;
|
|
466
|
+
yScale /= $devicePixelRatio;
|
|
467
|
+
xScale *= 2;
|
|
468
|
+
yScale *= 2;
|
|
496
469
|
for (let idx = 0; idx < filters.length; ++idx) {
|
|
497
470
|
filterBounds = filters[idx]
|
|
498
|
-
._$generateFilterRect(filterBounds,
|
|
471
|
+
._$generateFilterRect(filterBounds, xScale, yScale);
|
|
499
472
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
473
|
+
xMax += filterBounds.xMax - (xMax - xMin);
|
|
474
|
+
yMax += filterBounds.yMax - (yMax - yMin);
|
|
475
|
+
xMin += filterBounds.xMin;
|
|
476
|
+
yMin += filterBounds.yMin;
|
|
504
477
|
$poolBoundsObject(filterBounds);
|
|
505
478
|
return $getBoundsObject(xMin, xMax, yMin, yMax);
|
|
506
479
|
}
|
|
@@ -537,8 +510,6 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
537
510
|
}
|
|
538
511
|
return currentChildren;
|
|
539
512
|
}
|
|
540
|
-
const player = $currentPlayer();
|
|
541
|
-
const cacheStore = player.cacheStore;
|
|
542
513
|
const useWorker = !!$rendererWorker && !!this._$stage;
|
|
543
514
|
const skipIds = $getMap();
|
|
544
515
|
const poolInstances = $getMap();
|
|
@@ -590,9 +561,12 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
590
561
|
if (useWorker) {
|
|
591
562
|
instance._$removeWorkerInstance();
|
|
592
563
|
}
|
|
593
|
-
cacheStore.setRemoveTimer(instanceId);
|
|
564
|
+
$cacheStore.setRemoveTimer(instanceId);
|
|
594
565
|
if (instance._$loaderInfo && instance._$characterId) {
|
|
595
|
-
cacheStore.setRemoveTimer(`${instance._$loaderInfo._$id}@${instance._$characterId}`);
|
|
566
|
+
$cacheStore.setRemoveTimer(`${instance._$loaderInfo._$id}@${instance._$characterId}`);
|
|
567
|
+
}
|
|
568
|
+
if (instance._$graphics) {
|
|
569
|
+
$cacheStore.setRemoveTimer(instance._$graphics._$uniqueKey);
|
|
596
570
|
}
|
|
597
571
|
// remove event
|
|
598
572
|
if (instance.willTrigger(Next2DEvent.REMOVED)) {
|
|
@@ -695,7 +669,6 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
695
669
|
}
|
|
696
670
|
if ($rendererWorker) {
|
|
697
671
|
child._$createWorkerInstance();
|
|
698
|
-
child._$postProperty();
|
|
699
672
|
this._$postChildrenIds();
|
|
700
673
|
}
|
|
701
674
|
}
|
|
@@ -743,7 +716,6 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
743
716
|
if (!instance._$addedStage) {
|
|
744
717
|
if ($rendererWorker) {
|
|
745
718
|
instance._$createWorkerInstance();
|
|
746
|
-
instance._$postProperty();
|
|
747
719
|
}
|
|
748
720
|
if (instance.willTrigger(Next2DEvent.ADDED_TO_STAGE)) {
|
|
749
721
|
instance.dispatchEvent(new Next2DEvent(Next2DEvent.ADDED_TO_STAGE));
|
|
@@ -818,11 +790,12 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
818
790
|
child._$executeRemovedFromStage();
|
|
819
791
|
}
|
|
820
792
|
}
|
|
821
|
-
|
|
822
|
-
const cacheStore = player.cacheStore;
|
|
823
|
-
cacheStore.setRemoveTimer(child._$instanceId);
|
|
793
|
+
$cacheStore.setRemoveTimer(child._$instanceId);
|
|
824
794
|
if (child._$loaderInfo && child._$characterId) {
|
|
825
|
-
cacheStore.setRemoveTimer(`${child._$loaderInfo._$id}@${child._$characterId}`);
|
|
795
|
+
$cacheStore.setRemoveTimer(`${child._$loaderInfo._$id}@${child._$characterId}`);
|
|
796
|
+
}
|
|
797
|
+
if (child._$graphics) {
|
|
798
|
+
$cacheStore.setRemoveTimer(child._$graphics._$uniqueKey);
|
|
826
799
|
}
|
|
827
800
|
// reset params
|
|
828
801
|
if (child instanceof DisplayObjectContainer) {
|
|
@@ -881,13 +854,14 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
881
854
|
const children = this._$needsChildren
|
|
882
855
|
? this._$getChildren()
|
|
883
856
|
: this._$children;
|
|
884
|
-
const player = $currentPlayer();
|
|
885
|
-
const cacheStore = player.cacheStore;
|
|
886
857
|
for (let idx = 0; idx < children.length; ++idx) {
|
|
887
858
|
const instance = children[idx];
|
|
888
|
-
cacheStore.setRemoveTimer(instance._$instanceId);
|
|
859
|
+
$cacheStore.setRemoveTimer(instance._$instanceId);
|
|
889
860
|
if (instance._$loaderInfo && instance._$characterId) {
|
|
890
|
-
cacheStore.setRemoveTimer(`${instance._$loaderInfo._$id}@${instance._$characterId}`);
|
|
861
|
+
$cacheStore.setRemoveTimer(`${instance._$loaderInfo._$id}@${instance._$characterId}`);
|
|
862
|
+
}
|
|
863
|
+
if (instance._$graphics) {
|
|
864
|
+
$cacheStore.setRemoveTimer(instance._$graphics._$uniqueKey);
|
|
891
865
|
}
|
|
892
866
|
if (instance instanceof DisplayObjectContainer) {
|
|
893
867
|
instance._$removeParentAndStage();
|
|
@@ -967,12 +941,6 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
967
941
|
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
968
942
|
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
969
943
|
}
|
|
970
|
-
const graphics = "_$graphics" in this
|
|
971
|
-
? this._$graphics
|
|
972
|
-
: null;
|
|
973
|
-
if (graphics && graphics._$canDraw) {
|
|
974
|
-
graphics._$clip(context, multiMatrix);
|
|
975
|
-
}
|
|
976
944
|
const children = this._$getChildren();
|
|
977
945
|
for (let idx = 0; idx < children.length; ++idx) {
|
|
978
946
|
const instance = children[idx];
|
|
@@ -1005,6 +973,9 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1005
973
|
// size zero
|
|
1006
974
|
if (!multiMatrix[0] && !multiMatrix[1]
|
|
1007
975
|
|| !multiMatrix[2] && !multiMatrix[3]) {
|
|
976
|
+
if (multiMatrix !== matrix) {
|
|
977
|
+
$poolFloat32Array6(multiMatrix);
|
|
978
|
+
}
|
|
1008
979
|
return null;
|
|
1009
980
|
}
|
|
1010
981
|
// return object
|
|
@@ -1024,101 +995,96 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1024
995
|
const yMax = +bounds.yMax;
|
|
1025
996
|
const yMin = +bounds.yMin;
|
|
1026
997
|
$poolBoundsObject(bounds);
|
|
1027
|
-
const width = $Math.abs(xMax - xMin);
|
|
1028
|
-
const height = $Math.abs(yMax - yMin);
|
|
998
|
+
const width = $Math.ceil($Math.abs(xMax - xMin));
|
|
999
|
+
const height = $Math.ceil($Math.abs(yMax - yMin));
|
|
1029
1000
|
if (0 >= width || 0 >= height) {
|
|
1030
1001
|
$poolPreObject(object);
|
|
1002
|
+
if (multiMatrix !== matrix) {
|
|
1003
|
+
$poolFloat32Array6(multiMatrix);
|
|
1004
|
+
}
|
|
1031
1005
|
return null;
|
|
1032
1006
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1007
|
+
let xScale = +$Math.sqrt(multiMatrix[0] * multiMatrix[0]
|
|
1008
|
+
+ multiMatrix[1] * multiMatrix[1]);
|
|
1009
|
+
if (!$Number.isInteger(xScale)) {
|
|
1010
|
+
const value = xScale.toString();
|
|
1011
|
+
const index = value.indexOf("e");
|
|
1012
|
+
if (index !== -1) {
|
|
1013
|
+
xScale = +value.slice(0, index);
|
|
1014
|
+
}
|
|
1015
|
+
xScale = +xScale.toFixed(4);
|
|
1016
|
+
}
|
|
1017
|
+
let yScale = +$Math.sqrt(multiMatrix[2] * multiMatrix[2]
|
|
1018
|
+
+ multiMatrix[3] * multiMatrix[3]);
|
|
1019
|
+
if (!$Number.isInteger(yScale)) {
|
|
1020
|
+
const value = yScale.toString();
|
|
1021
|
+
const index = value.indexOf("e");
|
|
1022
|
+
if (index !== -1) {
|
|
1023
|
+
yScale = +value.slice(0, index);
|
|
1024
|
+
}
|
|
1025
|
+
yScale = +yScale.toFixed(4);
|
|
1026
|
+
}
|
|
1027
|
+
object.canApply = this._$canApply(filters);
|
|
1028
|
+
let filterBounds = $getBoundsObject(0, width, 0, height);
|
|
1029
|
+
if (object.canApply && filters) {
|
|
1030
|
+
for (let idx = 0; idx < filters.length; ++idx) {
|
|
1031
|
+
filterBounds = filters[idx]
|
|
1032
|
+
._$generateFilterRect(filterBounds, xScale, yScale);
|
|
1033
|
+
}
|
|
1036
1034
|
}
|
|
1037
1035
|
const currentAttachment = context
|
|
1038
1036
|
.frameBuffer
|
|
1039
1037
|
.currentAttachment;
|
|
1040
1038
|
if (!currentAttachment
|
|
1041
1039
|
|| !currentAttachment.texture
|
|
1042
|
-
|| xMin > currentAttachment.width
|
|
1043
|
-
|| yMin > currentAttachment.height) {
|
|
1040
|
+
|| xMin - filterBounds.xMin > currentAttachment.width
|
|
1041
|
+
|| yMin - filterBounds.yMin > currentAttachment.height) {
|
|
1042
|
+
$poolBoundsObject(filterBounds);
|
|
1044
1043
|
$poolPreObject(object);
|
|
1044
|
+
if (multiMatrix !== matrix) {
|
|
1045
|
+
$poolFloat32Array6(multiMatrix);
|
|
1046
|
+
}
|
|
1045
1047
|
return null;
|
|
1046
1048
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
object.basePosition.y = rawMatrix[5];
|
|
1050
|
-
// check after size
|
|
1051
|
-
const baseLayerBounds = this._$getLayerBounds(null);
|
|
1052
|
-
const layerBounds = $boundsMatrix(baseLayerBounds, multiMatrix);
|
|
1053
|
-
// filter size
|
|
1054
|
-
let layerWidth = $Math.abs(layerBounds.xMax - layerBounds.xMin);
|
|
1055
|
-
let layerHeight = $Math.abs(layerBounds.yMax - layerBounds.yMin);
|
|
1056
|
-
$poolBoundsObject(layerBounds);
|
|
1057
|
-
// move size
|
|
1058
|
-
let tx = multiMatrix[4] - $Math.floor(xMin);
|
|
1059
|
-
let ty = multiMatrix[5] - $Math.floor(yMin);
|
|
1060
|
-
let dx = $Math.floor(xMin);
|
|
1061
|
-
let dy = $Math.floor(yMin);
|
|
1062
|
-
let originX = xMin;
|
|
1063
|
-
let originY = yMin;
|
|
1064
|
-
if (layerWidth !== width || layerHeight !== height) {
|
|
1065
|
-
const layerMatrix = $getFloat32Array6(multiMatrix[0], multiMatrix[1], multiMatrix[2], multiMatrix[3], 0, 0);
|
|
1066
|
-
const moveBounds = $boundsMatrix(baseLayerBounds, layerMatrix);
|
|
1067
|
-
// pool
|
|
1068
|
-
$poolFloat32Array6(layerMatrix);
|
|
1069
|
-
tx += -$Math.floor(moveBounds.xMin) - tx;
|
|
1070
|
-
ty += -$Math.floor(moveBounds.yMin) - ty;
|
|
1071
|
-
dx -= -$Math.floor(moveBounds.xMin) - (multiMatrix[4] - dx);
|
|
1072
|
-
dy -= -$Math.floor(moveBounds.yMin) - (multiMatrix[5] - dy);
|
|
1073
|
-
originX -= -moveBounds.xMin - (multiMatrix[4] - originX);
|
|
1074
|
-
originY -= -moveBounds.yMin - (multiMatrix[5] - originY);
|
|
1075
|
-
$poolBoundsObject(moveBounds);
|
|
1076
|
-
}
|
|
1077
|
-
$poolBoundsObject(baseLayerBounds);
|
|
1078
|
-
// set position
|
|
1079
|
-
object.position.dx = dx > 0 ? dx : 0;
|
|
1080
|
-
object.position.dy = dy > 0 ? dy : 0;
|
|
1081
|
-
// resize
|
|
1082
|
-
if (layerWidth + originX > currentAttachment.texture.width) {
|
|
1083
|
-
layerWidth -= layerWidth - currentAttachment.texture.width + originX;
|
|
1084
|
-
}
|
|
1085
|
-
if (layerHeight + originY > currentAttachment.texture.height) {
|
|
1086
|
-
layerHeight -= layerHeight - currentAttachment.texture.height + originY;
|
|
1087
|
-
}
|
|
1088
|
-
if (0 > dx) {
|
|
1089
|
-
tx += dx;
|
|
1090
|
-
layerWidth += originX;
|
|
1091
|
-
}
|
|
1092
|
-
if (0 > dy) {
|
|
1093
|
-
ty += dy;
|
|
1094
|
-
layerHeight += originY;
|
|
1095
|
-
}
|
|
1096
|
-
if (0 >= layerWidth || 0 >= layerHeight // size (-)
|
|
1097
|
-
|| !layerWidth || !layerHeight // NaN or Infinity
|
|
1098
|
-
) {
|
|
1049
|
+
if (0 > xMin + filterBounds.xMax || 0 > yMin + filterBounds.yMax) {
|
|
1050
|
+
$poolBoundsObject(filterBounds);
|
|
1099
1051
|
$poolPreObject(object);
|
|
1052
|
+
if (multiMatrix !== matrix) {
|
|
1053
|
+
$poolFloat32Array6(multiMatrix);
|
|
1054
|
+
}
|
|
1100
1055
|
return null;
|
|
1101
1056
|
}
|
|
1057
|
+
// move size
|
|
1058
|
+
let tx = multiMatrix[4] - xMin;
|
|
1059
|
+
let ty = multiMatrix[5] - yMin;
|
|
1102
1060
|
// start layer
|
|
1103
|
-
context._$startLayer($getBoundsObject(
|
|
1061
|
+
context._$startLayer($getBoundsObject(xMin, xMax, yMin, yMax));
|
|
1104
1062
|
// check cache
|
|
1105
|
-
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
|
|
1063
|
+
const updated = this._$isFilterUpdated(multiMatrix, filters, object.canApply);
|
|
1064
|
+
const layerBounds = this._$getLayerBounds(multiMatrix);
|
|
1065
|
+
const layerWidth = $Math.ceil($Math.abs(layerBounds.xMax - layerBounds.xMin));
|
|
1066
|
+
const layerHeight = $Math.ceil($Math.abs(layerBounds.yMax - layerBounds.yMin));
|
|
1067
|
+
$poolBoundsObject(layerBounds);
|
|
1068
|
+
const sw = layerWidth - filterBounds.xMax + filterBounds.xMin;
|
|
1069
|
+
const sh = layerHeight - filterBounds.yMax + filterBounds.yMin;
|
|
1070
|
+
tx += sw;
|
|
1071
|
+
ty += sh;
|
|
1072
|
+
object.sw = sw;
|
|
1073
|
+
object.sh = sh;
|
|
1109
1074
|
if (updated) {
|
|
1110
|
-
context._$saveAttachment($Math.ceil(
|
|
1075
|
+
context._$saveAttachment($Math.ceil(width + sw), $Math.ceil(height + sh), true);
|
|
1111
1076
|
}
|
|
1112
1077
|
// setup
|
|
1113
|
-
object.
|
|
1078
|
+
object.isLayer = true;
|
|
1114
1079
|
object.isUpdated = updated;
|
|
1115
|
-
object.color = $getFloat32Array8();
|
|
1116
|
-
object.baseMatrix = multiMatrix;
|
|
1117
1080
|
object.filters = filters;
|
|
1118
1081
|
object.blendMode = blendMode;
|
|
1119
|
-
object.
|
|
1120
|
-
object.layerHeight = layerHeight;
|
|
1082
|
+
object.color = $getFloat32Array8();
|
|
1121
1083
|
object.matrix = $getFloat32Array6(multiMatrix[0], multiMatrix[1], multiMatrix[2], multiMatrix[3], tx, ty);
|
|
1084
|
+
if (multiMatrix !== matrix) {
|
|
1085
|
+
$poolFloat32Array6(multiMatrix);
|
|
1086
|
+
}
|
|
1087
|
+
$poolBoundsObject(filterBounds);
|
|
1122
1088
|
}
|
|
1123
1089
|
return object;
|
|
1124
1090
|
}
|
|
@@ -1132,105 +1098,66 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1132
1098
|
* @private
|
|
1133
1099
|
*/
|
|
1134
1100
|
_$postDraw(context, matrix, color_transform, object) {
|
|
1101
|
+
context.drawInstacedArray();
|
|
1135
1102
|
// cache
|
|
1136
1103
|
const cacheKeys = $getArray(this._$instanceId, "f");
|
|
1137
|
-
const player = $currentPlayer();
|
|
1138
|
-
const cacheStore = player.cacheStore;
|
|
1139
1104
|
const manager = context.frameBuffer;
|
|
1140
|
-
|
|
1141
|
-
let
|
|
1142
|
-
|
|
1105
|
+
const multiMatrix = object.matrix;
|
|
1106
|
+
let offsetX = 0;
|
|
1107
|
+
let offsetY = 0;
|
|
1108
|
+
let texture = $cacheStore.get(cacheKeys);
|
|
1109
|
+
if (!texture || object.isUpdated) {
|
|
1110
|
+
// remove
|
|
1111
|
+
if (texture) {
|
|
1112
|
+
$cacheStore.set(cacheKeys, null);
|
|
1113
|
+
}
|
|
1143
1114
|
texture = manager
|
|
1144
1115
|
.getTextureFromCurrentAttachment();
|
|
1145
|
-
const cacheTexture = cacheStore.get(cacheKeys);
|
|
1146
|
-
if (cacheTexture) {
|
|
1147
|
-
cacheStore.set(cacheKeys, null);
|
|
1148
|
-
manager.releaseTexture(cacheTexture);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
else {
|
|
1152
|
-
texture = cacheStore.get(cacheKeys);
|
|
1153
|
-
if (!texture) {
|
|
1154
|
-
throw new Error("the texture is null.");
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
// blend only
|
|
1158
|
-
if (!object.canApply) {
|
|
1159
|
-
texture._$offsetX = 0;
|
|
1160
|
-
texture._$offsetY = 0;
|
|
1161
|
-
}
|
|
1162
|
-
// set cache offset
|
|
1163
|
-
let offsetX = texture._$offsetX;
|
|
1164
|
-
let offsetY = texture._$offsetY;
|
|
1165
|
-
// execute filter
|
|
1166
|
-
if (object.isUpdated && object.canApply) {
|
|
1167
|
-
// cache clear
|
|
1168
|
-
const cache = cacheStore.get(cacheKeys);
|
|
1169
|
-
if (cache) {
|
|
1170
|
-
// reset cache params
|
|
1171
|
-
cacheStore.set(cacheKeys, null);
|
|
1172
|
-
cache.layerWidth = 0;
|
|
1173
|
-
cache.layerHeight = 0;
|
|
1174
|
-
cache._$offsetX = 0;
|
|
1175
|
-
cache._$offsetY = 0;
|
|
1176
|
-
cache.matrix = null;
|
|
1177
|
-
cache.colorTransform = null;
|
|
1178
|
-
manager.releaseTexture(cache);
|
|
1179
|
-
}
|
|
1180
|
-
// apply filter
|
|
1181
1116
|
const filters = object.filters;
|
|
1117
|
+
let filterState = false;
|
|
1182
1118
|
if (filters && filters.length) {
|
|
1183
|
-
// init
|
|
1184
|
-
context._$offsetX = 0;
|
|
1185
|
-
context._$offsetY = 0;
|
|
1186
1119
|
for (let idx = 0; idx < filters.length; ++idx) {
|
|
1187
1120
|
texture = filters[idx]
|
|
1188
1121
|
._$applyFilter(context, matrix);
|
|
1189
1122
|
}
|
|
1123
|
+
// update
|
|
1124
|
+
filterState = true;
|
|
1190
1125
|
offsetX = context._$offsetX;
|
|
1191
1126
|
offsetY = context._$offsetY;
|
|
1192
1127
|
// reset
|
|
1193
1128
|
context._$offsetX = 0;
|
|
1194
1129
|
context._$offsetY = 0;
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
texture.
|
|
1203
|
-
|
|
1204
|
-
const matrix = object.baseMatrix;
|
|
1205
|
-
if (matrix) {
|
|
1206
|
-
texture.matrix = `${matrix[0]}_${matrix[1]}_${matrix[2]}_${matrix[3]}`;
|
|
1207
|
-
}
|
|
1208
|
-
texture.layerWidth = object.layerWidth;
|
|
1209
|
-
texture.layerHeight = object.layerHeight;
|
|
1210
|
-
}
|
|
1211
|
-
// cache texture
|
|
1212
|
-
cacheStore.set(cacheKeys, texture);
|
|
1213
|
-
$poolArray(cacheKeys);
|
|
1214
|
-
// set current buffer
|
|
1215
|
-
if (object.isUpdated) {
|
|
1130
|
+
}
|
|
1131
|
+
texture.filterState = filterState;
|
|
1132
|
+
texture.matrix = `${multiMatrix[0]}_`
|
|
1133
|
+
+ `${multiMatrix[1]}_`
|
|
1134
|
+
+ `${multiMatrix[2]}_`
|
|
1135
|
+
+ `${multiMatrix[3]}`;
|
|
1136
|
+
texture.offsetX = offsetX;
|
|
1137
|
+
texture.offsetY = offsetY;
|
|
1138
|
+
$cacheStore.set(cacheKeys, texture);
|
|
1216
1139
|
context._$restoreAttachment();
|
|
1217
1140
|
}
|
|
1141
|
+
if (texture.offsetX) {
|
|
1142
|
+
offsetX = texture.offsetX;
|
|
1143
|
+
}
|
|
1144
|
+
if (texture.offsetY) {
|
|
1145
|
+
offsetY = texture.offsetY;
|
|
1146
|
+
}
|
|
1218
1147
|
// set
|
|
1219
1148
|
context.reset();
|
|
1220
1149
|
context.globalAlpha = $clamp(color_transform[3] + color_transform[7] / 255, 0, 1);
|
|
1221
1150
|
context.globalCompositeOperation = object.blendMode;
|
|
1222
|
-
context.
|
|
1223
|
-
context.
|
|
1151
|
+
const bounds = context.getCurrentPosition();
|
|
1152
|
+
context.setTransform(1, 0, 0, 1, bounds.xMin - offsetX - object.sw, bounds.yMin - offsetY - object.sh);
|
|
1153
|
+
context.drawImage(texture, 0, 0, texture.width, texture.height, color_transform);
|
|
1224
1154
|
// end blend
|
|
1225
1155
|
context._$endLayer();
|
|
1226
|
-
// reset
|
|
1227
|
-
context._$restoreCurrentMask();
|
|
1228
1156
|
// object pool
|
|
1229
|
-
if (object.baseMatrix !== matrix) {
|
|
1230
|
-
$poolFloat32Array6(object.baseMatrix);
|
|
1231
|
-
}
|
|
1232
1157
|
$poolFloat32Array6(object.matrix);
|
|
1233
1158
|
$poolPreObject(object);
|
|
1159
|
+
// reset
|
|
1160
|
+
context.cachePosition = null;
|
|
1234
1161
|
}
|
|
1235
1162
|
/**
|
|
1236
1163
|
* @param {CanvasToWebGLContext} context
|
|
@@ -1263,10 +1190,7 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1263
1190
|
// not draw
|
|
1264
1191
|
const children = this._$getChildren();
|
|
1265
1192
|
const length = children.length;
|
|
1266
|
-
|
|
1267
|
-
? this._$graphics
|
|
1268
|
-
: null;
|
|
1269
|
-
if (!length && (!graphics || !graphics._$canDraw)) {
|
|
1193
|
+
if (!length) {
|
|
1270
1194
|
return;
|
|
1271
1195
|
}
|
|
1272
1196
|
// pre data
|
|
@@ -1275,25 +1199,17 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1275
1199
|
return;
|
|
1276
1200
|
}
|
|
1277
1201
|
// use cache
|
|
1278
|
-
if (preObject.
|
|
1202
|
+
if (preObject.isLayer && !preObject.isUpdated) {
|
|
1279
1203
|
this._$postDraw(context, matrix, multiColor, preObject);
|
|
1280
1204
|
return;
|
|
1281
1205
|
}
|
|
1282
|
-
|
|
1283
|
-
const preColorTransform = preObject.
|
|
1206
|
+
const preMatrix = preObject.matrix;
|
|
1207
|
+
const preColorTransform = preObject.isLayer && preObject.color
|
|
1284
1208
|
? preObject.color
|
|
1285
1209
|
: multiColor;
|
|
1286
|
-
// if graphics draw
|
|
1287
|
-
if (graphics && graphics._$canDraw) {
|
|
1288
|
-
graphics._$draw(context, preMatrix, preColorTransform);
|
|
1289
|
-
}
|
|
1290
1210
|
// init clip params
|
|
1291
1211
|
let shouldClip = true;
|
|
1292
1212
|
let clipDepth = 0;
|
|
1293
|
-
const clipMatrix = $getArray();
|
|
1294
|
-
const instanceMatrix = $getArray();
|
|
1295
|
-
const clipStack = $getArray();
|
|
1296
|
-
const shouldClips = $getArray();
|
|
1297
1213
|
const player = $currentPlayer();
|
|
1298
1214
|
// draw children
|
|
1299
1215
|
const isLayer = context.isLayer;
|
|
@@ -1319,17 +1235,10 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1319
1235
|
context.restore();
|
|
1320
1236
|
if (shouldClip) {
|
|
1321
1237
|
context._$leaveClip();
|
|
1322
|
-
if (clipMatrix.length) {
|
|
1323
|
-
const matrix = clipMatrix.pop();
|
|
1324
|
-
if (matrix) {
|
|
1325
|
-
$poolFloat32Array6(preMatrix);
|
|
1326
|
-
preMatrix = matrix;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
1238
|
}
|
|
1330
1239
|
// clear
|
|
1331
|
-
clipDepth =
|
|
1332
|
-
shouldClip =
|
|
1240
|
+
clipDepth = 0;
|
|
1241
|
+
shouldClip = true;
|
|
1333
1242
|
}
|
|
1334
1243
|
// mask size 0
|
|
1335
1244
|
if (!shouldClip) {
|
|
@@ -1337,23 +1246,11 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1337
1246
|
}
|
|
1338
1247
|
// mask start
|
|
1339
1248
|
if (instance._$clipDepth > 0) {
|
|
1340
|
-
context.save();
|
|
1341
|
-
if (clipDepth) {
|
|
1342
|
-
clipStack.push(clipDepth);
|
|
1343
|
-
}
|
|
1344
|
-
shouldClips.push(shouldClip);
|
|
1345
1249
|
clipDepth = instance._$clipDepth;
|
|
1346
1250
|
shouldClip = instance._$shouldClip(preMatrix);
|
|
1347
1251
|
if (shouldClip) {
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
shouldClip = false;
|
|
1351
|
-
continue;
|
|
1352
|
-
}
|
|
1353
|
-
if (adjMatrix instanceof Float32Array) {
|
|
1354
|
-
clipMatrix.push(preMatrix);
|
|
1355
|
-
preMatrix = adjMatrix;
|
|
1356
|
-
}
|
|
1252
|
+
context.save();
|
|
1253
|
+
shouldClip = instance._$startClip(context, preMatrix);
|
|
1357
1254
|
}
|
|
1358
1255
|
continue;
|
|
1359
1256
|
}
|
|
@@ -1381,33 +1278,16 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1381
1278
|
maskMatrix[4] -= currentPosition.xMin;
|
|
1382
1279
|
maskMatrix[5] -= currentPosition.yMin;
|
|
1383
1280
|
}
|
|
1384
|
-
if (context.cacheBounds) {
|
|
1385
|
-
maskMatrix[4] -= context.cacheBounds.xMin;
|
|
1386
|
-
maskMatrix[5] -= context.cacheBounds.yMin;
|
|
1387
|
-
}
|
|
1388
1281
|
}
|
|
1389
1282
|
if (!maskInstance._$shouldClip(maskMatrix)) {
|
|
1390
1283
|
continue;
|
|
1391
1284
|
}
|
|
1392
|
-
const
|
|
1285
|
+
const result = maskInstance._$startClip(context, maskMatrix);
|
|
1393
1286
|
context.save();
|
|
1394
|
-
if (
|
|
1287
|
+
if (!result) { // fixed
|
|
1395
1288
|
context.restore();
|
|
1396
1289
|
continue;
|
|
1397
1290
|
}
|
|
1398
|
-
if (adjMatrix instanceof Float32Array) {
|
|
1399
|
-
instanceMatrix.push(preMatrix);
|
|
1400
|
-
if (this !== maskInstance._$parent) {
|
|
1401
|
-
const rawMatrix = transform._$rawMatrix();
|
|
1402
|
-
adjMatrix[0] = $Math.abs(preMatrix[0]) * $Math.sign(rawMatrix[0]);
|
|
1403
|
-
adjMatrix[1] = $Math.abs(preMatrix[1]) * $Math.sign(rawMatrix[1]);
|
|
1404
|
-
adjMatrix[2] = $Math.abs(preMatrix[2]) * $Math.sign(rawMatrix[2]);
|
|
1405
|
-
adjMatrix[3] = $Math.abs(preMatrix[3]) * $Math.sign(rawMatrix[3]);
|
|
1406
|
-
adjMatrix[4] = preMatrix[4] - context.cacheBounds.xMin;
|
|
1407
|
-
adjMatrix[5] = preMatrix[5] - context.cacheBounds.yMin;
|
|
1408
|
-
}
|
|
1409
|
-
preMatrix = adjMatrix;
|
|
1410
|
-
}
|
|
1411
1291
|
}
|
|
1412
1292
|
instance._$draw(context, preMatrix, preColorTransform);
|
|
1413
1293
|
instance._$updated = false;
|
|
@@ -1415,29 +1295,17 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1415
1295
|
if (maskInstance) {
|
|
1416
1296
|
context.restore();
|
|
1417
1297
|
context._$leaveClip();
|
|
1418
|
-
if (instanceMatrix.length) {
|
|
1419
|
-
const matrix = instanceMatrix.pop();
|
|
1420
|
-
if (matrix) {
|
|
1421
|
-
$poolFloat32Array6(preMatrix);
|
|
1422
|
-
preMatrix = matrix;
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
1298
|
}
|
|
1426
1299
|
}
|
|
1427
1300
|
// end mask
|
|
1428
1301
|
if (clipDepth) {
|
|
1429
1302
|
context.restore();
|
|
1430
|
-
if (
|
|
1303
|
+
if (shouldClip) {
|
|
1431
1304
|
context._$leaveClip();
|
|
1432
1305
|
}
|
|
1433
1306
|
}
|
|
1434
|
-
// object pool
|
|
1435
|
-
$poolArray(clipMatrix);
|
|
1436
|
-
$poolArray(instanceMatrix);
|
|
1437
|
-
$poolArray(clipStack);
|
|
1438
|
-
$poolArray(shouldClips);
|
|
1439
1307
|
// filter and blend
|
|
1440
|
-
if (preObject.
|
|
1308
|
+
if (preObject.isLayer) {
|
|
1441
1309
|
return this._$postDraw(context, matrix, multiColor, preObject);
|
|
1442
1310
|
}
|
|
1443
1311
|
if (preObject.matrix !== matrix) {
|
|
@@ -1577,15 +1445,6 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1577
1445
|
$poolArray(clips);
|
|
1578
1446
|
$poolArray(targets);
|
|
1579
1447
|
$poolMap(clipIndexes);
|
|
1580
|
-
// graphics
|
|
1581
|
-
if (!hit) {
|
|
1582
|
-
const graphics = "_$graphics" in this
|
|
1583
|
-
? this._$graphics
|
|
1584
|
-
: null;
|
|
1585
|
-
if (graphics) {
|
|
1586
|
-
hit = graphics._$hit(context, multiMatrix, options);
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
1448
|
if (multiMatrix !== matrix) {
|
|
1590
1449
|
$poolFloat32Array6(multiMatrix);
|
|
1591
1450
|
}
|
|
@@ -1617,17 +1476,10 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1617
1476
|
return true;
|
|
1618
1477
|
}
|
|
1619
1478
|
}
|
|
1620
|
-
let hit = false;
|
|
1621
|
-
const graphics = "_$graphics" in this
|
|
1622
|
-
? this._$graphics
|
|
1623
|
-
: null;
|
|
1624
|
-
if (graphics) {
|
|
1625
|
-
hit = graphics._$hit(context, multiMatrix, options);
|
|
1626
|
-
}
|
|
1627
1479
|
if (multiMatrix !== matrix) {
|
|
1628
1480
|
$poolFloat32Array6(multiMatrix);
|
|
1629
1481
|
}
|
|
1630
|
-
return
|
|
1482
|
+
return false;
|
|
1631
1483
|
}
|
|
1632
1484
|
/**
|
|
1633
1485
|
* @param {number} index
|
|
@@ -1686,30 +1538,24 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1686
1538
|
return;
|
|
1687
1539
|
}
|
|
1688
1540
|
this._$created = true;
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
options.push(recodes.buffer);
|
|
1701
|
-
message.recodes = recodes;
|
|
1702
|
-
message.maxAlpha = graphics._$maxAlpha;
|
|
1703
|
-
message.canDraw = graphics._$canDraw;
|
|
1704
|
-
message.xMin = graphics._$xMin;
|
|
1705
|
-
message.yMin = graphics._$yMin;
|
|
1706
|
-
message.xMax = graphics._$xMax;
|
|
1707
|
-
message.yMax = graphics._$yMax;
|
|
1708
|
-
}
|
|
1541
|
+
this._$posted = true;
|
|
1542
|
+
this._$updated = false;
|
|
1543
|
+
let index = 0;
|
|
1544
|
+
const buffer = $getRenderBufferArray();
|
|
1545
|
+
buffer[index++] = this._$instanceId;
|
|
1546
|
+
buffer[index++] = this._$parent ? this._$parent._$instanceId : -1;
|
|
1547
|
+
this._$registerProperty(buffer, index);
|
|
1548
|
+
const message = $getRenderMessageObject();
|
|
1549
|
+
message.command = "createDisplayObjectContainer";
|
|
1550
|
+
message.buffer = buffer;
|
|
1551
|
+
const options = $getArray(buffer.buffer);
|
|
1709
1552
|
$rendererWorker.postMessage(message, options);
|
|
1553
|
+
$poolRenderMessageObject(message);
|
|
1554
|
+
$poolArray(options);
|
|
1555
|
+
this._$postChildrenIds();
|
|
1710
1556
|
}
|
|
1711
1557
|
/**
|
|
1712
|
-
* @return {
|
|
1558
|
+
* @return {void}
|
|
1713
1559
|
* @method
|
|
1714
1560
|
* @private
|
|
1715
1561
|
*/
|
|
@@ -1720,21 +1566,6 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1720
1566
|
this._$postChildrenIds();
|
|
1721
1567
|
const options = $getArray();
|
|
1722
1568
|
const message = this._$createMessage();
|
|
1723
|
-
const graphics = "_$graphics" in this
|
|
1724
|
-
? this._$graphics
|
|
1725
|
-
: null;
|
|
1726
|
-
if (graphics && !graphics._$buffer) {
|
|
1727
|
-
message.maxAlpha = graphics._$maxAlpha;
|
|
1728
|
-
message.canDraw = graphics._$canDraw;
|
|
1729
|
-
const recodes = graphics._$getRecodes();
|
|
1730
|
-
message.recodes = recodes;
|
|
1731
|
-
options.push(recodes.buffer);
|
|
1732
|
-
const bounds = this._$getBounds();
|
|
1733
|
-
message.xMin = bounds.xMin;
|
|
1734
|
-
message.yMin = bounds.yMin;
|
|
1735
|
-
message.xMax = bounds.xMax;
|
|
1736
|
-
message.yMax = bounds.yMax;
|
|
1737
|
-
}
|
|
1738
1569
|
$rendererWorker
|
|
1739
1570
|
.postMessage(message, options);
|
|
1740
1571
|
$poolArray(options);
|
|
@@ -1748,28 +1579,30 @@ export class DisplayObjectContainer extends InteractiveObject {
|
|
|
1748
1579
|
* @private
|
|
1749
1580
|
*/
|
|
1750
1581
|
_$postChildrenIds(childrenIds = null) {
|
|
1751
|
-
if (!$rendererWorker) {
|
|
1582
|
+
if (!$rendererWorker || !this._$created) {
|
|
1752
1583
|
return;
|
|
1753
1584
|
}
|
|
1585
|
+
let poolIds = false;
|
|
1754
1586
|
if (!childrenIds) {
|
|
1755
1587
|
const children = this._$getChildren();
|
|
1756
1588
|
childrenIds = $getArray();
|
|
1757
1589
|
for (let idx = 0; idx < children.length; ++idx) {
|
|
1758
1590
|
childrenIds.push(children[idx]._$instanceId);
|
|
1759
1591
|
}
|
|
1760
|
-
|
|
1761
|
-
"command": "setChildren",
|
|
1762
|
-
"instanceId": this._$instanceId,
|
|
1763
|
-
"children": childrenIds
|
|
1764
|
-
});
|
|
1765
|
-
$poolArray(childrenIds);
|
|
1592
|
+
poolIds = true;
|
|
1766
1593
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1594
|
+
const buffer = new Int32Array(childrenIds.length + 1);
|
|
1595
|
+
buffer[0] = this._$instanceId;
|
|
1596
|
+
buffer.set(childrenIds, 1);
|
|
1597
|
+
const message = $getRenderMessageObject();
|
|
1598
|
+
message.command = "setChildren";
|
|
1599
|
+
message.buffer = buffer;
|
|
1600
|
+
const options = $getArray(buffer.buffer);
|
|
1601
|
+
$rendererWorker.postMessage(message, options);
|
|
1602
|
+
$poolRenderMessageObject(message);
|
|
1603
|
+
$poolArray(options);
|
|
1604
|
+
if (poolIds) {
|
|
1605
|
+
$poolArray(childrenIds);
|
|
1773
1606
|
}
|
|
1774
1607
|
}
|
|
1775
1608
|
}
|