pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
1 lines • 5.31 kB
Source Map (JSON)
{"version":3,"file":"ColorMaskPipe.mjs","sources":["../../../../src/rendering/mask/color/ColorMaskPipe.ts"],"sourcesContent":["import { ExtensionType } from '../../../extensions/Extensions';\n\nimport type { Container } from '../../../scene/container/Container';\nimport type { Effect } from '../../../scene/container/Effect';\nimport type { Instruction } from '../../renderers/shared/instructions/Instruction';\nimport type { InstructionSet } from '../../renderers/shared/instructions/InstructionSet';\nimport type { InstructionPipe } from '../../renderers/shared/instructions/RenderPipe';\nimport type { Renderer } from '../../renderers/types';\nimport type { ColorMask } from './ColorMask';\n\n/** @internal */\nexport interface ColorMaskInstruction extends Instruction\n{\n renderPipeId: 'colorMask',\n colorMask: number,\n}\n\n/** @internal */\nexport class ColorMaskPipe implements InstructionPipe<ColorMaskInstruction>\n{\n /** @ignore */\n public static extension = {\n type: [\n ExtensionType.WebGLPipes,\n ExtensionType.WebGPUPipes,\n ExtensionType.CanvasPipes,\n ],\n name: 'colorMask',\n } as const;\n\n private readonly _renderer: Renderer;\n private _colorStack: number[] = [];\n private _colorStackIndex = 0;\n private _currentColor = 0;\n\n constructor(renderer: Renderer)\n {\n this._renderer = renderer;\n }\n\n public buildStart()\n {\n this._colorStack[0] = 0xF;\n this._colorStackIndex = 1;\n this._currentColor = 0xF;\n }\n\n public push(mask: Effect, _container: Container, instructionSet: InstructionSet): void\n {\n const renderer = this._renderer;\n\n renderer.renderPipes.batch.break(instructionSet);\n\n const colorStack = this._colorStack;\n\n colorStack[this._colorStackIndex] = colorStack[this._colorStackIndex - 1] & (mask as ColorMask).mask;\n\n const currentColor = this._colorStack[this._colorStackIndex];\n\n if (currentColor !== this._currentColor)\n {\n this._currentColor = currentColor;\n instructionSet.add({\n renderPipeId: 'colorMask',\n colorMask: currentColor,\n canBundle: false,\n } as ColorMaskInstruction);\n }\n\n this._colorStackIndex++;\n }\n\n public pop(_mask: Effect, _container: Container, instructionSet: InstructionSet): void\n {\n const renderer = this._renderer;\n\n renderer.renderPipes.batch.break(instructionSet);\n\n const colorStack = this._colorStack;\n\n this._colorStackIndex--;\n\n const currentColor = colorStack[this._colorStackIndex - 1];\n\n if (currentColor !== this._currentColor)\n {\n this._currentColor = currentColor;\n\n instructionSet.add({\n renderPipeId: 'colorMask',\n colorMask: currentColor,\n canBundle: false,\n } as ColorMaskInstruction);\n }\n }\n\n public execute(instruction: ColorMaskInstruction)\n {\n const renderer = this._renderer;\n\n renderer.colorMask.setMask(instruction.colorMask);\n }\n\n public destroy()\n {\n this._colorStack = null;\n }\n}\n"],"names":[],"mappings":";;;AAkBO,MAAM,aACb,CAAA;AAAA,EAgBI,YAAY,QACZ,EAAA;AALA,IAAA,IAAA,CAAQ,cAAwB,EAAC,CAAA;AACjC,IAAA,IAAA,CAAQ,gBAAmB,GAAA,CAAA,CAAA;AAC3B,IAAA,IAAA,CAAQ,aAAgB,GAAA,CAAA,CAAA;AAIpB,IAAA,IAAA,CAAK,SAAY,GAAA,QAAA,CAAA;AAAA,GACrB;AAAA,EAEO,UACP,GAAA;AACI,IAAK,IAAA,CAAA,WAAA,CAAY,CAAC,CAAI,GAAA,EAAA,CAAA;AACtB,IAAA,IAAA,CAAK,gBAAmB,GAAA,CAAA,CAAA;AACxB,IAAA,IAAA,CAAK,aAAgB,GAAA,EAAA,CAAA;AAAA,GACzB;AAAA,EAEO,IAAA,CAAK,IAAc,EAAA,UAAA,EAAuB,cACjD,EAAA;AACI,IAAA,MAAM,WAAW,IAAK,CAAA,SAAA,CAAA;AAEtB,IAAS,QAAA,CAAA,WAAA,CAAY,KAAM,CAAA,KAAA,CAAM,cAAc,CAAA,CAAA;AAE/C,IAAA,MAAM,aAAa,IAAK,CAAA,WAAA,CAAA;AAExB,IAAW,UAAA,CAAA,IAAA,CAAK,g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