shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$text_bitmap$AbstractBitmapTextPipe = function(global, require, module, exports) { function syncWithProxy(container, proxy) { proxy.groupTransform = container.groupTransform; proxy.groupColorAlpha = container.groupColorAlpha; proxy.groupColor = container.groupColor; proxy.groupBlendMode = container.groupBlendMode; proxy.globalDisplayStatus = container.globalDisplayStatus; proxy.groupTransform = container.groupTransform; proxy.localDisplayStatus = container.localDisplayStatus; proxy.groupAlpha = container.groupAlpha; proxy._roundPixels = container._roundPixels; } var Cache = require("module$node_modules$pixi_DOT_js$lib$assets$cache$Cache"), GCManagedHash = require("module$node_modules$pixi_DOT_js$lib$utils$data$GCManagedHash"); global = require("module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$Graphics"); var CanvasTextMetrics = require("module$node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics"), BitmapFontManager = require("module$node_modules$pixi_DOT_js$lib$scene$text_bitmap$BitmapFontManager"), getBitmapTextLayout = require("module$node_modules$pixi_DOT_js$lib$scene$text_bitmap$utils$getBitmapTextLayout"); "use strict"; class BitmapTextGraphics extends global.Graphics { destroy() { this.context.customShader && this.context.customShader.destroy(); super.destroy(); } } class AbstractBitmapTextPipe { constructor(renderer) { this._renderer = renderer; this._managedBitmapTexts = new GCManagedHash.GCManagedHash({renderer, type:"renderable", priority:-2, name:"bitmapText"}); } validateRenderable(bitmapText) { bitmapText = this._getGpuBitmapText(bitmapText); return this._renderer.renderPipes.graphics.validateRenderable(bitmapText); } addRenderable(bitmapText, instructionSet) { const graphicsRenderable = this._getGpuBitmapText(bitmapText); syncWithProxy(bitmapText, graphicsRenderable); bitmapText._didTextUpdate && (bitmapText._didTextUpdate = !1, this._updateContext(bitmapText, graphicsRenderable)); this._renderer.renderPipes.graphics.addRenderable(graphicsRenderable, instructionSet); graphicsRenderable.context.customShader && this._updateDistanceField(bitmapText); } updateRenderable(bitmapText) { const graphicsRenderable = this._getGpuBitmapText(bitmapText); syncWithProxy(bitmapText, graphicsRenderable); this._renderer.renderPipes.graphics.updateRenderable(graphicsRenderable); graphicsRenderable.context.customShader && this._updateDistanceField(bitmapText); } _updateContext(bitmapText, proxyGraphics) { ({context:proxyGraphics} = proxyGraphics); const bitmapFont = BitmapFontManager.BitmapFontManager.getFont(bitmapText.text, bitmapText._style); proxyGraphics.clear(); if ("none" !== bitmapFont.distanceField.type) { var sdfShader = this.getSdfShader(); sdfShader && !proxyGraphics.customShader && (proxyGraphics.customShader = sdfShader); } var chars = CanvasTextMetrics.CanvasTextMetrics.graphemeSegmenter(bitmapText.text), style = bitmapText._style; sdfShader = bitmapFont.baseLineOffset; chars = getBitmapTextLayout.getBitmapTextLayout(chars, style, bitmapFont, !0); var padding = style.padding, scale = chars.scale, tx = chars.width, ty = chars.height + chars.offsetY; style._stroke && (tx += style._stroke.width / scale, ty += style._stroke.width / scale); proxyGraphics.translate(-bitmapText._anchor._x * tx - padding, -bitmapText._anchor._y * ty - padding).scale(scale, scale); bitmapText = bitmapFont.applyFillAsTint ? style._fill.color : 16777215; tx = bitmapFont.fontMetrics.fontSize; padding = bitmapFont.lineHeight; style.lineHeight && (tx = style.fontSize / scale, padding = style.lineHeight / scale); style = (padding - tx) / 2; 0 > style - bitmapFont.baseLineOffset && (style = 0); for (scale = 0; scale < chars.lines.length; scale++) { tx = chars.lines[scale]; for (ty = 0; ty < tx.charPositions.length; ty++) { const charData = bitmapFont.chars[tx.chars[ty]]; if (charData?.texture) { const texture = charData.texture; proxyGraphics.texture(texture, bitmapText, Math.round(tx.charPositions[ty] + charData.xOffset), Math.round(sdfShader + charData.yOffset + style), texture.orig.width, texture.orig.height); } } sdfShader += padding; } } _getGpuBitmapText(bitmapText) { return bitmapText._gpuData[this._renderer.uid] || this.initGpuText(bitmapText); } initGpuText(bitmapText) { const proxyRenderable = new BitmapTextGraphics(); bitmapText._gpuData[this._renderer.uid] = proxyRenderable; this._updateContext(bitmapText, proxyRenderable); this._managedBitmapTexts.add(bitmapText); return proxyRenderable; } _updateDistanceField(bitmapText) { const context = this._getGpuBitmapText(bitmapText).context, dynamicFont = Cache.Cache.get(`${bitmapText._style.fontFamily}-bitmap`), {a, b, c, d} = bitmapText.groupTransform; context.customShader.resources.localUniforms.uniforms.uDistance = (Math.abs(Math.sqrt(a * a + b * b)) + Math.abs(Math.sqrt(c * c + d * d))) / 2 * dynamicFont.distanceField.range * (1 / (dynamicFont.baseRenderedFontSize / bitmapText._style.fontSize)); } destroy() { this._managedBitmapTexts.destroy(); this._managedBitmapTexts = this._renderer = null; } } exports.AbstractBitmapTextPipe = AbstractBitmapTextPipe; exports.BitmapTextGraphics = BitmapTextGraphics; }; //# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$text_bitmap$AbstractBitmapTextPipe.js.map