Set the graphics context size using the width and height of the stream instead of the initial size of the NaCl element. This closes issue #16

This commit is contained in:
Cameron Gutman 2016-02-25 22:48:22 -05:00
parent 24cf97b0ae
commit e7b45e5b6c
4 changed files with 9 additions and 22 deletions

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" href="static/css/material.min.css">
<link rel="stylesheet" href="static/css/style.css">
</head>
<body data-name="moonlight-chrome" data-width="1280" data-height="720" data-tools="pnacl" data-configs="Debug Release" data-path="{tc}/{config}">
<body data-name="moonlight-chrome" data-tools="pnacl" data-configs="Debug Release" data-path="{tc}/{config}">
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">

View File

@ -175,6 +175,9 @@ void MoonlightInstance::handleStartStream(std::string startStreamMessage) {
m_ServerMajorVersion = 5;
// Initialize the rendering surface before starting the connection
InitializeRenderingSurface(m_StreamConfig.width, m_StreamConfig.height);
// Store the host from the start message
m_Host = splitString.at(1);

View File

@ -76,9 +76,6 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
void OnConnectionStarted(uint32_t error);
void StopConnection();
void DidChangeView(const pp::Rect& position,
const pp::Rect& clip_ignored);
static void* ConnectionThreadFunc(void* context);
static void* GamepadThreadFunc(void* context);
static void* StopThreadFunc(void* context);
@ -97,6 +94,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
void DispatchGetPicture(uint32_t unused);
void PictureReady(int32_t result, PP_VideoPicture picture);
void PaintPicture(void);
void InitializeRenderingSurface(int width, int height);
static void VidDecSetup(int width, int height, int redrawRate, void* context, int drFlags);
static void VidDecCleanup(void);
@ -121,7 +119,6 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
pp::Graphics3D m_Graphics3D;
pp::VideoDecoder* m_VideoDecoder;
pp::Size m_ViewSize;
Shader m_Texture2DShader;
Shader m_RectangleArbShader;
Shader m_ExternalOesShader;

View File

@ -70,20 +70,7 @@ void MoonlightInstance::DidChangeFocus(bool got_focus) {
}
}
void MoonlightInstance::DidChangeView(const pp::Rect& position,
const pp::Rect& clip) {
if (position.width() == 0 || position.height() == 0) {
return;
}
if (m_ViewSize.width()) {
assert(position.size() == m_ViewSize);
return;
}
m_ViewSize = position.size();
printf("View size: %dx%d\n", m_ViewSize.width(), m_ViewSize.height());
void MoonlightInstance::InitializeRenderingSurface(int width, int height) {
if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) {
return;
}
@ -97,8 +84,8 @@ void MoonlightInstance::DidChangeView(const pp::Rect& position,
PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0,
PP_GRAPHICS3DATTRIB_SAMPLES, 0,
PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0,
PP_GRAPHICS3DATTRIB_WIDTH, position.size().width(),
PP_GRAPHICS3DATTRIB_HEIGHT, position.size().height(),
PP_GRAPHICS3DATTRIB_WIDTH, width,
PP_GRAPHICS3DATTRIB_HEIGHT, height,
PP_GRAPHICS3DATTRIB_NONE
};
g_Instance->m_Graphics3D = pp::Graphics3D(this, contextAttributes);
@ -114,7 +101,7 @@ void MoonlightInstance::DidChangeView(const pp::Rect& position,
glDisable(GL_DITHER);
glViewport(0, 0, m_ViewSize.width(), m_ViewSize.height());
glViewport(0, 0, width, height);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);