@next2d/media 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/Video.d.ts +2 -0
- package/dist/Video.js +114 -74
- package/package.json +10 -10
package/dist/Video.d.ts
CHANGED
package/dist/Video.js
CHANGED
|
@@ -2,7 +2,7 @@ import { SoundMixer } from "./SoundMixer";
|
|
|
2
2
|
import { DisplayObject } from "@next2d/display";
|
|
3
3
|
import { VideoEvent } from "@next2d/events";
|
|
4
4
|
import { $document, $audioContext, $currentPlayer, $isTouch, $rendererWorker } from "@next2d/util";
|
|
5
|
-
import { $Math, $cancelAnimationFrame, $requestAnimationFrame, $getBoundsObject, $boundsMatrix, $clamp, $multiplicationMatrix, $poolFloat32Array6, $MATRIX_ARRAY_IDENTITY, $OffscreenCanvas, $multiplicationColor, $poolFloat32Array8, $Infinity, $poolBoundsObject, $
|
|
5
|
+
import { $Math, $cancelAnimationFrame, $requestAnimationFrame, $getBoundsObject, $boundsMatrix, $clamp, $multiplicationMatrix, $poolFloat32Array6, $MATRIX_ARRAY_IDENTITY, $OffscreenCanvas, $multiplicationColor, $poolFloat32Array8, $Infinity, $poolBoundsObject, $getArray, $Number, $poolArray, $cacheStore, $getFloat32Array6 } from "@next2d/share";
|
|
6
6
|
/**
|
|
7
7
|
* サーバーまたはローカルに保存された録画済みビデオファイルを再生する Video オブジェクトです。
|
|
8
8
|
* ビデオストリームを再生するには、attachNetStream() を使用して、ビデオを Video オブジェクトに関連付けます。
|
|
@@ -97,6 +97,16 @@ export class Video extends DisplayObject {
|
|
|
97
97
|
* @private
|
|
98
98
|
*/
|
|
99
99
|
this._$context = null;
|
|
100
|
+
/**
|
|
101
|
+
* @type {array}
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
this._$cacheKeys = $getArray();
|
|
105
|
+
/**
|
|
106
|
+
* @type {array}
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
this._$cacheParams = $getArray(0, 0, 0);
|
|
100
110
|
}
|
|
101
111
|
/**
|
|
102
112
|
* @description 指定されたクラスのストリングを返します。
|
|
@@ -453,6 +463,8 @@ export class Video extends DisplayObject {
|
|
|
453
463
|
* @private
|
|
454
464
|
*/
|
|
455
465
|
_$initializeVideo() {
|
|
466
|
+
// clear cache key
|
|
467
|
+
this._$cacheKeys.length = 0;
|
|
456
468
|
const video = $document.createElement("video");
|
|
457
469
|
video.autoplay = false;
|
|
458
470
|
video.crossOrigin = "anonymous";
|
|
@@ -625,93 +637,118 @@ export class Video extends DisplayObject {
|
|
|
625
637
|
default:
|
|
626
638
|
break;
|
|
627
639
|
}
|
|
640
|
+
let xScale = +$Math.sqrt(multiMatrix[0] * multiMatrix[0]
|
|
641
|
+
+ multiMatrix[1] * multiMatrix[1]);
|
|
642
|
+
if (!$Number.isInteger(xScale)) {
|
|
643
|
+
const value = xScale.toString();
|
|
644
|
+
const index = value.indexOf("e");
|
|
645
|
+
if (index !== -1) {
|
|
646
|
+
xScale = +value.slice(0, index);
|
|
647
|
+
}
|
|
648
|
+
xScale = +xScale.toFixed(4);
|
|
649
|
+
}
|
|
650
|
+
let yScale = +$Math.sqrt(multiMatrix[2] * multiMatrix[2]
|
|
651
|
+
+ multiMatrix[3] * multiMatrix[3]);
|
|
652
|
+
if (!$Number.isInteger(yScale)) {
|
|
653
|
+
const value = yScale.toString();
|
|
654
|
+
const index = value.indexOf("e");
|
|
655
|
+
if (index !== -1) {
|
|
656
|
+
yScale = +value.slice(0, index);
|
|
657
|
+
}
|
|
658
|
+
yScale = +yScale.toFixed(4);
|
|
659
|
+
}
|
|
660
|
+
const filters = this._$filters || this.filters;
|
|
661
|
+
const canApply = filters && filters.length > 0 && this._$canApply(filters);
|
|
662
|
+
let filterBounds = $getBoundsObject(0, width, 0, height);
|
|
663
|
+
if (canApply) {
|
|
664
|
+
for (let idx = 0; idx < filters.length; ++idx) {
|
|
665
|
+
filterBounds = filters[idx]
|
|
666
|
+
._$generateFilterRect(filterBounds, xScale, yScale);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
628
669
|
// cache current buffer
|
|
629
670
|
const manager = context.frameBuffer;
|
|
630
671
|
const currentAttachment = manager.currentAttachment;
|
|
631
672
|
if (!currentAttachment
|
|
632
|
-
|| xMin > currentAttachment.width
|
|
633
|
-
|| yMin > currentAttachment.height) {
|
|
673
|
+
|| xMin - filterBounds.xMin > currentAttachment.width
|
|
674
|
+
|| yMin - filterBounds.yMin > currentAttachment.height) {
|
|
675
|
+
$poolBoundsObject(filterBounds);
|
|
634
676
|
return;
|
|
635
677
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
$poolBoundsObject(filterBounds);
|
|
654
|
-
}
|
|
655
|
-
else {
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
678
|
+
if (0 > xMin + filterBounds.xMax || 0 > yMin + filterBounds.yMax) {
|
|
679
|
+
$poolBoundsObject(filterBounds);
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
$poolBoundsObject(filterBounds);
|
|
683
|
+
if (!this._$cacheKeys.length
|
|
684
|
+
|| this._$cacheParams[0] !== xScale
|
|
685
|
+
|| this._$cacheParams[1] !== yScale
|
|
686
|
+
|| this._$cacheParams[2] !== color_transform[7]) {
|
|
687
|
+
const keys = $getArray();
|
|
688
|
+
keys[0] = xScale;
|
|
689
|
+
keys[1] = yScale;
|
|
690
|
+
this._$cacheKeys = $cacheStore.generateKeys(this._$instanceId, keys, color_transform);
|
|
691
|
+
$poolArray(keys);
|
|
692
|
+
this._$cacheParams[0] = xScale;
|
|
693
|
+
this._$cacheParams[1] = yScale;
|
|
694
|
+
this._$cacheParams[2] = color_transform[7];
|
|
658
695
|
}
|
|
659
696
|
const blendMode = this._$blendMode || this.blendMode;
|
|
660
|
-
|
|
661
|
-
if (
|
|
662
|
-
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
$poolFloat32Array6(baseMatrix);
|
|
678
|
-
context.reset();
|
|
679
|
-
context.setTransform(scaleMatrix[0], scaleMatrix[1], scaleMatrix[2], scaleMatrix[3], scaleMatrix[4], scaleMatrix[5]);
|
|
680
|
-
context.drawImage(texture, 0, 0, texture.width, texture.height);
|
|
681
|
-
manager.releaseTexture(texture);
|
|
682
|
-
$poolFloat32Array6(scaleMatrix);
|
|
683
|
-
texture = manager.getTextureFromCurrentAttachment();
|
|
684
|
-
// release buffer
|
|
685
|
-
manager.releaseAttachment(attachment, false);
|
|
686
|
-
// end draw and reset current buffer
|
|
687
|
-
context._$bind(currentAttachment);
|
|
688
|
-
}
|
|
689
|
-
// draw filter
|
|
690
|
-
texture = this._$drawFilter(context, texture, multiMatrix, filters, width, height);
|
|
691
|
-
// reset
|
|
697
|
+
context.cachePosition = $cacheStore.get(this._$cacheKeys);
|
|
698
|
+
if (!context.cachePosition) {
|
|
699
|
+
const width = $Math.ceil($Math.abs(this._$bounds.xMax - this._$bounds.xMin));
|
|
700
|
+
const height = $Math.ceil($Math.abs(this._$bounds.yMax - this._$bounds.yMin));
|
|
701
|
+
const position = manager
|
|
702
|
+
.createCachePosition(width, height);
|
|
703
|
+
context.cachePosition = position;
|
|
704
|
+
$cacheStore.set(this._$cacheKeys, position);
|
|
705
|
+
}
|
|
706
|
+
const texture = manager.createTextureFromVideo(this._$video, this._$smoothing);
|
|
707
|
+
let offsetX = 0;
|
|
708
|
+
let offsetY = 0;
|
|
709
|
+
if (canApply) {
|
|
710
|
+
const currentAttachment = manager.currentAttachment;
|
|
711
|
+
const attachment = manager
|
|
712
|
+
.createCacheAttachment(width, height);
|
|
713
|
+
context._$bind(attachment);
|
|
692
714
|
context.reset();
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
context.
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
715
|
+
const parentMatrix = $getFloat32Array6(xScale, 0, 0, yScale, width / 2, height / 2);
|
|
716
|
+
const baseMatrix = $getFloat32Array6(1, 0, 0, 1, -texture.width / 2, -texture.height / 2);
|
|
717
|
+
const scaleMatrix = $multiplicationMatrix(parentMatrix, baseMatrix);
|
|
718
|
+
$poolFloat32Array6(parentMatrix);
|
|
719
|
+
$poolFloat32Array6(baseMatrix);
|
|
720
|
+
context.setTransform(scaleMatrix[0], scaleMatrix[1], scaleMatrix[2], scaleMatrix[3], scaleMatrix[4], scaleMatrix[5]);
|
|
721
|
+
context.drawImage(texture, 0, 0, texture.width, texture.height);
|
|
722
|
+
const videoTexture = manager.getTextureFromCurrentAttachment();
|
|
723
|
+
context._$bind(currentAttachment);
|
|
724
|
+
manager.releaseAttachment(attachment);
|
|
725
|
+
// release
|
|
726
|
+
context.drawTextureFromRect(texture, context.cachePosition);
|
|
727
|
+
const position = this._$drawFilter(context, multiMatrix, filters, width, height, videoTexture);
|
|
728
|
+
if (position.offsetX) {
|
|
729
|
+
offsetX = position.offsetX;
|
|
730
|
+
}
|
|
731
|
+
if (position.offsetY) {
|
|
732
|
+
offsetY = position.offsetY;
|
|
733
|
+
}
|
|
734
|
+
// update
|
|
735
|
+
context.cachePosition = position;
|
|
736
|
+
context.setTransform(1, 0, 0, 1, xMin - offsetX, yMin - offsetY);
|
|
703
737
|
}
|
|
704
738
|
else {
|
|
705
|
-
|
|
706
|
-
context.reset();
|
|
739
|
+
context.drawTextureFromRect(texture, context.cachePosition);
|
|
707
740
|
context.setTransform(multiMatrix[0], multiMatrix[1], multiMatrix[2], multiMatrix[3], multiMatrix[4], multiMatrix[5]);
|
|
708
|
-
|
|
741
|
+
}
|
|
742
|
+
// draw
|
|
743
|
+
if (context.cachePosition) {
|
|
709
744
|
context.globalAlpha = alpha;
|
|
710
|
-
context.imageSmoothingEnabled =
|
|
745
|
+
context.imageSmoothingEnabled = true;
|
|
711
746
|
context.globalCompositeOperation = blendMode;
|
|
712
|
-
context.
|
|
713
|
-
|
|
747
|
+
context.drawInstance(xMin - offsetX, yMin - offsetY, xMax, yMax, color_transform);
|
|
748
|
+
// cache position clear
|
|
749
|
+
context.cachePosition = null;
|
|
714
750
|
}
|
|
751
|
+
// pool
|
|
715
752
|
if (multiMatrix !== matrix) {
|
|
716
753
|
$poolFloat32Array6(multiMatrix);
|
|
717
754
|
}
|
|
@@ -779,7 +816,9 @@ export class Video extends DisplayObject {
|
|
|
779
816
|
if (matrix) {
|
|
780
817
|
let multiMatrix = matrix;
|
|
781
818
|
const rawMatrix = this._$transform._$rawMatrix();
|
|
782
|
-
if (rawMatrix !==
|
|
819
|
+
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
820
|
+
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
821
|
+
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
783
822
|
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
784
823
|
}
|
|
785
824
|
const bounds = $boundsMatrix(this._$bounds, multiMatrix);
|
|
@@ -802,6 +841,7 @@ export class Video extends DisplayObject {
|
|
|
802
841
|
this._$created = true;
|
|
803
842
|
const message = {
|
|
804
843
|
"command": "createVideo",
|
|
844
|
+
"buffer": new Float32Array(),
|
|
805
845
|
"instanceId": this._$instanceId,
|
|
806
846
|
"parentId": this._$parent ? this._$parent._$instanceId : -1,
|
|
807
847
|
"smoothing": this._$smoothing,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/media",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Next2D Media Packages",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@tvon.jp> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@next2d/events": "1.
|
|
36
|
-
"@next2d/net": "1.
|
|
37
|
-
"@next2d/display": "1.
|
|
38
|
-
"@next2d/interface": "1.
|
|
39
|
-
"@next2d/core": "1.
|
|
40
|
-
"@next2d/share": "1.
|
|
41
|
-
"@next2d/util": "1.
|
|
42
|
-
"@next2d/geom": "1.
|
|
43
|
-
"@next2d/webgl": "1.
|
|
35
|
+
"@next2d/events": "1.17.0",
|
|
36
|
+
"@next2d/net": "1.17.0",
|
|
37
|
+
"@next2d/display": "1.17.0",
|
|
38
|
+
"@next2d/interface": "1.17.0",
|
|
39
|
+
"@next2d/core": "1.17.0",
|
|
40
|
+
"@next2d/share": "1.17.0",
|
|
41
|
+
"@next2d/util": "1.17.0",
|
|
42
|
+
"@next2d/geom": "1.17.0",
|
|
43
|
+
"@next2d/webgl": "1.17.0"
|
|
44
44
|
}
|
|
45
45
|
}
|