lighteningcards 2.2.1 → 2.2.2
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/index.cjs.js +447 -1234
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +447 -1234
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/LighteningCard.css +5 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2959,8 +2959,8 @@ const _TextureStyle = class _TextureStyle extends EventEmitter {
|
|
|
2959
2959
|
return this._sharedResourceId || this._generateResourceId();
|
|
2960
2960
|
}
|
|
2961
2961
|
update() {
|
|
2962
|
-
this._sharedResourceId = null;
|
|
2963
2962
|
this.emit("change", this);
|
|
2963
|
+
this._sharedResourceId = null;
|
|
2964
2964
|
}
|
|
2965
2965
|
_generateResourceId() {
|
|
2966
2966
|
const bigKey = `${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;
|
|
@@ -2989,10 +2989,6 @@ const _TextureSource = class _TextureSource extends EventEmitter {
|
|
|
2989
2989
|
constructor(options = {}) {
|
|
2990
2990
|
super();
|
|
2991
2991
|
this.options = options;
|
|
2992
|
-
/** @internal */
|
|
2993
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
2994
|
-
/** @internal */
|
|
2995
|
-
this._gcLastUsed = -1;
|
|
2996
2992
|
/** unique id for this Texture source */
|
|
2997
2993
|
this.uid = uid$1("textureSource");
|
|
2998
2994
|
/**
|
|
@@ -3188,8 +3184,8 @@ const _TextureSource = class _TextureSource extends EventEmitter {
|
|
|
3188
3184
|
/** Destroys this texture source */
|
|
3189
3185
|
destroy() {
|
|
3190
3186
|
this.destroyed = true;
|
|
3191
|
-
this.unload();
|
|
3192
3187
|
this.emit("destroy", this);
|
|
3188
|
+
this.emit("change", this);
|
|
3193
3189
|
if (this._style) {
|
|
3194
3190
|
this._style.destroy();
|
|
3195
3191
|
this._style = null;
|
|
@@ -3206,10 +3202,6 @@ const _TextureSource = class _TextureSource extends EventEmitter {
|
|
|
3206
3202
|
this._resourceId = uid$1("resource");
|
|
3207
3203
|
this.emit("change", this);
|
|
3208
3204
|
this.emit("unload", this);
|
|
3209
|
-
for (const key in this._gpuData) {
|
|
3210
|
-
this._gpuData[key]?.destroy?.();
|
|
3211
|
-
}
|
|
3212
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
3213
3205
|
}
|
|
3214
3206
|
/** the width of the resource. This is the REAL pure number, not accounting resolution */
|
|
3215
3207
|
get resourceWidth() {
|
|
@@ -3576,7 +3568,6 @@ class Texture extends EventEmitter {
|
|
|
3576
3568
|
*/
|
|
3577
3569
|
destroy(destroySource = false) {
|
|
3578
3570
|
if (this._source) {
|
|
3579
|
-
this._source.off("resize", this.update, this);
|
|
3580
3571
|
if (destroySource) {
|
|
3581
3572
|
this._source.destroy();
|
|
3582
3573
|
this._source = null;
|
|
@@ -5412,7 +5403,6 @@ class Pool {
|
|
|
5412
5403
|
item = this._pool[--this._index];
|
|
5413
5404
|
} else {
|
|
5414
5405
|
item = new this._classType();
|
|
5415
|
-
this._count++;
|
|
5416
5406
|
}
|
|
5417
5407
|
item.init?.(data);
|
|
5418
5408
|
return item;
|
|
@@ -6870,13 +6860,6 @@ class Container extends EventEmitter {
|
|
|
6870
6860
|
this.measurable = true;
|
|
6871
6861
|
/** @private */
|
|
6872
6862
|
this.isSimple = true;
|
|
6873
|
-
/**
|
|
6874
|
-
* The RenderLayer this container belongs to, if any.
|
|
6875
|
-
* If it belongs to a RenderLayer, it will be rendered from the RenderLayer's position in the scene.
|
|
6876
|
-
* @readonly
|
|
6877
|
-
* @advanced
|
|
6878
|
-
*/
|
|
6879
|
-
this.parentRenderLayer = null;
|
|
6880
6863
|
// / /////////////Transform related props//////////////
|
|
6881
6864
|
// used by the transform system to check if a container needs to be updated that frame
|
|
6882
6865
|
// if the tick matches the current transform system tick, it is not updated again
|
|
@@ -7952,6 +7935,7 @@ extensions.mixin(
|
|
|
7952
7935
|
);
|
|
7953
7936
|
|
|
7954
7937
|
class ViewContainer extends Container {
|
|
7938
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
7955
7939
|
constructor(options) {
|
|
7956
7940
|
super(options);
|
|
7957
7941
|
/** @internal */
|
|
@@ -7964,13 +7948,8 @@ class ViewContainer extends Container {
|
|
|
7964
7948
|
this._lastUsed = -1;
|
|
7965
7949
|
/** @internal */
|
|
7966
7950
|
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
7967
|
-
/** If set to true, the resource will be garbage collected automatically when it is not used. */
|
|
7968
|
-
this.autoGarbageCollect = true;
|
|
7969
|
-
/** @internal */
|
|
7970
|
-
this._gcLastUsed = -1;
|
|
7971
7951
|
this._bounds = new Bounds(0, 1, 0, 0);
|
|
7972
7952
|
this._boundsDirty = true;
|
|
7973
|
-
this.autoGarbageCollect = options.autoGarbageCollect ?? true;
|
|
7974
7953
|
}
|
|
7975
7954
|
/**
|
|
7976
7955
|
* The local bounds of the view in its own coordinate space.
|
|
@@ -8039,19 +8018,13 @@ class ViewContainer extends Container {
|
|
|
8039
8018
|
renderGroup.onChildViewUpdate(this);
|
|
8040
8019
|
}
|
|
8041
8020
|
}
|
|
8042
|
-
/** Unloads the GPU data from the view. */
|
|
8043
|
-
unload() {
|
|
8044
|
-
this.emit("unload", this);
|
|
8045
|
-
for (const key in this._gpuData) {
|
|
8046
|
-
this._gpuData[key]?.destroy();
|
|
8047
|
-
}
|
|
8048
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
8049
|
-
this.onViewUpdate();
|
|
8050
|
-
}
|
|
8051
8021
|
destroy(options) {
|
|
8052
|
-
this.unload();
|
|
8053
8022
|
super.destroy(options);
|
|
8054
8023
|
this._bounds = null;
|
|
8024
|
+
for (const key in this._gpuData) {
|
|
8025
|
+
this._gpuData[key].destroy?.();
|
|
8026
|
+
}
|
|
8027
|
+
this._gpuData = null;
|
|
8055
8028
|
}
|
|
8056
8029
|
/**
|
|
8057
8030
|
* Collects renderables for the view container.
|
|
@@ -8243,6 +8216,7 @@ class Sprite extends ViewContainer {
|
|
|
8243
8216
|
this._visualBounds = null;
|
|
8244
8217
|
this._bounds = null;
|
|
8245
8218
|
this._anchor = null;
|
|
8219
|
+
this._gpuData = null;
|
|
8246
8220
|
}
|
|
8247
8221
|
/**
|
|
8248
8222
|
* The anchor sets the origin point of the sprite. The default value is taken from the {@link Texture}
|
|
@@ -8455,8 +8429,6 @@ class AlphaMask {
|
|
|
8455
8429
|
this.mask.measurable = false;
|
|
8456
8430
|
}
|
|
8457
8431
|
reset() {
|
|
8458
|
-
if (this.mask === null)
|
|
8459
|
-
return;
|
|
8460
8432
|
this.mask.measurable = true;
|
|
8461
8433
|
this.mask = null;
|
|
8462
8434
|
}
|
|
@@ -8514,8 +8486,6 @@ class StencilMask {
|
|
|
8514
8486
|
this.mask.measurable = false;
|
|
8515
8487
|
}
|
|
8516
8488
|
reset() {
|
|
8517
|
-
if (this.mask === null)
|
|
8518
|
-
return;
|
|
8519
8489
|
this.mask.measurable = true;
|
|
8520
8490
|
this.mask.includeInBuild = true;
|
|
8521
8491
|
this.mask = null;
|
|
@@ -8772,6 +8742,7 @@ const _Ticker = class _Ticker {
|
|
|
8772
8742
|
*
|
|
8773
8743
|
* This is NOT in milliseconds - it's a scalar multiplier for frame-independent animations.
|
|
8774
8744
|
* For actual milliseconds, use {@link Ticker#deltaMS}.
|
|
8745
|
+
* @member {number}
|
|
8775
8746
|
* @example
|
|
8776
8747
|
* ```ts
|
|
8777
8748
|
* // Frame-independent animation using deltaTime scalar
|
|
@@ -8787,6 +8758,7 @@ const _Ticker = class _Ticker {
|
|
|
8787
8758
|
* Similar to performance.now() timestamp format.
|
|
8788
8759
|
*
|
|
8789
8760
|
* Used internally for calculating time deltas between frames.
|
|
8761
|
+
* @member {number}
|
|
8790
8762
|
* @example
|
|
8791
8763
|
* ```ts
|
|
8792
8764
|
* ticker.add((ticker) => {
|
|
@@ -10804,12 +10776,7 @@ class Resolver {
|
|
|
10804
10776
|
const assetArray = convertToList(assets);
|
|
10805
10777
|
assetArray.forEach((asset) => {
|
|
10806
10778
|
const { src } = asset;
|
|
10807
|
-
let {
|
|
10808
|
-
data,
|
|
10809
|
-
format,
|
|
10810
|
-
loadParser: userDefinedLoadParser,
|
|
10811
|
-
parser: userDefinedParser
|
|
10812
|
-
} = asset;
|
|
10779
|
+
let { data, format, loadParser: userDefinedLoadParser, parser: userDefinedParser } = asset;
|
|
10813
10780
|
const srcsToUse = convertToList(src).map((src2) => {
|
|
10814
10781
|
if (typeof src2 === "string") {
|
|
10815
10782
|
return createStringVariations(src2);
|
|
@@ -10819,18 +10786,18 @@ class Resolver {
|
|
|
10819
10786
|
const aliasesToUse = this.getAlias(asset);
|
|
10820
10787
|
Array.isArray(aliasesToUse) ? aliasesToUse.forEach(keyCheck) : keyCheck(aliasesToUse);
|
|
10821
10788
|
const resolvedAssets = [];
|
|
10822
|
-
const parseUrl = (url) => {
|
|
10823
|
-
const parser = this._parsers.find((p) => p.test(url));
|
|
10824
|
-
return {
|
|
10825
|
-
...parser?.parse(url),
|
|
10826
|
-
src: url
|
|
10827
|
-
};
|
|
10828
|
-
};
|
|
10829
10789
|
srcsToUse.forEach((srcs) => {
|
|
10830
10790
|
srcs.forEach((src2) => {
|
|
10831
10791
|
let formattedAsset = {};
|
|
10832
10792
|
if (typeof src2 !== "object") {
|
|
10833
|
-
formattedAsset =
|
|
10793
|
+
formattedAsset.src = src2;
|
|
10794
|
+
for (let i = 0; i < this._parsers.length; i++) {
|
|
10795
|
+
const parser = this._parsers[i];
|
|
10796
|
+
if (parser.test(src2)) {
|
|
10797
|
+
formattedAsset = parser.parse(src2);
|
|
10798
|
+
break;
|
|
10799
|
+
}
|
|
10800
|
+
}
|
|
10834
10801
|
} else {
|
|
10835
10802
|
data = src2.data ?? data;
|
|
10836
10803
|
format = src2.format ?? format;
|
|
@@ -10839,7 +10806,7 @@ class Resolver {
|
|
|
10839
10806
|
userDefinedParser = src2.parser ?? userDefinedParser;
|
|
10840
10807
|
}
|
|
10841
10808
|
formattedAsset = {
|
|
10842
|
-
...
|
|
10809
|
+
...formattedAsset,
|
|
10843
10810
|
...src2
|
|
10844
10811
|
};
|
|
10845
10812
|
}
|
|
@@ -10851,8 +10818,7 @@ class Resolver {
|
|
|
10851
10818
|
data,
|
|
10852
10819
|
format,
|
|
10853
10820
|
loadParser: userDefinedLoadParser,
|
|
10854
|
-
parser: userDefinedParser
|
|
10855
|
-
progressSize: asset.progressSize
|
|
10821
|
+
parser: userDefinedParser
|
|
10856
10822
|
});
|
|
10857
10823
|
resolvedAssets.push(formattedAsset);
|
|
10858
10824
|
});
|
|
@@ -11012,7 +10978,7 @@ class Resolver {
|
|
|
11012
10978
|
return `${url}${paramConnector}${this._defaultSearchParams}`;
|
|
11013
10979
|
}
|
|
11014
10980
|
_buildResolvedAsset(formattedAsset, data) {
|
|
11015
|
-
const { aliases, data: assetData, loadParser, parser, format
|
|
10981
|
+
const { aliases, data: assetData, loadParser, parser, format } = data;
|
|
11016
10982
|
if (this._basePath || this._rootPath) {
|
|
11017
10983
|
formattedAsset.src = path.toAbsolute(formattedAsset.src, this._basePath, this._rootPath);
|
|
11018
10984
|
}
|
|
@@ -11022,9 +10988,6 @@ class Resolver {
|
|
|
11022
10988
|
formattedAsset.loadParser = loadParser ?? formattedAsset.loadParser;
|
|
11023
10989
|
formattedAsset.parser = parser ?? formattedAsset.parser;
|
|
11024
10990
|
formattedAsset.format = format ?? formattedAsset.format ?? getUrlExtension(formattedAsset.src);
|
|
11025
|
-
if (progressSize !== void 0) {
|
|
11026
|
-
formattedAsset.progressSize = progressSize;
|
|
11027
|
-
}
|
|
11028
10991
|
return formattedAsset;
|
|
11029
10992
|
}
|
|
11030
10993
|
}
|
|
@@ -11801,7 +11764,7 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11801
11764
|
/** This is the dom element that will sit over the PixiJS element. This is where the div overlays will go. */
|
|
11802
11765
|
this._div = null;
|
|
11803
11766
|
/** A simple pool for storing divs. */
|
|
11804
|
-
this.
|
|
11767
|
+
this._pool = [];
|
|
11805
11768
|
/** This is a tick used to check if an object is no longer being rendered. */
|
|
11806
11769
|
this._renderId = 0;
|
|
11807
11770
|
/** The array of currently active accessible items. */
|
|
@@ -11810,11 +11773,6 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11810
11773
|
this._androidUpdateCount = 0;
|
|
11811
11774
|
/** The frequency to update the div elements. */
|
|
11812
11775
|
this._androidUpdateFrequency = 500;
|
|
11813
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly
|
|
11814
|
-
this._isRunningTests = false;
|
|
11815
|
-
/** Bound function references for proper event listener removal */
|
|
11816
|
-
this._boundOnKeyDown = this._onKeyDown.bind(this);
|
|
11817
|
-
this._boundOnMouseMove = this._onMouseMove.bind(this);
|
|
11818
11776
|
this._hookDiv = null;
|
|
11819
11777
|
if (_mobileInfo.tablet || _mobileInfo.phone) {
|
|
11820
11778
|
this._createTouchHook();
|
|
@@ -11838,19 +11796,12 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11838
11796
|
return this._isMobileAccessibility;
|
|
11839
11797
|
}
|
|
11840
11798
|
/**
|
|
11841
|
-
*
|
|
11799
|
+
* The DOM element that will sit over the PixiJS element. This is where the div overlays will go.
|
|
11842
11800
|
* @readonly
|
|
11843
11801
|
*/
|
|
11844
11802
|
get hookDiv() {
|
|
11845
11803
|
return this._hookDiv;
|
|
11846
11804
|
}
|
|
11847
|
-
/**
|
|
11848
|
-
* The DOM element that will sit over the PixiJS element. This is where the div overlays will go.
|
|
11849
|
-
* @readonly
|
|
11850
|
-
*/
|
|
11851
|
-
get div() {
|
|
11852
|
-
return this._div;
|
|
11853
|
-
}
|
|
11854
11805
|
/**
|
|
11855
11806
|
* Creates the touch hooks.
|
|
11856
11807
|
* @private
|
|
@@ -11907,10 +11858,12 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11907
11858
|
});
|
|
11908
11859
|
}
|
|
11909
11860
|
if (this._activateOnTab) {
|
|
11910
|
-
|
|
11861
|
+
this._onKeyDown = this._onKeyDown.bind(this);
|
|
11862
|
+
globalThis.addEventListener("keydown", this._onKeyDown, false);
|
|
11911
11863
|
}
|
|
11912
11864
|
if (this._deactivateOnMouseMove) {
|
|
11913
|
-
|
|
11865
|
+
this._onMouseMove = this._onMouseMove.bind(this);
|
|
11866
|
+
globalThis.document.addEventListener("mousemove", this._onMouseMove, true);
|
|
11914
11867
|
}
|
|
11915
11868
|
const canvas = this._renderer.view.canvas;
|
|
11916
11869
|
if (!canvas.parentNode) {
|
|
@@ -11943,31 +11896,27 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11943
11896
|
return;
|
|
11944
11897
|
}
|
|
11945
11898
|
this._isActive = false;
|
|
11946
|
-
globalThis.document.removeEventListener("mousemove", this.
|
|
11899
|
+
globalThis.document.removeEventListener("mousemove", this._onMouseMove, true);
|
|
11947
11900
|
if (this._activateOnTab) {
|
|
11948
|
-
globalThis.addEventListener("keydown", this.
|
|
11901
|
+
globalThis.addEventListener("keydown", this._onKeyDown, false);
|
|
11949
11902
|
}
|
|
11950
11903
|
this._renderer.runners.postrender.remove(this);
|
|
11951
11904
|
for (const child of this._children) {
|
|
11952
|
-
if (child._accessibleDiv
|
|
11905
|
+
if (child._accessibleDiv && child._accessibleDiv.parentNode) {
|
|
11953
11906
|
child._accessibleDiv.parentNode.removeChild(child._accessibleDiv);
|
|
11954
11907
|
child._accessibleDiv = null;
|
|
11955
11908
|
}
|
|
11956
11909
|
child._accessibleActive = false;
|
|
11957
11910
|
}
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
});
|
|
11965
|
-
delete this._pools[accessibleType];
|
|
11966
|
-
}
|
|
11967
|
-
if (this._div?.parentNode) {
|
|
11911
|
+
this._pool.forEach((div) => {
|
|
11912
|
+
if (div.parentNode) {
|
|
11913
|
+
div.parentNode.removeChild(div);
|
|
11914
|
+
}
|
|
11915
|
+
});
|
|
11916
|
+
if (this._div && this._div.parentNode) {
|
|
11968
11917
|
this._div.parentNode.removeChild(this._div);
|
|
11969
11918
|
}
|
|
11970
|
-
this.
|
|
11919
|
+
this._pool = [];
|
|
11971
11920
|
this._children = [];
|
|
11972
11921
|
}
|
|
11973
11922
|
/**
|
|
@@ -12009,6 +11958,9 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12009
11958
|
this._deactivateOnMouseMove = mergedOptions.accessibilityOptions.deactivateOnMouseMove;
|
|
12010
11959
|
if (mergedOptions.accessibilityOptions.enabledByDefault) {
|
|
12011
11960
|
this._activate();
|
|
11961
|
+
} else if (this._activateOnTab) {
|
|
11962
|
+
this._onKeyDown = this._onKeyDown.bind(this);
|
|
11963
|
+
globalThis.addEventListener("keydown", this._onKeyDown, false);
|
|
12012
11964
|
}
|
|
12013
11965
|
this._renderer.runners.postrender.remove(this);
|
|
12014
11966
|
}
|
|
@@ -12026,7 +11978,7 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12026
11978
|
return;
|
|
12027
11979
|
}
|
|
12028
11980
|
this._androidUpdateCount = now + this._androidUpdateFrequency;
|
|
12029
|
-
if (
|
|
11981
|
+
if (!this._renderer.renderingToScreen || !this._renderer.view.canvas) {
|
|
12030
11982
|
return;
|
|
12031
11983
|
}
|
|
12032
11984
|
const activeIds = /* @__PURE__ */ new Set();
|
|
@@ -12043,8 +11995,7 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12043
11995
|
if (!activeIds.has(i)) {
|
|
12044
11996
|
if (child._accessibleDiv && child._accessibleDiv.parentNode) {
|
|
12045
11997
|
child._accessibleDiv.parentNode.removeChild(child._accessibleDiv);
|
|
12046
|
-
|
|
12047
|
-
pool.push(child._accessibleDiv);
|
|
11998
|
+
this._pool.push(child._accessibleDiv);
|
|
12048
11999
|
child._accessibleDiv = null;
|
|
12049
12000
|
}
|
|
12050
12001
|
child._accessibleActive = false;
|
|
@@ -12113,14 +12064,8 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12113
12064
|
* @param {Container} container - The child to make accessible.
|
|
12114
12065
|
*/
|
|
12115
12066
|
_addChild(container) {
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
if (div) {
|
|
12119
|
-
div.innerHTML = "";
|
|
12120
|
-
div.removeAttribute("title");
|
|
12121
|
-
div.removeAttribute("aria-label");
|
|
12122
|
-
div.tabIndex = 0;
|
|
12123
|
-
} else {
|
|
12067
|
+
let div = this._pool.pop();
|
|
12068
|
+
if (!div) {
|
|
12124
12069
|
if (container.accessibleType === "button") {
|
|
12125
12070
|
div = document.createElement("button");
|
|
12126
12071
|
} else {
|
|
@@ -12263,14 +12208,12 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12263
12208
|
this._canvasObserver?.destroy();
|
|
12264
12209
|
this._canvasObserver = null;
|
|
12265
12210
|
this._div = null;
|
|
12266
|
-
this.
|
|
12211
|
+
this._pool = null;
|
|
12267
12212
|
this._children = null;
|
|
12268
12213
|
this._renderer = null;
|
|
12269
|
-
this.
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
globalThis.document.removeEventListener("mousemove", this._boundOnMouseMove, true);
|
|
12273
|
-
this._boundOnMouseMove = null;
|
|
12214
|
+
if (this._activateOnTab) {
|
|
12215
|
+
globalThis.removeEventListener("keydown", this._onKeyDown);
|
|
12216
|
+
}
|
|
12274
12217
|
}
|
|
12275
12218
|
/**
|
|
12276
12219
|
* Enables or disables the accessibility system.
|
|
@@ -12288,12 +12231,6 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12288
12231
|
this._deactivate();
|
|
12289
12232
|
}
|
|
12290
12233
|
}
|
|
12291
|
-
_getPool(accessibleType) {
|
|
12292
|
-
if (!this._pools[accessibleType]) {
|
|
12293
|
-
this._pools[accessibleType] = [];
|
|
12294
|
-
}
|
|
12295
|
-
return this._pools[accessibleType];
|
|
12296
|
-
}
|
|
12297
12234
|
};
|
|
12298
12235
|
/** @ignore */
|
|
12299
12236
|
_AccessibilitySystem.extension = {
|
|
@@ -13020,14 +12957,12 @@ class BindGroup {
|
|
|
13020
12957
|
/**
|
|
13021
12958
|
* Used internally to 'touch' each resource, to ensure that the GC
|
|
13022
12959
|
* knows that all resources in this bind group are still being used.
|
|
13023
|
-
* @param now - The current time in milliseconds.
|
|
13024
12960
|
* @param tick - The current tick.
|
|
13025
12961
|
* @internal
|
|
13026
12962
|
*/
|
|
13027
|
-
_touch(
|
|
12963
|
+
_touch(tick) {
|
|
13028
12964
|
const resources = this.resources;
|
|
13029
12965
|
for (const i in resources) {
|
|
13030
|
-
resources[i]._gcLastUsed = now;
|
|
13031
12966
|
resources[i]._touched = tick;
|
|
13032
12967
|
}
|
|
13033
12968
|
}
|
|
@@ -13074,8 +13009,6 @@ class Shader extends EventEmitter {
|
|
|
13074
13009
|
*/
|
|
13075
13010
|
this._uniformBindMap = /* @__PURE__ */ Object.create(null);
|
|
13076
13011
|
this._ownedBindGroups = [];
|
|
13077
|
-
/** @internal */
|
|
13078
|
-
this._destroyed = false;
|
|
13079
13012
|
let {
|
|
13080
13013
|
gpuProgram,
|
|
13081
13014
|
glProgram,
|
|
@@ -13203,9 +13136,6 @@ class Shader extends EventEmitter {
|
|
|
13203
13136
|
* Make sure its not being used by other shaders!
|
|
13204
13137
|
*/
|
|
13205
13138
|
destroy(destroyPrograms = false) {
|
|
13206
|
-
if (this._destroyed)
|
|
13207
|
-
return;
|
|
13208
|
-
this._destroyed = true;
|
|
13209
13139
|
this.emit("destroy", this);
|
|
13210
13140
|
if (destroyPrograms) {
|
|
13211
13141
|
this.gpuProgram?.destroy();
|
|
@@ -13420,9 +13350,6 @@ const _Filter = class _Filter extends Shader {
|
|
|
13420
13350
|
this.blendRequired = options.blendRequired;
|
|
13421
13351
|
this.clipToViewport = options.clipToViewport;
|
|
13422
13352
|
this.addResource("uTexture", 0, 1);
|
|
13423
|
-
if (options.blendRequired) {
|
|
13424
|
-
this.addResource("uBackTexture", 0, 3);
|
|
13425
|
-
}
|
|
13426
13353
|
}
|
|
13427
13354
|
/**
|
|
13428
13355
|
* Applies the filter
|
|
@@ -14264,8 +14191,6 @@ const _AbstractRenderer = class _AbstractRenderer extends EventEmitter {
|
|
|
14264
14191
|
*/
|
|
14265
14192
|
constructor(config) {
|
|
14266
14193
|
super();
|
|
14267
|
-
/** The current tick of the renderer. */
|
|
14268
|
-
this.tick = 0;
|
|
14269
14194
|
/** @internal */
|
|
14270
14195
|
this.uid = uid$1("renderer");
|
|
14271
14196
|
/** @internal */
|
|
@@ -14303,7 +14228,6 @@ const _AbstractRenderer = class _AbstractRenderer extends EventEmitter {
|
|
|
14303
14228
|
this._initOptions = options;
|
|
14304
14229
|
}
|
|
14305
14230
|
render(args, deprecated) {
|
|
14306
|
-
this.tick++;
|
|
14307
14231
|
let options = args;
|
|
14308
14232
|
if (options instanceof Container) {
|
|
14309
14233
|
options = { container: options };
|
|
@@ -14479,12 +14403,12 @@ const _AbstractRenderer = class _AbstractRenderer extends EventEmitter {
|
|
|
14479
14403
|
destroy(options = false) {
|
|
14480
14404
|
this.runners.destroy.items.reverse();
|
|
14481
14405
|
this.runners.destroy.emit(options);
|
|
14482
|
-
if (options === true || typeof options === "object" && options.releaseGlobalResources) {
|
|
14483
|
-
GlobalResourceRegistry.release();
|
|
14484
|
-
}
|
|
14485
14406
|
Object.values(this.runners).forEach((runner) => {
|
|
14486
14407
|
runner.destroy();
|
|
14487
14408
|
});
|
|
14409
|
+
if (options === true || typeof options === "object" && options.releaseGlobalResources) {
|
|
14410
|
+
GlobalResourceRegistry.release();
|
|
14411
|
+
}
|
|
14488
14412
|
this._systemsHash = null;
|
|
14489
14413
|
this.renderPipes = null;
|
|
14490
14414
|
}
|
|
@@ -14673,7 +14597,7 @@ async function autoDetectRenderer(options) {
|
|
|
14673
14597
|
return renderer;
|
|
14674
14598
|
}
|
|
14675
14599
|
|
|
14676
|
-
const VERSION = "8.
|
|
14600
|
+
const VERSION = "8.13.2";
|
|
14677
14601
|
|
|
14678
14602
|
class ApplicationInitHook {
|
|
14679
14603
|
static init() {
|
|
@@ -14747,7 +14671,6 @@ const _Application = class _Application {
|
|
|
14747
14671
|
*/
|
|
14748
14672
|
async init(options) {
|
|
14749
14673
|
options = { ...options };
|
|
14750
|
-
this.stage || (this.stage = new Container());
|
|
14751
14674
|
this.renderer = await autoDetectRenderer(options);
|
|
14752
14675
|
_Application._plugins.forEach((plugin) => {
|
|
14753
14676
|
plugin.init.call(this, options);
|
|
@@ -14913,7 +14836,6 @@ class ResizePlugin {
|
|
|
14913
14836
|
this,
|
|
14914
14837
|
"resizeTo",
|
|
14915
14838
|
{
|
|
14916
|
-
configurable: true,
|
|
14917
14839
|
set(dom) {
|
|
14918
14840
|
globalThis.removeEventListener("resize", this.queueResize);
|
|
14919
14841
|
this._resizeTo = dom;
|
|
@@ -14993,7 +14915,6 @@ class TickerPlugin {
|
|
|
14993
14915
|
this,
|
|
14994
14916
|
"ticker",
|
|
14995
14917
|
{
|
|
14996
|
-
configurable: true,
|
|
14997
14918
|
set(ticker) {
|
|
14998
14919
|
if (this._ticker) {
|
|
14999
14920
|
this._ticker.remove(this.render, this);
|
|
@@ -15124,9 +15045,9 @@ class AbstractBitmapFont extends EventEmitter {
|
|
|
15124
15045
|
/**
|
|
15125
15046
|
* tiny-lru
|
|
15126
15047
|
*
|
|
15127
|
-
* @copyright
|
|
15048
|
+
* @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
15128
15049
|
* @license BSD-3-Clause
|
|
15129
|
-
* @version 11.4.
|
|
15050
|
+
* @version 11.4.5
|
|
15130
15051
|
*/
|
|
15131
15052
|
/**
|
|
15132
15053
|
* A high-performance Least Recently Used (LRU) cache implementation with optional TTL support.
|
|
@@ -15249,13 +15170,7 @@ class LRU {
|
|
|
15249
15170
|
* @since 11.1.0
|
|
15250
15171
|
*/
|
|
15251
15172
|
entries (keys = this.keys()) {
|
|
15252
|
-
|
|
15253
|
-
for (let i = 0; i < keys.length; i++) {
|
|
15254
|
-
const key = keys[i];
|
|
15255
|
-
result[i] = [key, this.get(key)];
|
|
15256
|
-
}
|
|
15257
|
-
|
|
15258
|
-
return result;
|
|
15173
|
+
return keys.map(key => [key, this.get(key)]);
|
|
15259
15174
|
}
|
|
15260
15175
|
|
|
15261
15176
|
/**
|
|
@@ -15432,12 +15347,11 @@ class LRU {
|
|
|
15432
15347
|
* @since 9.0.0
|
|
15433
15348
|
*/
|
|
15434
15349
|
keys () {
|
|
15435
|
-
const result =
|
|
15350
|
+
const result = [];
|
|
15436
15351
|
let x = this.first;
|
|
15437
|
-
let i = 0;
|
|
15438
15352
|
|
|
15439
15353
|
while (x !== null) {
|
|
15440
|
-
result
|
|
15354
|
+
result.push(x.key);
|
|
15441
15355
|
x = x.next;
|
|
15442
15356
|
}
|
|
15443
15357
|
|
|
@@ -15566,12 +15480,7 @@ class LRU {
|
|
|
15566
15480
|
* @since 11.1.0
|
|
15567
15481
|
*/
|
|
15568
15482
|
values (keys = this.keys()) {
|
|
15569
|
-
|
|
15570
|
-
for (let i = 0; i < keys.length; i++) {
|
|
15571
|
-
result[i] = this.get(keys[i]);
|
|
15572
|
-
}
|
|
15573
|
-
|
|
15574
|
-
return result;
|
|
15483
|
+
return keys.map(key => this.get(key));
|
|
15575
15484
|
}
|
|
15576
15485
|
}
|
|
15577
15486
|
|
|
@@ -17931,15 +17840,13 @@ class ViewableBuffer {
|
|
|
17931
17840
|
/** Destroys all buffer references. Do not use after calling this. */
|
|
17932
17841
|
destroy() {
|
|
17933
17842
|
this.rawBinaryData = null;
|
|
17934
|
-
this.uint32View = null;
|
|
17935
|
-
this.float32View = null;
|
|
17936
|
-
this.uint16View = null;
|
|
17937
17843
|
this._int8View = null;
|
|
17938
17844
|
this._uint8View = null;
|
|
17939
17845
|
this._int16View = null;
|
|
17846
|
+
this.uint16View = null;
|
|
17940
17847
|
this._int32View = null;
|
|
17941
|
-
this.
|
|
17942
|
-
this.
|
|
17848
|
+
this.uint32View = null;
|
|
17849
|
+
this.float32View = null;
|
|
17943
17850
|
}
|
|
17944
17851
|
/**
|
|
17945
17852
|
* Returns the size of the given type in bytes.
|
|
@@ -18402,24 +18309,13 @@ const _Batcher = class _Batcher {
|
|
|
18402
18309
|
indexBuffer[index++] = indicesOffset + indices[i + indexOffset] - attributeOffset;
|
|
18403
18310
|
}
|
|
18404
18311
|
}
|
|
18405
|
-
|
|
18406
|
-
* Destroys the batch and its resources.
|
|
18407
|
-
* @param options - destruction options
|
|
18408
|
-
* @param options.shader - whether to destroy the associated shader
|
|
18409
|
-
*/
|
|
18410
|
-
destroy(options = {}) {
|
|
18312
|
+
destroy() {
|
|
18411
18313
|
if (this.batches === null)
|
|
18412
18314
|
return;
|
|
18413
|
-
for (let i = 0; i < this.
|
|
18315
|
+
for (let i = 0; i < this.batches.length; i++) {
|
|
18414
18316
|
returnBatchToPool(this.batches[i]);
|
|
18415
18317
|
}
|
|
18416
18318
|
this.batches = null;
|
|
18417
|
-
this.geometry.destroy(true);
|
|
18418
|
-
this.geometry = null;
|
|
18419
|
-
if (options.shader) {
|
|
18420
|
-
this.shader?.destroy();
|
|
18421
|
-
this.shader = null;
|
|
18422
|
-
}
|
|
18423
18319
|
for (let i = 0; i < this._elements.length; i++) {
|
|
18424
18320
|
if (this._elements[i])
|
|
18425
18321
|
this._elements[i]._batch = null;
|
|
@@ -18475,12 +18371,6 @@ class Buffer extends EventEmitter {
|
|
|
18475
18371
|
* emits when the buffer is destroyed. letting the renderer know that it needs to destroy the buffer on the GPU
|
|
18476
18372
|
* @event destroy
|
|
18477
18373
|
*/
|
|
18478
|
-
/** @internal */
|
|
18479
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
18480
|
-
/** @internal */
|
|
18481
|
-
this._gcLastUsed = -1;
|
|
18482
|
-
/** If set to true, the buffer will be garbage collected automatically when it is not used. */
|
|
18483
|
-
this.autoGarbageCollect = true;
|
|
18484
18374
|
/** a unique id for this uniform group used through the renderer */
|
|
18485
18375
|
this.uid = uid$1("buffer");
|
|
18486
18376
|
/**
|
|
@@ -18596,18 +18486,9 @@ class Buffer extends EventEmitter {
|
|
|
18596
18486
|
this._updateID++;
|
|
18597
18487
|
this.emit("update", this);
|
|
18598
18488
|
}
|
|
18599
|
-
/** Unloads the buffer from the GPU */
|
|
18600
|
-
unload() {
|
|
18601
|
-
this.emit("unload", this);
|
|
18602
|
-
for (const key in this._gpuData) {
|
|
18603
|
-
this._gpuData[key]?.destroy();
|
|
18604
|
-
}
|
|
18605
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
18606
|
-
}
|
|
18607
18489
|
/** Destroys the buffer */
|
|
18608
18490
|
destroy() {
|
|
18609
18491
|
this.destroyed = true;
|
|
18610
|
-
this.unload();
|
|
18611
18492
|
this.emit("destroy", this);
|
|
18612
18493
|
this.emit("change", this);
|
|
18613
18494
|
this._data = null;
|
|
@@ -18689,12 +18570,6 @@ class Geometry extends EventEmitter {
|
|
|
18689
18570
|
*/
|
|
18690
18571
|
constructor(options = {}) {
|
|
18691
18572
|
super();
|
|
18692
|
-
/** @internal */
|
|
18693
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
18694
|
-
/** If set to true, the resource will be garbage collected automatically when it is not used. */
|
|
18695
|
-
this.autoGarbageCollect = true;
|
|
18696
|
-
/** @internal */
|
|
18697
|
-
this._gcLastUsed = -1;
|
|
18698
18573
|
/** The unique id of the geometry. */
|
|
18699
18574
|
this.uid = uid$1("geometry");
|
|
18700
18575
|
/**
|
|
@@ -18790,14 +18665,6 @@ class Geometry extends EventEmitter {
|
|
|
18790
18665
|
this._boundsDirty = false;
|
|
18791
18666
|
return getGeometryBounds(this, "aPosition", this._bounds);
|
|
18792
18667
|
}
|
|
18793
|
-
/** Unloads the geometry from the GPU. */
|
|
18794
|
-
unload() {
|
|
18795
|
-
this.emit("unload", this);
|
|
18796
|
-
for (const key in this._gpuData) {
|
|
18797
|
-
this._gpuData[key]?.destroy();
|
|
18798
|
-
}
|
|
18799
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
18800
|
-
}
|
|
18801
18668
|
/**
|
|
18802
18669
|
* destroys the geometry.
|
|
18803
18670
|
* @param destroyBuffers - destroy the buffers associated with this geometry
|
|
@@ -18808,8 +18675,6 @@ class Geometry extends EventEmitter {
|
|
|
18808
18675
|
if (destroyBuffers) {
|
|
18809
18676
|
this.buffers.forEach((buffer) => buffer.destroy());
|
|
18810
18677
|
}
|
|
18811
|
-
this.unload();
|
|
18812
|
-
this.indexBuffer?.destroy();
|
|
18813
18678
|
this.attributes = null;
|
|
18814
18679
|
this.buffers = null;
|
|
18815
18680
|
this.indexBuffer = null;
|
|
@@ -19485,7 +19350,6 @@ class DefaultShader extends Shader {
|
|
|
19485
19350
|
batchSamplers: getBatchSamplersUniformGroup(maxTextures)
|
|
19486
19351
|
}
|
|
19487
19352
|
});
|
|
19488
|
-
this.maxTextures = maxTextures;
|
|
19489
19353
|
}
|
|
19490
19354
|
}
|
|
19491
19355
|
|
|
@@ -19583,21 +19447,6 @@ const _DefaultBatcher = class _DefaultBatcher extends Batcher {
|
|
|
19583
19447
|
uint32View[index + 22] = argb;
|
|
19584
19448
|
uint32View[index + 23] = textureIdAndRound;
|
|
19585
19449
|
}
|
|
19586
|
-
/**
|
|
19587
|
-
* Updates the maximum number of textures that can be used in the shader.
|
|
19588
|
-
* @param maxTextures - The maximum number of textures that can be used in the shader.
|
|
19589
|
-
* @internal
|
|
19590
|
-
*/
|
|
19591
|
-
_updateMaxTextures(maxTextures) {
|
|
19592
|
-
if (this.shader.maxTextures === maxTextures)
|
|
19593
|
-
return;
|
|
19594
|
-
defaultShader = new DefaultShader(maxTextures);
|
|
19595
|
-
this.shader = defaultShader;
|
|
19596
|
-
}
|
|
19597
|
-
destroy() {
|
|
19598
|
-
this.shader = null;
|
|
19599
|
-
super.destroy();
|
|
19600
|
-
}
|
|
19601
19450
|
};
|
|
19602
19451
|
/** @ignore */
|
|
19603
19452
|
_DefaultBatcher.extension = {
|
|
@@ -19608,51 +19457,6 @@ _DefaultBatcher.extension = {
|
|
|
19608
19457
|
};
|
|
19609
19458
|
let DefaultBatcher = _DefaultBatcher;
|
|
19610
19459
|
|
|
19611
|
-
class GCManagedHash {
|
|
19612
|
-
constructor(options) {
|
|
19613
|
-
// Exposed directly for GC system access
|
|
19614
|
-
this.items = /* @__PURE__ */ Object.create(null);
|
|
19615
|
-
const { renderer, type, onUnload, priority, name } = options;
|
|
19616
|
-
this._renderer = renderer;
|
|
19617
|
-
renderer.gc.addResourceHash(this, "items", type, priority ?? 0);
|
|
19618
|
-
this._onUnload = onUnload;
|
|
19619
|
-
this.name = name;
|
|
19620
|
-
}
|
|
19621
|
-
/**
|
|
19622
|
-
* Add an item to the hash. No-op if already added.
|
|
19623
|
-
* @param item
|
|
19624
|
-
* @returns true if the item was added, false if it was already in the hash
|
|
19625
|
-
*/
|
|
19626
|
-
add(item) {
|
|
19627
|
-
if (this.items[item.uid])
|
|
19628
|
-
return false;
|
|
19629
|
-
this.items[item.uid] = item;
|
|
19630
|
-
item.once("unload", this.remove, this);
|
|
19631
|
-
item._gcLastUsed = this._renderer.gc.now;
|
|
19632
|
-
return true;
|
|
19633
|
-
}
|
|
19634
|
-
remove(item, ...args) {
|
|
19635
|
-
if (!this.items[item.uid])
|
|
19636
|
-
return;
|
|
19637
|
-
const gpuData = item._gpuData[this._renderer.uid];
|
|
19638
|
-
if (!gpuData)
|
|
19639
|
-
return;
|
|
19640
|
-
this._onUnload?.(item, ...args);
|
|
19641
|
-
gpuData.destroy();
|
|
19642
|
-
item._gpuData[this._renderer.uid] = null;
|
|
19643
|
-
this.items[item.uid] = null;
|
|
19644
|
-
}
|
|
19645
|
-
removeAll(...args) {
|
|
19646
|
-
Object.values(this.items).forEach((item) => item && this.remove(item, ...args));
|
|
19647
|
-
}
|
|
19648
|
-
destroy(...args) {
|
|
19649
|
-
this.removeAll(...args);
|
|
19650
|
-
this.items = /* @__PURE__ */ Object.create(null);
|
|
19651
|
-
this._renderer = null;
|
|
19652
|
-
this._onUnload = null;
|
|
19653
|
-
}
|
|
19654
|
-
}
|
|
19655
|
-
|
|
19656
19460
|
function buildUvs(vertices, verticesStride, verticesOffset, uvs, uvsOffset, uvsStride, size, matrix = null) {
|
|
19657
19461
|
let index = 0;
|
|
19658
19462
|
verticesOffset *= verticesStride;
|
|
@@ -20620,36 +20424,15 @@ class GpuGraphicsContext {
|
|
|
20620
20424
|
indices: []
|
|
20621
20425
|
};
|
|
20622
20426
|
}
|
|
20623
|
-
reset() {
|
|
20624
|
-
if (this.batches) {
|
|
20625
|
-
this.batches.forEach((batch) => {
|
|
20626
|
-
BigPool.return(batch);
|
|
20627
|
-
});
|
|
20628
|
-
}
|
|
20629
|
-
if (this.graphicsData) {
|
|
20630
|
-
BigPool.return(this.graphicsData);
|
|
20631
|
-
}
|
|
20632
|
-
this.isBatchable = false;
|
|
20633
|
-
this.context = null;
|
|
20634
|
-
this.batches.length = 0;
|
|
20635
|
-
this.geometryData.indices.length = 0;
|
|
20636
|
-
this.geometryData.vertices.length = 0;
|
|
20637
|
-
this.geometryData.uvs.length = 0;
|
|
20638
|
-
this.graphicsData = null;
|
|
20639
|
-
}
|
|
20640
|
-
destroy() {
|
|
20641
|
-
this.reset();
|
|
20642
|
-
this.batches = null;
|
|
20643
|
-
this.geometryData = null;
|
|
20644
|
-
}
|
|
20645
20427
|
}
|
|
20646
20428
|
class GraphicsContextRenderData {
|
|
20647
20429
|
constructor() {
|
|
20648
20430
|
this.instructions = new InstructionSet();
|
|
20649
20431
|
}
|
|
20650
|
-
init(
|
|
20651
|
-
|
|
20652
|
-
|
|
20432
|
+
init(maxTextures) {
|
|
20433
|
+
this.batcher = new DefaultBatcher({
|
|
20434
|
+
maxTextures
|
|
20435
|
+
});
|
|
20653
20436
|
this.instructions.reset();
|
|
20654
20437
|
}
|
|
20655
20438
|
/**
|
|
@@ -20670,8 +20453,14 @@ class GraphicsContextRenderData {
|
|
|
20670
20453
|
}
|
|
20671
20454
|
const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
20672
20455
|
constructor(renderer) {
|
|
20456
|
+
// the root context batches, used to either make a batch or geometry
|
|
20457
|
+
// all graphics use this as a base
|
|
20458
|
+
this._gpuContextHash = {};
|
|
20459
|
+
// used for non-batchable graphics
|
|
20460
|
+
this._graphicsDataContextHash = /* @__PURE__ */ Object.create(null);
|
|
20673
20461
|
this._renderer = renderer;
|
|
20674
|
-
|
|
20462
|
+
renderer.renderableGC.addManagedHash(this, "_gpuContextHash");
|
|
20463
|
+
renderer.renderableGC.addManagedHash(this, "_graphicsDataContextHash");
|
|
20675
20464
|
}
|
|
20676
20465
|
/**
|
|
20677
20466
|
* Runner init called, update the default options
|
|
@@ -20686,7 +20475,7 @@ const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
|
20686
20475
|
* @internal
|
|
20687
20476
|
*/
|
|
20688
20477
|
getContextRenderData(context) {
|
|
20689
|
-
return
|
|
20478
|
+
return this._graphicsDataContextHash[context.uid] || this._initContextRenderData(context);
|
|
20690
20479
|
}
|
|
20691
20480
|
/**
|
|
20692
20481
|
* Updates the GPU context for a given GraphicsContext.
|
|
@@ -20696,11 +20485,12 @@ const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
|
20696
20485
|
* @internal
|
|
20697
20486
|
*/
|
|
20698
20487
|
updateGpuContext(context) {
|
|
20699
|
-
|
|
20700
|
-
|
|
20701
|
-
|
|
20702
|
-
|
|
20703
|
-
|
|
20488
|
+
let gpuContext = this._gpuContextHash[context.uid] || this._initContext(context);
|
|
20489
|
+
if (context.dirty) {
|
|
20490
|
+
if (gpuContext) {
|
|
20491
|
+
this._cleanGraphicsContextData(context);
|
|
20492
|
+
} else {
|
|
20493
|
+
gpuContext = this._initContext(context);
|
|
20704
20494
|
}
|
|
20705
20495
|
buildContextBatches(context, gpuContext);
|
|
20706
20496
|
const batchMode = context.batchMode;
|
|
@@ -20723,15 +20513,13 @@ const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
|
20723
20513
|
* @internal
|
|
20724
20514
|
*/
|
|
20725
20515
|
getGpuContext(context) {
|
|
20726
|
-
return
|
|
20516
|
+
return this._gpuContextHash[context.uid] || this._initContext(context);
|
|
20727
20517
|
}
|
|
20728
20518
|
_initContextRenderData(context) {
|
|
20729
20519
|
const graphicsData = BigPool.get(GraphicsContextRenderData, {
|
|
20730
20520
|
maxTextures: this._renderer.limits.maxBatchableTextures
|
|
20731
20521
|
});
|
|
20732
|
-
const
|
|
20733
|
-
const { batches, geometryData } = gpuContext;
|
|
20734
|
-
gpuContext.graphicsData = graphicsData;
|
|
20522
|
+
const { batches, geometryData } = this._gpuContextHash[context.uid];
|
|
20735
20523
|
const vertexSize = geometryData.vertices.length;
|
|
20736
20524
|
const indexSize = geometryData.indices.length;
|
|
20737
20525
|
for (let i = 0; i < batches.length; i++) {
|
|
@@ -20758,18 +20546,41 @@ const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
|
20758
20546
|
this._renderer.limits.maxBatchableTextures
|
|
20759
20547
|
);
|
|
20760
20548
|
}
|
|
20549
|
+
this._graphicsDataContextHash[context.uid] = graphicsData;
|
|
20761
20550
|
return graphicsData;
|
|
20762
20551
|
}
|
|
20763
20552
|
_initContext(context) {
|
|
20764
20553
|
const gpuContext = new GpuGraphicsContext();
|
|
20765
20554
|
gpuContext.context = context;
|
|
20766
|
-
|
|
20767
|
-
this.
|
|
20768
|
-
return
|
|
20555
|
+
this._gpuContextHash[context.uid] = gpuContext;
|
|
20556
|
+
context.on("destroy", this.onGraphicsContextDestroy, this);
|
|
20557
|
+
return this._gpuContextHash[context.uid];
|
|
20558
|
+
}
|
|
20559
|
+
onGraphicsContextDestroy(context) {
|
|
20560
|
+
this._cleanGraphicsContextData(context);
|
|
20561
|
+
context.off("destroy", this.onGraphicsContextDestroy, this);
|
|
20562
|
+
this._gpuContextHash[context.uid] = null;
|
|
20563
|
+
}
|
|
20564
|
+
_cleanGraphicsContextData(context) {
|
|
20565
|
+
const gpuContext = this._gpuContextHash[context.uid];
|
|
20566
|
+
if (!gpuContext.isBatchable) {
|
|
20567
|
+
if (this._graphicsDataContextHash[context.uid]) {
|
|
20568
|
+
BigPool.return(this.getContextRenderData(context));
|
|
20569
|
+
this._graphicsDataContextHash[context.uid] = null;
|
|
20570
|
+
}
|
|
20571
|
+
}
|
|
20572
|
+
if (gpuContext.batches) {
|
|
20573
|
+
gpuContext.batches.forEach((batch) => {
|
|
20574
|
+
BigPool.return(batch);
|
|
20575
|
+
});
|
|
20576
|
+
}
|
|
20769
20577
|
}
|
|
20770
20578
|
destroy() {
|
|
20771
|
-
this.
|
|
20772
|
-
|
|
20579
|
+
for (const i in this._gpuContextHash) {
|
|
20580
|
+
if (this._gpuContextHash[i]) {
|
|
20581
|
+
this.onGraphicsContextDestroy(this._gpuContextHash[i].context);
|
|
20582
|
+
}
|
|
20583
|
+
}
|
|
20773
20584
|
}
|
|
20774
20585
|
};
|
|
20775
20586
|
/** @ignore */
|
|
@@ -22592,7 +22403,7 @@ function renderChildren(svg, session, fillStyle, strokeStyle) {
|
|
|
22592
22403
|
break;
|
|
22593
22404
|
case "polygon":
|
|
22594
22405
|
pointsString = svg.getAttribute("points");
|
|
22595
|
-
points = pointsString.match(
|
|
22406
|
+
points = pointsString.match(/\d+/g).map((n) => parseInt(n, 10));
|
|
22596
22407
|
session.context.poly(points, true);
|
|
22597
22408
|
if (fillStyle)
|
|
22598
22409
|
session.context.fill(fillStyle);
|
|
@@ -22601,7 +22412,7 @@ function renderChildren(svg, session, fillStyle, strokeStyle) {
|
|
|
22601
22412
|
break;
|
|
22602
22413
|
case "polyline":
|
|
22603
22414
|
pointsString = svg.getAttribute("points");
|
|
22604
|
-
points = pointsString.match(
|
|
22415
|
+
points = pointsString.match(/\d+/g).map((n) => parseInt(n, 10));
|
|
22605
22416
|
session.context.poly(points, false);
|
|
22606
22417
|
if (strokeStyle)
|
|
22607
22418
|
session.context.stroke(strokeStyle);
|
|
@@ -22711,12 +22522,6 @@ const tempMatrix$2 = new Matrix();
|
|
|
22711
22522
|
const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
22712
22523
|
constructor() {
|
|
22713
22524
|
super(...arguments);
|
|
22714
|
-
/** @internal */
|
|
22715
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
22716
|
-
/** If set to true, the resource will be garbage collected automatically when it is not used. */
|
|
22717
|
-
this.autoGarbageCollect = true;
|
|
22718
|
-
/** @internal */
|
|
22719
|
-
this._gcLastUsed = -1;
|
|
22720
22525
|
/**
|
|
22721
22526
|
* unique id for this graphics context
|
|
22722
22527
|
* @internal
|
|
@@ -22731,8 +22536,6 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
22731
22536
|
this.batchMode = "auto";
|
|
22732
22537
|
/** @internal */
|
|
22733
22538
|
this.instructions = [];
|
|
22734
|
-
/** Whether the graphics context has been destroyed. */
|
|
22735
|
-
this.destroyed = false;
|
|
22736
22539
|
this._activePath = new GraphicsPath();
|
|
22737
22540
|
this._transform = new Matrix();
|
|
22738
22541
|
this._fillStyle = { ..._GraphicsContext.defaultFillStyle };
|
|
@@ -22829,7 +22632,7 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
22829
22632
|
fill(style, alpha) {
|
|
22830
22633
|
let path;
|
|
22831
22634
|
const lastInstruction = this.instructions[this.instructions.length - 1];
|
|
22832
|
-
if (this._tick === 0 && lastInstruction
|
|
22635
|
+
if (this._tick === 0 && lastInstruction && lastInstruction.action === "stroke") {
|
|
22833
22636
|
path = lastInstruction.data.path;
|
|
22834
22637
|
} else {
|
|
22835
22638
|
path = this._activePath.clone();
|
|
@@ -22867,7 +22670,7 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
22867
22670
|
stroke(style) {
|
|
22868
22671
|
let path;
|
|
22869
22672
|
const lastInstruction = this.instructions[this.instructions.length - 1];
|
|
22870
|
-
if (this._tick === 0 && lastInstruction
|
|
22673
|
+
if (this._tick === 0 && lastInstruction && lastInstruction.action === "fill") {
|
|
22871
22674
|
path = lastInstruction.data.path;
|
|
22872
22675
|
} else {
|
|
22873
22676
|
path = this._activePath.clone();
|
|
@@ -23449,14 +23252,6 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
23449
23252
|
}
|
|
23450
23253
|
return hasHit;
|
|
23451
23254
|
}
|
|
23452
|
-
/** Unloads the GPU data from the graphics context. */
|
|
23453
|
-
unload() {
|
|
23454
|
-
this.emit("unload", this);
|
|
23455
|
-
for (const key in this._gpuData) {
|
|
23456
|
-
this._gpuData[key]?.destroy();
|
|
23457
|
-
}
|
|
23458
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
23459
|
-
}
|
|
23460
23255
|
/**
|
|
23461
23256
|
* Destroys the GraphicsData object.
|
|
23462
23257
|
* @param options - Options parameter. A boolean will act as if all options
|
|
@@ -23467,12 +23262,8 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
23467
23262
|
* context.destroy({ texture: true, textureSource: true });
|
|
23468
23263
|
*/
|
|
23469
23264
|
destroy(options = false) {
|
|
23470
|
-
if (this.destroyed)
|
|
23471
|
-
return;
|
|
23472
|
-
this.destroyed = true;
|
|
23473
23265
|
this._stateStack.length = 0;
|
|
23474
23266
|
this._transform = null;
|
|
23475
|
-
this.unload();
|
|
23476
23267
|
this.emit("destroy", this);
|
|
23477
23268
|
this.removeAllListeners();
|
|
23478
23269
|
const destroyTexture = typeof options === "boolean" ? options : options?.texture;
|
|
@@ -23571,8 +23362,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23571
23362
|
return this._align;
|
|
23572
23363
|
}
|
|
23573
23364
|
set align(value) {
|
|
23574
|
-
if (this._align === value)
|
|
23575
|
-
return;
|
|
23576
23365
|
this._align = value;
|
|
23577
23366
|
this.update();
|
|
23578
23367
|
}
|
|
@@ -23581,8 +23370,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23581
23370
|
return this._breakWords;
|
|
23582
23371
|
}
|
|
23583
23372
|
set breakWords(value) {
|
|
23584
|
-
if (this._breakWords === value)
|
|
23585
|
-
return;
|
|
23586
23373
|
this._breakWords = value;
|
|
23587
23374
|
this.update();
|
|
23588
23375
|
}
|
|
@@ -23591,8 +23378,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23591
23378
|
return this._dropShadow;
|
|
23592
23379
|
}
|
|
23593
23380
|
set dropShadow(value) {
|
|
23594
|
-
if (this._dropShadow === value)
|
|
23595
|
-
return;
|
|
23596
23381
|
if (value !== null && typeof value === "object") {
|
|
23597
23382
|
this._dropShadow = this._createProxy({ ..._TextStyle.defaultDropShadow, ...value });
|
|
23598
23383
|
} else {
|
|
@@ -23605,8 +23390,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23605
23390
|
return this._fontFamily;
|
|
23606
23391
|
}
|
|
23607
23392
|
set fontFamily(value) {
|
|
23608
|
-
if (this._fontFamily === value)
|
|
23609
|
-
return;
|
|
23610
23393
|
this._fontFamily = value;
|
|
23611
23394
|
this.update();
|
|
23612
23395
|
}
|
|
@@ -23615,8 +23398,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23615
23398
|
return this._fontSize;
|
|
23616
23399
|
}
|
|
23617
23400
|
set fontSize(value) {
|
|
23618
|
-
if (this._fontSize === value)
|
|
23619
|
-
return;
|
|
23620
23401
|
if (typeof value === "string") {
|
|
23621
23402
|
this._fontSize = parseInt(value, 10);
|
|
23622
23403
|
} else {
|
|
@@ -23632,8 +23413,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23632
23413
|
return this._fontStyle;
|
|
23633
23414
|
}
|
|
23634
23415
|
set fontStyle(value) {
|
|
23635
|
-
if (this._fontStyle === value)
|
|
23636
|
-
return;
|
|
23637
23416
|
this._fontStyle = value.toLowerCase();
|
|
23638
23417
|
this.update();
|
|
23639
23418
|
}
|
|
@@ -23645,8 +23424,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23645
23424
|
return this._fontVariant;
|
|
23646
23425
|
}
|
|
23647
23426
|
set fontVariant(value) {
|
|
23648
|
-
if (this._fontVariant === value)
|
|
23649
|
-
return;
|
|
23650
23427
|
this._fontVariant = value;
|
|
23651
23428
|
this.update();
|
|
23652
23429
|
}
|
|
@@ -23658,8 +23435,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23658
23435
|
return this._fontWeight;
|
|
23659
23436
|
}
|
|
23660
23437
|
set fontWeight(value) {
|
|
23661
|
-
if (this._fontWeight === value)
|
|
23662
|
-
return;
|
|
23663
23438
|
this._fontWeight = value;
|
|
23664
23439
|
this.update();
|
|
23665
23440
|
}
|
|
@@ -23668,8 +23443,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23668
23443
|
return this._leading;
|
|
23669
23444
|
}
|
|
23670
23445
|
set leading(value) {
|
|
23671
|
-
if (this._leading === value)
|
|
23672
|
-
return;
|
|
23673
23446
|
this._leading = value;
|
|
23674
23447
|
this.update();
|
|
23675
23448
|
}
|
|
@@ -23678,8 +23451,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23678
23451
|
return this._letterSpacing;
|
|
23679
23452
|
}
|
|
23680
23453
|
set letterSpacing(value) {
|
|
23681
|
-
if (this._letterSpacing === value)
|
|
23682
|
-
return;
|
|
23683
23454
|
this._letterSpacing = value;
|
|
23684
23455
|
this.update();
|
|
23685
23456
|
}
|
|
@@ -23688,8 +23459,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23688
23459
|
return this._lineHeight;
|
|
23689
23460
|
}
|
|
23690
23461
|
set lineHeight(value) {
|
|
23691
|
-
if (this._lineHeight === value)
|
|
23692
|
-
return;
|
|
23693
23462
|
this._lineHeight = value;
|
|
23694
23463
|
this.update();
|
|
23695
23464
|
}
|
|
@@ -23702,8 +23471,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23702
23471
|
return this._padding;
|
|
23703
23472
|
}
|
|
23704
23473
|
set padding(value) {
|
|
23705
|
-
if (this._padding === value)
|
|
23706
|
-
return;
|
|
23707
23474
|
this._padding = value;
|
|
23708
23475
|
this.update();
|
|
23709
23476
|
}
|
|
@@ -23717,8 +23484,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23717
23484
|
return this._filters;
|
|
23718
23485
|
}
|
|
23719
23486
|
set filters(value) {
|
|
23720
|
-
if (this._filters === value)
|
|
23721
|
-
return;
|
|
23722
23487
|
this._filters = Object.freeze(value);
|
|
23723
23488
|
this.update();
|
|
23724
23489
|
}
|
|
@@ -23732,8 +23497,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23732
23497
|
return this._trim;
|
|
23733
23498
|
}
|
|
23734
23499
|
set trim(value) {
|
|
23735
|
-
if (this._trim === value)
|
|
23736
|
-
return;
|
|
23737
23500
|
this._trim = value;
|
|
23738
23501
|
this.update();
|
|
23739
23502
|
}
|
|
@@ -23745,8 +23508,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23745
23508
|
return this._textBaseline;
|
|
23746
23509
|
}
|
|
23747
23510
|
set textBaseline(value) {
|
|
23748
|
-
if (this._textBaseline === value)
|
|
23749
|
-
return;
|
|
23750
23511
|
this._textBaseline = value;
|
|
23751
23512
|
this.update();
|
|
23752
23513
|
}
|
|
@@ -23765,8 +23526,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23765
23526
|
return this._whiteSpace;
|
|
23766
23527
|
}
|
|
23767
23528
|
set whiteSpace(value) {
|
|
23768
|
-
if (this._whiteSpace === value)
|
|
23769
|
-
return;
|
|
23770
23529
|
this._whiteSpace = value;
|
|
23771
23530
|
this.update();
|
|
23772
23531
|
}
|
|
@@ -23775,8 +23534,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23775
23534
|
return this._wordWrap;
|
|
23776
23535
|
}
|
|
23777
23536
|
set wordWrap(value) {
|
|
23778
|
-
if (this._wordWrap === value)
|
|
23779
|
-
return;
|
|
23780
23537
|
this._wordWrap = value;
|
|
23781
23538
|
this.update();
|
|
23782
23539
|
}
|
|
@@ -23785,8 +23542,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23785
23542
|
return this._wordWrapWidth;
|
|
23786
23543
|
}
|
|
23787
23544
|
set wordWrapWidth(value) {
|
|
23788
|
-
if (this._wordWrapWidth === value)
|
|
23789
|
-
return;
|
|
23790
23545
|
this._wordWrapWidth = value;
|
|
23791
23546
|
this.update();
|
|
23792
23547
|
}
|
|
@@ -23952,8 +23707,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23952
23707
|
_createProxy(value, cb) {
|
|
23953
23708
|
return new Proxy(value, {
|
|
23954
23709
|
set: (target, property, newValue) => {
|
|
23955
|
-
if (target[property] === newValue)
|
|
23956
|
-
return true;
|
|
23957
23710
|
target[property] = newValue;
|
|
23958
23711
|
cb?.(property, newValue);
|
|
23959
23712
|
this.update();
|
|
@@ -25134,7 +24887,7 @@ const bitmapFontXMLParser = {
|
|
|
25134
24887
|
|
|
25135
24888
|
const bitmapFontXMLStringParser = {
|
|
25136
24889
|
test(data) {
|
|
25137
|
-
if (typeof data === "string" && data.
|
|
24890
|
+
if (typeof data === "string" && data.includes("<font>")) {
|
|
25138
24891
|
return bitmapFontXMLParser.test(DOMAdapter.get().parseXML(data));
|
|
25139
24892
|
}
|
|
25140
24893
|
return false;
|
|
@@ -25433,26 +25186,8 @@ const detectWebp = {
|
|
|
25433
25186
|
remove: async (formats) => formats.filter((f) => f !== "webp")
|
|
25434
25187
|
};
|
|
25435
25188
|
|
|
25436
|
-
|
|
25189
|
+
class Loader {
|
|
25437
25190
|
constructor() {
|
|
25438
|
-
/**
|
|
25439
|
-
* Options for loading assets with the loader.
|
|
25440
|
-
* These options will be used as defaults for all load calls made with this loader instance.
|
|
25441
|
-
* They can be overridden by passing options directly to the load method.
|
|
25442
|
-
* @example
|
|
25443
|
-
* ```ts
|
|
25444
|
-
* // Create a loader with custom default options
|
|
25445
|
-
* const loader = new Loader();
|
|
25446
|
-
* loader.loadOptions = {
|
|
25447
|
-
* strategy: 'skip', // Default strategy to 'skip'
|
|
25448
|
-
* retryCount: 5, // Default retry count to 5
|
|
25449
|
-
* retryDelay: 500, // Default retry delay to 500ms
|
|
25450
|
-
* };
|
|
25451
|
-
*
|
|
25452
|
-
* // This load call will use the loader's default options
|
|
25453
|
-
* await loader.load('image1.png');
|
|
25454
|
-
*/
|
|
25455
|
-
this.loadOptions = { ..._Loader.defaultOptions };
|
|
25456
25191
|
this._parsers = [];
|
|
25457
25192
|
this._parsersValidated = false;
|
|
25458
25193
|
/**
|
|
@@ -25529,12 +25264,10 @@ const _Loader = class _Loader {
|
|
|
25529
25264
|
})();
|
|
25530
25265
|
return result;
|
|
25531
25266
|
}
|
|
25532
|
-
async load(assetsToLoadIn,
|
|
25267
|
+
async load(assetsToLoadIn, onProgress) {
|
|
25533
25268
|
if (!this._parsersValidated) {
|
|
25534
25269
|
this._validateParsers();
|
|
25535
25270
|
}
|
|
25536
|
-
const options = typeof onProgressOrOptions === "function" ? { ..._Loader.defaultOptions, ...this.loadOptions, onProgress: onProgressOrOptions } : { ..._Loader.defaultOptions, ...this.loadOptions, ...onProgressOrOptions || {} };
|
|
25537
|
-
const { onProgress, onError, strategy, retryCount, retryDelay } = options;
|
|
25538
25271
|
let count = 0;
|
|
25539
25272
|
const assets = {};
|
|
25540
25273
|
const singleAsset = isSingleItem(assetsToLoadIn);
|
|
@@ -25543,15 +25276,24 @@ const _Loader = class _Loader {
|
|
|
25543
25276
|
src: item,
|
|
25544
25277
|
data: {}
|
|
25545
25278
|
}));
|
|
25546
|
-
const total = assetsToLoad.
|
|
25279
|
+
const total = assetsToLoad.length;
|
|
25547
25280
|
const promises = assetsToLoad.map(async (asset) => {
|
|
25548
25281
|
const url = path.toAbsolute(asset.src);
|
|
25549
|
-
if (assets[asset.src])
|
|
25550
|
-
|
|
25551
|
-
|
|
25552
|
-
|
|
25553
|
-
|
|
25554
|
-
|
|
25282
|
+
if (!assets[asset.src]) {
|
|
25283
|
+
try {
|
|
25284
|
+
if (!this.promiseCache[url]) {
|
|
25285
|
+
this.promiseCache[url] = this._getLoadPromiseAndParser(url, asset);
|
|
25286
|
+
}
|
|
25287
|
+
assets[asset.src] = await this.promiseCache[url].promise;
|
|
25288
|
+
if (onProgress)
|
|
25289
|
+
onProgress(++count / total);
|
|
25290
|
+
} catch (e) {
|
|
25291
|
+
delete this.promiseCache[url];
|
|
25292
|
+
delete assets[asset.src];
|
|
25293
|
+
throw new Error(`[Loader.load] Failed to load ${url}.
|
|
25294
|
+
${e}`);
|
|
25295
|
+
}
|
|
25296
|
+
}
|
|
25555
25297
|
});
|
|
25556
25298
|
await Promise.all(promises);
|
|
25557
25299
|
return singleAsset ? assets[assetsToLoad[0].src] : assets;
|
|
@@ -25599,65 +25341,7 @@ const _Loader = class _Loader {
|
|
|
25599
25341
|
return hash;
|
|
25600
25342
|
}, {});
|
|
25601
25343
|
}
|
|
25602
|
-
|
|
25603
|
-
let attempt = 0;
|
|
25604
|
-
const { onError, strategy, retryCount, retryDelay } = options;
|
|
25605
|
-
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
25606
|
-
while (true) {
|
|
25607
|
-
try {
|
|
25608
|
-
if (!this.promiseCache[url]) {
|
|
25609
|
-
this.promiseCache[url] = this._getLoadPromiseAndParser(url, asset);
|
|
25610
|
-
}
|
|
25611
|
-
assets[asset.src] = await this.promiseCache[url].promise;
|
|
25612
|
-
return;
|
|
25613
|
-
} catch (e) {
|
|
25614
|
-
delete this.promiseCache[url];
|
|
25615
|
-
delete assets[asset.src];
|
|
25616
|
-
attempt++;
|
|
25617
|
-
const isLast = strategy !== "retry" || attempt > retryCount;
|
|
25618
|
-
if (strategy === "retry" && !isLast) {
|
|
25619
|
-
if (onError)
|
|
25620
|
-
onError(e, asset);
|
|
25621
|
-
await wait(retryDelay);
|
|
25622
|
-
continue;
|
|
25623
|
-
}
|
|
25624
|
-
if (strategy === "skip") {
|
|
25625
|
-
if (onError)
|
|
25626
|
-
onError(e, asset);
|
|
25627
|
-
return;
|
|
25628
|
-
}
|
|
25629
|
-
if (onError)
|
|
25630
|
-
onError(e, asset);
|
|
25631
|
-
const error = new Error(`[Loader.load] Failed to load ${url}.
|
|
25632
|
-
${e}`);
|
|
25633
|
-
if (e instanceof Error && e.stack) {
|
|
25634
|
-
error.stack = e.stack;
|
|
25635
|
-
}
|
|
25636
|
-
throw error;
|
|
25637
|
-
}
|
|
25638
|
-
}
|
|
25639
|
-
}
|
|
25640
|
-
};
|
|
25641
|
-
/**
|
|
25642
|
-
* Default options for loading assets
|
|
25643
|
-
* @example
|
|
25644
|
-
* ```ts
|
|
25645
|
-
* // Change default load options globally
|
|
25646
|
-
* Loader.defaultOptions = {
|
|
25647
|
-
* strategy: 'skip', // Change default strategy to 'skip'
|
|
25648
|
-
* retryCount: 5, // Change default retry count to 5
|
|
25649
|
-
* retryDelay: 500, // Change default retry delay to 500ms
|
|
25650
|
-
* };
|
|
25651
|
-
* ```
|
|
25652
|
-
*/
|
|
25653
|
-
_Loader.defaultOptions = {
|
|
25654
|
-
onProgress: void 0,
|
|
25655
|
-
onError: void 0,
|
|
25656
|
-
strategy: "throw",
|
|
25657
|
-
retryCount: 3,
|
|
25658
|
-
retryDelay: 250
|
|
25659
|
-
};
|
|
25660
|
-
let Loader = _Loader;
|
|
25344
|
+
}
|
|
25661
25345
|
|
|
25662
25346
|
function checkDataUrl(url, mimes) {
|
|
25663
25347
|
if (Array.isArray(mimes)) {
|
|
@@ -26056,15 +25740,12 @@ class WorkerManagerClass {
|
|
|
26056
25740
|
* @param data - Result data from the worker containing uuid, data, and optional error
|
|
26057
25741
|
*/
|
|
26058
25742
|
_complete(data) {
|
|
26059
|
-
if (!this._resolveHash[data.uuid]) {
|
|
26060
|
-
return;
|
|
26061
|
-
}
|
|
26062
25743
|
if (data.error !== void 0) {
|
|
26063
25744
|
this._resolveHash[data.uuid].reject(data.error);
|
|
26064
25745
|
} else {
|
|
26065
25746
|
this._resolveHash[data.uuid].resolve(data.data);
|
|
26066
25747
|
}
|
|
26067
|
-
|
|
25748
|
+
this._resolveHash[data.uuid] = null;
|
|
26068
25749
|
}
|
|
26069
25750
|
/**
|
|
26070
25751
|
* Executes a task using the worker pool system.
|
|
@@ -26125,7 +25806,7 @@ class WorkerManagerClass {
|
|
|
26125
25806
|
this._workerPool.forEach((worker) => worker.terminate());
|
|
26126
25807
|
this._workerPool.length = 0;
|
|
26127
25808
|
Object.values(this._resolveHash).forEach(({ reject }) => {
|
|
26128
|
-
reject?.(new Error("WorkerManager
|
|
25809
|
+
reject?.(new Error("WorkerManager destroyed"));
|
|
26129
25810
|
});
|
|
26130
25811
|
this._resolveHash = {};
|
|
26131
25812
|
this._queue.length = 0;
|
|
@@ -26464,12 +26145,6 @@ class AssetsClass {
|
|
|
26464
26145
|
if (options.preferences) {
|
|
26465
26146
|
this.setPreferences(options.preferences);
|
|
26466
26147
|
}
|
|
26467
|
-
if (options.loadOptions) {
|
|
26468
|
-
this.loader.loadOptions = {
|
|
26469
|
-
...this.loader.loadOptions,
|
|
26470
|
-
...options.loadOptions
|
|
26471
|
-
};
|
|
26472
|
-
}
|
|
26473
26148
|
}
|
|
26474
26149
|
/**
|
|
26475
26150
|
* Registers assets with the Assets resolver. This method maps keys (aliases) to asset sources,
|
|
@@ -26689,22 +26364,17 @@ class AssetsClass {
|
|
|
26689
26364
|
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
26690
26365
|
const out = {};
|
|
26691
26366
|
const keys = Object.keys(resolveResults);
|
|
26367
|
+
let count = 0;
|
|
26692
26368
|
let total = 0;
|
|
26693
|
-
const counts = [];
|
|
26694
26369
|
const _onProgress = () => {
|
|
26695
|
-
onProgress?.(
|
|
26370
|
+
onProgress?.(++count / total);
|
|
26696
26371
|
};
|
|
26697
|
-
const promises = keys.map((bundleId
|
|
26372
|
+
const promises = keys.map((bundleId) => {
|
|
26698
26373
|
const resolveResult = resolveResults[bundleId];
|
|
26699
26374
|
const values = Object.values(resolveResult);
|
|
26700
26375
|
const totalAssetsToLoad = [...new Set(values.flat())];
|
|
26701
|
-
|
|
26702
|
-
|
|
26703
|
-
total += progressSize;
|
|
26704
|
-
return this._mapLoadToResolve(resolveResult, (e) => {
|
|
26705
|
-
counts[i] = e * progressSize;
|
|
26706
|
-
_onProgress();
|
|
26707
|
-
}).then((resolveResult2) => {
|
|
26376
|
+
total += totalAssetsToLoad.length;
|
|
26377
|
+
return this._mapLoadToResolve(resolveResult, _onProgress).then((resolveResult2) => {
|
|
26708
26378
|
out[bundleId] = resolveResult2;
|
|
26709
26379
|
});
|
|
26710
26380
|
});
|
|
@@ -26856,12 +26526,12 @@ class AssetsClass {
|
|
|
26856
26526
|
/**
|
|
26857
26527
|
* helper function to map resolved assets back to loaded assets
|
|
26858
26528
|
* @param resolveResults - the resolve results from the resolver
|
|
26859
|
-
* @param
|
|
26529
|
+
* @param onProgress - the progress callback
|
|
26860
26530
|
*/
|
|
26861
|
-
async _mapLoadToResolve(resolveResults,
|
|
26531
|
+
async _mapLoadToResolve(resolveResults, onProgress) {
|
|
26862
26532
|
const resolveArray = [...new Set(Object.values(resolveResults))];
|
|
26863
26533
|
this._backgroundLoader.active = false;
|
|
26864
|
-
const loadedAssets = await this.loader.load(resolveArray,
|
|
26534
|
+
const loadedAssets = await this.loader.load(resolveArray, onProgress);
|
|
26865
26535
|
this._backgroundLoader.active = true;
|
|
26866
26536
|
const out = {};
|
|
26867
26537
|
resolveArray.forEach((resolveResult) => {
|
|
@@ -29146,31 +28816,6 @@ const FederatedContainer = {
|
|
|
29146
28816
|
}
|
|
29147
28817
|
};
|
|
29148
28818
|
|
|
29149
|
-
var vertex$2 = "in vec2 aPosition;\nout vec2 vTextureCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n";
|
|
29150
|
-
|
|
29151
|
-
var fragment$2 = "in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n";
|
|
29152
|
-
|
|
29153
|
-
var source$1 = "struct GlobalFilterUniforms {\n uInputSize: vec4<f32>,\n uInputPixel: vec4<f32>,\n uInputClamp: vec4<f32>,\n uOutputFrame: vec4<f32>,\n uGlobalFrame: vec4<f32>,\n uOutputTexture: vec4<f32>,\n};\n\n@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler: sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>\n};\n\nfn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition: vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, uv);\n}\n";
|
|
29154
|
-
|
|
29155
|
-
class PassthroughFilter extends Filter {
|
|
29156
|
-
constructor() {
|
|
29157
|
-
const gpuProgram = GpuProgram.from({
|
|
29158
|
-
vertex: { source: source$1, entryPoint: "mainVertex" },
|
|
29159
|
-
fragment: { source: source$1, entryPoint: "mainFragment" },
|
|
29160
|
-
name: "passthrough-filter"
|
|
29161
|
-
});
|
|
29162
|
-
const glProgram = GlProgram.from({
|
|
29163
|
-
vertex: vertex$2,
|
|
29164
|
-
fragment: fragment$2,
|
|
29165
|
-
name: "passthrough-filter"
|
|
29166
|
-
});
|
|
29167
|
-
super({
|
|
29168
|
-
gpuProgram,
|
|
29169
|
-
glProgram
|
|
29170
|
-
});
|
|
29171
|
-
}
|
|
29172
|
-
}
|
|
29173
|
-
|
|
29174
28819
|
class FilterPipe {
|
|
29175
28820
|
constructor(renderer) {
|
|
29176
28821
|
this._renderer = renderer;
|
|
@@ -29295,10 +28940,6 @@ class FilterData {
|
|
|
29295
28940
|
* @type {{ x: number, y: number, width: number, height: number }}
|
|
29296
28941
|
*/
|
|
29297
28942
|
this.globalFrame = { x: 0, y: 0, width: 0, height: 0 };
|
|
29298
|
-
/** The first enabled filter index in the current filter list. */
|
|
29299
|
-
this.firstEnabledIndex = -1;
|
|
29300
|
-
/** The last enabled filter index in the current filter list. */
|
|
29301
|
-
this.lastEnabledIndex = -1;
|
|
29302
28943
|
}
|
|
29303
28944
|
}
|
|
29304
28945
|
class FilterSystem {
|
|
@@ -29339,7 +28980,7 @@ class FilterSystem {
|
|
|
29339
28980
|
const colorTextureSource = renderer.renderTarget.renderTarget.colorTexture.source;
|
|
29340
28981
|
const rootResolution = colorTextureSource.resolution;
|
|
29341
28982
|
const rootAntialias = colorTextureSource.antialias;
|
|
29342
|
-
if (filters.
|
|
28983
|
+
if (filters.length === 0) {
|
|
29343
28984
|
filterData.skip = true;
|
|
29344
28985
|
return;
|
|
29345
28986
|
}
|
|
@@ -29402,7 +29043,7 @@ class FilterSystem {
|
|
|
29402
29043
|
const colorTextureSource = texture.source;
|
|
29403
29044
|
const rootResolution = colorTextureSource.resolution;
|
|
29404
29045
|
const rootAntialias = colorTextureSource.antialias;
|
|
29405
|
-
if (filters.
|
|
29046
|
+
if (filters.length === 0) {
|
|
29406
29047
|
filterData.skip = true;
|
|
29407
29048
|
return texture;
|
|
29408
29049
|
}
|
|
@@ -29509,8 +29150,7 @@ class FilterSystem {
|
|
|
29509
29150
|
offsetY = offset.y;
|
|
29510
29151
|
}
|
|
29511
29152
|
this._updateFilterUniforms(input, output, filterData, offsetX, offsetY, resolution, isFinalTarget, clear);
|
|
29512
|
-
|
|
29513
|
-
this._setupBindGroupsAndRender(filterToApply, input, renderer);
|
|
29153
|
+
this._setupBindGroupsAndRender(filter, input, renderer);
|
|
29514
29154
|
}
|
|
29515
29155
|
/**
|
|
29516
29156
|
* Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_.
|
|
@@ -29545,12 +29185,6 @@ class FilterSystem {
|
|
|
29545
29185
|
return mappedMatrix;
|
|
29546
29186
|
}
|
|
29547
29187
|
destroy() {
|
|
29548
|
-
this._passthroughFilter?.destroy(true);
|
|
29549
|
-
this._passthroughFilter = null;
|
|
29550
|
-
}
|
|
29551
|
-
_getPassthroughFilter() {
|
|
29552
|
-
this._passthroughFilter ?? (this._passthroughFilter = new PassthroughFilter());
|
|
29553
|
-
return this._passthroughFilter;
|
|
29554
29188
|
}
|
|
29555
29189
|
/**
|
|
29556
29190
|
* Sets up the bind groups and renders the filter.
|
|
@@ -29736,12 +29370,10 @@ class FilterSystem {
|
|
|
29736
29370
|
const inputTexture = filterData.inputTexture;
|
|
29737
29371
|
const bounds = filterData.bounds;
|
|
29738
29372
|
const filters = filterData.filters;
|
|
29739
|
-
const firstEnabled = filterData.firstEnabledIndex;
|
|
29740
|
-
const lastEnabled = filterData.lastEnabledIndex;
|
|
29741
29373
|
this._globalFilterBindGroup.setResource(inputTexture.source.style, 2);
|
|
29742
29374
|
this._globalFilterBindGroup.setResource(filterData.backTexture.source, 3);
|
|
29743
|
-
if (
|
|
29744
|
-
filters[
|
|
29375
|
+
if (filters.length === 1) {
|
|
29376
|
+
filters[0].apply(this, inputTexture, filterData.outputRenderSurface, clear);
|
|
29745
29377
|
} else {
|
|
29746
29378
|
let flip = filterData.inputTexture;
|
|
29747
29379
|
const tempTexture = TexturePool.getOptimalTexture(
|
|
@@ -29751,16 +29383,15 @@ class FilterSystem {
|
|
|
29751
29383
|
false
|
|
29752
29384
|
);
|
|
29753
29385
|
let flop = tempTexture;
|
|
29754
|
-
|
|
29386
|
+
let i = 0;
|
|
29387
|
+
for (i = 0; i < filters.length - 1; ++i) {
|
|
29755
29388
|
const filter = filters[i];
|
|
29756
|
-
if (!filter.enabled)
|
|
29757
|
-
continue;
|
|
29758
29389
|
filter.apply(this, flip, flop, true);
|
|
29759
29390
|
const t = flip;
|
|
29760
29391
|
flip = flop;
|
|
29761
29392
|
flop = t;
|
|
29762
29393
|
}
|
|
29763
|
-
filters[
|
|
29394
|
+
filters[i].apply(this, flip, filterData.outputRenderSurface, clear);
|
|
29764
29395
|
TexturePool.returnTexture(tempTexture);
|
|
29765
29396
|
}
|
|
29766
29397
|
}
|
|
@@ -29774,15 +29405,8 @@ class FilterSystem {
|
|
|
29774
29405
|
let blendRequired = false;
|
|
29775
29406
|
let enabled = false;
|
|
29776
29407
|
let clipToViewport = true;
|
|
29777
|
-
let firstEnabledIndex = -1;
|
|
29778
|
-
let lastEnabledIndex = -1;
|
|
29779
29408
|
for (let i = 0; i < filters.length; i++) {
|
|
29780
29409
|
const filter = filters[i];
|
|
29781
|
-
if (!filter.enabled)
|
|
29782
|
-
continue;
|
|
29783
|
-
if (firstEnabledIndex === -1)
|
|
29784
|
-
firstEnabledIndex = i;
|
|
29785
|
-
lastEnabledIndex = i;
|
|
29786
29410
|
resolution = Math.min(resolution, filter.resolution === "inherit" ? rootResolution : filter.resolution);
|
|
29787
29411
|
padding += filter.padding;
|
|
29788
29412
|
if (filter.antialias === "off") {
|
|
@@ -29803,7 +29427,7 @@ class FilterSystem {
|
|
|
29803
29427
|
enabled = false;
|
|
29804
29428
|
break;
|
|
29805
29429
|
}
|
|
29806
|
-
enabled =
|
|
29430
|
+
enabled = filter.enabled || enabled;
|
|
29807
29431
|
blendRequired || (blendRequired = filter.blendRequired);
|
|
29808
29432
|
}
|
|
29809
29433
|
if (!enabled) {
|
|
@@ -29821,8 +29445,6 @@ class FilterSystem {
|
|
|
29821
29445
|
filterData.antialias = antialias;
|
|
29822
29446
|
filterData.resolution = resolution;
|
|
29823
29447
|
filterData.blendRequired = blendRequired;
|
|
29824
|
-
filterData.firstEnabledIndex = firstEnabledIndex;
|
|
29825
|
-
filterData.lastEnabledIndex = lastEnabledIndex;
|
|
29826
29448
|
}
|
|
29827
29449
|
_popFilterData() {
|
|
29828
29450
|
this._filterStackIndex--;
|
|
@@ -29936,11 +29558,11 @@ class Graphics extends ViewContainer {
|
|
|
29936
29558
|
/** @internal */
|
|
29937
29559
|
this.renderPipeId = "graphics";
|
|
29938
29560
|
if (!context) {
|
|
29939
|
-
this.
|
|
29940
|
-
this.context.autoGarbageCollect = this.autoGarbageCollect;
|
|
29561
|
+
this._context = this._ownedContext = new GraphicsContext();
|
|
29941
29562
|
} else {
|
|
29942
|
-
this.
|
|
29563
|
+
this._context = context;
|
|
29943
29564
|
}
|
|
29565
|
+
this._context.on("update", this.onViewUpdate, this);
|
|
29944
29566
|
this.didViewUpdate = true;
|
|
29945
29567
|
this.allowChildren = false;
|
|
29946
29568
|
this.roundPixels = roundPixels ?? false;
|
|
@@ -29948,13 +29570,9 @@ class Graphics extends ViewContainer {
|
|
|
29948
29570
|
set context(context) {
|
|
29949
29571
|
if (context === this._context)
|
|
29950
29572
|
return;
|
|
29951
|
-
|
|
29952
|
-
this._context.off("update", this.onViewUpdate, this);
|
|
29953
|
-
this._context.off("unload", this.unload, this);
|
|
29954
|
-
}
|
|
29573
|
+
this._context.off("update", this.onViewUpdate, this);
|
|
29955
29574
|
this._context = context;
|
|
29956
29575
|
this._context.on("update", this.onViewUpdate, this);
|
|
29957
|
-
this._context.on("unload", this.unload, this);
|
|
29958
29576
|
this.onViewUpdate();
|
|
29959
29577
|
}
|
|
29960
29578
|
/**
|
|
@@ -30068,14 +29686,6 @@ class Graphics extends ViewContainer {
|
|
|
30068
29686
|
this._context = null;
|
|
30069
29687
|
super.destroy(options);
|
|
30070
29688
|
}
|
|
30071
|
-
/**
|
|
30072
|
-
* @param now - The current time in milliseconds.
|
|
30073
|
-
* @internal
|
|
30074
|
-
*/
|
|
30075
|
-
_onTouch(now) {
|
|
30076
|
-
this._gcLastUsed = now;
|
|
30077
|
-
this._context._gcLastUsed = now;
|
|
30078
|
-
}
|
|
30079
29689
|
_callContextMethod(method, args) {
|
|
30080
29690
|
this.context[method](...args);
|
|
30081
29691
|
return this;
|
|
@@ -32192,7 +31802,7 @@ class GpuBatchAdaptor {
|
|
|
32192
31802
|
tempState,
|
|
32193
31803
|
batch.topology
|
|
32194
31804
|
);
|
|
32195
|
-
batch.bindGroup._touch(renderer.
|
|
31805
|
+
batch.bindGroup._touch(renderer.textureGC.count);
|
|
32196
31806
|
encoder.setPipeline(pipeline);
|
|
32197
31807
|
encoder.renderPassEncoder.setBindGroup(1, gpuBindGroup);
|
|
32198
31808
|
encoder.renderPassEncoder.drawIndexed(batch.size, 1, batch.start);
|
|
@@ -32798,14 +32408,6 @@ class GlBuffer {
|
|
|
32798
32408
|
this.byteLength = -1;
|
|
32799
32409
|
this.type = type;
|
|
32800
32410
|
}
|
|
32801
|
-
destroy() {
|
|
32802
|
-
this.buffer = null;
|
|
32803
|
-
this.updateID = -1;
|
|
32804
|
-
this.byteLength = -1;
|
|
32805
|
-
this.type = -1;
|
|
32806
|
-
this._lastBindBaseLocation = -1;
|
|
32807
|
-
this._lastBindCallId = -1;
|
|
32808
|
-
}
|
|
32809
32411
|
}
|
|
32810
32412
|
|
|
32811
32413
|
class GlBufferSystem {
|
|
@@ -32813,35 +32415,30 @@ class GlBufferSystem {
|
|
|
32813
32415
|
* @param {Renderer} renderer - The renderer this System works for.
|
|
32814
32416
|
*/
|
|
32815
32417
|
constructor(renderer) {
|
|
32418
|
+
this._gpuBuffers = /* @__PURE__ */ Object.create(null);
|
|
32816
32419
|
/** Cache keeping track of the base bound buffer bases */
|
|
32817
32420
|
this._boundBufferBases = /* @__PURE__ */ Object.create(null);
|
|
32818
32421
|
this._minBaseLocation = 0;
|
|
32819
32422
|
this._nextBindBaseIndex = this._minBaseLocation;
|
|
32820
32423
|
this._bindCallId = 0;
|
|
32821
32424
|
this._renderer = renderer;
|
|
32822
|
-
this.
|
|
32823
|
-
renderer,
|
|
32824
|
-
type: "resource",
|
|
32825
|
-
onUnload: this.onBufferUnload.bind(this),
|
|
32826
|
-
name: "glBuffer"
|
|
32827
|
-
});
|
|
32425
|
+
this._renderer.renderableGC.addManagedHash(this, "_gpuBuffers");
|
|
32828
32426
|
}
|
|
32829
32427
|
/** @ignore */
|
|
32830
32428
|
destroy() {
|
|
32831
|
-
this._managedBuffers.destroy();
|
|
32832
32429
|
this._renderer = null;
|
|
32833
32430
|
this._gl = null;
|
|
32834
|
-
this.
|
|
32431
|
+
this._gpuBuffers = null;
|
|
32432
|
+
this._boundBufferBases = null;
|
|
32835
32433
|
}
|
|
32836
32434
|
/** Sets up the renderer context and necessary buffers. */
|
|
32837
32435
|
contextChange() {
|
|
32838
32436
|
this._gl = this._renderer.gl;
|
|
32839
|
-
this.
|
|
32437
|
+
this._gpuBuffers = /* @__PURE__ */ Object.create(null);
|
|
32840
32438
|
this._maxBindings = this._renderer.limits.maxUniformBindings;
|
|
32841
32439
|
}
|
|
32842
32440
|
getGlBuffer(buffer) {
|
|
32843
|
-
buffer.
|
|
32844
|
-
return buffer._gpuData[this._renderer.uid] || this.createGLBuffer(buffer);
|
|
32441
|
+
return this._gpuBuffers[buffer.uid] || this.createGLBuffer(buffer);
|
|
32845
32442
|
}
|
|
32846
32443
|
/**
|
|
32847
32444
|
* This binds specified buffer. On first run, it will create the webGL buffers for the context too
|
|
@@ -32956,19 +32553,26 @@ class GlBufferSystem {
|
|
|
32956
32553
|
}
|
|
32957
32554
|
return glBuffer;
|
|
32958
32555
|
}
|
|
32556
|
+
/** dispose all WebGL resources of all managed buffers */
|
|
32557
|
+
destroyAll() {
|
|
32558
|
+
const gl = this._gl;
|
|
32559
|
+
for (const id in this._gpuBuffers) {
|
|
32560
|
+
gl.deleteBuffer(this._gpuBuffers[id].buffer);
|
|
32561
|
+
}
|
|
32562
|
+
this._gpuBuffers = /* @__PURE__ */ Object.create(null);
|
|
32563
|
+
}
|
|
32959
32564
|
/**
|
|
32960
|
-
*
|
|
32961
|
-
* @param
|
|
32565
|
+
* Disposes buffer
|
|
32566
|
+
* @param {Buffer} buffer - buffer with data
|
|
32567
|
+
* @param {boolean} [contextLost=false] - If context was lost, we suppress deleteVertexArray
|
|
32962
32568
|
*/
|
|
32963
|
-
|
|
32964
|
-
this.
|
|
32965
|
-
|
|
32966
|
-
|
|
32967
|
-
|
|
32968
|
-
|
|
32969
|
-
|
|
32970
|
-
if (!contextLost)
|
|
32971
|
-
this._gl.deleteBuffer(glBuffer.buffer);
|
|
32569
|
+
onBufferDestroy(buffer, contextLost) {
|
|
32570
|
+
const glBuffer = this._gpuBuffers[buffer.uid];
|
|
32571
|
+
const gl = this._gl;
|
|
32572
|
+
if (!contextLost) {
|
|
32573
|
+
gl.deleteBuffer(glBuffer.buffer);
|
|
32574
|
+
}
|
|
32575
|
+
this._gpuBuffers[buffer.uid] = null;
|
|
32972
32576
|
}
|
|
32973
32577
|
/**
|
|
32974
32578
|
* creates and attaches a GLBuffer object tied to the current context.
|
|
@@ -32984,8 +32588,8 @@ class GlBufferSystem {
|
|
|
32984
32588
|
type = BUFFER_TYPE.UNIFORM_BUFFER;
|
|
32985
32589
|
}
|
|
32986
32590
|
const glBuffer = new GlBuffer(gl.createBuffer(), type);
|
|
32987
|
-
|
|
32988
|
-
this.
|
|
32591
|
+
this._gpuBuffers[buffer.uid] = glBuffer;
|
|
32592
|
+
buffer.on("destroy", this.onBufferDestroy, this);
|
|
32989
32593
|
return glBuffer;
|
|
32990
32594
|
}
|
|
32991
32595
|
resetState() {
|
|
@@ -33397,28 +33001,16 @@ const topologyToGlMap = {
|
|
|
33397
33001
|
"triangle-list": 4,
|
|
33398
33002
|
"triangle-strip": 5
|
|
33399
33003
|
};
|
|
33400
|
-
class GlGeometryGpuData {
|
|
33401
|
-
constructor() {
|
|
33402
|
-
this.vaoCache = /* @__PURE__ */ Object.create(null);
|
|
33403
|
-
}
|
|
33404
|
-
destroy() {
|
|
33405
|
-
this.vaoCache = /* @__PURE__ */ Object.create(null);
|
|
33406
|
-
}
|
|
33407
|
-
}
|
|
33408
33004
|
class GlGeometrySystem {
|
|
33409
33005
|
/** @param renderer - The renderer this System works for. */
|
|
33410
33006
|
constructor(renderer) {
|
|
33007
|
+
this._geometryVaoHash = /* @__PURE__ */ Object.create(null);
|
|
33411
33008
|
this._renderer = renderer;
|
|
33412
33009
|
this._activeGeometry = null;
|
|
33413
33010
|
this._activeVao = null;
|
|
33414
33011
|
this.hasVao = true;
|
|
33415
33012
|
this.hasInstance = true;
|
|
33416
|
-
this.
|
|
33417
|
-
renderer,
|
|
33418
|
-
type: "resource",
|
|
33419
|
-
onUnload: this.onGeometryUnload.bind(this),
|
|
33420
|
-
name: "glGeometry"
|
|
33421
|
-
});
|
|
33013
|
+
this._renderer.renderableGC.addManagedHash(this, "_geometryVaoHash");
|
|
33422
33014
|
}
|
|
33423
33015
|
/** Sets up the renderer context and necessary buffers. */
|
|
33424
33016
|
contextChange() {
|
|
@@ -33426,7 +33018,6 @@ class GlGeometrySystem {
|
|
|
33426
33018
|
if (!this._renderer.context.supports.vertexArrayObject) {
|
|
33427
33019
|
throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");
|
|
33428
33020
|
}
|
|
33429
|
-
this.destroyAll(true);
|
|
33430
33021
|
const nativeVaoExtension = this._renderer.context.extensions.vertexArrayObject;
|
|
33431
33022
|
if (nativeVaoExtension) {
|
|
33432
33023
|
gl.createVertexArray = () => nativeVaoExtension.createVertexArrayOES();
|
|
@@ -33445,6 +33036,7 @@ class GlGeometrySystem {
|
|
|
33445
33036
|
}
|
|
33446
33037
|
this._activeGeometry = null;
|
|
33447
33038
|
this._activeVao = null;
|
|
33039
|
+
this._geometryVaoHash = /* @__PURE__ */ Object.create(null);
|
|
33448
33040
|
}
|
|
33449
33041
|
/**
|
|
33450
33042
|
* Binds geometry so that is can be drawn. Creating a Vao if required
|
|
@@ -33473,7 +33065,6 @@ class GlGeometrySystem {
|
|
|
33473
33065
|
const buffer = geometry.buffers[i];
|
|
33474
33066
|
bufferSystem.updateBuffer(buffer);
|
|
33475
33067
|
}
|
|
33476
|
-
geometry._gcLastUsed = this._renderer.gc.now;
|
|
33477
33068
|
}
|
|
33478
33069
|
/**
|
|
33479
33070
|
* Check compatibility between a geometry and a program
|
|
@@ -33507,7 +33098,7 @@ class GlGeometrySystem {
|
|
|
33507
33098
|
return strings.join("-");
|
|
33508
33099
|
}
|
|
33509
33100
|
getVao(geometry, program) {
|
|
33510
|
-
return
|
|
33101
|
+
return this._geometryVaoHash[geometry.uid]?.[program._key] || this.initGeometryVao(geometry, program);
|
|
33511
33102
|
}
|
|
33512
33103
|
/**
|
|
33513
33104
|
* Creates or gets Vao with the same structure as the geometry and stores it on the geometry.
|
|
@@ -33523,10 +33114,11 @@ class GlGeometrySystem {
|
|
|
33523
33114
|
this._renderer.shader._getProgramData(program);
|
|
33524
33115
|
this.checkCompatibility(geometry, program);
|
|
33525
33116
|
const signature = this.getSignature(geometry, program);
|
|
33526
|
-
|
|
33527
|
-
|
|
33528
|
-
|
|
33529
|
-
|
|
33117
|
+
if (!this._geometryVaoHash[geometry.uid]) {
|
|
33118
|
+
this._geometryVaoHash[geometry.uid] = /* @__PURE__ */ Object.create(null);
|
|
33119
|
+
geometry.on("destroy", this.onGeometryDestroy, this);
|
|
33120
|
+
}
|
|
33121
|
+
const vaoObjectHash = this._geometryVaoHash[geometry.uid];
|
|
33530
33122
|
let vao = vaoObjectHash[signature];
|
|
33531
33123
|
if (vao) {
|
|
33532
33124
|
vaoObjectHash[program._key] = vao;
|
|
@@ -33546,18 +33138,24 @@ class GlGeometrySystem {
|
|
|
33546
33138
|
gl.bindVertexArray(null);
|
|
33547
33139
|
return vao;
|
|
33548
33140
|
}
|
|
33549
|
-
|
|
33550
|
-
|
|
33551
|
-
|
|
33552
|
-
|
|
33553
|
-
|
|
33554
|
-
|
|
33555
|
-
|
|
33556
|
-
|
|
33557
|
-
|
|
33141
|
+
/**
|
|
33142
|
+
* Disposes geometry.
|
|
33143
|
+
* @param geometry - Geometry with buffers. Only VAO will be disposed
|
|
33144
|
+
* @param [contextLost=false] - If context was lost, we suppress deleteVertexArray
|
|
33145
|
+
*/
|
|
33146
|
+
onGeometryDestroy(geometry, contextLost) {
|
|
33147
|
+
const vaoObjectHash = this._geometryVaoHash[geometry.uid];
|
|
33148
|
+
const gl = this.gl;
|
|
33149
|
+
if (vaoObjectHash) {
|
|
33150
|
+
if (contextLost) {
|
|
33151
|
+
for (const i in vaoObjectHash) {
|
|
33152
|
+
if (this._activeVao !== vaoObjectHash[i]) {
|
|
33153
|
+
this.unbind();
|
|
33154
|
+
}
|
|
33155
|
+
gl.deleteVertexArray(vaoObjectHash[i]);
|
|
33558
33156
|
}
|
|
33559
|
-
this.gl.deleteVertexArray(vaoCache[i]);
|
|
33560
33157
|
}
|
|
33158
|
+
this._geometryVaoHash[geometry.uid] = null;
|
|
33561
33159
|
}
|
|
33562
33160
|
}
|
|
33563
33161
|
/**
|
|
@@ -33565,7 +33163,19 @@ class GlGeometrySystem {
|
|
|
33565
33163
|
* @param [contextLost=false] - If context was lost, we suppress `gl.delete` calls
|
|
33566
33164
|
*/
|
|
33567
33165
|
destroyAll(contextLost = false) {
|
|
33568
|
-
this.
|
|
33166
|
+
const gl = this.gl;
|
|
33167
|
+
for (const i in this._geometryVaoHash) {
|
|
33168
|
+
if (contextLost) {
|
|
33169
|
+
for (const j in this._geometryVaoHash[i]) {
|
|
33170
|
+
const vaoObjectHash = this._geometryVaoHash[i];
|
|
33171
|
+
if (this._activeVao !== vaoObjectHash) {
|
|
33172
|
+
this.unbind();
|
|
33173
|
+
}
|
|
33174
|
+
gl.deleteVertexArray(vaoObjectHash[j]);
|
|
33175
|
+
}
|
|
33176
|
+
}
|
|
33177
|
+
this._geometryVaoHash[i] = null;
|
|
33178
|
+
}
|
|
33569
33179
|
}
|
|
33570
33180
|
/**
|
|
33571
33181
|
* Activate vertex array object.
|
|
@@ -33642,12 +33252,12 @@ class GlGeometrySystem {
|
|
|
33642
33252
|
if (geometry.indexBuffer) {
|
|
33643
33253
|
const byteSize = geometry.indexBuffer.data.BYTES_PER_ELEMENT;
|
|
33644
33254
|
const glType = byteSize === 2 ? gl.UNSIGNED_SHORT : gl.UNSIGNED_INT;
|
|
33645
|
-
if (instanceCount
|
|
33255
|
+
if (instanceCount > 1) {
|
|
33646
33256
|
gl.drawElementsInstanced(glTopology, size || geometry.indexBuffer.data.length, glType, (start || 0) * byteSize, instanceCount);
|
|
33647
33257
|
} else {
|
|
33648
33258
|
gl.drawElements(glTopology, size || geometry.indexBuffer.data.length, glType, (start || 0) * byteSize);
|
|
33649
33259
|
}
|
|
33650
|
-
} else if (instanceCount
|
|
33260
|
+
} else if (instanceCount > 1) {
|
|
33651
33261
|
gl.drawArraysInstanced(glTopology, start || 0, size || geometry.getSize(), instanceCount);
|
|
33652
33262
|
} else {
|
|
33653
33263
|
gl.drawArrays(glTopology, start || 0, size || geometry.getSize());
|
|
@@ -33661,11 +33271,11 @@ class GlGeometrySystem {
|
|
|
33661
33271
|
this._activeGeometry = null;
|
|
33662
33272
|
}
|
|
33663
33273
|
destroy() {
|
|
33664
|
-
this._managedGeometries.destroy();
|
|
33665
33274
|
this._renderer = null;
|
|
33666
33275
|
this.gl = null;
|
|
33667
33276
|
this._activeVao = null;
|
|
33668
33277
|
this._activeGeometry = null;
|
|
33278
|
+
this._geometryVaoHash = null;
|
|
33669
33279
|
}
|
|
33670
33280
|
}
|
|
33671
33281
|
/** @ignore */
|
|
@@ -34466,11 +34076,6 @@ class GlRenderTargetAdaptor {
|
|
|
34466
34076
|
contextChange() {
|
|
34467
34077
|
this._clearColorCache = [0, 0, 0, 0];
|
|
34468
34078
|
this._viewPortCache = new Rectangle();
|
|
34469
|
-
const gl = this._renderer.gl;
|
|
34470
|
-
this._drawBuffersCache = [];
|
|
34471
|
-
for (let i = 1; i <= 16; i++) {
|
|
34472
|
-
this._drawBuffersCache[i] = Array.from({ length: i }, (_, j) => gl.COLOR_ATTACHMENT0 + j);
|
|
34473
|
-
}
|
|
34474
34079
|
}
|
|
34475
34080
|
copyToTexture(sourceRenderSurfaceTexture, destinationTexture, originSrc, size, originDest) {
|
|
34476
34081
|
const renderTargetSystem = this._renderTargetSystem;
|
|
@@ -34498,16 +34103,13 @@ class GlRenderTargetAdaptor {
|
|
|
34498
34103
|
const gpuRenderTarget = renderTargetSystem.getGpuRenderTarget(renderTarget);
|
|
34499
34104
|
let viewPortY = viewport.y;
|
|
34500
34105
|
if (renderTarget.isRoot) {
|
|
34501
|
-
viewPortY = source.pixelHeight - viewport.height
|
|
34106
|
+
viewPortY = source.pixelHeight - viewport.height;
|
|
34502
34107
|
}
|
|
34503
34108
|
renderTarget.colorTextures.forEach((texture) => {
|
|
34504
34109
|
this._renderer.texture.unbind(texture);
|
|
34505
34110
|
});
|
|
34506
34111
|
const gl = this._renderer.gl;
|
|
34507
34112
|
gl.bindFramebuffer(gl.FRAMEBUFFER, gpuRenderTarget.framebuffer);
|
|
34508
|
-
if (renderTarget.colorTextures.length > 1) {
|
|
34509
|
-
this._setDrawBuffers(renderTarget, gl);
|
|
34510
|
-
}
|
|
34511
34113
|
const viewPortCache = this._viewPortCache;
|
|
34512
34114
|
if (viewPortCache.x !== viewport.x || viewPortCache.y !== viewPortY || viewPortCache.width !== viewport.width || viewPortCache.height !== viewport.height) {
|
|
34513
34115
|
viewPortCache.x = viewport.x;
|
|
@@ -34621,8 +34223,7 @@ class GlRenderTargetAdaptor {
|
|
|
34621
34223
|
gl.bindFramebuffer(gl.FRAMEBUFFER, resolveTargetFramebuffer);
|
|
34622
34224
|
glRenderTarget.width = renderTarget.colorTexture.source.pixelWidth;
|
|
34623
34225
|
glRenderTarget.height = renderTarget.colorTexture.source.pixelHeight;
|
|
34624
|
-
|
|
34625
|
-
colorTextures.forEach((colorTexture, i) => {
|
|
34226
|
+
renderTarget.colorTextures.forEach((colorTexture, i) => {
|
|
34626
34227
|
const source = colorTexture.source;
|
|
34627
34228
|
if (source.antialias) {
|
|
34628
34229
|
if (renderer.context.supports.msaa) {
|
|
@@ -34756,20 +34357,6 @@ class GlRenderTargetAdaptor {
|
|
|
34756
34357
|
);
|
|
34757
34358
|
}
|
|
34758
34359
|
}
|
|
34759
|
-
_setDrawBuffers(renderTarget, gl) {
|
|
34760
|
-
const count = renderTarget.colorTextures.length;
|
|
34761
|
-
const bufferArray = this._drawBuffersCache[count];
|
|
34762
|
-
if (this._renderer.context.webGLVersion === 1) {
|
|
34763
|
-
const ext = this._renderer.context.extensions.drawBuffers;
|
|
34764
|
-
if (!ext) {
|
|
34765
|
-
warn("[RenderTexture] This WebGL1 context does not support rendering to multiple targets");
|
|
34766
|
-
} else {
|
|
34767
|
-
ext.drawBuffersWEBGL(bufferArray);
|
|
34768
|
-
}
|
|
34769
|
-
} else {
|
|
34770
|
-
gl.drawBuffers(bufferArray);
|
|
34771
|
-
}
|
|
34772
|
-
}
|
|
34773
34360
|
}
|
|
34774
34361
|
|
|
34775
34362
|
function calculateProjection(pm, x, y, width, height, flipY) {
|
|
@@ -35314,7 +34901,6 @@ class BufferResource extends EventEmitter {
|
|
|
35314
34901
|
}
|
|
35315
34902
|
this.emit("change", this);
|
|
35316
34903
|
this.buffer = null;
|
|
35317
|
-
this.removeAllListeners();
|
|
35318
34904
|
}
|
|
35319
34905
|
}
|
|
35320
34906
|
|
|
@@ -35729,6 +35315,7 @@ class GlShaderSystem {
|
|
|
35729
35315
|
this._programDataHash = /* @__PURE__ */ Object.create(null);
|
|
35730
35316
|
this._shaderSyncFunctions = /* @__PURE__ */ Object.create(null);
|
|
35731
35317
|
this._renderer = renderer;
|
|
35318
|
+
this._renderer.renderableGC.addManagedHash(this, "_programDataHash");
|
|
35732
35319
|
}
|
|
35733
35320
|
contextChange(gl) {
|
|
35734
35321
|
this._gl = gl;
|
|
@@ -35815,7 +35402,9 @@ class GlShaderSystem {
|
|
|
35815
35402
|
}
|
|
35816
35403
|
destroy() {
|
|
35817
35404
|
for (const key of Object.keys(this._programDataHash)) {
|
|
35818
|
-
this._programDataHash[key]
|
|
35405
|
+
const programData = this._programDataHash[key];
|
|
35406
|
+
programData.destroy();
|
|
35407
|
+
this._programDataHash[key] = null;
|
|
35819
35408
|
}
|
|
35820
35409
|
this._programDataHash = null;
|
|
35821
35410
|
this._shaderSyncFunctions = null;
|
|
@@ -36359,8 +35948,6 @@ class GlTexture {
|
|
|
36359
35948
|
this.format = GL_FORMATS.RGBA;
|
|
36360
35949
|
this.samplerType = 0;
|
|
36361
35950
|
}
|
|
36362
|
-
destroy() {
|
|
36363
|
-
}
|
|
36364
35951
|
}
|
|
36365
35952
|
|
|
36366
35953
|
const glUploadBufferImageResource = {
|
|
@@ -36900,6 +36487,8 @@ function mapFormatToGlType(gl) {
|
|
|
36900
36487
|
const BYTES_PER_PIXEL = 4;
|
|
36901
36488
|
class GlTextureSystem {
|
|
36902
36489
|
constructor(renderer) {
|
|
36490
|
+
this.managedTextures = [];
|
|
36491
|
+
this._glTextures = /* @__PURE__ */ Object.create(null);
|
|
36903
36492
|
this._glSamplers = /* @__PURE__ */ Object.create(null);
|
|
36904
36493
|
this._boundTextures = [];
|
|
36905
36494
|
this._activeTextureLocation = -1;
|
|
@@ -36914,18 +36503,8 @@ class GlTextureSystem {
|
|
|
36914
36503
|
// TODO - separate samplers will be a cool thing to add, but not right now!
|
|
36915
36504
|
this._useSeparateSamplers = false;
|
|
36916
36505
|
this._renderer = renderer;
|
|
36917
|
-
this.
|
|
36918
|
-
|
|
36919
|
-
type: "resource",
|
|
36920
|
-
onUnload: this.onSourceUnload.bind(this),
|
|
36921
|
-
name: "glTexture"
|
|
36922
|
-
});
|
|
36923
|
-
}
|
|
36924
|
-
/**
|
|
36925
|
-
* @deprecated since 8.15.0
|
|
36926
|
-
*/
|
|
36927
|
-
get managedTextures() {
|
|
36928
|
-
return Object.values(this._managedTextures.items);
|
|
36506
|
+
this._renderer.renderableGC.addManagedHash(this, "_glTextures");
|
|
36507
|
+
this._renderer.renderableGC.addManagedHash(this, "_glSamplers");
|
|
36929
36508
|
}
|
|
36930
36509
|
contextChange(gl) {
|
|
36931
36510
|
this._gl = gl;
|
|
@@ -36934,7 +36513,7 @@ class GlTextureSystem {
|
|
|
36934
36513
|
this._mapFormatToType = mapFormatToGlType(gl);
|
|
36935
36514
|
this._mapFormatToFormat = mapFormatToGlFormat(gl);
|
|
36936
36515
|
}
|
|
36937
|
-
this.
|
|
36516
|
+
this._glTextures = /* @__PURE__ */ Object.create(null);
|
|
36938
36517
|
this._glSamplers = /* @__PURE__ */ Object.create(null);
|
|
36939
36518
|
this._boundSamplers = /* @__PURE__ */ Object.create(null);
|
|
36940
36519
|
this._premultiplyAlpha = false;
|
|
@@ -36966,7 +36545,7 @@ class GlTextureSystem {
|
|
|
36966
36545
|
}
|
|
36967
36546
|
bindSource(source, location = 0) {
|
|
36968
36547
|
const gl = this._gl;
|
|
36969
|
-
source.
|
|
36548
|
+
source._touched = this._renderer.textureGC.count;
|
|
36970
36549
|
if (this._boundTextures[location] !== source) {
|
|
36971
36550
|
this._boundTextures[location] = source;
|
|
36972
36551
|
this._activateLocation(location);
|
|
@@ -37017,13 +36596,15 @@ class GlTextureSystem {
|
|
|
37017
36596
|
const biggestDimension = Math.max(source.width, source.height);
|
|
37018
36597
|
source.mipLevelCount = Math.floor(Math.log2(biggestDimension)) + 1;
|
|
37019
36598
|
}
|
|
37020
|
-
|
|
37021
|
-
|
|
37022
|
-
if (added) {
|
|
36599
|
+
this._glTextures[source.uid] = glTexture;
|
|
36600
|
+
if (!this.managedTextures.includes(source)) {
|
|
37023
36601
|
source.on("update", this.onSourceUpdate, this);
|
|
37024
36602
|
source.on("resize", this.onSourceUpdate, this);
|
|
37025
36603
|
source.on("styleChange", this.onStyleChange, this);
|
|
36604
|
+
source.on("destroy", this.onSourceDestroy, this);
|
|
36605
|
+
source.on("unload", this.onSourceUnload, this);
|
|
37026
36606
|
source.on("updateMipmaps", this.onUpdateMipmaps, this);
|
|
36607
|
+
this.managedTextures.push(source);
|
|
37027
36608
|
}
|
|
37028
36609
|
this.onSourceUpdate(source);
|
|
37029
36610
|
this.updateStyle(source, false);
|
|
@@ -37049,18 +36630,13 @@ class GlTextureSystem {
|
|
|
37049
36630
|
firstCreation
|
|
37050
36631
|
);
|
|
37051
36632
|
}
|
|
37052
|
-
onSourceUnload(source
|
|
37053
|
-
const glTexture =
|
|
36633
|
+
onSourceUnload(source) {
|
|
36634
|
+
const glTexture = this._glTextures[source.uid];
|
|
37054
36635
|
if (!glTexture)
|
|
37055
36636
|
return;
|
|
37056
|
-
|
|
37057
|
-
|
|
37058
|
-
|
|
37059
|
-
}
|
|
37060
|
-
source.off("update", this.onSourceUpdate, this);
|
|
37061
|
-
source.off("resize", this.onSourceUpdate, this);
|
|
37062
|
-
source.off("styleChange", this.onStyleChange, this);
|
|
37063
|
-
source.off("updateMipmaps", this.onUpdateMipmaps, this);
|
|
36637
|
+
this.unbind(source);
|
|
36638
|
+
this._glTextures[source.uid] = null;
|
|
36639
|
+
this._gl.deleteTexture(glTexture.texture);
|
|
37064
36640
|
}
|
|
37065
36641
|
onSourceUpdate(source) {
|
|
37066
36642
|
const gl = this._gl;
|
|
@@ -37075,17 +36651,7 @@ class GlTextureSystem {
|
|
|
37075
36651
|
if (this._uploads[source.uploadMethodId]) {
|
|
37076
36652
|
this._uploads[source.uploadMethodId].upload(source, glTexture, gl, this._renderer.context.webGLVersion);
|
|
37077
36653
|
} else {
|
|
37078
|
-
gl.texImage2D(
|
|
37079
|
-
gl.TEXTURE_2D,
|
|
37080
|
-
0,
|
|
37081
|
-
glTexture.internalFormat,
|
|
37082
|
-
source.pixelWidth,
|
|
37083
|
-
source.pixelHeight,
|
|
37084
|
-
0,
|
|
37085
|
-
glTexture.format,
|
|
37086
|
-
glTexture.type,
|
|
37087
|
-
null
|
|
37088
|
-
);
|
|
36654
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, source.pixelWidth, source.pixelHeight, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
37089
36655
|
}
|
|
37090
36656
|
if (source.autoGenerateMipmaps && source.mipLevelCount > 1) {
|
|
37091
36657
|
this.onUpdateMipmaps(source, false);
|
|
@@ -37097,6 +36663,16 @@ class GlTextureSystem {
|
|
|
37097
36663
|
const glTexture = this.getGlSource(source);
|
|
37098
36664
|
this._gl.generateMipmap(glTexture.target);
|
|
37099
36665
|
}
|
|
36666
|
+
onSourceDestroy(source) {
|
|
36667
|
+
source.off("destroy", this.onSourceDestroy, this);
|
|
36668
|
+
source.off("update", this.onSourceUpdate, this);
|
|
36669
|
+
source.off("resize", this.onSourceUpdate, this);
|
|
36670
|
+
source.off("unload", this.onSourceUnload, this);
|
|
36671
|
+
source.off("styleChange", this.onStyleChange, this);
|
|
36672
|
+
source.off("updateMipmaps", this.onUpdateMipmaps, this);
|
|
36673
|
+
this.managedTextures.splice(this.managedTextures.indexOf(source), 1);
|
|
36674
|
+
this.onSourceUnload(source);
|
|
36675
|
+
}
|
|
37100
36676
|
_initSampler(style) {
|
|
37101
36677
|
const gl = this._gl;
|
|
37102
36678
|
const glSampler = this._gl.createSampler();
|
|
@@ -37117,8 +36693,7 @@ class GlTextureSystem {
|
|
|
37117
36693
|
return this._glSamplers[sampler._resourceId] || this._initSampler(sampler);
|
|
37118
36694
|
}
|
|
37119
36695
|
getGlSource(source) {
|
|
37120
|
-
source.
|
|
37121
|
-
return source._gpuData[this._renderer.uid] || this._initSource(source);
|
|
36696
|
+
return this._glTextures[source.uid] || this._initSource(source);
|
|
37122
36697
|
}
|
|
37123
36698
|
generateCanvas(texture) {
|
|
37124
36699
|
const { pixels, width, height } = this.getPixels(texture);
|
|
@@ -37156,7 +36731,9 @@ class GlTextureSystem {
|
|
|
37156
36731
|
return { pixels: new Uint8ClampedArray(pixels.buffer), width, height };
|
|
37157
36732
|
}
|
|
37158
36733
|
destroy() {
|
|
37159
|
-
this.
|
|
36734
|
+
this.managedTextures.slice().forEach((source) => this.onSourceDestroy(source));
|
|
36735
|
+
this.managedTextures = null;
|
|
36736
|
+
this._glTextures = null;
|
|
37160
36737
|
this._glSamplers = null;
|
|
37161
36738
|
this._boundTextures = null;
|
|
37162
36739
|
this._boundSamplers = null;
|
|
@@ -37360,7 +36937,6 @@ class BatchableSprite {
|
|
|
37360
36937
|
this.bounds = null;
|
|
37361
36938
|
}
|
|
37362
36939
|
destroy() {
|
|
37363
|
-
this.reset();
|
|
37364
36940
|
}
|
|
37365
36941
|
}
|
|
37366
36942
|
|
|
@@ -37573,9 +37149,9 @@ function updateColorBlendVisibility(container, parent, updateFlags) {
|
|
|
37573
37149
|
}
|
|
37574
37150
|
|
|
37575
37151
|
function validateRenderables(renderGroup, renderPipes) {
|
|
37576
|
-
const { list } = renderGroup.childrenRenderablesToUpdate;
|
|
37152
|
+
const { list, index } = renderGroup.childrenRenderablesToUpdate;
|
|
37577
37153
|
let rebuildRequired = false;
|
|
37578
|
-
for (let i = 0; i <
|
|
37154
|
+
for (let i = 0; i < index; i++) {
|
|
37579
37155
|
const container = list[i];
|
|
37580
37156
|
const renderable = container;
|
|
37581
37157
|
const pipe = renderPipes[renderable.renderPipeId];
|
|
@@ -38387,19 +37963,9 @@ _ExtractSystem.defaultImageOptions = {
|
|
|
38387
37963
|
let ExtractSystem = _ExtractSystem;
|
|
38388
37964
|
|
|
38389
37965
|
class RenderTexture extends Texture {
|
|
38390
|
-
/**
|
|
38391
|
-
* Creates a RenderTexture. Pass `dynamic: true` in options to allow resizing after creation.
|
|
38392
|
-
* @param options - Options for the RenderTexture, including width, height, and dynamic.
|
|
38393
|
-
* @returns A new RenderTexture instance.
|
|
38394
|
-
* @example
|
|
38395
|
-
* const rt = RenderTexture.create({ width: 100, height: 100, dynamic: true });
|
|
38396
|
-
* rt.resize(500, 500);
|
|
38397
|
-
*/
|
|
38398
37966
|
static create(options) {
|
|
38399
|
-
const { dynamic, ...rest } = options;
|
|
38400
37967
|
return new RenderTexture({
|
|
38401
|
-
source: new TextureSource(
|
|
38402
|
-
dynamic: dynamic ?? false
|
|
37968
|
+
source: new TextureSource(options)
|
|
38403
37969
|
});
|
|
38404
37970
|
}
|
|
38405
37971
|
/**
|
|
@@ -38510,278 +38076,6 @@ GenerateTextureSystem.extension = {
|
|
|
38510
38076
|
name: "textureGenerator"
|
|
38511
38077
|
};
|
|
38512
38078
|
|
|
38513
|
-
const _GCSystem = class _GCSystem {
|
|
38514
|
-
/**
|
|
38515
|
-
* Creates a new GCSystem instance.
|
|
38516
|
-
* @param renderer - The renderer this garbage collection system works for
|
|
38517
|
-
*/
|
|
38518
|
-
constructor(renderer) {
|
|
38519
|
-
/** Array of resources being tracked for garbage collection */
|
|
38520
|
-
this._managedResources = [];
|
|
38521
|
-
this._managedResourceHashes = [];
|
|
38522
|
-
this._ready = false;
|
|
38523
|
-
this._renderer = renderer;
|
|
38524
|
-
}
|
|
38525
|
-
/**
|
|
38526
|
-
* Initializes the garbage collection system with the provided options.
|
|
38527
|
-
* @param options - Configuration options
|
|
38528
|
-
*/
|
|
38529
|
-
init(options) {
|
|
38530
|
-
options = { ..._GCSystem.defaultOptions, ...options };
|
|
38531
|
-
this.maxUnusedTime = options.gcMaxUnusedTime;
|
|
38532
|
-
this._frequency = options.gcFrequency;
|
|
38533
|
-
this.enabled = options.gcActive;
|
|
38534
|
-
this.now = performance.now();
|
|
38535
|
-
}
|
|
38536
|
-
/**
|
|
38537
|
-
* Gets whether the garbage collection system is currently enabled.
|
|
38538
|
-
* @returns True if GC is enabled, false otherwise
|
|
38539
|
-
*/
|
|
38540
|
-
get enabled() {
|
|
38541
|
-
return !!this._handler;
|
|
38542
|
-
}
|
|
38543
|
-
/**
|
|
38544
|
-
* Enables or disables the garbage collection system.
|
|
38545
|
-
* When enabled, schedules periodic cleanup of resources.
|
|
38546
|
-
* When disabled, cancels all scheduled cleanups.
|
|
38547
|
-
*/
|
|
38548
|
-
set enabled(value) {
|
|
38549
|
-
if (this.enabled === value)
|
|
38550
|
-
return;
|
|
38551
|
-
if (value) {
|
|
38552
|
-
this._handler = this._renderer.scheduler.repeat(
|
|
38553
|
-
() => {
|
|
38554
|
-
this._ready = true;
|
|
38555
|
-
},
|
|
38556
|
-
this._frequency,
|
|
38557
|
-
false
|
|
38558
|
-
);
|
|
38559
|
-
} else {
|
|
38560
|
-
this._renderer.scheduler.cancel(this._handler);
|
|
38561
|
-
this._handler = 0;
|
|
38562
|
-
}
|
|
38563
|
-
}
|
|
38564
|
-
/**
|
|
38565
|
-
* Called before rendering. Updates the current timestamp.
|
|
38566
|
-
* @param options - The render options
|
|
38567
|
-
* @param options.container - The container to render
|
|
38568
|
-
*/
|
|
38569
|
-
prerender({ container }) {
|
|
38570
|
-
this.now = performance.now();
|
|
38571
|
-
container.renderGroup.gcTick = this._renderer.tick++;
|
|
38572
|
-
this._updateInstructionGCTick(container.renderGroup, container.renderGroup.gcTick);
|
|
38573
|
-
}
|
|
38574
|
-
/** Performs garbage collection after rendering. */
|
|
38575
|
-
postrender() {
|
|
38576
|
-
if (!this._ready || !this.enabled)
|
|
38577
|
-
return;
|
|
38578
|
-
this.run();
|
|
38579
|
-
this._ready = false;
|
|
38580
|
-
}
|
|
38581
|
-
/**
|
|
38582
|
-
* Updates the GC tick counter for a render group and its children.
|
|
38583
|
-
* @param renderGroup - The render group to update
|
|
38584
|
-
* @param gcTick - The new tick value
|
|
38585
|
-
*/
|
|
38586
|
-
_updateInstructionGCTick(renderGroup, gcTick) {
|
|
38587
|
-
renderGroup.instructionSet.gcTick = gcTick;
|
|
38588
|
-
for (const child of renderGroup.renderGroupChildren) {
|
|
38589
|
-
this._updateInstructionGCTick(child, gcTick);
|
|
38590
|
-
}
|
|
38591
|
-
}
|
|
38592
|
-
/**
|
|
38593
|
-
* Registers a resource for garbage collection tracking.
|
|
38594
|
-
* @param resource - The resource to track
|
|
38595
|
-
* @param type - The type of resource to track
|
|
38596
|
-
*/
|
|
38597
|
-
addResource(resource, type) {
|
|
38598
|
-
if (resource._gcLastUsed !== -1) {
|
|
38599
|
-
resource._gcLastUsed = this.now;
|
|
38600
|
-
resource._onTouch?.(this.now);
|
|
38601
|
-
return;
|
|
38602
|
-
}
|
|
38603
|
-
const index = this._managedResources.length;
|
|
38604
|
-
resource._gcData = {
|
|
38605
|
-
index,
|
|
38606
|
-
type
|
|
38607
|
-
};
|
|
38608
|
-
resource._gcLastUsed = this.now;
|
|
38609
|
-
resource._onTouch?.(this.now);
|
|
38610
|
-
resource.once("unload", this.removeResource, this);
|
|
38611
|
-
this._managedResources.push(resource);
|
|
38612
|
-
}
|
|
38613
|
-
/**
|
|
38614
|
-
* Removes a resource from garbage collection tracking.
|
|
38615
|
-
* Call this when manually destroying a resource.
|
|
38616
|
-
* @param resource - The resource to stop tracking
|
|
38617
|
-
*/
|
|
38618
|
-
removeResource(resource) {
|
|
38619
|
-
const gcData = resource._gcData;
|
|
38620
|
-
if (!gcData)
|
|
38621
|
-
return;
|
|
38622
|
-
const index = gcData.index;
|
|
38623
|
-
const last = this._managedResources.length - 1;
|
|
38624
|
-
if (index !== last) {
|
|
38625
|
-
const lastResource = this._managedResources[last];
|
|
38626
|
-
this._managedResources[index] = lastResource;
|
|
38627
|
-
lastResource._gcData.index = index;
|
|
38628
|
-
}
|
|
38629
|
-
this._managedResources.length--;
|
|
38630
|
-
resource._gcData = null;
|
|
38631
|
-
resource._gcLastUsed = -1;
|
|
38632
|
-
}
|
|
38633
|
-
/**
|
|
38634
|
-
* Registers a hash-based resource collection for garbage collection tracking.
|
|
38635
|
-
* Resources in the hash will be automatically tracked and cleaned up when unused.
|
|
38636
|
-
* @param context - The object containing the hash property
|
|
38637
|
-
* @param hash - The property name on context that holds the resource hash
|
|
38638
|
-
* @param type - The type of resources in the hash ('resource' or 'renderable')
|
|
38639
|
-
* @param priority - Processing priority (lower values are processed first)
|
|
38640
|
-
*/
|
|
38641
|
-
addResourceHash(context, hash, type, priority = 0) {
|
|
38642
|
-
this._managedResourceHashes.push({
|
|
38643
|
-
context,
|
|
38644
|
-
hash,
|
|
38645
|
-
type,
|
|
38646
|
-
priority
|
|
38647
|
-
});
|
|
38648
|
-
this._managedResourceHashes.sort((a, b) => a.priority - b.priority);
|
|
38649
|
-
}
|
|
38650
|
-
/**
|
|
38651
|
-
* Performs garbage collection by cleaning up unused resources.
|
|
38652
|
-
* Removes resources that haven't been used for longer than maxUnusedTime.
|
|
38653
|
-
*/
|
|
38654
|
-
run() {
|
|
38655
|
-
const now = performance.now();
|
|
38656
|
-
const managedResourceHashes = this._managedResourceHashes;
|
|
38657
|
-
for (const hashEntry of managedResourceHashes) {
|
|
38658
|
-
this.runOnHash(hashEntry, now);
|
|
38659
|
-
}
|
|
38660
|
-
let writeIndex = 0;
|
|
38661
|
-
for (let i = 0; i < this._managedResources.length; i++) {
|
|
38662
|
-
const resource = this._managedResources[i];
|
|
38663
|
-
writeIndex = this.runOnResource(resource, now, writeIndex);
|
|
38664
|
-
}
|
|
38665
|
-
this._managedResources.length = writeIndex;
|
|
38666
|
-
}
|
|
38667
|
-
updateRenderableGCTick(renderable, now) {
|
|
38668
|
-
const renderGroup = renderable.renderGroup ?? renderable.parentRenderGroup;
|
|
38669
|
-
const currentTick = renderGroup?.instructionSet?.gcTick ?? -1;
|
|
38670
|
-
if ((renderGroup?.gcTick ?? 0) === currentTick) {
|
|
38671
|
-
renderable._gcLastUsed = now;
|
|
38672
|
-
renderable._onTouch?.(now);
|
|
38673
|
-
}
|
|
38674
|
-
}
|
|
38675
|
-
runOnResource(resource, now, writeIndex) {
|
|
38676
|
-
const gcData = resource._gcData;
|
|
38677
|
-
if (gcData.type === "renderable") {
|
|
38678
|
-
this.updateRenderableGCTick(resource, now);
|
|
38679
|
-
}
|
|
38680
|
-
const isRecentlyUsed = now - resource._gcLastUsed < this.maxUnusedTime;
|
|
38681
|
-
if (isRecentlyUsed || !resource.autoGarbageCollect) {
|
|
38682
|
-
this._managedResources[writeIndex] = resource;
|
|
38683
|
-
gcData.index = writeIndex;
|
|
38684
|
-
writeIndex++;
|
|
38685
|
-
} else {
|
|
38686
|
-
resource.unload();
|
|
38687
|
-
resource._gcData = null;
|
|
38688
|
-
resource._gcLastUsed = -1;
|
|
38689
|
-
resource.off("unload", this.removeResource, this);
|
|
38690
|
-
}
|
|
38691
|
-
return writeIndex;
|
|
38692
|
-
}
|
|
38693
|
-
/**
|
|
38694
|
-
* Creates a clone of the hash, copying all non-null entries up to (but not including) the stop key.
|
|
38695
|
-
* @param hashValue - The original hash to clone from
|
|
38696
|
-
* @param stopKey - The key to stop at (exclusive)
|
|
38697
|
-
* @returns A new hash object with copied entries
|
|
38698
|
-
*/
|
|
38699
|
-
_createHashClone(hashValue, stopKey) {
|
|
38700
|
-
const hashClone = /* @__PURE__ */ Object.create(null);
|
|
38701
|
-
for (const k in hashValue) {
|
|
38702
|
-
if (k === stopKey)
|
|
38703
|
-
break;
|
|
38704
|
-
if (hashValue[k] !== null)
|
|
38705
|
-
hashClone[k] = hashValue[k];
|
|
38706
|
-
}
|
|
38707
|
-
return hashClone;
|
|
38708
|
-
}
|
|
38709
|
-
runOnHash(hashEntry, now) {
|
|
38710
|
-
const { context, hash, type } = hashEntry;
|
|
38711
|
-
const hashValue = context[hash];
|
|
38712
|
-
let hashClone = null;
|
|
38713
|
-
let nullCount = 0;
|
|
38714
|
-
for (const key in hashValue) {
|
|
38715
|
-
const resource = hashValue[key];
|
|
38716
|
-
if (resource === null) {
|
|
38717
|
-
nullCount++;
|
|
38718
|
-
if (nullCount === 1e4 && !hashClone) {
|
|
38719
|
-
hashClone = this._createHashClone(hashValue, key);
|
|
38720
|
-
}
|
|
38721
|
-
continue;
|
|
38722
|
-
}
|
|
38723
|
-
if (resource._gcLastUsed === -1) {
|
|
38724
|
-
resource._gcLastUsed = now;
|
|
38725
|
-
resource._onTouch?.(now);
|
|
38726
|
-
if (hashClone)
|
|
38727
|
-
hashClone[key] = resource;
|
|
38728
|
-
continue;
|
|
38729
|
-
}
|
|
38730
|
-
if (type === "renderable") {
|
|
38731
|
-
this.updateRenderableGCTick(resource, now);
|
|
38732
|
-
}
|
|
38733
|
-
const isRecentlyUsed = now - resource._gcLastUsed < this.maxUnusedTime;
|
|
38734
|
-
if (!isRecentlyUsed && resource.autoGarbageCollect) {
|
|
38735
|
-
if (!hashClone) {
|
|
38736
|
-
if (nullCount + 1 !== 1e4) {
|
|
38737
|
-
hashValue[key] = null;
|
|
38738
|
-
nullCount++;
|
|
38739
|
-
} else {
|
|
38740
|
-
hashClone = this._createHashClone(hashValue, key);
|
|
38741
|
-
}
|
|
38742
|
-
}
|
|
38743
|
-
resource.unload();
|
|
38744
|
-
resource._gcData = null;
|
|
38745
|
-
resource._gcLastUsed = -1;
|
|
38746
|
-
} else if (hashClone) {
|
|
38747
|
-
hashClone[key] = resource;
|
|
38748
|
-
}
|
|
38749
|
-
}
|
|
38750
|
-
if (hashClone) {
|
|
38751
|
-
context[hash] = hashClone;
|
|
38752
|
-
}
|
|
38753
|
-
}
|
|
38754
|
-
/** Cleans up the garbage collection system. Disables GC and removes all tracked resources. */
|
|
38755
|
-
destroy() {
|
|
38756
|
-
this.enabled = false;
|
|
38757
|
-
this._managedResources.forEach((resource) => {
|
|
38758
|
-
resource.off("unload", this.removeResource, this);
|
|
38759
|
-
});
|
|
38760
|
-
this._managedResources.length = 0;
|
|
38761
|
-
this._managedResourceHashes.length = 0;
|
|
38762
|
-
this._renderer = null;
|
|
38763
|
-
}
|
|
38764
|
-
};
|
|
38765
|
-
/** @ignore */
|
|
38766
|
-
_GCSystem.extension = {
|
|
38767
|
-
type: [
|
|
38768
|
-
ExtensionType.WebGLSystem,
|
|
38769
|
-
ExtensionType.WebGPUSystem
|
|
38770
|
-
],
|
|
38771
|
-
name: "gc",
|
|
38772
|
-
priority: 0
|
|
38773
|
-
};
|
|
38774
|
-
/** Default options for the GCSystem */
|
|
38775
|
-
_GCSystem.defaultOptions = {
|
|
38776
|
-
/** Enable/disable the garbage collector */
|
|
38777
|
-
gcActive: true,
|
|
38778
|
-
/** Time in ms before an unused resource is collected (default 1 minute) */
|
|
38779
|
-
gcMaxUnusedTime: 6e4,
|
|
38780
|
-
/** How often to run garbage collection in ms (default 30 seconds) */
|
|
38781
|
-
gcFrequency: 3e4
|
|
38782
|
-
};
|
|
38783
|
-
let GCSystem = _GCSystem;
|
|
38784
|
-
|
|
38785
38079
|
function color32BitToUniform(abgr, out, offset) {
|
|
38786
38080
|
const alpha = (abgr >> 24 & 255) / 255;
|
|
38787
38081
|
out[offset++] = (abgr & 255) / 255 * alpha;
|
|
@@ -39288,86 +38582,48 @@ _RenderableGCSystem.defaultOptions = {
|
|
|
39288
38582
|
let RenderableGCSystem = _RenderableGCSystem;
|
|
39289
38583
|
|
|
39290
38584
|
const _TextureGCSystem = class _TextureGCSystem {
|
|
39291
|
-
/**
|
|
39292
|
-
* Frame count since started.
|
|
39293
|
-
* @readonly
|
|
39294
|
-
* @deprecated since 8.15.0
|
|
39295
|
-
*/
|
|
39296
|
-
get count() {
|
|
39297
|
-
return this._renderer.tick;
|
|
39298
|
-
}
|
|
39299
|
-
/**
|
|
39300
|
-
* Frame count since last garbage collection.
|
|
39301
|
-
* @readonly
|
|
39302
|
-
* @deprecated since 8.15.0
|
|
39303
|
-
*/
|
|
39304
|
-
get checkCount() {
|
|
39305
|
-
return this._checkCount;
|
|
39306
|
-
}
|
|
39307
|
-
set checkCount(value) {
|
|
39308
|
-
deprecation("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
39309
|
-
this._checkCount = value;
|
|
39310
|
-
}
|
|
39311
|
-
/**
|
|
39312
|
-
* Maximum idle frames before a texture is destroyed by garbage collection.
|
|
39313
|
-
* @see TextureGCSystem.defaultMaxIdle
|
|
39314
|
-
* @deprecated since 8.15.0
|
|
39315
|
-
*/
|
|
39316
|
-
get maxIdle() {
|
|
39317
|
-
return this._renderer.gc.maxUnusedTime / 1e3 * 60;
|
|
39318
|
-
}
|
|
39319
|
-
set maxIdle(value) {
|
|
39320
|
-
deprecation("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
39321
|
-
this._renderer.gc.maxUnusedTime = value / 60 * 1e3;
|
|
39322
|
-
}
|
|
39323
|
-
/**
|
|
39324
|
-
* Frames between two garbage collections.
|
|
39325
|
-
* @see TextureGCSystem.defaultCheckCountMax
|
|
39326
|
-
* @deprecated since 8.15.0
|
|
39327
|
-
*/
|
|
39328
|
-
// eslint-disable-next-line dot-notation
|
|
39329
|
-
get checkCountMax() {
|
|
39330
|
-
return Math.floor(this._renderer.gc["_frequency"] / 1e3);
|
|
39331
|
-
}
|
|
39332
|
-
set checkCountMax(_value) {
|
|
39333
|
-
deprecation("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
39334
|
-
}
|
|
39335
|
-
/**
|
|
39336
|
-
* Current garbage collection mode.
|
|
39337
|
-
* @see TextureGCSystem.defaultMode
|
|
39338
|
-
* @deprecated since 8.15.0
|
|
39339
|
-
*/
|
|
39340
|
-
get active() {
|
|
39341
|
-
return this._renderer.gc.enabled;
|
|
39342
|
-
}
|
|
39343
|
-
set active(value) {
|
|
39344
|
-
deprecation("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
39345
|
-
this._renderer.gc.enabled = value;
|
|
39346
|
-
}
|
|
39347
38585
|
/** @param renderer - The renderer this System works for. */
|
|
39348
38586
|
constructor(renderer) {
|
|
39349
38587
|
this._renderer = renderer;
|
|
39350
|
-
this.
|
|
38588
|
+
this.count = 0;
|
|
38589
|
+
this.checkCount = 0;
|
|
39351
38590
|
}
|
|
39352
38591
|
init(options) {
|
|
39353
|
-
|
|
39354
|
-
|
|
39355
|
-
|
|
39356
|
-
|
|
39357
|
-
|
|
38592
|
+
options = { ..._TextureGCSystem.defaultOptions, ...options };
|
|
38593
|
+
this.checkCountMax = options.textureGCCheckCountMax;
|
|
38594
|
+
this.maxIdle = options.textureGCAMaxIdle ?? options.textureGCMaxIdle;
|
|
38595
|
+
this.active = options.textureGCActive;
|
|
38596
|
+
}
|
|
38597
|
+
/**
|
|
38598
|
+
* Checks to see when the last time a texture was used.
|
|
38599
|
+
* If the texture has not been used for a specified amount of time, it will be removed from the GPU.
|
|
38600
|
+
*/
|
|
38601
|
+
postrender() {
|
|
38602
|
+
if (!this._renderer.renderingToScreen) {
|
|
38603
|
+
return;
|
|
39358
38604
|
}
|
|
39359
|
-
|
|
39360
|
-
|
|
38605
|
+
this.count++;
|
|
38606
|
+
if (!this.active)
|
|
38607
|
+
return;
|
|
38608
|
+
this.checkCount++;
|
|
38609
|
+
if (this.checkCount > this.checkCountMax) {
|
|
38610
|
+
this.checkCount = 0;
|
|
38611
|
+
this.run();
|
|
39361
38612
|
}
|
|
39362
38613
|
}
|
|
39363
38614
|
/**
|
|
39364
38615
|
* Checks to see when the last time a texture was used.
|
|
39365
38616
|
* If the texture has not been used for a specified amount of time, it will be removed from the GPU.
|
|
39366
|
-
* @deprecated since 8.15.0
|
|
39367
38617
|
*/
|
|
39368
38618
|
run() {
|
|
39369
|
-
|
|
39370
|
-
|
|
38619
|
+
const managedTextures = this._renderer.texture.managedTextures;
|
|
38620
|
+
for (let i = 0; i < managedTextures.length; i++) {
|
|
38621
|
+
const texture = managedTextures[i];
|
|
38622
|
+
if (texture.autoGarbageCollect && texture.resource && texture._touched > -1 && this.count - texture._touched > this.maxIdle) {
|
|
38623
|
+
texture._touched = -1;
|
|
38624
|
+
texture.unload();
|
|
38625
|
+
}
|
|
38626
|
+
}
|
|
39371
38627
|
}
|
|
39372
38628
|
destroy() {
|
|
39373
38629
|
this._renderer = null;
|
|
@@ -39381,10 +38637,7 @@ _TextureGCSystem.extension = {
|
|
|
39381
38637
|
],
|
|
39382
38638
|
name: "textureGC"
|
|
39383
38639
|
};
|
|
39384
|
-
/**
|
|
39385
|
-
* Default options for the TextureGCSystem
|
|
39386
|
-
* @deprecated since 8.15.0
|
|
39387
|
-
*/
|
|
38640
|
+
/** default options for the TextureGCSystem */
|
|
39388
38641
|
_TextureGCSystem.defaultOptions = {
|
|
39389
38642
|
/**
|
|
39390
38643
|
* If set to true, this will enable the garbage collector on the GPU.
|
|
@@ -39525,7 +38778,6 @@ const SharedSystems = [
|
|
|
39525
38778
|
HelloSystem,
|
|
39526
38779
|
ViewSystem,
|
|
39527
38780
|
RenderGroupSystem,
|
|
39528
|
-
GCSystem,
|
|
39529
38781
|
TextureGCSystem,
|
|
39530
38782
|
GenerateTextureSystem,
|
|
39531
38783
|
ExtractSystem,
|
|
@@ -39592,6 +38844,7 @@ class BindGroupSystem {
|
|
|
39592
38844
|
constructor(renderer) {
|
|
39593
38845
|
this._hash = /* @__PURE__ */ Object.create(null);
|
|
39594
38846
|
this._renderer = renderer;
|
|
38847
|
+
this._renderer.renderableGC.addManagedHash(this, "_hash");
|
|
39595
38848
|
}
|
|
39596
38849
|
contextChange(gpu) {
|
|
39597
38850
|
this._gpu = gpu;
|
|
@@ -39637,7 +38890,7 @@ class BindGroupSystem {
|
|
|
39637
38890
|
gpuResource = renderer.texture.getGpuSampler(sampler);
|
|
39638
38891
|
} else if (resource._resourceType === "textureSource") {
|
|
39639
38892
|
const texture = resource;
|
|
39640
|
-
gpuResource = renderer.texture.getGpuSource(texture).createView();
|
|
38893
|
+
gpuResource = renderer.texture.getGpuSource(texture).createView({});
|
|
39641
38894
|
}
|
|
39642
38895
|
entries.push({
|
|
39643
38896
|
binding: groupLayout[j],
|
|
@@ -39653,6 +38906,9 @@ class BindGroupSystem {
|
|
|
39653
38906
|
return gpuBindGroup;
|
|
39654
38907
|
}
|
|
39655
38908
|
destroy() {
|
|
38909
|
+
for (const key of Object.keys(this._hash)) {
|
|
38910
|
+
this._hash[key] = null;
|
|
38911
|
+
}
|
|
39656
38912
|
this._hash = null;
|
|
39657
38913
|
this._renderer = null;
|
|
39658
38914
|
}
|
|
@@ -39665,34 +38921,20 @@ BindGroupSystem.extension = {
|
|
|
39665
38921
|
name: "bindGroup"
|
|
39666
38922
|
};
|
|
39667
38923
|
|
|
39668
|
-
class GpuBufferData {
|
|
39669
|
-
constructor(gpuBuffer) {
|
|
39670
|
-
this.gpuBuffer = gpuBuffer;
|
|
39671
|
-
}
|
|
39672
|
-
destroy() {
|
|
39673
|
-
this.gpuBuffer.destroy();
|
|
39674
|
-
this.gpuBuffer = null;
|
|
39675
|
-
}
|
|
39676
|
-
}
|
|
39677
38924
|
class GpuBufferSystem {
|
|
39678
38925
|
constructor(renderer) {
|
|
39679
|
-
this.
|
|
39680
|
-
this._managedBuffers =
|
|
39681
|
-
|
|
39682
|
-
type: "resource",
|
|
39683
|
-
onUnload: this.onBufferUnload.bind(this),
|
|
39684
|
-
name: "gpuBuffer"
|
|
39685
|
-
});
|
|
38926
|
+
this._gpuBuffers = /* @__PURE__ */ Object.create(null);
|
|
38927
|
+
this._managedBuffers = [];
|
|
38928
|
+
renderer.renderableGC.addManagedHash(this, "_gpuBuffers");
|
|
39686
38929
|
}
|
|
39687
38930
|
contextChange(gpu) {
|
|
39688
38931
|
this._gpu = gpu;
|
|
39689
38932
|
}
|
|
39690
38933
|
getGPUBuffer(buffer) {
|
|
39691
|
-
buffer.
|
|
39692
|
-
return buffer._gpuData[this._renderer.uid]?.gpuBuffer || this.createGPUBuffer(buffer);
|
|
38934
|
+
return this._gpuBuffers[buffer.uid] || this.createGPUBuffer(buffer);
|
|
39693
38935
|
}
|
|
39694
38936
|
updateBuffer(buffer) {
|
|
39695
|
-
const gpuBuffer = this.
|
|
38937
|
+
const gpuBuffer = this._gpuBuffers[buffer.uid] || this.createGPUBuffer(buffer);
|
|
39696
38938
|
const data = buffer.data;
|
|
39697
38939
|
if (buffer._updateID && data) {
|
|
39698
38940
|
buffer._updateID = 0;
|
|
@@ -39709,36 +38951,53 @@ class GpuBufferSystem {
|
|
|
39709
38951
|
}
|
|
39710
38952
|
/** dispose all WebGL resources of all managed buffers */
|
|
39711
38953
|
destroyAll() {
|
|
39712
|
-
this.
|
|
39713
|
-
|
|
39714
|
-
|
|
39715
|
-
|
|
39716
|
-
buffer.off("change", this.onBufferChange, this);
|
|
38954
|
+
for (const id in this._gpuBuffers) {
|
|
38955
|
+
this._gpuBuffers[id].destroy();
|
|
38956
|
+
}
|
|
38957
|
+
this._gpuBuffers = {};
|
|
39717
38958
|
}
|
|
39718
38959
|
createGPUBuffer(buffer) {
|
|
38960
|
+
if (!this._gpuBuffers[buffer.uid]) {
|
|
38961
|
+
buffer.on("update", this.updateBuffer, this);
|
|
38962
|
+
buffer.on("change", this.onBufferChange, this);
|
|
38963
|
+
buffer.on("destroy", this.onBufferDestroy, this);
|
|
38964
|
+
this._managedBuffers.push(buffer);
|
|
38965
|
+
}
|
|
39719
38966
|
const gpuBuffer = this._gpu.device.createBuffer(buffer.descriptor);
|
|
39720
38967
|
buffer._updateID = 0;
|
|
39721
|
-
buffer._resourceId = uid$1("resource");
|
|
39722
38968
|
if (buffer.data) {
|
|
39723
38969
|
fastCopy(buffer.data.buffer, gpuBuffer.getMappedRange());
|
|
39724
38970
|
gpuBuffer.unmap();
|
|
39725
38971
|
}
|
|
39726
|
-
|
|
39727
|
-
if (this._managedBuffers.add(buffer)) {
|
|
39728
|
-
buffer.on("update", this.updateBuffer, this);
|
|
39729
|
-
buffer.on("change", this.onBufferChange, this);
|
|
39730
|
-
}
|
|
38972
|
+
this._gpuBuffers[buffer.uid] = gpuBuffer;
|
|
39731
38973
|
return gpuBuffer;
|
|
39732
38974
|
}
|
|
39733
38975
|
onBufferChange(buffer) {
|
|
39734
|
-
this.
|
|
38976
|
+
const gpuBuffer = this._gpuBuffers[buffer.uid];
|
|
38977
|
+
gpuBuffer.destroy();
|
|
39735
38978
|
buffer._updateID = 0;
|
|
39736
|
-
this.createGPUBuffer(buffer);
|
|
38979
|
+
this._gpuBuffers[buffer.uid] = this.createGPUBuffer(buffer);
|
|
38980
|
+
}
|
|
38981
|
+
/**
|
|
38982
|
+
* Disposes buffer
|
|
38983
|
+
* @param buffer - buffer with data
|
|
38984
|
+
*/
|
|
38985
|
+
onBufferDestroy(buffer) {
|
|
38986
|
+
this._managedBuffers.splice(this._managedBuffers.indexOf(buffer), 1);
|
|
38987
|
+
this._destroyBuffer(buffer);
|
|
39737
38988
|
}
|
|
39738
38989
|
destroy() {
|
|
39739
|
-
this._managedBuffers.
|
|
39740
|
-
this.
|
|
39741
|
-
this.
|
|
38990
|
+
this._managedBuffers.forEach((buffer) => this._destroyBuffer(buffer));
|
|
38991
|
+
this._managedBuffers = null;
|
|
38992
|
+
this._gpuBuffers = null;
|
|
38993
|
+
}
|
|
38994
|
+
_destroyBuffer(buffer) {
|
|
38995
|
+
const gpuBuffer = this._gpuBuffers[buffer.uid];
|
|
38996
|
+
gpuBuffer.destroy();
|
|
38997
|
+
buffer.off("update", this.updateBuffer, this);
|
|
38998
|
+
buffer.off("change", this.onBufferChange, this);
|
|
38999
|
+
buffer.off("destroy", this.onBufferDestroy, this);
|
|
39000
|
+
this._gpuBuffers[buffer.uid] = null;
|
|
39742
39001
|
}
|
|
39743
39002
|
}
|
|
39744
39003
|
/** @ignore */
|
|
@@ -39935,7 +39194,7 @@ class GpuEncoderSystem {
|
|
|
39935
39194
|
if (this._boundBindGroup[index] === bindGroup)
|
|
39936
39195
|
return;
|
|
39937
39196
|
this._boundBindGroup[index] = bindGroup;
|
|
39938
|
-
bindGroup._touch(this._renderer.
|
|
39197
|
+
bindGroup._touch(this._renderer.textureGC.count);
|
|
39939
39198
|
const gpuBindGroup = this._renderer.bindGroup.getBindGroup(bindGroup, program, index);
|
|
39940
39199
|
this.renderPassEncoder.setBindGroup(index, gpuBindGroup);
|
|
39941
39200
|
}
|
|
@@ -40221,6 +39480,7 @@ class GpuUniformBatchPipe {
|
|
|
40221
39480
|
this._bindGroups = [];
|
|
40222
39481
|
this._bufferResources = [];
|
|
40223
39482
|
this._renderer = renderer;
|
|
39483
|
+
this._renderer.renderableGC.addManagedHash(this, "_bindGroupHash");
|
|
40224
39484
|
this._batchBuffer = new UboBatch({ minUniformOffsetAlignment });
|
|
40225
39485
|
const totalBuffers = 256 / minUniformOffsetAlignment;
|
|
40226
39486
|
for (let i = 0; i < totalBuffers; i++) {
|
|
@@ -40238,7 +39498,9 @@ class GpuUniformBatchPipe {
|
|
|
40238
39498
|
this._resetBindGroups();
|
|
40239
39499
|
}
|
|
40240
39500
|
_resetBindGroups() {
|
|
40241
|
-
|
|
39501
|
+
for (const i in this._bindGroupHash) {
|
|
39502
|
+
this._bindGroupHash[i] = null;
|
|
39503
|
+
}
|
|
40242
39504
|
this._batchBuffer.clear();
|
|
40243
39505
|
}
|
|
40244
39506
|
// just works for single bind groups for now
|
|
@@ -40321,6 +39583,7 @@ class GpuUniformBatchPipe {
|
|
|
40321
39583
|
}
|
|
40322
39584
|
this._bufferResources = null;
|
|
40323
39585
|
this._batchBuffer.destroy();
|
|
39586
|
+
this._bindGroupHash = null;
|
|
40324
39587
|
this._renderer = null;
|
|
40325
39588
|
}
|
|
40326
39589
|
}
|
|
@@ -40342,8 +39605,8 @@ const topologyStringToId = {
|
|
|
40342
39605
|
function getGraphicsStateKey(geometryLayout, shaderKey, state, blendMode, topology) {
|
|
40343
39606
|
return geometryLayout << 24 | shaderKey << 16 | state << 10 | blendMode << 5 | topology;
|
|
40344
39607
|
}
|
|
40345
|
-
function getGlobalStateKey(stencilStateId, multiSampleCount, colorMask, renderTarget
|
|
40346
|
-
return colorMask <<
|
|
39608
|
+
function getGlobalStateKey(stencilStateId, multiSampleCount, colorMask, renderTarget) {
|
|
39609
|
+
return colorMask << 6 | stencilStateId << 3 | renderTarget << 1 | multiSampleCount;
|
|
40347
39610
|
}
|
|
40348
39611
|
class PipelineSystem {
|
|
40349
39612
|
constructor(renderer) {
|
|
@@ -40354,7 +39617,6 @@ class PipelineSystem {
|
|
|
40354
39617
|
this._pipeStateCaches = /* @__PURE__ */ Object.create(null);
|
|
40355
39618
|
this._colorMask = 15;
|
|
40356
39619
|
this._multisampleCount = 1;
|
|
40357
|
-
this._colorTargetCount = 1;
|
|
40358
39620
|
this._renderer = renderer;
|
|
40359
39621
|
}
|
|
40360
39622
|
contextChange(gpu) {
|
|
@@ -40371,7 +39633,6 @@ class PipelineSystem {
|
|
|
40371
39633
|
setRenderTarget(renderTarget) {
|
|
40372
39634
|
this._multisampleCount = renderTarget.msaaSamples;
|
|
40373
39635
|
this._depthStencilAttachment = renderTarget.descriptor.depthStencilAttachment ? 1 : 0;
|
|
40374
|
-
this._colorTargetCount = renderTarget.colorTargetCount;
|
|
40375
39636
|
this._updatePipeHash();
|
|
40376
39637
|
}
|
|
40377
39638
|
setColorMask(colorMask) {
|
|
@@ -40412,11 +39673,8 @@ class PipelineSystem {
|
|
|
40412
39673
|
_createPipeline(geometry, program, state, topology) {
|
|
40413
39674
|
const device = this._gpu.device;
|
|
40414
39675
|
const buffers = this._createVertexBufferLayouts(geometry, program);
|
|
40415
|
-
const blendModes = this._renderer.state.getColorTargets(state
|
|
40416
|
-
|
|
40417
|
-
for (let i = 0; i < blendModes.length; i++) {
|
|
40418
|
-
blendModes[i].writeMask = writeMask;
|
|
40419
|
-
}
|
|
39676
|
+
const blendModes = this._renderer.state.getColorTargets(state);
|
|
39677
|
+
blendModes[0].writeMask = this._stencilMode === STENCIL_MODES.RENDERING_MASK_ADD ? 0 : this._colorMask;
|
|
40420
39678
|
const layout = this._renderer.shader.getProgramData(program).pipeline;
|
|
40421
39679
|
const descriptor = {
|
|
40422
39680
|
// TODO later check if its helpful to create..
|
|
@@ -40560,8 +39818,7 @@ class PipelineSystem {
|
|
|
40560
39818
|
this._stencilMode,
|
|
40561
39819
|
this._multisampleCount,
|
|
40562
39820
|
this._colorMask,
|
|
40563
|
-
this._depthStencilAttachment
|
|
40564
|
-
this._colorTargetCount
|
|
39821
|
+
this._depthStencilAttachment
|
|
40565
39822
|
);
|
|
40566
39823
|
if (!this._pipeStateCaches[key]) {
|
|
40567
39824
|
this._pipeStateCaches[key] = /* @__PURE__ */ Object.create(null);
|
|
@@ -40721,7 +39978,6 @@ class GpuRenderTargetAdaptor {
|
|
|
40721
39978
|
initGpuRenderTarget(renderTarget) {
|
|
40722
39979
|
renderTarget.isRoot = true;
|
|
40723
39980
|
const gpuRenderTarget = new GpuRenderTarget();
|
|
40724
|
-
gpuRenderTarget.colorTargetCount = renderTarget.colorTextures.length;
|
|
40725
39981
|
renderTarget.colorTextures.forEach((colorTexture, i) => {
|
|
40726
39982
|
if (colorTexture instanceof CanvasSource) {
|
|
40727
39983
|
const context = colorTexture.resource.getContext(
|
|
@@ -40994,20 +40250,16 @@ class GpuStateSystem {
|
|
|
40994
40250
|
/**
|
|
40995
40251
|
* Gets the blend mode data for the current state
|
|
40996
40252
|
* @param state - The state to get the blend mode from
|
|
40997
|
-
* @param count - The number of color targets to create
|
|
40998
40253
|
*/
|
|
40999
|
-
getColorTargets(state
|
|
40254
|
+
getColorTargets(state) {
|
|
41000
40255
|
const blend = GpuBlendModesToPixi[state.blendMode] || GpuBlendModesToPixi.normal;
|
|
41001
|
-
|
|
41002
|
-
|
|
41003
|
-
|
|
41004
|
-
|
|
41005
|
-
|
|
41006
|
-
|
|
41007
|
-
|
|
41008
|
-
targets[i] = target;
|
|
41009
|
-
}
|
|
41010
|
-
return targets;
|
|
40256
|
+
return [
|
|
40257
|
+
{
|
|
40258
|
+
format: "bgra8unorm",
|
|
40259
|
+
writeMask: 0,
|
|
40260
|
+
blend
|
|
40261
|
+
}
|
|
40262
|
+
];
|
|
41011
40263
|
}
|
|
41012
40264
|
destroy() {
|
|
41013
40265
|
this.gpu = null;
|
|
@@ -41033,7 +40285,7 @@ const gpuUploadBufferImageResource = {
|
|
|
41033
40285
|
{
|
|
41034
40286
|
offset: 0,
|
|
41035
40287
|
rowsPerImage: source.pixelHeight,
|
|
41036
|
-
bytesPerRow: source.
|
|
40288
|
+
bytesPerRow: source.pixelHeight * bytesPerPixel
|
|
41037
40289
|
},
|
|
41038
40290
|
{
|
|
41039
40291
|
width: source.pixelWidth,
|
|
@@ -41272,22 +40524,13 @@ class GpuMipmapGenerator {
|
|
|
41272
40524
|
}
|
|
41273
40525
|
}
|
|
41274
40526
|
|
|
41275
|
-
class GPUTextureGpuData {
|
|
41276
|
-
constructor(gpuTexture) {
|
|
41277
|
-
this.textureView = null;
|
|
41278
|
-
this.gpuTexture = gpuTexture;
|
|
41279
|
-
}
|
|
41280
|
-
/** Destroys this GPU data instance. */
|
|
41281
|
-
destroy() {
|
|
41282
|
-
this.gpuTexture.destroy();
|
|
41283
|
-
this.textureView = null;
|
|
41284
|
-
this.gpuTexture = null;
|
|
41285
|
-
}
|
|
41286
|
-
}
|
|
41287
40527
|
class GpuTextureSystem {
|
|
41288
40528
|
constructor(renderer) {
|
|
40529
|
+
this.managedTextures = [];
|
|
40530
|
+
this._gpuSources = /* @__PURE__ */ Object.create(null);
|
|
41289
40531
|
this._gpuSamplers = /* @__PURE__ */ Object.create(null);
|
|
41290
40532
|
this._bindGroupHash = /* @__PURE__ */ Object.create(null);
|
|
40533
|
+
this._textureViewHash = /* @__PURE__ */ Object.create(null);
|
|
41291
40534
|
this._uploads = {
|
|
41292
40535
|
image: gpuUploadImageResource,
|
|
41293
40536
|
buffer: gpuUploadBufferImageResource,
|
|
@@ -41295,19 +40538,10 @@ class GpuTextureSystem {
|
|
|
41295
40538
|
compressed: gpuUploadCompressedTextureResource
|
|
41296
40539
|
};
|
|
41297
40540
|
this._renderer = renderer;
|
|
40541
|
+
renderer.renderableGC.addManagedHash(this, "_gpuSources");
|
|
40542
|
+
renderer.renderableGC.addManagedHash(this, "_gpuSamplers");
|
|
41298
40543
|
renderer.renderableGC.addManagedHash(this, "_bindGroupHash");
|
|
41299
|
-
this
|
|
41300
|
-
renderer,
|
|
41301
|
-
type: "resource",
|
|
41302
|
-
onUnload: this.onSourceUnload.bind(this),
|
|
41303
|
-
name: "gpuTextureSource"
|
|
41304
|
-
});
|
|
41305
|
-
}
|
|
41306
|
-
/**
|
|
41307
|
-
* @deprecated since 8.15.0
|
|
41308
|
-
*/
|
|
41309
|
-
get managedTextures() {
|
|
41310
|
-
return Object.values(this._managedTextures.items);
|
|
40544
|
+
renderer.renderableGC.addManagedHash(this, "_textureViewHash");
|
|
41311
40545
|
}
|
|
41312
40546
|
contextChange(gpu) {
|
|
41313
40547
|
this._gpu = gpu;
|
|
@@ -41318,7 +40552,10 @@ class GpuTextureSystem {
|
|
|
41318
40552
|
* @returns The initialized texture source.
|
|
41319
40553
|
*/
|
|
41320
40554
|
initSource(source) {
|
|
41321
|
-
|
|
40555
|
+
if (this._gpuSources[source.uid]) {
|
|
40556
|
+
return this._gpuSources[source.uid];
|
|
40557
|
+
}
|
|
40558
|
+
return this._initSource(source);
|
|
41322
40559
|
}
|
|
41323
40560
|
_initSource(source) {
|
|
41324
40561
|
if (source.autoGenerateMipmaps) {
|
|
@@ -41342,13 +40579,14 @@ class GpuTextureSystem {
|
|
|
41342
40579
|
dimension: source.dimension,
|
|
41343
40580
|
usage
|
|
41344
40581
|
};
|
|
41345
|
-
const gpuTexture = this._gpu.device.createTexture(textureDescriptor);
|
|
41346
|
-
|
|
41347
|
-
const added = this._managedTextures.add(source);
|
|
41348
|
-
if (added) {
|
|
40582
|
+
const gpuTexture = this._gpuSources[source.uid] = this._gpu.device.createTexture(textureDescriptor);
|
|
40583
|
+
if (!this.managedTextures.includes(source)) {
|
|
41349
40584
|
source.on("update", this.onSourceUpdate, this);
|
|
41350
40585
|
source.on("resize", this.onSourceResize, this);
|
|
40586
|
+
source.on("destroy", this.onSourceDestroy, this);
|
|
40587
|
+
source.on("unload", this.onSourceUnload, this);
|
|
41351
40588
|
source.on("updateMipmaps", this.onUpdateMipmaps, this);
|
|
40589
|
+
this.managedTextures.push(source);
|
|
41352
40590
|
}
|
|
41353
40591
|
this.onSourceUpdate(source);
|
|
41354
40592
|
return gpuTexture;
|
|
@@ -41364,6 +40602,13 @@ class GpuTextureSystem {
|
|
|
41364
40602
|
this.onUpdateMipmaps(source);
|
|
41365
40603
|
}
|
|
41366
40604
|
}
|
|
40605
|
+
onSourceUnload(source) {
|
|
40606
|
+
const gpuTexture = this._gpuSources[source.uid];
|
|
40607
|
+
if (gpuTexture) {
|
|
40608
|
+
this._gpuSources[source.uid] = null;
|
|
40609
|
+
gpuTexture.destroy();
|
|
40610
|
+
}
|
|
40611
|
+
}
|
|
41367
40612
|
onUpdateMipmaps(source) {
|
|
41368
40613
|
if (!this._mipmapGenerator) {
|
|
41369
40614
|
this._mipmapGenerator = new GpuMipmapGenerator(this._gpu.device);
|
|
@@ -41371,21 +40616,23 @@ class GpuTextureSystem {
|
|
|
41371
40616
|
const gpuTexture = this.getGpuSource(source);
|
|
41372
40617
|
this._mipmapGenerator.generateMipmap(gpuTexture);
|
|
41373
40618
|
}
|
|
41374
|
-
|
|
40619
|
+
onSourceDestroy(source) {
|
|
41375
40620
|
source.off("update", this.onSourceUpdate, this);
|
|
40621
|
+
source.off("unload", this.onSourceUnload, this);
|
|
40622
|
+
source.off("destroy", this.onSourceDestroy, this);
|
|
41376
40623
|
source.off("resize", this.onSourceResize, this);
|
|
41377
40624
|
source.off("updateMipmaps", this.onUpdateMipmaps, this);
|
|
40625
|
+
this.managedTextures.splice(this.managedTextures.indexOf(source), 1);
|
|
40626
|
+
this.onSourceUnload(source);
|
|
41378
40627
|
}
|
|
41379
40628
|
onSourceResize(source) {
|
|
41380
|
-
|
|
41381
|
-
const gpuData = source._gpuData[this._renderer.uid];
|
|
41382
|
-
const gpuTexture = gpuData?.gpuTexture;
|
|
40629
|
+
const gpuTexture = this._gpuSources[source.uid];
|
|
41383
40630
|
if (!gpuTexture) {
|
|
41384
40631
|
this.initSource(source);
|
|
41385
40632
|
} else if (gpuTexture.width !== source.pixelWidth || gpuTexture.height !== source.pixelHeight) {
|
|
41386
|
-
|
|
40633
|
+
this._textureViewHash[source.uid] = null;
|
|
41387
40634
|
this._bindGroupHash[source.uid] = null;
|
|
41388
|
-
|
|
40635
|
+
this.onSourceUnload(source);
|
|
41389
40636
|
this.initSource(source);
|
|
41390
40637
|
}
|
|
41391
40638
|
}
|
|
@@ -41397,8 +40644,7 @@ class GpuTextureSystem {
|
|
|
41397
40644
|
return this._gpuSamplers[sampler._resourceId] || this._initSampler(sampler);
|
|
41398
40645
|
}
|
|
41399
40646
|
getGpuSource(source) {
|
|
41400
|
-
source.
|
|
41401
|
-
return source._gpuData[this._renderer.uid]?.gpuTexture || this.initSource(source);
|
|
40647
|
+
return this._gpuSources[source.uid] || this.initSource(source);
|
|
41402
40648
|
}
|
|
41403
40649
|
/**
|
|
41404
40650
|
* this returns s bind group for a specific texture, the bind group contains
|
|
@@ -41410,7 +40656,7 @@ class GpuTextureSystem {
|
|
|
41410
40656
|
* @returns the bind group for the texture
|
|
41411
40657
|
*/
|
|
41412
40658
|
getTextureBindGroup(texture) {
|
|
41413
|
-
return this._bindGroupHash[texture.uid]
|
|
40659
|
+
return this._bindGroupHash[texture.uid] ?? this._createTextureBindGroup(texture);
|
|
41414
40660
|
}
|
|
41415
40661
|
_createTextureBindGroup(texture) {
|
|
41416
40662
|
const source = texture.source;
|
|
@@ -41425,15 +40671,11 @@ class GpuTextureSystem {
|
|
|
41425
40671
|
}
|
|
41426
40672
|
getTextureView(texture) {
|
|
41427
40673
|
const source = texture.source;
|
|
41428
|
-
source.
|
|
41429
|
-
|
|
41430
|
-
|
|
41431
|
-
|
|
41432
|
-
|
|
41433
|
-
gpuData = source._gpuData[this._renderer.uid];
|
|
41434
|
-
}
|
|
41435
|
-
textureView = gpuData.textureView || gpuData.gpuTexture.createView();
|
|
41436
|
-
return textureView;
|
|
40674
|
+
return this._textureViewHash[source.uid] ?? this._createTextureView(source);
|
|
40675
|
+
}
|
|
40676
|
+
_createTextureView(texture) {
|
|
40677
|
+
this._textureViewHash[texture.uid] = this.getGpuSource(texture).createView();
|
|
40678
|
+
return this._textureViewHash[texture.uid];
|
|
41437
40679
|
}
|
|
41438
40680
|
generateCanvas(texture) {
|
|
41439
40681
|
const renderer = this._renderer;
|
|
@@ -41475,17 +40717,20 @@ class GpuTextureSystem {
|
|
|
41475
40717
|
return { pixels, width, height };
|
|
41476
40718
|
}
|
|
41477
40719
|
destroy() {
|
|
41478
|
-
this.
|
|
40720
|
+
this.managedTextures.slice().forEach((source) => this.onSourceDestroy(source));
|
|
40721
|
+
this.managedTextures = null;
|
|
41479
40722
|
for (const k of Object.keys(this._bindGroupHash)) {
|
|
41480
40723
|
const key = Number(k);
|
|
41481
40724
|
const bindGroup = this._bindGroupHash[key];
|
|
41482
40725
|
bindGroup?.destroy();
|
|
40726
|
+
this._bindGroupHash[key] = null;
|
|
41483
40727
|
}
|
|
41484
|
-
this._renderer = null;
|
|
41485
40728
|
this._gpu = null;
|
|
41486
40729
|
this._mipmapGenerator = null;
|
|
41487
|
-
this.
|
|
40730
|
+
this._gpuSources = null;
|
|
41488
40731
|
this._bindGroupHash = null;
|
|
40732
|
+
this._textureViewHash = null;
|
|
40733
|
+
this._gpuSamplers = null;
|
|
41489
40734
|
}
|
|
41490
40735
|
}
|
|
41491
40736
|
/** @ignore */
|
|
@@ -41702,7 +40947,6 @@ class GraphicsPipe {
|
|
|
41702
40947
|
this.renderer = renderer;
|
|
41703
40948
|
this._adaptor = adaptor;
|
|
41704
40949
|
this.renderer.runners.contextChange.add(this);
|
|
41705
|
-
this._managedGraphics = new GCManagedHash({ renderer, type: "renderable", priority: -1, name: "graphics" });
|
|
41706
40950
|
}
|
|
41707
40951
|
contextChange() {
|
|
41708
40952
|
this._adaptor.contextChange(this.renderer);
|
|
@@ -41779,7 +41023,6 @@ class GraphicsPipe {
|
|
|
41779
41023
|
_initGpuDataForRenderable(graphics) {
|
|
41780
41024
|
const gpuData = new GraphicsGpuData();
|
|
41781
41025
|
graphics._gpuData[this.renderer.uid] = gpuData;
|
|
41782
|
-
this._managedGraphics.add(graphics);
|
|
41783
41026
|
return gpuData;
|
|
41784
41027
|
}
|
|
41785
41028
|
_updateBatchesForRenderable(graphics, gpuData) {
|
|
@@ -41795,7 +41038,6 @@ class GraphicsPipe {
|
|
|
41795
41038
|
});
|
|
41796
41039
|
}
|
|
41797
41040
|
destroy() {
|
|
41798
|
-
this._managedGraphics.destroy();
|
|
41799
41041
|
this.renderer = null;
|
|
41800
41042
|
this._adaptor.destroy();
|
|
41801
41043
|
this._adaptor = null;
|
|
@@ -42368,7 +41610,6 @@ class ParticleContainerPipe {
|
|
|
42368
41610
|
this.adaptor = adaptor;
|
|
42369
41611
|
this.defaultShader = new ParticleShader();
|
|
42370
41612
|
this.state = State.for2d();
|
|
42371
|
-
this._managedContainers = new GCManagedHash({ renderer, type: "renderable", name: "particleContainer" });
|
|
42372
41613
|
}
|
|
42373
41614
|
validateRenderable(_renderable) {
|
|
42374
41615
|
return false;
|
|
@@ -42385,7 +41626,6 @@ class ParticleContainerPipe {
|
|
|
42385
41626
|
size: renderable.particleChildren.length,
|
|
42386
41627
|
properties: renderable._properties
|
|
42387
41628
|
});
|
|
42388
|
-
this._managedContainers.add(renderable);
|
|
42389
41629
|
return renderable._gpuData[this.renderer.uid];
|
|
42390
41630
|
}
|
|
42391
41631
|
updateRenderable(_renderable) {
|
|
@@ -42417,7 +41657,6 @@ class ParticleContainerPipe {
|
|
|
42417
41657
|
}
|
|
42418
41658
|
/** Destroys the ParticleRenderer. */
|
|
42419
41659
|
destroy() {
|
|
42420
|
-
this._managedContainers.destroy();
|
|
42421
41660
|
this.renderer = null;
|
|
42422
41661
|
if (this.defaultShader) {
|
|
42423
41662
|
this.defaultShader.destroy();
|
|
@@ -42560,7 +41799,6 @@ class NineSliceSpriteGpuData extends BatchableMesh {
|
|
|
42560
41799
|
class NineSliceSpritePipe {
|
|
42561
41800
|
constructor(renderer) {
|
|
42562
41801
|
this._renderer = renderer;
|
|
42563
|
-
this._managedSprites = new GCManagedHash({ renderer, type: "renderable", name: "nineSliceSprite" });
|
|
42564
41802
|
}
|
|
42565
41803
|
addRenderable(sprite, instructionSet) {
|
|
42566
41804
|
const gpuSprite = this._getGpuSprite(sprite);
|
|
@@ -42595,14 +41833,12 @@ class NineSliceSpritePipe {
|
|
|
42595
41833
|
batchableMesh.transform = sprite.groupTransform;
|
|
42596
41834
|
batchableMesh.texture = sprite._texture;
|
|
42597
41835
|
batchableMesh.roundPixels = this._renderer._roundPixels | sprite._roundPixels;
|
|
42598
|
-
this._managedSprites.add(sprite);
|
|
42599
41836
|
if (!sprite.didViewUpdate) {
|
|
42600
41837
|
this._updateBatchableSprite(sprite, batchableMesh);
|
|
42601
41838
|
}
|
|
42602
41839
|
return gpuData;
|
|
42603
41840
|
}
|
|
42604
41841
|
destroy() {
|
|
42605
|
-
this._managedSprites.destroy();
|
|
42606
41842
|
this._renderer = null;
|
|
42607
41843
|
}
|
|
42608
41844
|
}
|
|
@@ -42885,7 +42121,6 @@ class TilingSpritePipe {
|
|
|
42885
42121
|
constructor(renderer) {
|
|
42886
42122
|
this._state = State.default2d;
|
|
42887
42123
|
this._renderer = renderer;
|
|
42888
|
-
this._managedTilingSprites = new GCManagedHash({ renderer, type: "renderable", name: "tilingSprite" });
|
|
42889
42124
|
}
|
|
42890
42125
|
validateRenderable(renderable) {
|
|
42891
42126
|
const tilingSpriteData = this._getTilingSpriteData(renderable);
|
|
@@ -42970,7 +42205,6 @@ class TilingSpritePipe {
|
|
|
42970
42205
|
const gpuData = new TilingSpriteGpuData();
|
|
42971
42206
|
gpuData.renderable = tilingSprite;
|
|
42972
42207
|
tilingSprite._gpuData[this._renderer.uid] = gpuData;
|
|
42973
|
-
this._managedTilingSprites.add(tilingSprite);
|
|
42974
42208
|
return gpuData;
|
|
42975
42209
|
}
|
|
42976
42210
|
_updateBatchableMesh(tilingSprite) {
|
|
@@ -42985,7 +42219,6 @@ class TilingSpritePipe {
|
|
|
42985
42219
|
setPositions(tilingSprite, geometry.positions);
|
|
42986
42220
|
}
|
|
42987
42221
|
destroy() {
|
|
42988
|
-
this._managedTilingSprites.destroy();
|
|
42989
42222
|
this._renderer = null;
|
|
42990
42223
|
}
|
|
42991
42224
|
_updateCanBatch(tilingSprite) {
|
|
@@ -43232,7 +42465,6 @@ class BitmapTextGraphics extends Graphics {
|
|
|
43232
42465
|
class BitmapTextPipe {
|
|
43233
42466
|
constructor(renderer) {
|
|
43234
42467
|
this._renderer = renderer;
|
|
43235
|
-
this._managedBitmapTexts = new GCManagedHash({ renderer, type: "renderable", priority: -2, name: "bitmapText" });
|
|
43236
42468
|
}
|
|
43237
42469
|
validateRenderable(bitmapText) {
|
|
43238
42470
|
const graphicsRenderable = this._getGpuBitmapText(bitmapText);
|
|
@@ -43318,7 +42550,6 @@ class BitmapTextPipe {
|
|
|
43318
42550
|
const proxyRenderable = new BitmapTextGraphics();
|
|
43319
42551
|
bitmapText._gpuData[this._renderer.uid] = proxyRenderable;
|
|
43320
42552
|
this._updateContext(bitmapText, proxyRenderable);
|
|
43321
|
-
this._managedBitmapTexts.add(bitmapText);
|
|
43322
42553
|
return proxyRenderable;
|
|
43323
42554
|
}
|
|
43324
42555
|
_updateDistanceField(bitmapText) {
|
|
@@ -43334,9 +42565,7 @@ class BitmapTextPipe {
|
|
|
43334
42565
|
context.customShader.resources.localUniforms.uniforms.uDistance = distance;
|
|
43335
42566
|
}
|
|
43336
42567
|
destroy() {
|
|
43337
|
-
this._managedBitmapTexts.destroy();
|
|
43338
42568
|
this._renderer = null;
|
|
43339
|
-
this._managedBitmapTexts = null;
|
|
43340
42569
|
}
|
|
43341
42570
|
}
|
|
43342
42571
|
/** @ignore */
|
|
@@ -43361,17 +42590,31 @@ function syncWithProxy(container, proxy) {
|
|
|
43361
42590
|
}
|
|
43362
42591
|
|
|
43363
42592
|
class BatchableHTMLText extends BatchableSprite {
|
|
43364
|
-
|
|
43365
|
-
|
|
42593
|
+
/**
|
|
42594
|
+
* Creates an instance of BatchableHTMLText.
|
|
42595
|
+
* @param renderer - The renderer instance to be used.
|
|
42596
|
+
*/
|
|
42597
|
+
constructor(renderer) {
|
|
42598
|
+
super();
|
|
43366
42599
|
this.generatingTexture = false;
|
|
43367
42600
|
this.currentKey = "--";
|
|
42601
|
+
this._renderer = renderer;
|
|
42602
|
+
renderer.runners.resolutionChange.add(this);
|
|
42603
|
+
}
|
|
42604
|
+
/** Handles resolution changes for the HTML text. If the text has auto resolution enabled, it triggers a view update. */
|
|
42605
|
+
resolutionChange() {
|
|
42606
|
+
const text = this.renderable;
|
|
42607
|
+
if (text._autoResolution) {
|
|
42608
|
+
text.onViewUpdate();
|
|
42609
|
+
}
|
|
43368
42610
|
}
|
|
43369
42611
|
/** Destroys the BatchableHTMLText instance. Returns the texture promise to the renderer and cleans up references. */
|
|
43370
42612
|
destroy() {
|
|
42613
|
+
const { htmlText } = this._renderer;
|
|
42614
|
+
htmlText.getReferenceCount(this.currentKey) === null ? htmlText.returnTexturePromise(this.texturePromise) : htmlText.decreaseReferenceCount(this.currentKey);
|
|
42615
|
+
this._renderer.runners.resolutionChange.remove(this);
|
|
43371
42616
|
this.texturePromise = null;
|
|
43372
|
-
this.
|
|
43373
|
-
this.currentKey = "--";
|
|
43374
|
-
super.destroy();
|
|
42617
|
+
this._renderer = null;
|
|
43375
42618
|
}
|
|
43376
42619
|
}
|
|
43377
42620
|
|
|
@@ -43390,21 +42633,6 @@ function updateTextBounds(batchableSprite, text) {
|
|
|
43390
42633
|
class HTMLTextPipe {
|
|
43391
42634
|
constructor(renderer) {
|
|
43392
42635
|
this._renderer = renderer;
|
|
43393
|
-
renderer.runners.resolutionChange.add(this);
|
|
43394
|
-
this._managedTexts = new GCManagedHash({
|
|
43395
|
-
renderer,
|
|
43396
|
-
type: "renderable",
|
|
43397
|
-
onUnload: this.onTextUnload.bind(this),
|
|
43398
|
-
name: "htmlText"
|
|
43399
|
-
});
|
|
43400
|
-
}
|
|
43401
|
-
resolutionChange() {
|
|
43402
|
-
for (const key in this._managedTexts.items) {
|
|
43403
|
-
const text = this._managedTexts.items[key];
|
|
43404
|
-
if (text?._autoResolution) {
|
|
43405
|
-
text.onViewUpdate();
|
|
43406
|
-
}
|
|
43407
|
-
}
|
|
43408
42636
|
}
|
|
43409
42637
|
validateRenderable(htmlText) {
|
|
43410
42638
|
const gpuText = this._getGpuText(htmlText);
|
|
@@ -43462,7 +42690,7 @@ class HTMLTextPipe {
|
|
|
43462
42690
|
return htmlText._gpuData[this._renderer.uid] || this.initGpuText(htmlText);
|
|
43463
42691
|
}
|
|
43464
42692
|
initGpuText(htmlText) {
|
|
43465
|
-
const batchableHTMLText = new BatchableHTMLText();
|
|
42693
|
+
const batchableHTMLText = new BatchableHTMLText(this._renderer);
|
|
43466
42694
|
batchableHTMLText.renderable = htmlText;
|
|
43467
42695
|
batchableHTMLText.transform = htmlText.groupTransform;
|
|
43468
42696
|
batchableHTMLText.texture = Texture.EMPTY;
|
|
@@ -43470,18 +42698,9 @@ class HTMLTextPipe {
|
|
|
43470
42698
|
batchableHTMLText.roundPixels = this._renderer._roundPixels | htmlText._roundPixels;
|
|
43471
42699
|
htmlText._resolution = htmlText._autoResolution ? this._renderer.resolution : htmlText.resolution;
|
|
43472
42700
|
htmlText._gpuData[this._renderer.uid] = batchableHTMLText;
|
|
43473
|
-
this._managedTexts.add(htmlText);
|
|
43474
42701
|
return batchableHTMLText;
|
|
43475
42702
|
}
|
|
43476
|
-
onTextUnload(text) {
|
|
43477
|
-
const gpuData = text._gpuData[this._renderer.uid];
|
|
43478
|
-
if (!gpuData)
|
|
43479
|
-
return;
|
|
43480
|
-
const { htmlText } = this._renderer;
|
|
43481
|
-
htmlText.getReferenceCount(gpuData.currentKey) === null ? htmlText.returnTexturePromise(gpuData.texturePromise) : htmlText.decreaseReferenceCount(gpuData.currentKey);
|
|
43482
|
-
}
|
|
43483
42703
|
destroy() {
|
|
43484
|
-
this._managedTexts.destroy();
|
|
43485
42704
|
this._renderer = null;
|
|
43486
42705
|
}
|
|
43487
42706
|
}
|
|
@@ -43789,25 +43008,33 @@ HTMLTextSystem.extension = {
|
|
|
43789
43008
|
};
|
|
43790
43009
|
|
|
43791
43010
|
class BatchableText extends BatchableSprite {
|
|
43792
|
-
}
|
|
43793
|
-
|
|
43794
|
-
class CanvasTextPipe {
|
|
43795
43011
|
constructor(renderer) {
|
|
43012
|
+
super();
|
|
43796
43013
|
this._renderer = renderer;
|
|
43797
43014
|
renderer.runners.resolutionChange.add(this);
|
|
43798
|
-
this._managedTexts = new GCManagedHash({
|
|
43799
|
-
renderer,
|
|
43800
|
-
type: "renderable",
|
|
43801
|
-
onUnload: this.onTextUnload.bind(this),
|
|
43802
|
-
name: "canvasText"
|
|
43803
|
-
});
|
|
43804
43015
|
}
|
|
43805
43016
|
resolutionChange() {
|
|
43806
|
-
|
|
43807
|
-
|
|
43808
|
-
|
|
43809
|
-
|
|
43017
|
+
const text = this.renderable;
|
|
43018
|
+
if (text._autoResolution) {
|
|
43019
|
+
text.onViewUpdate();
|
|
43020
|
+
}
|
|
43021
|
+
}
|
|
43022
|
+
destroy() {
|
|
43023
|
+
const { canvasText } = this._renderer;
|
|
43024
|
+
const refCount = canvasText.getReferenceCount(this.currentKey);
|
|
43025
|
+
if (refCount > 0) {
|
|
43026
|
+
canvasText.decreaseReferenceCount(this.currentKey);
|
|
43027
|
+
} else if (this.texture) {
|
|
43028
|
+
canvasText.returnTexture(this.texture);
|
|
43810
43029
|
}
|
|
43030
|
+
this._renderer.runners.resolutionChange.remove(this);
|
|
43031
|
+
this._renderer = null;
|
|
43032
|
+
}
|
|
43033
|
+
}
|
|
43034
|
+
|
|
43035
|
+
class CanvasTextPipe {
|
|
43036
|
+
constructor(renderer) {
|
|
43037
|
+
this._renderer = renderer;
|
|
43811
43038
|
}
|
|
43812
43039
|
validateRenderable(text) {
|
|
43813
43040
|
const gpuText = this._getGpuText(text);
|
|
@@ -43824,7 +43051,6 @@ class CanvasTextPipe {
|
|
|
43824
43051
|
this._updateGpuText(text);
|
|
43825
43052
|
}
|
|
43826
43053
|
text._didTextUpdate = false;
|
|
43827
|
-
updateTextBounds(batchableText, text);
|
|
43828
43054
|
}
|
|
43829
43055
|
this._renderer.renderPipes.batch.addToBatch(batchableText, instructionSet);
|
|
43830
43056
|
}
|
|
@@ -43840,35 +43066,22 @@ class CanvasTextPipe {
|
|
|
43840
43066
|
text._resolution = text._autoResolution ? this._renderer.resolution : text.resolution;
|
|
43841
43067
|
batchableText.texture = this._renderer.canvasText.getManagedTexture(text);
|
|
43842
43068
|
batchableText.currentKey = text.styleKey;
|
|
43069
|
+
updateTextBounds(batchableText, text);
|
|
43843
43070
|
}
|
|
43844
43071
|
_getGpuText(text) {
|
|
43845
43072
|
return text._gpuData[this._renderer.uid] || this.initGpuText(text);
|
|
43846
43073
|
}
|
|
43847
43074
|
initGpuText(text) {
|
|
43848
|
-
const batchableText = new BatchableText();
|
|
43075
|
+
const batchableText = new BatchableText(this._renderer);
|
|
43849
43076
|
batchableText.currentKey = "--";
|
|
43850
43077
|
batchableText.renderable = text;
|
|
43851
43078
|
batchableText.transform = text.groupTransform;
|
|
43852
43079
|
batchableText.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 };
|
|
43853
43080
|
batchableText.roundPixels = this._renderer._roundPixels | text._roundPixels;
|
|
43854
43081
|
text._gpuData[this._renderer.uid] = batchableText;
|
|
43855
|
-
this._managedTexts.add(text);
|
|
43856
43082
|
return batchableText;
|
|
43857
43083
|
}
|
|
43858
|
-
onTextUnload(text) {
|
|
43859
|
-
const gpuData = text._gpuData[this._renderer.uid];
|
|
43860
|
-
if (!gpuData)
|
|
43861
|
-
return;
|
|
43862
|
-
const { canvasText } = this._renderer;
|
|
43863
|
-
const refCount = canvasText.getReferenceCount(gpuData.currentKey);
|
|
43864
|
-
if (refCount > 0) {
|
|
43865
|
-
canvasText.decreaseReferenceCount(gpuData.currentKey);
|
|
43866
|
-
} else if (gpuData.texture) {
|
|
43867
|
-
canvasText.returnTexture(gpuData.texture);
|
|
43868
|
-
}
|
|
43869
|
-
}
|
|
43870
43084
|
destroy() {
|
|
43871
|
-
this._managedTexts.destroy();
|
|
43872
43085
|
this._renderer = null;
|
|
43873
43086
|
}
|
|
43874
43087
|
}
|