initial commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
shadow$provide.module$node_modules$pixi_DOT_js$lib$utils$data$GCManagedHash = function(global, require, module, exports) {
|
||||
class GCManagedHash {
|
||||
constructor(options) {
|
||||
this.items = Object.create(null);
|
||||
const {renderer, type, onUnload, priority, name} = options;
|
||||
this._renderer = renderer;
|
||||
renderer.gc.addResourceHash(this, "items", type, priority ?? 0);
|
||||
this._onUnload = onUnload;
|
||||
this.name = name;
|
||||
}
|
||||
add(item) {
|
||||
if (this.items[item.uid]) {
|
||||
return !1;
|
||||
}
|
||||
this.items[item.uid] = item;
|
||||
item.once("unload", this.remove, this);
|
||||
item._gcLastUsed = this._renderer.gc.now;
|
||||
return !0;
|
||||
}
|
||||
remove(item, ...args) {
|
||||
if (this.items[item.uid]) {
|
||||
var gpuData = item._gpuData[this._renderer.uid];
|
||||
gpuData && (this._onUnload?.(item, ...args), gpuData.destroy(), item._gpuData[this._renderer.uid] = null, this.items[item.uid] = null);
|
||||
}
|
||||
}
|
||||
removeAll(...args) {
|
||||
Object.values(this.items).forEach(item => item && this.remove(item, ...args));
|
||||
}
|
||||
destroy(...args) {
|
||||
this.removeAll(...args);
|
||||
this.items = Object.create(null);
|
||||
this._onUnload = this._renderer = null;
|
||||
}
|
||||
}
|
||||
exports.GCManagedHash = GCManagedHash;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$utils$data$GCManagedHash.js.map
|
||||
Reference in New Issue
Block a user