mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 06:01:12 +00:00
Draw a black background behind the rendering
This commit is contained in:
@@ -376,6 +376,11 @@ bool DXVA2Renderer::initialize(SDL_Window* window, int videoFormat, int width, i
|
|||||||
|
|
||||||
m_Device = SDL_RenderGetD3D9Device(m_SdlRenderer);
|
m_Device = SDL_RenderGetD3D9Device(m_SdlRenderer);
|
||||||
|
|
||||||
|
// Draw a black frame until the video stream starts rendering
|
||||||
|
SDL_SetRenderDrawColor(m_SdlRenderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||||
|
SDL_RenderClear(m_SdlRenderer);
|
||||||
|
SDL_RenderPresent(m_SdlRenderer);
|
||||||
|
|
||||||
RtlZeroMemory(&m_Desc, sizeof(m_Desc));
|
RtlZeroMemory(&m_Desc, sizeof(m_Desc));
|
||||||
m_Desc.SampleWidth = m_VideoWidth;
|
m_Desc.SampleWidth = m_VideoWidth;
|
||||||
m_Desc.SampleHeight = m_VideoHeight;
|
m_Desc.SampleHeight = m_VideoHeight;
|
||||||
@@ -457,9 +462,6 @@ void DXVA2Renderer::renderFrame(AVFrame* frame)
|
|||||||
|
|
||||||
bltParams.TargetFrame = m_FrameIndex++;
|
bltParams.TargetFrame = m_FrameIndex++;
|
||||||
bltParams.TargetRect = sample.DstRect;
|
bltParams.TargetRect = sample.DstRect;
|
||||||
bltParams.BackgroundColor.Y = 0x1000;
|
|
||||||
bltParams.BackgroundColor.Cb = 0x8000;
|
|
||||||
bltParams.BackgroundColor.Cr = 0x8000;
|
|
||||||
bltParams.BackgroundColor.Alpha = 0xFFFF;
|
bltParams.BackgroundColor.Alpha = 0xFFFF;
|
||||||
|
|
||||||
bltParams.DestFormat.SampleFormat = DXVA2_SampleProgressiveFrame;
|
bltParams.DestFormat.SampleFormat = DXVA2_SampleProgressiveFrame;
|
||||||
@@ -471,11 +473,22 @@ void DXVA2Renderer::renderFrame(AVFrame* frame)
|
|||||||
|
|
||||||
bltParams.Alpha = DXVA2_Fixed32OpaqueAlpha();
|
bltParams.Alpha = DXVA2_Fixed32OpaqueAlpha();
|
||||||
|
|
||||||
|
hr = m_Device->Clear(0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 0, 0, 0), 0.0f, 0);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Clear() failed: %x",
|
||||||
|
hr);
|
||||||
|
av_frame_free(&frame);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
hr = m_Processor->VideoProcessBlt(m_RenderTarget, &bltParams, &sample, 1, nullptr);
|
hr = m_Processor->VideoProcessBlt(m_RenderTarget, &bltParams, &sample, 1, nullptr);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"VideoProcessBlt() failed: %x",
|
"VideoProcessBlt() failed: %x",
|
||||||
hr);
|
hr);
|
||||||
|
av_frame_free(&frame);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Device->Present(nullptr, nullptr, nullptr, nullptr);
|
m_Device->Present(nullptr, nullptr, nullptr, nullptr);
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ bool SdlRenderer::initialize(SDL_Window* window,
|
|||||||
// logical rendering surface size is equal to the stream size
|
// logical rendering surface size is equal to the stream size
|
||||||
SDL_RenderSetLogicalSize(m_Renderer, width, height);
|
SDL_RenderSetLogicalSize(m_Renderer, width, height);
|
||||||
|
|
||||||
|
// Draw a black frame until the video stream starts rendering
|
||||||
|
SDL_SetRenderDrawColor(m_Renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||||
|
SDL_RenderClear(m_Renderer);
|
||||||
|
SDL_RenderPresent(m_Renderer);
|
||||||
|
|
||||||
m_Texture = SDL_CreateTexture(m_Renderer,
|
m_Texture = SDL_CreateTexture(m_Renderer,
|
||||||
SDL_PIXELFORMAT_YV12,
|
SDL_PIXELFORMAT_YV12,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
|
|||||||
Reference in New Issue
Block a user