Files
il/resources/public/js/cljs-runtime/module$node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor.js
2026-07-01 22:38:29 -06:00

79 lines
6.7 KiB
JavaScript

shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor = function(global, require, module, exports) {
global = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions");
var groupD8 = require("module$node_modules$pixi_DOT_js$lib$maths$matrix$groupD8");
module = require("module$node_modules$pixi_DOT_js$lib$maths$matrix$Matrix");
var getGlobalMixin = require("module$node_modules$pixi_DOT_js$lib$scene$container$container_mixins$getGlobalMixin"), multiplyHexColors = require("module$node_modules$pixi_DOT_js$lib$scene$container$utils$multiplyHexColors"), canvasUtils = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$canvas$utils$canvasUtils");
"use strict";
const node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor$classdecl$var29 = class {
static _getPatternRepeat(addressModeU, addressModeV) {
addressModeU = addressModeU && "clamp-to-edge" !== addressModeU;
addressModeV = addressModeV && "clamp-to-edge" !== addressModeV;
return addressModeU && addressModeV ? "repeat" : addressModeU ? "repeat-x" : addressModeV ? "repeat-y" : "no-repeat";
}
start(batchPipe, geometry, shader) {
}
execute(batchPipe, batch) {
const elements = batch.elements;
if (elements && elements.length) {
batchPipe = batchPipe.renderer;
var contextSystem = batchPipe.canvasContext, context = contextSystem.activeContext;
for (let i = 0; i < elements.length; i++) {
var element = elements[i];
if (!element.packAsQuad) {
continue;
}
var quad = element, source = (element = quad.texture) ? canvasUtils.canvasUtils.getCanvasSource(element) : null;
if (!source) {
continue;
}
var textureStyle = element.source.style, smoothProperty = contextSystem.smoothProperty, shouldSmooth = "nearest" !== textureStyle.scaleMode;
context[smoothProperty] !== shouldSmooth && (context[smoothProperty] = shouldSmooth);
contextSystem.setBlendMode(batch.blendMode);
smoothProperty = batchPipe.globalUniforms.globalUniformData?.worldColor ?? 4294967295;
shouldSmooth = quad.color;
var alpha = (smoothProperty >>> 24 & 255) / 255 * ((shouldSmooth >>> 24 & 255) / 255) * (batchPipe.filter?.alphaMultiplier ?? 1);
if (0 >= alpha) {
continue;
}
context.globalAlpha = alpha;
var tint = getGlobalMixin.bgr2rgb(multiplyHexColors.multiplyHexColors(shouldSmooth & 16777215, smoothProperty & 16777215)), frame = element.frame, repeat = node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor$classdecl$var29._getPatternRepeat(textureStyle.addressModeU ?? textureStyle.addressMode, textureStyle.addressModeV ?? textureStyle.addressMode);
textureStyle = element.source._resolution ?? element.source.resolution ?? 1;
smoothProperty = quad.renderable?.renderGroup?.isCachedAsTexture;
var sx = frame.x * textureStyle;
const sy = frame.y * textureStyle, sw = frame.width * textureStyle, sh = frame.height * textureStyle;
textureStyle = quad.bounds;
shouldSmooth = batchPipe.renderTarget.renderTarget.isRoot;
alpha = textureStyle.minX;
var dy = textureStyle.minY;
const dw = textureStyle.maxX - textureStyle.minX, dh = textureStyle.maxY - textureStyle.minY, rotate = element.rotate;
textureStyle = element.uvs;
var uvMin = Math.min(textureStyle.x0, textureStyle.x1, textureStyle.x2, textureStyle.x3, textureStyle.y0, textureStyle.y1, textureStyle.y2, textureStyle.y3), uvMax = Math.max(textureStyle.x0, textureStyle.x1, textureStyle.x2, textureStyle.x3, textureStyle.y0, textureStyle.y1, textureStyle.y2, textureStyle.y3);
uvMin = "no-repeat" !== repeat && (0 > uvMin || 1 < uvMax);
uvMax = !uvMin && (16777215 !== tint || rotate);
(uvMax = rotate && !uvMax) ? (node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor$classdecl$var29._tempPatternMatrix.copyFrom(quad.transform), groupD8.groupD8.matrixAppendRotationInv(node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor$classdecl$var29._tempPatternMatrix, rotate, alpha, dy, dw, dh), contextSystem.setContextTransform(node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor$classdecl$var29._tempPatternMatrix, 1 === quad.roundPixels,
void 0, smoothProperty && shouldSmooth)) : contextSystem.setContextTransform(quad.transform, 1 === quad.roundPixels, void 0, smoothProperty && shouldSmooth);
smoothProperty = dw;
shouldSmooth = dh;
alpha = uvMax ? 0 : alpha;
dy = uvMax ? 0 : dy;
uvMax || 1 !== quad.roundPixels || (alpha |= 0, dy |= 0);
if (uvMin) {
if (quad = frame.width <= element.source.width && frame.height <= element.source.height, 16777215 !== tint && !rotate && quad && (source = canvasUtils.canvasUtils.getTintedCanvas({texture:element}, tint)), source = context.createPattern(source, repeat)) {
tint = smoothProperty, quad = shouldSmooth, 0 !== tint && 0 !== quad && (tint = 1 / tint, repeat = 1 / quad, quad = (textureStyle.x1 - textureStyle.x0) * tint, tint *= textureStyle.y1 - textureStyle.y0, frame = (textureStyle.x3 - textureStyle.x0) * repeat, repeat *= textureStyle.y3 - textureStyle.y0, sx = element.source.pixelWidth, element = element.source.pixelHeight, node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor$classdecl$var29._tempPatternMatrix.set(quad *
sx, tint * element, frame * sx, repeat * element, (textureStyle.x0 - quad * alpha - frame * dy) * sx, (textureStyle.y0 - tint * alpha - repeat * dy) * element), canvasUtils.canvasUtils.applyPatternTransform(source, node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor$classdecl$var29._tempPatternMatrix), context.fillStyle = source, context.fillRect(alpha, dy, smoothProperty, shouldSmooth));
}
} else {
element = 16777215 !== tint || rotate ? canvasUtils.canvasUtils.getTintedCanvas({texture:element}, tint) : source, textureStyle = element !== source, context.drawImage(element, textureStyle ? 0 : sx, textureStyle ? 0 : sy, textureStyle ? element.width : sw, textureStyle ? element.height : sh, alpha, dy, smoothProperty, shouldSmooth);
}
}
}
}
};
require = node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor$classdecl$var29;
require._tempPatternMatrix = new module.Matrix();
require.extension = {type:[global.ExtensionType.CanvasPipesAdaptor], name:"batch"};
exports.CanvasBatchAdaptor = require;
};
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$batcher$canvas$CanvasBatchAdaptor.js.map