{"version":3,"file":"cacheAsTextureMixin.mjs","sources":["../../../../src/scene/container/container-mixins/cacheAsTextureMixin.ts"],"sourcesContent":["import { deprecation } from '../../../utils/logging/deprecation';\n\nimport type { Container } from '../Container';\nimport type { CacheAsTextureOptions } from '../RenderGroup';\n\n/** @ignore */\nexport interface CacheAsTextureMixinConstructor\n{\n    cacheAsTexture?: (val: boolean | CacheAsTextureOptions) => void;\n}\n\n/**\n * The CacheAsTextureMixin interface provides methods and properties for caching a container as a texture.\n * This can improve rendering performance for complex static containers by allowing them to be rendered as a single texture.\n * It includes methods to enable or disable caching, update the cached texture, and check\n * 1if the container is currently cached.\n * @category scene\n * @advanced\n */\nexport interface CacheAsTextureMixin extends Required<CacheAsTextureMixinConstructor>\n{\n    /**\n     * Caches this container as a texture. This allows the container to be rendered as a single texture,\n     * which can improve performance for complex static containers.\n     * @example\n     * ```ts\n     * // Basic caching\n     * container.cacheAsTexture(true);\n     *\n     * // With custom options\n     * container.cacheAsTexture({\n     *     resolution: 2,\n     *     antialias: true,\n     * });\n     *\n     * // Disable caching\n     * container.cacheAsTexture(false);\n     *\n     * // Cache a complex UI\n     * const ui = new Container();\n     * // Add multiple children...\n     * ui.cacheAsTexture(true);\n     * ui.updateCacheTexture(); // Update if contents change\n     * ```\n     * @param val - If true, enables caching with default options.\n     *             If false, disables caching.\n     *             Can also pass options object to configure caching behavior.\n     * @see {@link Container#updateCacheTexture} For updating cached content\n     * @see {@link Container#isCachedAsTexture} For checking cache state\n     */\n    cacheAsTexture: (val: boolean | CacheAsTextureOptions) => void;\n\n    /**\n     * Updates the cached texture of this container. This will flag the container's cached texture\n     * to be redrawn on the next render.\n     * @example\n     * ```ts\n     * // Basic update after changes\n     * container.updateCacheTexture();\n     * ```\n     */\n    updateCacheTexture: () => void;\n\n    /**\n     * Legacy property for backwards compatibility with PixiJS v7 and below.\n     * Use `cacheAsTexture` instead.\n     * @deprecated since 8.0.0\n     */\n    cacheAsBitmap: boolean;\n\n    /**\n     * Whether this container is currently cached as a texture.\n     * @example\n     * ```ts\n     * // Check cache state\n     * if (container.isCachedAsTexture) {\n     *     console.log('Container is cached');\n     * }\n     * ```\n     * @readonly\n     * @see {@link Container#cacheAsTexture} For enabling caching\n     * @see {@link Container#updateCacheTexture} For updating cache\n     */\n    readonly isCachedAsTexture: boolean;\n}\n\n/** @internal */\nexport const cacheAsTextureMixin: Partial<Container> = {\n    get isCachedAsTexture(): boolean\n    {\n        return !!this.renderGroup?.isCachedAsTexture;\n    },\n\n    cacheAsTexture(val: boolean | CacheAsTextureOptions): void\n    {\n        if (typeof val === 'boolean' && val === false)\n        {\n            this.disableRenderGroup();\n        }\n        else\n        {\n            this.enableRenderGroup();\n            this.renderGroup.enableCacheAsTexture(val === true ? {} : val);\n        }\n    },\n\n    updateCacheTexture(): void\n    {\n        this.renderGroup?.updateCacheTexture();\n    },\n\n    get cacheAsBitmap(): boolean\n    {\n        return this.isCachedAsTexture;\n    },\n\n    set cacheAsBitmap(val: boolean)\n    {\n        // #if _DEBUG\n        deprecation('v8.6.0', 'cacheAsBitmap is deprecated, use cacheAsTexture instead.');\n        // #endif\n        this.cacheAsTexture(val);\n    },\n} as Container;\n"],"names":[],"mappings":";;;AAuFO,MAAM,mBAAA,GAA0C;AAAA,EACnD,IAAI,iBAAA,GACJ;AACI,IAAA,OAAO,CAAC,CAAC,IAAA,CAAK,WAAA,EAAa,iBAAA;AAAA,EAC/B,CAAA;AAAA,EAEA,eAAe,GAAA,EACf;AACI,IAAA,IAAI,OAAO,GAAA,KAAQ,SAAA,IAAa,GAAA,KAAQ,KAAA,EACxC;AACI,MAAA,IAAA,CAAK,kBAAA,EAAmB;AAAA,IAC5B,CAAA,MAEA;AACI,MAAA,IAAA,CAAK,iBAAA,EAAkB;AACvB,MAAA,IAAA,CAAK,YAAY,oBAAA,CAAqB,GAAA,KAAQ,IAAA,GAAO,KAAK,GAAG,CAAA;AAAA,IACjE;AAAA,EACJ,CAAA;AAAA,EAEA,kBAAA,GACA;AACI,IAAA,IAAA,CAAK,aAAa,kBAAA,EAAmB;AAAA,EACzC,CAAA;AAAA,EAEA,IAAI,aAAA,GACJ;AACI,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EAChB,CAAA;AAAA,EAEA,IAAI,cAAc,GAAA,EAClB;AAEI,IAAA,WAAA,CAAY,UAAU,0DAA0D,CAAA;AAEhF,IAAA,IAAA,CAAK,eAAe,GAAG,CAAA;AAAA,EAC3B;AACJ;;;;"}