Clear the display when tearing down the decoder. This closes #50

This commit is contained in:
Cameron Gutman 2016-05-09 17:02:16 -04:00
parent b236632ce0
commit 68aecaeed5
2 changed files with 10 additions and 0 deletions

View File

@ -116,6 +116,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
void PaintFinished(int32_t result);
void DispatchGetPicture(uint32_t unused);
void DispatchClearDisplay(uint32_t unused);
void PictureReady(int32_t result, PP_VideoPicture picture);
void PaintPicture(void);
void InitializeRenderingSurface(int width, int height);

View File

@ -143,6 +143,11 @@ void MoonlightInstance::VidDecSetup(int videoFormat, int width, int height, int
g_Instance->m_CallbackFactory.NewCallback(&MoonlightInstance::DispatchGetPicture));
}
void MoonlightInstance::DispatchClearDisplay(uint32_t unused) {
glClear(GL_COLOR_BUFFER_BIT);
g_Instance->m_Graphics3D.SwapBuffers(pp::BlockUntilComplete());
}
void MoonlightInstance::DispatchGetPicture(uint32_t unused) {
// Queue the initial GetPicture callback on the main thread
g_Instance->m_VideoDecoder->GetPicture(
@ -156,6 +161,10 @@ void MoonlightInstance::VidDecCleanup(void) {
g_Instance->m_VideoDecoder->Flush(pp::BlockUntilComplete());
delete g_Instance->m_VideoDecoder;
// Clear the current contents of the display
pp::Module::Get()->core()->CallOnMainThread(0,
g_Instance->m_CallbackFactory.NewCallback(&MoonlightInstance::DispatchClearDisplay));
if (g_Instance->m_Texture2DShader.program) {
glDeleteProgram(g_Instance->m_Texture2DShader.program);
g_Instance->m_Texture2DShader.program = 0;