@next2d/display 1.15.0 → 1.16.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.
@@ -1,7 +1,7 @@
1
1
  import { InteractiveObject } from "./InteractiveObject";
2
2
  import { Event as Next2DEvent } from "@next2d/events";
3
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";
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 を含みません。
@@ -429,19 +429,11 @@ export class DisplayObjectContainer extends InteractiveObject {
429
429
  return $getBoundsObject(xMin, xMax, yMin, yMax);
430
430
  }
431
431
  /**
432
- * @param {array} [matrix=null]
432
+ * @param {Float32Array} multi_matrix
433
433
  * @return {object}
434
434
  * @private
435
435
  */
436
- _$getLayerBounds(matrix = null) {
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
- }
436
+ _$getLayerBounds(multi_matrix) {
445
437
  const graphics = "_$graphics" in this
446
438
  ? this._$graphics
447
439
  : null;
@@ -450,11 +442,7 @@ export class DisplayObjectContainer extends InteractiveObject {
450
442
  : this._$children;
451
443
  // size zero
452
444
  if (!children.length && !graphics) {
453
- const bounds = $getBoundsObject(multiMatrix[4], -multiMatrix[4], multiMatrix[5], -multiMatrix[5]);
454
- if (matrix && multiMatrix !== matrix) {
455
- $poolFloat32Array6(multiMatrix);
456
- }
457
- return bounds;
445
+ return $getBoundsObject(0, 0, 0, 0);
458
446
  }
459
447
  // data init
460
448
  const no = $Number.MAX_VALUE;
@@ -464,7 +452,7 @@ export class DisplayObjectContainer extends InteractiveObject {
464
452
  let yMax = -no;
465
453
  if (graphics) {
466
454
  const baseBounds = graphics._$getBounds();
467
- const bounds = $boundsMatrix(baseBounds, multiMatrix);
455
+ const bounds = $boundsMatrix(baseBounds, multi_matrix);
468
456
  $poolBoundsObject(baseBounds);
469
457
  xMin = +bounds.xMin;
470
458
  xMax = +bounds.xMax;
@@ -473,34 +461,45 @@ export class DisplayObjectContainer extends InteractiveObject {
473
461
  $poolBoundsObject(bounds);
474
462
  }
475
463
  for (let idx = 0; idx < children.length; ++idx) {
476
- const bounds = children[idx]
477
- ._$getLayerBounds(multiMatrix);
464
+ const instance = children[idx];
465
+ let multiMatrix = multi_matrix;
466
+ const rawMatrix = instance._$transform._$rawMatrix();
467
+ if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
468
+ || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
469
+ || rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
470
+ multiMatrix = $multiplicationMatrix(multi_matrix, rawMatrix);
471
+ }
472
+ const bounds = instance._$getLayerBounds(multiMatrix);
478
473
  xMin = $Math.min(xMin, bounds.xMin);
479
474
  xMax = $Math.max(xMax, bounds.xMax);
480
475
  yMin = $Math.min(yMin, bounds.yMin);
481
476
  yMax = $Math.max(yMax, bounds.yMax);
482
477
  $poolBoundsObject(bounds);
483
- }
484
- if (matrix && multiMatrix !== matrix) {
485
- $poolFloat32Array6(multiMatrix);
486
- }
487
- // end
488
- if (!matrix) {
489
- return $getBoundsObject(xMin, xMax, yMin, yMax);
478
+ if (multiMatrix !== multi_matrix) {
479
+ $poolFloat32Array6(multiMatrix);
480
+ }
490
481
  }
491
482
  const filters = this._$filters || this.filters;
492
483
  if (!filters.length) {
493
484
  return $getBoundsObject(xMin, xMax, yMin, yMax);
494
485
  }
495
- let filterBounds = $getBoundsObject(xMin, xMax - xMin, yMin, yMax - yMin);
486
+ let filterBounds = $getBoundsObject(0, xMax - xMin, 0, yMax - yMin);
487
+ let xScale = +$Math.sqrt(multi_matrix[0] * multi_matrix[0]
488
+ + multi_matrix[1] * multi_matrix[1]);
489
+ let yScale = +$Math.sqrt(multi_matrix[2] * multi_matrix[2]
490
+ + multi_matrix[3] * multi_matrix[3]);
491
+ xScale /= $devicePixelRatio;
492
+ yScale /= $devicePixelRatio;
493
+ xScale *= 2;
494
+ yScale *= 2;
496
495
  for (let idx = 0; idx < filters.length; ++idx) {
497
496
  filterBounds = filters[idx]
498
- ._$generateFilterRect(filterBounds, 0, 0);
497
+ ._$generateFilterRect(filterBounds, xScale, yScale);
499
498
  }
500
- xMin = filterBounds.xMin;
501
- xMax = filterBounds.xMin + filterBounds.xMax;
502
- yMin = filterBounds.yMin;
503
- yMax = filterBounds.yMin + filterBounds.yMax;
499
+ xMax += filterBounds.xMax - (xMax - xMin);
500
+ yMax += filterBounds.yMax - (yMax - yMin);
501
+ xMin += filterBounds.xMin;
502
+ yMin += filterBounds.yMin;
504
503
  $poolBoundsObject(filterBounds);
505
504
  return $getBoundsObject(xMin, xMax, yMin, yMax);
506
505
  }
@@ -537,8 +536,6 @@ export class DisplayObjectContainer extends InteractiveObject {
537
536
  }
538
537
  return currentChildren;
539
538
  }
540
- const player = $currentPlayer();
541
- const cacheStore = player.cacheStore;
542
539
  const useWorker = !!$rendererWorker && !!this._$stage;
543
540
  const skipIds = $getMap();
544
541
  const poolInstances = $getMap();
@@ -590,9 +587,12 @@ export class DisplayObjectContainer extends InteractiveObject {
590
587
  if (useWorker) {
591
588
  instance._$removeWorkerInstance();
592
589
  }
593
- cacheStore.setRemoveTimer(instanceId);
590
+ $cacheStore.setRemoveTimer(instanceId);
594
591
  if (instance._$loaderInfo && instance._$characterId) {
595
- cacheStore.setRemoveTimer(`${instance._$loaderInfo._$id}@${instance._$characterId}`);
592
+ $cacheStore.setRemoveTimer(`${instance._$loaderInfo._$id}@${instance._$characterId}`);
593
+ }
594
+ if (instance._$graphics) {
595
+ $cacheStore.setRemoveTimer(instance._$graphics._$cacheKey);
596
596
  }
597
597
  // remove event
598
598
  if (instance.willTrigger(Next2DEvent.REMOVED)) {
@@ -818,11 +818,12 @@ export class DisplayObjectContainer extends InteractiveObject {
818
818
  child._$executeRemovedFromStage();
819
819
  }
820
820
  }
821
- const player = $currentPlayer();
822
- const cacheStore = player.cacheStore;
823
- cacheStore.setRemoveTimer(child._$instanceId);
821
+ $cacheStore.setRemoveTimer(child._$instanceId);
824
822
  if (child._$loaderInfo && child._$characterId) {
825
- cacheStore.setRemoveTimer(`${child._$loaderInfo._$id}@${child._$characterId}`);
823
+ $cacheStore.setRemoveTimer(`${child._$loaderInfo._$id}@${child._$characterId}`);
824
+ }
825
+ if (child._$graphics) {
826
+ $cacheStore.setRemoveTimer(child._$graphics._$cacheKey);
826
827
  }
827
828
  // reset params
828
829
  if (child instanceof DisplayObjectContainer) {
@@ -881,13 +882,14 @@ export class DisplayObjectContainer extends InteractiveObject {
881
882
  const children = this._$needsChildren
882
883
  ? this._$getChildren()
883
884
  : this._$children;
884
- const player = $currentPlayer();
885
- const cacheStore = player.cacheStore;
886
885
  for (let idx = 0; idx < children.length; ++idx) {
887
886
  const instance = children[idx];
888
- cacheStore.setRemoveTimer(instance._$instanceId);
887
+ $cacheStore.setRemoveTimer(instance._$instanceId);
889
888
  if (instance._$loaderInfo && instance._$characterId) {
890
- cacheStore.setRemoveTimer(`${instance._$loaderInfo._$id}@${instance._$characterId}`);
889
+ $cacheStore.setRemoveTimer(`${instance._$loaderInfo._$id}@${instance._$characterId}`);
890
+ }
891
+ if (instance._$graphics) {
892
+ $cacheStore.setRemoveTimer(instance._$graphics._$cacheKey);
891
893
  }
892
894
  if (instance instanceof DisplayObjectContainer) {
893
895
  instance._$removeParentAndStage();
@@ -1005,6 +1007,9 @@ export class DisplayObjectContainer extends InteractiveObject {
1005
1007
  // size zero
1006
1008
  if (!multiMatrix[0] && !multiMatrix[1]
1007
1009
  || !multiMatrix[2] && !multiMatrix[3]) {
1010
+ if (multiMatrix !== matrix) {
1011
+ $poolFloat32Array6(multiMatrix);
1012
+ }
1008
1013
  return null;
1009
1014
  }
1010
1015
  // return object
@@ -1024,101 +1029,96 @@ export class DisplayObjectContainer extends InteractiveObject {
1024
1029
  const yMax = +bounds.yMax;
1025
1030
  const yMin = +bounds.yMin;
1026
1031
  $poolBoundsObject(bounds);
1027
- const width = $Math.abs(xMax - xMin);
1028
- const height = $Math.abs(yMax - yMin);
1032
+ const width = $Math.ceil($Math.abs(xMax - xMin));
1033
+ const height = $Math.ceil($Math.abs(yMax - yMin));
1029
1034
  if (0 >= width || 0 >= height) {
1030
1035
  $poolPreObject(object);
1036
+ if (multiMatrix !== matrix) {
1037
+ $poolFloat32Array6(multiMatrix);
1038
+ }
1031
1039
  return null;
1032
1040
  }
1033
- if (0 > xMin + width || 0 > yMin + height) {
1034
- $poolPreObject(object);
1035
- return null;
1041
+ let xScale = +$Math.sqrt(multiMatrix[0] * multiMatrix[0]
1042
+ + multiMatrix[1] * multiMatrix[1]);
1043
+ if (!$Number.isInteger(xScale)) {
1044
+ const value = xScale.toString();
1045
+ const index = value.indexOf("e");
1046
+ if (index !== -1) {
1047
+ xScale = +value.slice(0, index);
1048
+ }
1049
+ xScale = +xScale.toFixed(4);
1050
+ }
1051
+ let yScale = +$Math.sqrt(multiMatrix[2] * multiMatrix[2]
1052
+ + multiMatrix[3] * multiMatrix[3]);
1053
+ if (!$Number.isInteger(yScale)) {
1054
+ const value = yScale.toString();
1055
+ const index = value.indexOf("e");
1056
+ if (index !== -1) {
1057
+ yScale = +value.slice(0, index);
1058
+ }
1059
+ yScale = +yScale.toFixed(4);
1060
+ }
1061
+ object.canApply = this._$canApply(filters);
1062
+ let filterBounds = $getBoundsObject(0, width, 0, height);
1063
+ if (object.canApply && filters) {
1064
+ for (let idx = 0; idx < filters.length; ++idx) {
1065
+ filterBounds = filters[idx]
1066
+ ._$generateFilterRect(filterBounds, xScale, yScale);
1067
+ }
1036
1068
  }
1037
1069
  const currentAttachment = context
1038
1070
  .frameBuffer
1039
1071
  .currentAttachment;
1040
1072
  if (!currentAttachment
1041
1073
  || !currentAttachment.texture
1042
- || xMin > currentAttachment.width
1043
- || yMin > currentAttachment.height) {
1074
+ || xMin - filterBounds.xMin > currentAttachment.width
1075
+ || yMin - filterBounds.yMin > currentAttachment.height) {
1076
+ $poolBoundsObject(filterBounds);
1044
1077
  $poolPreObject(object);
1078
+ if (multiMatrix !== matrix) {
1079
+ $poolFloat32Array6(multiMatrix);
1080
+ }
1045
1081
  return null;
1046
1082
  }
1047
- // set origin position
1048
- object.basePosition.x = rawMatrix[4];
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
- ) {
1083
+ if (0 > xMin + filterBounds.xMax || 0 > yMin + filterBounds.yMax) {
1084
+ $poolBoundsObject(filterBounds);
1099
1085
  $poolPreObject(object);
1086
+ if (multiMatrix !== matrix) {
1087
+ $poolFloat32Array6(multiMatrix);
1088
+ }
1100
1089
  return null;
1101
1090
  }
1091
+ // move size
1092
+ let tx = multiMatrix[4] - xMin;
1093
+ let ty = multiMatrix[5] - yMin;
1102
1094
  // start layer
1103
- context._$startLayer($getBoundsObject(originX, 0, originY, 0));
1095
+ context._$startLayer($getBoundsObject(xMin, xMax, yMin, yMax));
1104
1096
  // check cache
1105
- object.canApply = this._$canApply(filters);
1106
- const updated = this._$isFilterUpdated(layerWidth, layerHeight, multiMatrix, filters, object.canApply, object.basePosition.x, object.basePosition.y);
1107
- // current mask cache
1108
- context._$saveCurrentMask();
1097
+ const updated = this._$isFilterUpdated(multiMatrix, filters, object.canApply);
1098
+ const layerBounds = this._$getLayerBounds(multiMatrix);
1099
+ const layerWidth = $Math.ceil($Math.abs(layerBounds.xMax - layerBounds.xMin));
1100
+ const layerHeight = $Math.ceil($Math.abs(layerBounds.yMax - layerBounds.yMin));
1101
+ $poolBoundsObject(layerBounds);
1102
+ const sw = layerWidth - filterBounds.xMax + filterBounds.xMin;
1103
+ const sh = layerHeight - filterBounds.yMax + filterBounds.yMin;
1104
+ tx += sw;
1105
+ ty += sh;
1106
+ object.sw = sw;
1107
+ object.sh = sh;
1109
1108
  if (updated) {
1110
- context._$saveAttachment($Math.ceil(layerWidth), $Math.ceil(layerHeight), false);
1109
+ context._$saveAttachment($Math.ceil(width + sw), $Math.ceil(height + sh), true);
1111
1110
  }
1112
1111
  // setup
1113
- object.isFilter = true;
1112
+ object.isLayer = true;
1114
1113
  object.isUpdated = updated;
1115
- object.color = $getFloat32Array8();
1116
- object.baseMatrix = multiMatrix;
1117
1114
  object.filters = filters;
1118
1115
  object.blendMode = blendMode;
1119
- object.layerWidth = layerWidth;
1120
- object.layerHeight = layerHeight;
1116
+ object.color = $getFloat32Array8();
1121
1117
  object.matrix = $getFloat32Array6(multiMatrix[0], multiMatrix[1], multiMatrix[2], multiMatrix[3], tx, ty);
1118
+ if (multiMatrix !== matrix) {
1119
+ $poolFloat32Array6(multiMatrix);
1120
+ }
1121
+ $poolBoundsObject(filterBounds);
1122
1122
  }
1123
1123
  return object;
1124
1124
  }
@@ -1132,105 +1132,66 @@ export class DisplayObjectContainer extends InteractiveObject {
1132
1132
  * @private
1133
1133
  */
1134
1134
  _$postDraw(context, matrix, color_transform, object) {
1135
+ context.drawInstacedArray();
1135
1136
  // cache
1136
1137
  const cacheKeys = $getArray(this._$instanceId, "f");
1137
- const player = $currentPlayer();
1138
- const cacheStore = player.cacheStore;
1139
1138
  const manager = context.frameBuffer;
1140
- // cache or new texture
1141
- let texture = null;
1142
- if (object.isUpdated) {
1139
+ const multiMatrix = object.matrix;
1140
+ let offsetX = 0;
1141
+ let offsetY = 0;
1142
+ let texture = $cacheStore.get(cacheKeys);
1143
+ if (!texture || object.isUpdated) {
1144
+ // remove
1145
+ if (texture) {
1146
+ $cacheStore.set(cacheKeys, null);
1147
+ }
1143
1148
  texture = manager
1144
1149
  .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
1150
  const filters = object.filters;
1151
+ let filterState = false;
1182
1152
  if (filters && filters.length) {
1183
- // init
1184
- context._$offsetX = 0;
1185
- context._$offsetY = 0;
1186
1153
  for (let idx = 0; idx < filters.length; ++idx) {
1187
1154
  texture = filters[idx]
1188
1155
  ._$applyFilter(context, matrix);
1189
1156
  }
1157
+ // update
1158
+ filterState = true;
1190
1159
  offsetX = context._$offsetX;
1191
1160
  offsetY = context._$offsetY;
1192
1161
  // reset
1193
1162
  context._$offsetX = 0;
1194
1163
  context._$offsetY = 0;
1195
- // set offset
1196
- texture._$offsetX = offsetX;
1197
- texture._$offsetY = offsetY;
1198
- }
1199
- }
1200
- // update cache params
1201
- if (object.isUpdated) {
1202
- texture.filterState = object.canApply;
1203
- // cache texture
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) {
1164
+ }
1165
+ texture.filterState = filterState;
1166
+ texture.matrix = `${multiMatrix[0]}_`
1167
+ + `${multiMatrix[1]}_`
1168
+ + `${multiMatrix[2]}_`
1169
+ + `${multiMatrix[3]}`;
1170
+ texture.offsetX = offsetX;
1171
+ texture.offsetY = offsetY;
1172
+ $cacheStore.set(cacheKeys, texture);
1216
1173
  context._$restoreAttachment();
1217
1174
  }
1175
+ if (texture.offsetX) {
1176
+ offsetX = texture.offsetX;
1177
+ }
1178
+ if (texture.offsetY) {
1179
+ offsetY = texture.offsetY;
1180
+ }
1218
1181
  // set
1219
1182
  context.reset();
1220
1183
  context.globalAlpha = $clamp(color_transform[3] + color_transform[7] / 255, 0, 1);
1221
1184
  context.globalCompositeOperation = object.blendMode;
1222
- context.setTransform(1, 0, 0, 1, 0, 0);
1223
- context.drawImage(texture, -offsetX + object.position.dx, -offsetY + object.position.dy, texture.width, texture.height, color_transform);
1185
+ const bounds = context.getCurrentPosition();
1186
+ context.setTransform(1, 0, 0, 1, bounds.xMin - offsetX - object.sw, bounds.yMin - offsetY - object.sh);
1187
+ context.drawImage(texture, 0, 0, texture.width, texture.height, color_transform);
1224
1188
  // end blend
1225
1189
  context._$endLayer();
1226
- // reset
1227
- context._$restoreCurrentMask();
1228
1190
  // object pool
1229
- if (object.baseMatrix !== matrix) {
1230
- $poolFloat32Array6(object.baseMatrix);
1231
- }
1232
1191
  $poolFloat32Array6(object.matrix);
1233
1192
  $poolPreObject(object);
1193
+ // reset
1194
+ context.cachePosition = null;
1234
1195
  }
1235
1196
  /**
1236
1197
  * @param {CanvasToWebGLContext} context
@@ -1275,12 +1236,12 @@ export class DisplayObjectContainer extends InteractiveObject {
1275
1236
  return;
1276
1237
  }
1277
1238
  // use cache
1278
- if (preObject.isFilter && !preObject.isUpdated) {
1239
+ if (preObject.isLayer && !preObject.isUpdated) {
1279
1240
  this._$postDraw(context, matrix, multiColor, preObject);
1280
1241
  return;
1281
1242
  }
1282
- let preMatrix = preObject.matrix;
1283
- const preColorTransform = preObject.isFilter && preObject.color
1243
+ const preMatrix = preObject.matrix;
1244
+ const preColorTransform = preObject.isLayer && preObject.color
1284
1245
  ? preObject.color
1285
1246
  : multiColor;
1286
1247
  // if graphics draw
@@ -1290,10 +1251,6 @@ export class DisplayObjectContainer extends InteractiveObject {
1290
1251
  // init clip params
1291
1252
  let shouldClip = true;
1292
1253
  let clipDepth = 0;
1293
- const clipMatrix = $getArray();
1294
- const instanceMatrix = $getArray();
1295
- const clipStack = $getArray();
1296
- const shouldClips = $getArray();
1297
1254
  const player = $currentPlayer();
1298
1255
  // draw children
1299
1256
  const isLayer = context.isLayer;
@@ -1319,17 +1276,10 @@ export class DisplayObjectContainer extends InteractiveObject {
1319
1276
  context.restore();
1320
1277
  if (shouldClip) {
1321
1278
  context._$leaveClip();
1322
- if (clipMatrix.length) {
1323
- const matrix = clipMatrix.pop();
1324
- if (matrix) {
1325
- $poolFloat32Array6(preMatrix);
1326
- preMatrix = matrix;
1327
- }
1328
- }
1329
1279
  }
1330
1280
  // clear
1331
- clipDepth = clipStack.length ? clipStack.pop() || 0 : 0;
1332
- shouldClip = !!shouldClips.pop();
1281
+ clipDepth = 0;
1282
+ shouldClip = true;
1333
1283
  }
1334
1284
  // mask size 0
1335
1285
  if (!shouldClip) {
@@ -1337,23 +1287,11 @@ export class DisplayObjectContainer extends InteractiveObject {
1337
1287
  }
1338
1288
  // mask start
1339
1289
  if (instance._$clipDepth > 0) {
1340
- context.save();
1341
- if (clipDepth) {
1342
- clipStack.push(clipDepth);
1343
- }
1344
- shouldClips.push(shouldClip);
1345
1290
  clipDepth = instance._$clipDepth;
1346
1291
  shouldClip = instance._$shouldClip(preMatrix);
1347
1292
  if (shouldClip) {
1348
- const adjMatrix = instance._$startClip(context, preMatrix);
1349
- if (adjMatrix === false) { // fixed
1350
- shouldClip = false;
1351
- continue;
1352
- }
1353
- if (adjMatrix instanceof Float32Array) {
1354
- clipMatrix.push(preMatrix);
1355
- preMatrix = adjMatrix;
1356
- }
1293
+ context.save();
1294
+ shouldClip = instance._$startClip(context, preMatrix);
1357
1295
  }
1358
1296
  continue;
1359
1297
  }
@@ -1381,33 +1319,16 @@ export class DisplayObjectContainer extends InteractiveObject {
1381
1319
  maskMatrix[4] -= currentPosition.xMin;
1382
1320
  maskMatrix[5] -= currentPosition.yMin;
1383
1321
  }
1384
- if (context.cacheBounds) {
1385
- maskMatrix[4] -= context.cacheBounds.xMin;
1386
- maskMatrix[5] -= context.cacheBounds.yMin;
1387
- }
1388
1322
  }
1389
1323
  if (!maskInstance._$shouldClip(maskMatrix)) {
1390
1324
  continue;
1391
1325
  }
1392
- const adjMatrix = maskInstance._$startClip(context, maskMatrix);
1326
+ const result = maskInstance._$startClip(context, maskMatrix);
1393
1327
  context.save();
1394
- if (adjMatrix === false) { // fixed
1328
+ if (!result) { // fixed
1395
1329
  context.restore();
1396
1330
  continue;
1397
1331
  }
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
1332
  }
1412
1333
  instance._$draw(context, preMatrix, preColorTransform);
1413
1334
  instance._$updated = false;
@@ -1415,29 +1336,17 @@ export class DisplayObjectContainer extends InteractiveObject {
1415
1336
  if (maskInstance) {
1416
1337
  context.restore();
1417
1338
  context._$leaveClip();
1418
- if (instanceMatrix.length) {
1419
- const matrix = instanceMatrix.pop();
1420
- if (matrix) {
1421
- $poolFloat32Array6(preMatrix);
1422
- preMatrix = matrix;
1423
- }
1424
- }
1425
1339
  }
1426
1340
  }
1427
1341
  // end mask
1428
1342
  if (clipDepth) {
1429
1343
  context.restore();
1430
- if (shouldClips.pop()) {
1344
+ if (shouldClip) {
1431
1345
  context._$leaveClip();
1432
1346
  }
1433
1347
  }
1434
- // object pool
1435
- $poolArray(clipMatrix);
1436
- $poolArray(instanceMatrix);
1437
- $poolArray(clipStack);
1438
- $poolArray(shouldClips);
1439
1348
  // filter and blend
1440
- if (preObject.isFilter) {
1349
+ if (preObject.isLayer) {
1441
1350
  return this._$postDraw(context, matrix, multiColor, preObject);
1442
1351
  }
1443
1352
  if (preObject.matrix !== matrix) {
@@ -1,6 +1,6 @@
1
1
  import type { BitmapData } from "./BitmapData";
2
2
  import type { Matrix } from "@next2d/geom";
3
- import type { GraphicsParentImpl, CapsStyleImpl, JointStyleImpl, FilterArrayImpl, BlendModeImpl, BoundsImpl, PlayerHitObjectImpl, SpreadMethodImpl, GradientTypeImpl, InterpolationMethodImpl } from "@next2d/interface";
3
+ import type { GraphicsParentImpl, CapsStyleImpl, JointStyleImpl, FilterArrayImpl, BlendModeImpl, BoundsImpl, PlayerHitObjectImpl, SpreadMethodImpl, GradientTypeImpl, InterpolationMethodImpl, CachePositionImpl, ShapeModeImpl } from "@next2d/interface";
4
4
  import type { CanvasToWebGLContext } from "@next2d/webgl";
5
5
  /**
6
6
  * Graphics クラスには、ベクターシェイプの作成に使用できる一連のメソッドがあります。
@@ -51,6 +51,11 @@ export declare class Graphics {
51
51
  _$recode: any[] | null;
52
52
  private _$fills;
53
53
  private _$lines;
54
+ private _$uniqueKey;
55
+ private _$cacheKeys;
56
+ private _$cacheParams;
57
+ _$bitmapId: number;
58
+ _$mode: ShapeModeImpl;
54
59
  /**
55
60
  * @param {DisplayObject} src
56
61
  *
@@ -491,6 +496,12 @@ export declare class Graphics {
491
496
  * @private
492
497
  */
493
498
  _$draw(context: CanvasToWebGLContext, matrix: Float32Array, color_transform: Float32Array, blend_mode?: BlendModeImpl, filters?: FilterArrayImpl | null): void;
499
+ /**
500
+ * @return {WebGLTexture | null}
501
+ * @method
502
+ * @private
503
+ */
504
+ _$createBitmapTexture(context: CanvasToWebGLContext, position: CachePositionImpl, x_scale: number, y_scale: number, width: number, height: number): WebGLTexture | null;
494
505
  /**
495
506
  * @param {CanvasToWebGLContext} context
496
507
  * @param {Float32Array} [color_transform=null]
@@ -552,6 +563,12 @@ export declare class Graphics {
552
563
  * @private
553
564
  */
554
565
  _$margePath(data: any[]): void;
566
+ /**
567
+ * @return {string}
568
+ * @method
569
+ * @private
570
+ */
571
+ _$createCacheKey(): string;
555
572
  /**
556
573
  * @return {Float32Array}
557
574
  * @method