{"version":3,"file":"PrepareUpload.mjs","sources":["../../src/prepare/PrepareUpload.ts"],"sourcesContent":["import { TextureSource } from '../rendering/renderers/shared/texture/sources/TextureSource';\nimport { GraphicsContext } from '../scene/graphics/shared/GraphicsContext';\nimport { Text } from '../scene/text/Text';\nimport { BitmapText } from '../scene/text-bitmap/BitmapText';\nimport { HTMLText } from '../scene/text-html/HTMLText';\nimport { PrepareQueue } from './PrepareQueue';\n\nimport type { FillInstruction, TextureInstruction } from '../scene/graphics/shared/GraphicsContext';\nimport type { PrepareQueueItem } from './PrepareBase';\n\n/**\n * Part of the prepare system. Responsible for uploading all the items to the GPU.\n * This class extends the resolver functionality and uploads the given queue items.\n * @memberof rendering\n */\nexport abstract class PrepareUpload extends PrepareQueue\n{\n    /**\n     * Upload the given queue item\n     * @param item\n     */\n    protected uploadQueueItem(item: PrepareQueueItem): void\n    {\n        if (item instanceof TextureSource)\n        {\n            this.uploadTextureSource(item);\n        }\n        else if (item instanceof Text)\n        {\n            this.uploadText(item);\n        }\n        else if (item instanceof HTMLText)\n        {\n            this.uploadHTMLText(item);\n        }\n        else if (item instanceof BitmapText)\n        {\n            this.uploadBitmapText(item);\n        }\n        else if (item instanceof GraphicsContext)\n        {\n            this.uploadGraphicsContext(item);\n        }\n    }\n\n    protected uploadTextureSource(textureSource: TextureSource): void\n    {\n        this.renderer.texture.initSource(textureSource);\n    }\n\n    protected uploadText(_text: Text): void\n    {\n        this.renderer.renderPipes.text.initGpuText(_text);\n    }\n\n    protected uploadBitmapText(_text: BitmapText): void\n    {\n        this.renderer.renderPipes.bitmapText.initGpuText(_text);\n    }\n\n    protected uploadHTMLText(_text: HTMLText): void\n    {\n        this.renderer.renderPipes.htmlText.initGpuText(_text);\n    }\n\n    /**\n     * Resolve the given graphics context and return an item for the queue\n     * @param graphicsContext\n     */\n    protected uploadGraphicsContext(graphicsContext: GraphicsContext): void\n    {\n        this.renderer.graphicsContext.getContextRenderData(graphicsContext);\n\n        const { instructions } = graphicsContext;\n\n        for (const instruction of instructions)\n        {\n            if (instruction.action === 'texture')\n            {\n                const { image } = (instruction as TextureInstruction).data;\n\n                this.uploadTextureSource(image.source);\n            }\n            else if (instruction.action === 'fill')\n            {\n                const { texture } = (instruction as FillInstruction).data.style;\n\n                this.uploadTextureSource(texture.source);\n            }\n        }\n\n        return null;\n    }\n}\n"],"names":[],"mappings":";;;;;;;;AAeO,MAAe,sBAAsB,YAC5C,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKc,gBAAgB,IAC1B,EAAA;AACI,IAAA,IAAI,gBAAgB,aACpB,EAAA;AACI,MAAA,IAAA,CAAK,oBAAoB,IAAI,CAAA,CAAA;AAAA,KACjC,MAAA,IACS,gBAAgB,IACzB,EAAA;AACI,MAAA,IAAA,CAAK,WAAW,IAAI,CAAA,CAAA;AAAA,KACxB,MAAA,IACS,gBAAgB,QACzB,EAAA;AACI,MAAA,IAAA,CAAK,eAAe,IAAI,CAAA,CAAA;AAAA,KAC5B,MAAA,IACS,gBAAgB,UACzB,EAAA;AACI,MAAA,IAAA,CAAK,iBAAiB,IAAI,CAAA,CAAA;AAAA,KAC9B,MAAA,IACS,gBAAgB,eACzB,EAAA;AACI,MAAA,IAAA,CAAK,sBAAsB,IAAI,CAAA,CAAA;AAAA,KACnC;AAAA,GACJ;AAAA,EAEU,oBAAoB,aAC9B,EAAA;AACI,IAAK,IAAA,CAAA,QAAA,CAAS,OAAQ,CAAA,UAAA,CAAW,aAAa,CAAA,CAAA;AAAA,GAClD;AAAA,EAEU,WAAW,KACrB,EAAA;AACI,IAAA,IAAA,CAAK,QAAS,CAAA,WAAA,CAAY,IAAK,CAAA,WAAA,CAAY,KAAK,CAAA,CAAA;AAAA,GACpD;AAAA,EAEU,iBAAiB,KAC3B,EAAA;AACI,IAAA,IAAA,CAAK,QAAS,CAAA,WAAA,CAAY,UAAW,CAAA,WAAA,CAAY,KAAK,CAAA,CAAA;AAAA,GAC1D;AAAA,EAEU,eAAe,KACzB,EAAA;AACI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