Handle colorspace changes in SDL renderer

This commit is contained in:
Cameron Gutman
2022-01-13 01:16:09 -06:00
parent e555874485
commit abf2a14ee6
2 changed files with 14 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ SdlRenderer::SdlRenderer()
m_Renderer(nullptr),
m_Texture(nullptr),
m_SwPixelFormat(AV_PIX_FMT_NONE),
m_ColorSpace(AVCOL_SPC_UNSPECIFIED),
m_MapFrame(false)
{
SDL_zero(m_OverlayTextures);
@@ -372,6 +373,18 @@ ReadbackRetry:
}
}
// Because the specific YUV color conversion shader is established at
// texture creation for most SDL render backends, we need to recreate
// the texture when the colorspace changes.
if (frame->colorspace != m_ColorSpace && frame->colorspace != AVCOL_SPC_UNSPECIFIED) {
if (m_Texture != nullptr) {
SDL_DestroyTexture(m_Texture);
m_Texture = nullptr;
}
m_ColorSpace = frame->colorspace;
}
if (m_Texture == nullptr) {
Uint32 sdlFormat;