mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-02-16 02:30:52 +00:00
Handle colorspace changes in SDL renderer
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ private:
|
||||
SDL_Renderer* m_Renderer;
|
||||
SDL_Texture* m_Texture;
|
||||
enum AVPixelFormat m_SwPixelFormat;
|
||||
enum AVColorSpace m_ColorSpace;
|
||||
bool m_MapFrame;
|
||||
SDL_Texture* m_OverlayTextures[Overlay::OverlayMax];
|
||||
SDL_Rect m_OverlayRects[Overlay::OverlayMax];
|
||||
|
||||
Reference in New Issue
Block a user