/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/prepare/PrepareUpload.ts
95 строк
3 KB
Zyie
chore: add standard/advanced tags to documentation (#11448)
03 июн 2025, 10:12
Не верифицирован
03 июн 2025, 10:12
7d91234
Код
Авторство
О чём код?
import { TextureSource } from '../rendering/renderers/shared/texture/sources/TextureSource'; import { GraphicsContext } from '../scene/graphics/shared/GraphicsContext'; import { Text } from '../scene/text/Text'; import { BitmapText } from '../scene/text-bitmap/BitmapText'; import { HTMLText } from '../scene/text-html/HTMLText'; import { PrepareQueue } from './PrepareQueue'; import type { FillInstruction, TextureInstruction } from '../scene/graphics/shared/GraphicsContext'; import type { PrepareQueueItem } from './PrepareBase'; /** * @advanced * Part of the prepare system. Responsible for uploading all the items to the GPU. * This class extends the resolver functionality and uploads the given queue items. * @category rendering */ export abstract class PrepareUpload extends PrepareQueue { /** * Upload the given queue item * @param item */ protected uploadQueueItem(item: PrepareQueueItem): void { if (item instanceof TextureSource) { this.uploadTextureSource(item); } else if (item instanceof Text) { this.uploadText(item); } else if (item instanceof HTMLText) { this.uploadHTMLText(item); } else if (item instanceof BitmapText) { this.uploadBitmapText(item); } else if (item instanceof GraphicsContext) { this.uploadGraphicsContext(item); } } protected uploadTextureSource(textureSource: TextureSource): void { this.renderer.texture.initSource(textureSource); } protected uploadText(_text: Text): void { this.renderer.renderPipes.text.initGpuText(_text); } protected uploadBitmapText(_text: BitmapText): void { this.renderer.renderPipes.bitmapText.initGpuText(_text); } protected uploadHTMLText(_text: HTMLText): void { this.renderer.renderPipes.htmlText.initGpuText(_text); } /** * Resolve the given graphics context and return an item for the queue * @param graphicsContext */ protected uploadGraphicsContext(graphicsContext: GraphicsContext): void { this.renderer.graphicsContext.getGpuContext(graphicsContext); const { instructions } = graphicsContext; for (const instruction of instructions) { if (instruction.action === 'texture') { const { image } = (instruction as TextureInstruction).data; this.uploadTextureSource(image.source); } else if (instruction.action === 'fill') { const { texture } = (instruction as FillInstruction).data.style; this.uploadTextureSource(texture.source); } } return null; } }