@next2d/player 1.14.9 → 1.14.13

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 (31) hide show
  1. package/dist/player/index.js +5 -3
  2. package/dist/player/next2d/display/GraphicsGradientFill.d.ts +1 -1
  3. package/dist/player/next2d/display/GraphicsGradientFill.js +6 -2
  4. package/dist/player/next2d/display/Loader.d.ts +1 -1
  5. package/dist/player/player/Next2D.d.ts +1 -2
  6. package/dist/player/player/Next2D.js +7 -11
  7. package/package.json +1 -1
  8. package/dist/interface/ClassNameMap.d.ts +0 -4
  9. package/dist/interface/ClassNameMap.js +0 -1
  10. package/dist/interface/RenderDisplayObjectImpl.d.ts +0 -2
  11. package/dist/interface/RenderDisplayObjectImpl.js +0 -1
  12. package/dist/interface/TextFormatImpl.d.ts +0 -16
  13. package/dist/interface/TextFormatImpl.js +0 -1
  14. package/dist/interface/TextModeImpl.d.ts +0 -1
  15. package/dist/interface/TextModeImpl.js +0 -1
  16. package/dist/renderer/RenderDisplayObject.d.ts +0 -129
  17. package/dist/renderer/RenderDisplayObject.js +0 -567
  18. package/dist/renderer/RenderDisplayObjectContainer.d.ts +0 -70
  19. package/dist/renderer/RenderDisplayObjectContainer.js +0 -670
  20. package/dist/renderer/RenderGlobal.d.ts +0 -76
  21. package/dist/renderer/RenderGlobal.js +0 -88
  22. package/dist/renderer/RenderGraphics.d.ts +0 -90
  23. package/dist/renderer/RenderGraphics.js +0 -597
  24. package/dist/renderer/RenderPlayer.d.ts +0 -164
  25. package/dist/renderer/RenderPlayer.js +0 -421
  26. package/dist/renderer/RenderShape.d.ts +0 -32
  27. package/dist/renderer/RenderShape.js +0 -104
  28. package/dist/renderer/RenderTextField.d.ts +0 -119
  29. package/dist/renderer/RenderTextField.js +0 -709
  30. package/dist/renderer/RenderVideo.d.ts +0 -59
  31. package/dist/renderer/RenderVideo.js +0 -272
@@ -1,670 +0,0 @@
1
- import { RenderGraphics } from "./RenderGraphics";
2
- import { Rectangle } from "../player/next2d/geom/Rectangle";
3
- import { $containers, $renderPlayer } from "./RenderGlobal";
4
- import { $boundsMatrix, $clamp, $getArray, $getBoundsObject, $getFloat32Array6, $getFloat32Array8, $getPreObject, $Math, $MATRIX_ARRAY_IDENTITY, $multiplicationColor, $multiplicationMatrix, $Number, $poolArray, $poolBoundsObject, $poolFloat32Array6, $poolFloat32Array8, $poolPreObject } from "../player/util/RenderUtil";
5
- /**
6
- * @class
7
- */
8
- export class RenderDisplayObjectContainer extends RenderGraphics {
9
- _$children;
10
- /**
11
- * @constructor
12
- * @public
13
- */
14
- constructor() {
15
- super();
16
- /**
17
- * @type {array}
18
- * @private
19
- */
20
- this._$children = $getArray();
21
- }
22
- /**
23
- * @param {CanvasToWebGLContext} context
24
- * @param {Float32Array} matrix
25
- * @return {void}
26
- * @method
27
- * @private
28
- */
29
- _$clip(context, matrix) {
30
- let multiMatrix = matrix;
31
- const rawMatrix = this._$matrix;
32
- if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
33
- || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
34
- || rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
35
- multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
36
- }
37
- if (this._$recodes && this._$canDraw) {
38
- super._$clip(context, multiMatrix);
39
- }
40
- const instances = $renderPlayer.instances;
41
- const children = this._$children;
42
- for (let idx = 0; idx < this._$children.length; ++idx) {
43
- const id = children[idx];
44
- if (!instances.has(id)) {
45
- continue;
46
- }
47
- const instance = instances.get(id);
48
- // mask instance
49
- if (!instance || instance._$isMask) {
50
- continue;
51
- }
52
- instance._$clip(context, multiMatrix);
53
- instance._$updated = false;
54
- }
55
- if (multiMatrix !== matrix) {
56
- $poolFloat32Array6(multiMatrix);
57
- }
58
- }
59
- /**
60
- * @param {CanvasToWebGLContext} context
61
- * @param {Float32Array} matrix
62
- * @param {Float32Array} color_transform
63
- * @return {void}
64
- * @method
65
- * @private
66
- */
67
- _$draw(context, matrix, color_transform) {
68
- // not draw
69
- if (!this._$visible) {
70
- return;
71
- }
72
- let multiColor = color_transform;
73
- const rawColor = this._$colorTransform;
74
- if (rawColor[0] !== 1 || rawColor[1] !== 1
75
- || rawColor[2] !== 1 || rawColor[3] !== 1
76
- || rawColor[4] !== 0 || rawColor[5] !== 0
77
- || rawColor[6] !== 0 || rawColor[7] !== 0) {
78
- multiColor = $multiplicationColor(color_transform, rawColor);
79
- }
80
- // not draw
81
- const alpha = $clamp(multiColor[3] + multiColor[7] / 255, 0, 1, 0);
82
- if (!alpha) {
83
- return;
84
- }
85
- // not draw
86
- const children = this._$children;
87
- const length = children.length;
88
- if (!length && (!this._$recodes || !this._$canDraw)) {
89
- return;
90
- }
91
- // pre data
92
- const preObject = this._$preDraw(context, matrix);
93
- if (!preObject) {
94
- return;
95
- }
96
- // use cache
97
- if (preObject.isFilter && !preObject.isUpdated) {
98
- this._$postDraw(context, matrix, multiColor, preObject);
99
- return;
100
- }
101
- let preMatrix = preObject.matrix;
102
- const preColorTransform = preObject.isFilter && preObject.color
103
- ? preObject.color
104
- : multiColor;
105
- // if graphics draw
106
- if (this._$recodes && this._$canDraw && this._$maxAlpha > 0) {
107
- super._$draw(context, preMatrix, preColorTransform);
108
- }
109
- // init clip params
110
- let shouldClip = true;
111
- let clipDepth = 0;
112
- const clipMatrix = $getArray();
113
- const instanceMatrix = $getArray();
114
- const clipStack = $getArray();
115
- const shouldClips = $getArray();
116
- // draw children
117
- const instances = $renderPlayer.instances;
118
- const isLayer = context.isLayer;
119
- for (let idx = 0; idx < length; ++idx) {
120
- const id = children[idx];
121
- if (!instances.has(id)) {
122
- continue;
123
- }
124
- const instance = instances.get(id);
125
- // mask instance
126
- if (instance._$isMask) {
127
- continue;
128
- }
129
- // not layer mode
130
- const blendMode = instance._$blendMode;
131
- if ((blendMode === "alpha" || blendMode === "erase")
132
- && !isLayer) {
133
- continue;
134
- }
135
- // mask end
136
- if (clipDepth
137
- && (instance._$placeId > clipDepth || instance._$clipDepth > 0)) {
138
- context.restore();
139
- if (shouldClip) {
140
- context._$leaveClip();
141
- if (clipMatrix.length) {
142
- const matrix = clipMatrix.pop();
143
- if (matrix) {
144
- $poolFloat32Array6(preMatrix);
145
- preMatrix = matrix;
146
- }
147
- }
148
- }
149
- // clear
150
- clipDepth = clipStack.length ? clipStack.pop() || 0 : 0;
151
- shouldClip = !!shouldClips.pop();
152
- }
153
- // mask size 0
154
- if (!shouldClip) {
155
- continue;
156
- }
157
- // mask start
158
- if (instance._$clipDepth > 0) {
159
- context.save();
160
- if (clipDepth) {
161
- clipStack.push(clipDepth);
162
- }
163
- shouldClips.push(shouldClip);
164
- clipDepth = instance._$clipDepth;
165
- shouldClip = instance._$shouldClip(preMatrix);
166
- if (shouldClip) {
167
- const adjMatrix = instance._$startClip(context, preMatrix);
168
- if (adjMatrix === false) { // fixed
169
- shouldClip = false;
170
- continue;
171
- }
172
- if (adjMatrix instanceof Float32Array) {
173
- clipMatrix.push(preMatrix);
174
- preMatrix = adjMatrix;
175
- }
176
- }
177
- continue;
178
- }
179
- // mask start
180
- const maskInstance = instance._$maskId > -1 && instances.has(instance._$maskId)
181
- ? instances.get(instance._$maskId)
182
- : null;
183
- if (maskInstance) {
184
- maskInstance._$updated = false;
185
- let maskMatrix;
186
- if (this._$instanceId === maskInstance._$parentId) {
187
- maskMatrix = preMatrix;
188
- }
189
- else {
190
- maskMatrix = $MATRIX_ARRAY_IDENTITY;
191
- let parent = instances.get(maskInstance._$parentId);
192
- while (parent || parent._$instanceId !== parent._$parentId) {
193
- maskMatrix = $multiplicationMatrix(parent._$matrix, maskMatrix);
194
- parent = instances.get(parent._$parentId);
195
- }
196
- const mScale = $renderPlayer.scaleX;
197
- const playerMatrix = $getFloat32Array6(mScale, 0, 0, mScale, 0, 0);
198
- maskMatrix = $multiplicationMatrix(playerMatrix, maskMatrix);
199
- $poolFloat32Array6(playerMatrix);
200
- if (context.isLayer) {
201
- const currentPosition = context.getCurrentPosition();
202
- maskMatrix[4] -= currentPosition.xMin;
203
- maskMatrix[5] -= currentPosition.yMin;
204
- }
205
- if (context.cacheBounds) {
206
- maskMatrix[4] -= context.cacheBounds.xMin;
207
- maskMatrix[5] -= context.cacheBounds.yMin;
208
- }
209
- }
210
- if (!maskInstance._$shouldClip(maskMatrix)) {
211
- continue;
212
- }
213
- const adjMatrix = maskInstance._$startClip(context, maskMatrix);
214
- context.save();
215
- if (adjMatrix === false) { // fixed
216
- context.restore();
217
- continue;
218
- }
219
- if (adjMatrix instanceof Float32Array) {
220
- instanceMatrix.push(preMatrix);
221
- if (this !== maskInstance._$parent) {
222
- const rawMatrix = this._$matrix;
223
- adjMatrix[0] = $Math.abs(preMatrix[0]) * $Math.sign(rawMatrix[0]);
224
- adjMatrix[1] = $Math.abs(preMatrix[1]) * $Math.sign(rawMatrix[1]);
225
- adjMatrix[2] = $Math.abs(preMatrix[2]) * $Math.sign(rawMatrix[2]);
226
- adjMatrix[3] = $Math.abs(preMatrix[3]) * $Math.sign(rawMatrix[3]);
227
- adjMatrix[4] = preMatrix[4] - context.cacheBounds.xMin;
228
- adjMatrix[5] = preMatrix[5] - context.cacheBounds.yMin;
229
- }
230
- preMatrix = adjMatrix;
231
- }
232
- }
233
- instance._$draw(context, preMatrix, preColorTransform);
234
- instance._$updated = false;
235
- // mask end
236
- if (maskInstance) {
237
- context.restore();
238
- context._$leaveClip();
239
- if (instanceMatrix.length) {
240
- const matrix = instanceMatrix.pop();
241
- if (matrix) {
242
- $poolFloat32Array6(preMatrix);
243
- preMatrix = matrix;
244
- }
245
- }
246
- }
247
- }
248
- // end mask
249
- if (clipDepth) {
250
- context.restore();
251
- if (shouldClips.pop()) {
252
- context._$leaveClip();
253
- }
254
- }
255
- // object pool
256
- $poolArray(clipMatrix);
257
- $poolArray(instanceMatrix);
258
- $poolArray(clipStack);
259
- $poolArray(shouldClips);
260
- // filter and blend
261
- if (preObject.isFilter) {
262
- return this._$postDraw(context, matrix, multiColor, preObject);
263
- }
264
- if (preObject.matrix !== matrix) {
265
- $poolFloat32Array6(preObject.matrix);
266
- }
267
- if (multiColor !== color_transform) {
268
- $poolFloat32Array8(multiColor);
269
- }
270
- $poolPreObject(preObject);
271
- }
272
- /**
273
- * @param {array} [matrix=null]
274
- * @return {object}
275
- * @private
276
- */
277
- _$getLayerBounds(matrix = null) {
278
- let multiMatrix = $MATRIX_ARRAY_IDENTITY;
279
- if (matrix) {
280
- multiMatrix = matrix;
281
- const rawMatrix = this._$matrix;
282
- if (rawMatrix !== $MATRIX_ARRAY_IDENTITY) {
283
- multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
284
- }
285
- }
286
- const isGraphics = !!this._$recodes;
287
- const children = this._$children;
288
- const length = children.length;
289
- // size zero
290
- if (!length && !isGraphics) {
291
- const bounds = $getBoundsObject(multiMatrix[4], -multiMatrix[4], multiMatrix[5], -multiMatrix[5]);
292
- if (matrix && multiMatrix !== matrix) {
293
- $poolFloat32Array6(multiMatrix);
294
- }
295
- return bounds;
296
- }
297
- // data init
298
- const no = $Number.MAX_VALUE;
299
- let xMin = no;
300
- let xMax = -no;
301
- let yMin = no;
302
- let yMax = -no;
303
- if (isGraphics) {
304
- const baseBounds = $getBoundsObject(this._$xMin, this._$xMax, this._$yMin, this._$yMax);
305
- const bounds = $boundsMatrix(baseBounds, multiMatrix);
306
- $poolBoundsObject(baseBounds);
307
- xMin = +bounds.xMin;
308
- xMax = +bounds.xMax;
309
- yMin = +bounds.yMin;
310
- yMax = +bounds.yMax;
311
- $poolBoundsObject(bounds);
312
- }
313
- const instances = $renderPlayer.instances;
314
- for (let idx = 0; idx < children.length; ++idx) {
315
- const id = children[idx];
316
- if (!instances.has(id)) {
317
- continue;
318
- }
319
- const bounds = instances
320
- .get(id)
321
- ._$getLayerBounds(multiMatrix);
322
- xMin = $Math.min(xMin, bounds.xMin);
323
- xMax = $Math.max(xMax, bounds.xMax);
324
- yMin = $Math.min(yMin, bounds.yMin);
325
- yMax = $Math.max(yMax, bounds.yMax);
326
- $poolBoundsObject(bounds);
327
- }
328
- if (matrix && multiMatrix !== matrix) {
329
- $poolFloat32Array6(multiMatrix);
330
- }
331
- // end
332
- if (!matrix) {
333
- return $getBoundsObject(xMin, xMax, yMin, yMax);
334
- }
335
- if (!this._$filters) {
336
- return $getBoundsObject(xMin, xMax, yMin, yMax);
337
- }
338
- let rect = new Rectangle(xMin, yMin, xMax - xMin, yMax - yMin);
339
- for (let idx = 0; idx < this._$filters.length; ++idx) {
340
- rect = this._$filters[idx]
341
- ._$generateFilterRect(rect, 0, 0);
342
- }
343
- xMin = rect.x;
344
- xMax = rect.x + rect.width;
345
- yMin = rect.y;
346
- yMax = rect.y + rect.height;
347
- return $getBoundsObject(xMin, xMax, yMin, yMax);
348
- }
349
- /**
350
- * @param {Float32Array} [matrix=null]
351
- * @returns {object}
352
- * @method
353
- * @private
354
- */
355
- _$getBounds(matrix = null) {
356
- let multiMatrix = $MATRIX_ARRAY_IDENTITY;
357
- if (matrix) {
358
- multiMatrix = matrix;
359
- const rawMatrix = this._$matrix;
360
- if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
361
- || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
362
- || rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
363
- multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
364
- }
365
- }
366
- const isGraphics = !!this._$recodes;
367
- const children = this._$children;
368
- const length = children.length;
369
- // size zero
370
- if (!length && !isGraphics) {
371
- const bounds = $getBoundsObject(multiMatrix[4], -multiMatrix[4], multiMatrix[5], -multiMatrix[5]);
372
- if (matrix && multiMatrix !== matrix) {
373
- $poolFloat32Array6(multiMatrix);
374
- }
375
- return bounds;
376
- }
377
- // data init
378
- const no = $Number.MAX_VALUE;
379
- let xMin = no;
380
- let xMax = -no;
381
- let yMin = no;
382
- let yMax = -no;
383
- if (isGraphics) {
384
- const baseBounds = $getBoundsObject(this._$xMin, this._$xMax, this._$yMin, this._$yMax);
385
- $poolBoundsObject(baseBounds);
386
- const bounds = $boundsMatrix(baseBounds, multiMatrix);
387
- xMin = bounds.xMin;
388
- xMax = bounds.xMax;
389
- yMin = bounds.yMin;
390
- yMax = bounds.yMax;
391
- $poolBoundsObject(bounds);
392
- }
393
- const instances = $renderPlayer.instances;
394
- for (let idx = 0; idx < children.length; ++idx) {
395
- const id = children[idx];
396
- if (!instances.has(id)) {
397
- continue;
398
- }
399
- const bounds = instances
400
- .get(id)
401
- ._$getBounds(multiMatrix);
402
- xMin = $Math.min(xMin, bounds.xMin);
403
- xMax = $Math.max(xMax, bounds.xMax);
404
- yMin = $Math.min(yMin, bounds.yMin);
405
- yMax = $Math.max(yMax, bounds.yMax);
406
- $poolBoundsObject(bounds);
407
- }
408
- if (matrix && multiMatrix !== matrix) {
409
- $poolFloat32Array6(multiMatrix);
410
- }
411
- // end
412
- return $getBoundsObject(xMin, xMax, yMin, yMax);
413
- }
414
- /**
415
- * @param {CanvasToWebGLContext} context
416
- * @param {Float32Array} matrix
417
- * @return {object}
418
- * @private
419
- */
420
- _$preDraw(context, matrix) {
421
- let multiMatrix = matrix;
422
- const rawMatrix = this._$matrix;
423
- if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
424
- || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
425
- || rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
426
- multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
427
- }
428
- // size zero
429
- if (!multiMatrix[0] && !multiMatrix[1]
430
- || !multiMatrix[2] && !multiMatrix[3]) {
431
- return null;
432
- }
433
- // return object
434
- const object = $getPreObject();
435
- // setup
436
- object.matrix = multiMatrix;
437
- // check
438
- const blendMode = this._$blendMode;
439
- if (blendMode !== "normal"
440
- || this._$filters && this._$filters.length > 0) {
441
- // check size
442
- const baseBounds = this._$getBounds(null);
443
- const bounds = $boundsMatrix(baseBounds, multiMatrix);
444
- $poolBoundsObject(baseBounds);
445
- const xMax = +bounds.xMax;
446
- const xMin = +bounds.xMin;
447
- const yMax = +bounds.yMax;
448
- const yMin = +bounds.yMin;
449
- $poolBoundsObject(bounds);
450
- const width = $Math.abs(xMax - xMin);
451
- const height = $Math.abs(yMax - yMin);
452
- if (0 >= width || 0 >= height) {
453
- $poolPreObject(object);
454
- return null;
455
- }
456
- if (0 > xMin + width || 0 > yMin + height) {
457
- $poolPreObject(object);
458
- return null;
459
- }
460
- const currentAttachment = context
461
- .frameBuffer
462
- .currentAttachment;
463
- if (!currentAttachment
464
- || !currentAttachment.texture
465
- || xMin > currentAttachment.width
466
- || yMin > currentAttachment.height) {
467
- $poolPreObject(object);
468
- return null;
469
- }
470
- // set origin position
471
- object.basePosition.x = rawMatrix[4];
472
- object.basePosition.y = rawMatrix[5];
473
- // check after size
474
- const baseLayerBounds = this._$getLayerBounds(null);
475
- const layerBounds = $boundsMatrix(baseLayerBounds, multiMatrix);
476
- // filter size
477
- let layerWidth = $Math.abs(layerBounds.xMax - layerBounds.xMin);
478
- let layerHeight = $Math.abs(layerBounds.yMax - layerBounds.yMin);
479
- $poolBoundsObject(layerBounds);
480
- // move size
481
- let tx = multiMatrix[4] - $Math.floor(xMin);
482
- let ty = multiMatrix[5] - $Math.floor(yMin);
483
- let dx = $Math.floor(xMin);
484
- let dy = $Math.floor(yMin);
485
- let originX = xMin;
486
- let originY = yMin;
487
- if (layerWidth !== width || layerHeight !== height) {
488
- const layerMatrix = $getFloat32Array6(multiMatrix[0], multiMatrix[1], multiMatrix[2], multiMatrix[3], 0, 0);
489
- const moveBounds = $boundsMatrix(baseLayerBounds, layerMatrix);
490
- // pool
491
- $poolFloat32Array6(layerMatrix);
492
- tx += -$Math.floor(moveBounds.xMin) - tx;
493
- ty += -$Math.floor(moveBounds.yMin) - ty;
494
- dx -= -$Math.floor(moveBounds.xMin) - (multiMatrix[4] - dx);
495
- dy -= -$Math.floor(moveBounds.yMin) - (multiMatrix[5] - dy);
496
- originX -= -moveBounds.xMin - (multiMatrix[4] - originX);
497
- originY -= -moveBounds.yMin - (multiMatrix[5] - originY);
498
- $poolBoundsObject(moveBounds);
499
- }
500
- $poolBoundsObject(baseLayerBounds);
501
- // set position
502
- object.position.dx = dx > 0 ? dx : 0;
503
- object.position.dy = dy > 0 ? dy : 0;
504
- // resize
505
- if (layerWidth + originX > currentAttachment.texture.width) {
506
- layerWidth -= layerWidth - currentAttachment.texture.width + originX;
507
- }
508
- if (layerHeight + originY > currentAttachment.texture.height) {
509
- layerHeight -= layerHeight - currentAttachment.texture.height + originY;
510
- }
511
- if (0 > dx) {
512
- tx += dx;
513
- layerWidth += originX;
514
- }
515
- if (0 > dy) {
516
- ty += dy;
517
- layerHeight += originY;
518
- }
519
- if (0 >= layerWidth || 0 >= layerHeight // size (-)
520
- || !layerWidth || !layerHeight // NaN or Infinity
521
- ) {
522
- $poolPreObject(object);
523
- return null;
524
- }
525
- // start layer
526
- context._$startLayer($getBoundsObject(originX, 0, originY, 0));
527
- // check cache
528
- object.canApply = this._$canApply(this._$filters);
529
- const updated = this._$isFilterUpdated(layerWidth, layerHeight, multiMatrix, this._$filters, object.canApply, object.basePosition.x, object.basePosition.y);
530
- // current mask cache
531
- context._$saveCurrentMask();
532
- if (updated) {
533
- context._$saveAttachment($Math.ceil(layerWidth), $Math.ceil(layerHeight), false);
534
- }
535
- // setup
536
- object.isFilter = true;
537
- object.isUpdated = updated;
538
- object.color = $getFloat32Array8();
539
- object.baseMatrix = multiMatrix;
540
- object.filters = this._$filters;
541
- object.blendMode = blendMode;
542
- object.layerWidth = layerWidth;
543
- object.layerHeight = layerHeight;
544
- object.matrix = $getFloat32Array6(multiMatrix[0], multiMatrix[1], multiMatrix[2], multiMatrix[3], tx, ty);
545
- }
546
- return object;
547
- }
548
- /**
549
- * @param {CanvasToWebGLContext} context
550
- * @param {Float32Array} matrix
551
- * @param {Float32Array} color_transform
552
- * @param {object} object
553
- * @return {void}
554
- * @method
555
- * @private
556
- */
557
- _$postDraw(context, matrix, color_transform, object) {
558
- // cache
559
- const cacheKeys = $getArray(this._$instanceId, "f");
560
- const cacheStore = $renderPlayer.cacheStore;
561
- const manager = context.frameBuffer;
562
- // cache or new texture
563
- let texture;
564
- if (object.isUpdated) {
565
- texture = manager.getTextureFromCurrentAttachment();
566
- const cacheTexture = cacheStore.get(cacheKeys);
567
- if (cacheTexture) {
568
- cacheStore.set(cacheKeys, null);
569
- manager.releaseTexture(cacheTexture);
570
- }
571
- }
572
- else {
573
- texture = cacheStore.get(cacheKeys);
574
- if (!texture) {
575
- throw new Error("the texture is null.");
576
- }
577
- }
578
- // blend only
579
- if (!object.canApply) {
580
- texture._$offsetX = 0;
581
- texture._$offsetY = 0;
582
- }
583
- // set cache offset
584
- let offsetX = texture._$offsetX;
585
- let offsetY = texture._$offsetY;
586
- // execute filter
587
- if (object.isUpdated && object.canApply) {
588
- // cache clear
589
- const cache = cacheStore.get(cacheKeys);
590
- if (cache) {
591
- // reset cache params
592
- cacheStore.set(cacheKeys, null);
593
- cache.layerWidth = 0;
594
- cache.layerHeight = 0;
595
- cache._$offsetX = 0;
596
- cache._$offsetY = 0;
597
- cache.matrix = null;
598
- cache.colorTransform = null;
599
- manager.releaseTexture(cache);
600
- }
601
- // apply filter
602
- const filters = object.filters;
603
- if (filters && filters.length) {
604
- // init
605
- context._$offsetX = 0;
606
- context._$offsetY = 0;
607
- for (let idx = 0; idx < filters.length; ++idx) {
608
- texture = filters[idx]
609
- ._$applyFilter(context, matrix);
610
- }
611
- offsetX = context._$offsetX;
612
- offsetY = context._$offsetY;
613
- // reset
614
- context._$offsetX = 0;
615
- context._$offsetY = 0;
616
- // set offset
617
- texture._$offsetX = offsetX;
618
- texture._$offsetY = offsetY;
619
- }
620
- }
621
- // update cache params
622
- if (object.isUpdated) {
623
- texture.filterState = object.canApply;
624
- // cache texture
625
- const matrix = object.baseMatrix;
626
- if (matrix) {
627
- texture.matrix = `${matrix[0]}_${matrix[1]}_${matrix[2]}_${matrix[3]}`;
628
- }
629
- texture.layerWidth = object.layerWidth;
630
- texture.layerHeight = object.layerHeight;
631
- }
632
- // cache texture
633
- cacheStore.set(cacheKeys, texture);
634
- $poolArray(cacheKeys);
635
- // set current buffer
636
- if (object.isUpdated) {
637
- context._$restoreAttachment();
638
- }
639
- // set
640
- context.reset();
641
- context.globalAlpha = $clamp(color_transform[3] + color_transform[7] / 255, 0, 1);
642
- context.globalCompositeOperation = object.blendMode;
643
- context.setTransform(1, 0, 0, 1, 0, 0);
644
- context.drawImage(texture, -offsetX + object.position.dx, -offsetY + object.position.dy, texture.width, texture.height, color_transform);
645
- // end blend
646
- context._$endLayer();
647
- // reset
648
- context._$restoreCurrentMask();
649
- // object pool
650
- if (object.baseMatrix !== matrix) {
651
- $poolFloat32Array6(object.baseMatrix);
652
- }
653
- $poolFloat32Array6(object.matrix);
654
- $poolPreObject(object);
655
- }
656
- /**
657
- * @description Playerから登録を削除
658
- *
659
- * @return {void}
660
- * @method
661
- * @private
662
- */
663
- _$remove() {
664
- // reset
665
- this._$children.length = 0;
666
- this._$recodes = null;
667
- super._$remove();
668
- $containers.push(this);
669
- }
670
- }