{"version":3,"file":"AbstractMaskSystem.mjs","sources":["../../src/mask/AbstractMaskSystem.ts"],"sourcesContent":["import type { Renderer } from '../Renderer';\nimport type { ISystem } from '../system/ISystem';\nimport type { MaskData } from './MaskData';\n\n/**\n * System plugin to the renderer to manage specific types of masking operations.\n * @memberof PIXI\n */\nexport class AbstractMaskSystem implements ISystem\n{\n    /**\n     * The mask stack\n     * @member {PIXI.MaskData[]}\n     */\n    protected maskStack: Array<MaskData>;\n\n    /**\n     * Constant for gl.enable\n     * @private\n     */\n    protected glConst: number;\n    protected renderer: Renderer;\n\n    /**\n     * @param renderer - The renderer this System works for.\n     */\n    constructor(renderer: Renderer)\n    {\n        this.renderer = renderer;\n\n        this.maskStack = [];\n        this.glConst = 0;\n    }\n\n    /** Gets count of masks of certain type. */\n    getStackLength(): number\n    {\n        return this.maskStack.length;\n    }\n\n    /**\n     * Changes the mask stack that is used by this System.\n     * @param {PIXI.MaskData[]} maskStack - The mask stack\n     */\n    setMaskStack(maskStack: Array<MaskData>): void\n    {\n        const { gl } = this.renderer;\n        const curStackLen = this.getStackLength();\n\n        this.maskStack = maskStack;\n\n        const newStackLen = this.getStackLength();\n\n        if (newStackLen !== curStackLen)\n        {\n            if (newStackLen === 0)\n            {\n                gl.disable(this.glConst);\n            }\n            else\n            {\n                gl.enable(this.glConst);\n                this._useCurrent();\n            }\n        }\n    }\n\n    /**\n     * Setup renderer to use the current mask data.\n     * @private\n     */\n    protected _useCurrent(): void\n    {\n        // OVERWRITE;\n    }\n\n    /** Destroys the mask stack. */\n    destroy(): void\n    {\n        this.renderer = null;\n        this.maskStack = null;\n    }\n}\n"],"names":[],"mappings":"AAQO,MAAM,kBACb,CAAA;AAAA,EAiBI,YAAY,QACZ,EAAA;AACI,IAAA,IAAA,CAAK,QAAW,GAAA,QAAA,CAAA;AAEhB,IAAA,IAAA,CAAK,YAAY,EAAC,CAAA;AAClB,IAAA,IAAA,CAAK,OAAU,GAAA,CAAA,CAAA;AAAA,GACnB;AAAA,EAGA,cACA,GAAA;AACI,IAAA,OAAO,KAAK,SAAU,CAAA,MAAA,CAAA;AAAA,GAC1B;AAAA,EAMA,aAAa,SACb,EAAA;AACI,IAAM,MAAA,EAAE,OAAO,IAAK,CAAA,QAAA,CAAA;AACpB,IAAM,MAAA,WAAA,GAAc,KAAK,cAAe,EAAA,CAAA;AAExC,IAAA,IAAA,CAAK,SAAY,GAAA,SAAA,CAAA;AAEjB,IAAM,MAAA,WAAA,GAAc,KAAK,cAAe,EAAA,CAAA;AAExC,IAAA,IAAI,gBAAgB,WACpB,EAAA;AACI,MAAA,IAAI,gBAAgB,CACpB,EAAA;AACI,QAAG,EAAA,CAAA,OAAA,CAAQ,KAAK,OAAO,CAAA,CAAA;AAAA,OAG3B,MAAA;AACI,QAAG,EAAA,CAAA,MAAA,CAAO,KAAK,OAAO,CAAA,CAAA;AACtB,QAAA,IAAA,CAAK,WAAY,EAAA,CAAA;AAAA,OACrB;AAAA,KACJ;AAAA,GACJ;AAAA,EAMA,WACA,GAAA;AAAA,GAEA;AAAA,EAGA,OACA,GAAA;AACI,IAAA,IAAA,CAAK,QAAW,GAAA,IAAA,CAAA;AAChB,IAAA,IAAA,CAAK,SAAY,GAAA,IAAA,CAAA;AAAA,GACrB;AACJ;;;;"}