From 6c13c9b67d886deff260a3a0c4fc90f97b8cb858 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 9 Jun 2016 13:22:27 -0500 Subject: [PATCH] Only show the NaCl plugin when a frame has been rendered --- static/js/index.js | 1 - static/js/messages.js | 2 ++ viddec.cpp | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/static/js/index.js b/static/js/index.js index d613f39..93c8dad 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -340,7 +340,6 @@ function playGameMode() { $(".mdl-layout__header").hide(); $("#main-content").children().not("#listener, #loadingSpinner").hide(); $("#main-content").addClass("fullscreen"); - $("#listener").addClass("fullscreen"); fullscreenNaclModule(); $("body").css('backgroundColor', 'black'); diff --git a/static/js/messages.js b/static/js/messages.js index 0b93a65..4586396 100644 --- a/static/js/messages.js +++ b/static/js/messages.js @@ -32,6 +32,8 @@ function handleMessage(msg) { $('#loadingMessage').text(msg.data.replace('ProgressMsg: ', '')); } else if(msg.data.indexOf('TransientMsg: ') === 0) { snackbarLog(msg.data.replace('TransientMsg: ', '')); + } else if(msg.data === 'displayVideo') { + $("#listener").addClass("fullscreen"); } } } diff --git a/viddec.cpp b/viddec.cpp index b7b65d8..ca479fc 100644 --- a/viddec.cpp +++ b/viddec.cpp @@ -17,6 +17,7 @@ static unsigned char s_LastSps[256]; static unsigned char s_LastPps[256]; static unsigned int s_LastSpsLength; static unsigned int s_LastPpsLength; +static bool s_FirstFrameDisplayed; static uint64_t s_LastPaintFinishedTime; #define assertNoGLError() assert(!glGetError()) @@ -132,6 +133,7 @@ void MoonlightInstance::VidDecSetup(int videoFormat, int width, int height, int s_LastTextureId = 0; s_LastSpsLength = 0; s_LastPpsLength = 0; + s_FirstFrameDisplayed = false; int32_t err; @@ -407,6 +409,13 @@ void MoonlightInstance::PaintPicture(void) { void MoonlightInstance::PaintFinished(int32_t result) { m_IsPainting = false; + + if (!s_FirstFrameDisplayed) { + // Tell the JS code to display the video stream now + pp::Var response("displayVideo"); + g_Instance->PostMessage(response); + s_FirstFrameDisplayed = true; + } ProfilerPrintDeltaFromNow("Paint -> Paint", s_LastPaintFinishedTime); s_LastPaintFinishedTime = ProfilerGetMillis();