mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-02 22:06:14 +00:00
Use hasFrameFormatChanged() in SDLRenderer
This commit is contained in:
@@ -17,7 +17,6 @@ SdlRenderer::SdlRenderer()
|
|||||||
m_VideoFormat(0),
|
m_VideoFormat(0),
|
||||||
m_Renderer(nullptr),
|
m_Renderer(nullptr),
|
||||||
m_Texture(nullptr),
|
m_Texture(nullptr),
|
||||||
m_ColorSpace(-1),
|
|
||||||
m_NeedsYuvToRgbConversion(false),
|
m_NeedsYuvToRgbConversion(false),
|
||||||
m_SwsContext(nullptr),
|
m_SwsContext(nullptr),
|
||||||
m_RgbFrame(av_frame_alloc()),
|
m_RgbFrame(av_frame_alloc()),
|
||||||
@@ -286,11 +285,8 @@ ReadbackRetry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because the specific YUV color conversion shader is established at
|
// Recreate the texture if the frame format or size changes
|
||||||
// texture creation for most SDL render backends, we need to recreate
|
if (hasFrameFormatChanged(frame)) {
|
||||||
// the texture when the colorspace changes.
|
|
||||||
int colorspace = getFrameColorspace(frame);
|
|
||||||
if (colorspace != m_ColorSpace) {
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
if (m_CudaGLHelper != nullptr) {
|
if (m_CudaGLHelper != nullptr) {
|
||||||
delete m_CudaGLHelper;
|
delete m_CudaGLHelper;
|
||||||
@@ -302,17 +298,6 @@ ReadbackRetry:
|
|||||||
SDL_DestroyTexture(m_Texture);
|
SDL_DestroyTexture(m_Texture);
|
||||||
m_Texture = nullptr;
|
m_Texture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ColorSpace = colorspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recreate the texture if the frame changed in size
|
|
||||||
if (m_Texture != nullptr) {
|
|
||||||
int width, height;
|
|
||||||
if (SDL_QueryTexture(m_Texture, nullptr, nullptr, &width, &height) == 0 && (frame->width != width || frame->height != height)) {
|
|
||||||
SDL_DestroyTexture(m_Texture);
|
|
||||||
m_Texture = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Texture == nullptr) {
|
if (m_Texture == nullptr) {
|
||||||
@@ -400,7 +385,7 @@ ReadbackRetry:
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// SDL will perform YUV conversion on the GPU
|
// SDL will perform YUV conversion on the GPU
|
||||||
switch (colorspace)
|
switch (getFrameColorspace(frame))
|
||||||
{
|
{
|
||||||
case COLORSPACE_REC_709:
|
case COLORSPACE_REC_709:
|
||||||
SDL_assert(!isFrameFullRange(frame));
|
SDL_assert(!isFrameFullRange(frame));
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ private:
|
|||||||
int m_VideoFormat;
|
int m_VideoFormat;
|
||||||
SDL_Renderer* m_Renderer;
|
SDL_Renderer* m_Renderer;
|
||||||
SDL_Texture* m_Texture;
|
SDL_Texture* m_Texture;
|
||||||
int m_ColorSpace;
|
|
||||||
SDL_Texture* m_OverlayTextures[Overlay::OverlayMax];
|
SDL_Texture* m_OverlayTextures[Overlay::OverlayMax];
|
||||||
SDL_Rect m_OverlayRects[Overlay::OverlayMax];
|
SDL_Rect m_OverlayRects[Overlay::OverlayMax];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user