1 | {"version":3,"file":"BaseRenderTexture.js","sources":["../../src/renderTexture/BaseRenderTexture.ts"],"sourcesContent":["import { Color } from '@pixi/color';\nimport { MIPMAP_MODES, MSAA_QUALITY } from '@pixi/constants';\nimport { Framebuffer } from '../framebuffer/Framebuffer';\nimport { BaseTexture } from '../textures/BaseTexture';\n\nimport type { ColorSource } from '@pixi/color';\nimport type { MaskData } from '../mask/MaskData';\nimport type { IBaseTextureOptions } from '../textures/BaseTexture';\n\nexport interface BaseRenderTexture extends GlobalMixins.BaseRenderTexture, BaseTexture {}\n\n/**\n * A BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it.\n *\n * __Hint__: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded\n * otherwise black rectangles will be drawn instead.\n *\n * A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position\n * and rotation of the given Display Objects is ignored. For example:\n * @example\n * import { autoDetectRenderer, BaseRenderTexture, RenderTexture, Sprite } from 'pixi.js';\n *\n * const renderer = autoDetectRenderer();\n * const baseRenderTexture = new BaseRenderTexture({ width: 800, height: 600 });\n * const renderTexture = new RenderTexture(baseRenderTexture);\n * const sprite = Sprite.from('spinObj_01.png');\n *\n * sprite.position.x = 800 / 2;\n * sprite.position.y = 600 / 2;\n * sprite.anchor.x = 0.5;\n * sprite.anchor.y = 0.5;\n *\n * renderer.render(sprite, { renderTexture });\n *\n * // The Sprite in this case will be rendered using its local transform.\n * // To render this sprite at 0,0 you can clear the transform\n * sprite.setTransform();\n *\n * const baseRenderTexture = new BaseRenderTexture({ width: 100, height: 100 });\n * const renderTexture = new RenderTexture(baseRenderTexture);\n *\n * renderer.render(sprite, { renderTexture }); // Renders to center of RenderTexture\n * @memberof PIXI\n */\nexport class BaseRenderTexture extends BaseTexture\n{\n public _clear: Color;\n public framebuffer: Framebuffer;\n\n /** The data structure for the stencil masks. */\n maskStack: Array<MaskData>;\n\n /** The data structure for the filters. */\n filterStack: Array<any>;\n\n /**\n * @param options\n * @param {number} [options.width=100] - The width of the base render texture.\n * @param {number} [options.height=100] - The height of the base render texture.\n * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.BaseTexture.defaultOptions.scaleMode] - See {@link PIXI.SCALE_MODES}\n * for possible values.\n * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio\n * of the texture being generated.\n * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer.\n */\n constructor(options: IBaseTextureOptions = {})\n {\n if (typeof options === 'number')\n {\n /* eslint-disable prefer-rest-params */\n // Backward compatibility of signature\n const width = arguments[0];\n const height = arguments[1];\n const scaleMode = arguments[2];\n const resolution = arguments[3];\n\n options = { width, height, scaleMode, resolution };\n /* eslint-enable prefer-rest-params */\n }\n\n options.width = options.width || 100;\n options.height = options.height || 100;\n options.multisample ??= MSAA_QUALITY.NONE;\n\n super(null, options);\n\n // Set defaults\n this.mipmap = MIPMAP_MODES.OFF;\n this.valid = true;\n\n this._clear = new Color([0, 0, 0, 0]);\n this.framebuffer = new Framebuffer(this.realWidth, this.realHeight)\n .addColorTexture(0, this);\n this.framebuffer.multisample = options.multisample;\n\n // TODO - could this be added the systems?\n this.maskStack = [];\n this.filterStack = [{}];\n }\n\n /** Color when clearning the texture. */\n set clearColor(value: ColorSource)\n {\n this._clear.setValue(value);\n }\n get clearColor(): ColorSource\n {\n return this._clear.value;\n }\n\n /**\n * Color object when clearning the texture.\n * @readonly\n * @since 7.2.0\n */\n get clear(): Color\n {\n return this._clear;\n }\n\n /**\n * Resizes the BaseRenderTexture.\n * @param desiredWidth - The desired width to resize to.\n * @param desiredHeight - The desired height to resize to.\n */\n resize(desiredWidth: number, desiredHeight: number): void\n {\n this.framebuffer.resize(desiredWidth * this.resolution, desiredHeight * this.resolution);\n this.setRealSize(this.framebuffer.width, this.framebuffer.height);\n }\n\n /**\n * Frees the texture and framebuffer from WebGL memory without destroying this texture object.\n * This means you can still use the texture later which will upload it to GPU\n * memory again.\n * @fires PIXI.BaseTexture#dispose\n */\n dispose(): void\n {\n this.framebuffer.dispose();\n\n super.dispose();\n }\n\n /** Destroys this texture. */\n destroy(): void\n {\n super.destroy();\n\n this.framebuffer.destroyDepthTexture();\n this.framebuffer = null;\n }\n}\n"],"names":["BaseTexture","MSAA_QUALITY","MIPMAP_MODES","Color","Framebuffer"],"mappings":";;;;;;;;;AA4CO,MAAM,0BAA0BA,uBACvC,CAAA;AAAA,EAoBI,WAAA,CAAY,OAA+B,GAAA,EAC3C,EAAA;AACI,IAAI,IAAA,OAAO,YAAY,QACvB,EAAA;AAGI,MAAA,MAAM,QAAQ,SAAU,CAAA,CAAA,CAAA,CAAA;AACxB,MAAA,MAAM,SAAS,SAAU,CAAA,CAAA,CAAA,CAAA;AACzB,MAAA,MAAM,YAAY,SAAU,CAAA,CAAA,CAAA,CAAA;AAC5B,MAAA,MAAM,aAAa,SAAU,CAAA,CAAA,CAAA,CAAA;AAE7B,MAAA,OAAA,GAAU,EAAE,KAAA,EAAO,MAAQ,EAAA,SAAA,EAAW,UAAW,EAAA,CAAA;AAAA,KAErD;AAEA,IAAQ,OAAA,CAAA,KAAA,GAAQ,QAAQ,KAAS,IAAA,GAAA,CAAA;AACjC,IAAQ,OAAA,CAAA,MAAA,GAAS,QAAQ,MAAU,IAAA,GAAA,CAAA;AACnC,IAAQ,OAAA,CAAA,WAAA,KAAA,OAAA,CAAA,WAAA,GAAgBC,sBAAa,CAAA,IAAA,CAAA,CAAA;AAErC,IAAA,KAAA,CAAM,MAAM,OAAO,CAAA,CAAA;AAGnB,IAAA,IAAA,CAAK,SAASC,sBAAa,CAAA,GAAA,CAAA;AAC3B,IAAA,IAAA,CAAK,KAAQ,GAAA,IAAA,CAAA;AAEb,IAAK,IAAA,CAAA,MAAA,GAAS,IAAIC,WAAM,CAAA,CAAC,GAAG,CAAG,EAAA,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA;AACpC,IAAK,IAAA,CAAA,WAAA,G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