/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/rendering/renderers/gl/texture/uploaders/glUploadVideoResource.ts
48 строк
1 KB
Mat Groves
perf: use texImage2D instead of texSubImage2D for video in Safari (#11867)
03 фев 2026, 17:42
Не верифицирован
03 фев 2026, 17:42
7f78260
Код
Авторство
О чём код?
import { isSafari } from '../../../../../utils/browser/isSafari'; import { glUploadImageResource } from './glUploadImageResource'; import type { VideoSource } from '../../../shared/texture/sources/VideoSource'; import type { GlRenderingContext } from '../../context/GlRenderingContext'; import type { GlTexture } from '../GlTexture'; import type { GLTextureUploader } from './GLTextureUploader'; // In Safari, texImage2D is significantly faster than texSubImage2D for video sources // (see https://github.com/pixijs/pixijs/pull/10383) const defaultForceAllocation = isSafari(); /** @internal */ export const glUploadVideoResource = { id: 'video', upload( source: VideoSource, glTexture: GlTexture, gl: GlRenderingContext, webGLVersion: number, targetOverride?: number, forceAllocation = defaultForceAllocation ) { if (!source.isValid) { const target = targetOverride ?? glTexture.target; gl.texImage2D( target, 0, glTexture.internalFormat, 1, 1, 0, glTexture.format, glTexture.type, null ); return; } glUploadImageResource.upload(source as any, glTexture, gl, webGLVersion, targetOverride, forceAllocation); } } as GLTextureUploader;