From 68aecaeed5139c8d6ad4f4a0cda4b60bd3c1b94f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 9 May 2016 17:02:16 -0400 Subject: [PATCH] Clear the display when tearing down the decoder. This closes #50 --- moonlight.hpp | 1 + viddec.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/moonlight.hpp b/moonlight.hpp index ae38338..dad64d6 100644 --- a/moonlight.hpp +++ b/moonlight.hpp @@ -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); diff --git a/viddec.cpp b/viddec.cpp index f6194eb..3d5ad02 100644 --- a/viddec.cpp +++ b/viddec.cpp @@ -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;