shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextPipe = function(global, require, module, exports) { global = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions"); var GCManagedHash = require("module$node_modules$pixi_DOT_js$lib$utils$data$GCManagedHash"), updateTextBounds = require("module$node_modules$pixi_DOT_js$lib$scene$text$utils$updateTextBounds"), BatchableText = require("module$node_modules$pixi_DOT_js$lib$scene$text$canvas$BatchableText"); "use strict"; class CanvasTextPipe { constructor(renderer) { this._renderer = renderer; renderer.runners.resolutionChange.add(this); this._managedTexts = new GCManagedHash.GCManagedHash({renderer, type:"renderable", onUnload:this.onTextUnload.bind(this), name:"canvasText"}); } resolutionChange() { for (const key in this._managedTexts.items) { const text = this._managedTexts.items[key]; if (text?._autoResolution) { text.onViewUpdate(); } } } validateRenderable(text) { return this._getGpuText(text).currentKey !== text.styleKey ? !0 : text._didTextUpdate; } addRenderable(text, instructionSet) { const batchableText = this._getGpuText(text); if (text._didTextUpdate) { const resolution = text._autoResolution ? this._renderer.resolution : text.resolution; batchableText.currentKey === text.styleKey && text._resolution === resolution || this._updateGpuText(text); text._didTextUpdate = !1; updateTextBounds.updateTextBounds(batchableText, text); } this._renderer.renderPipes.batch.addToBatch(batchableText, instructionSet); } updateRenderable(text) { text = this._getGpuText(text); text._batcher.updateElement(text); } _updateGpuText(text) { const batchableText = this._getGpuText(text); batchableText.texture && this._renderer.canvasText.decreaseReferenceCount(batchableText.currentKey); text._resolution = text._autoResolution ? this._renderer.resolution : text.resolution; batchableText.texture = this._renderer.canvasText.getManagedTexture(text); batchableText.currentKey = text.styleKey; } _getGpuText(text) { return text._gpuData[this._renderer.uid] || this.initGpuText(text); } initGpuText(text) { const batchableText = new BatchableText.BatchableText(); batchableText.currentKey = "--"; batchableText.renderable = text; batchableText.transform = text.groupTransform; batchableText.bounds = {minX:0, maxX:1, minY:0, maxY:0}; batchableText.roundPixels = this._renderer._roundPixels | text._roundPixels; text._gpuData[this._renderer.uid] = batchableText; this._managedTexts.add(text); return batchableText; } onTextUnload(text) { if (text = text._gpuData[this._renderer.uid]) { var {canvasText} = this._renderer; 0 < canvasText.getReferenceCount(text.currentKey) ? canvasText.decreaseReferenceCount(text.currentKey) : text.texture && canvasText.returnTexture(text.texture); } } destroy() { this._managedTexts.destroy(); this._renderer = null; } } CanvasTextPipe.extension = {type:[global.ExtensionType.WebGLPipes, global.ExtensionType.WebGPUPipes, global.ExtensionType.CanvasPipes], name:"text"}; exports.CanvasTextPipe = CanvasTextPipe; }; //# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextPipe.js.map