Bug 1278199 - Reset viewport offset on SetDimensions and clamp to MAX_VIEWPORT_DIMS. r=jgilbert, a=jcristau
authorkvark <kvark@mozilla.com>
Tue, 10 Jan 2017 14:15:00 -0500
changeset 353611 d306f88dfd3a8701053073ae78d435d06e907d9c
parent 353610 e3034da75775f82574d9e275ec8cedf552d1d9be
child 353612 0180268319601dab3aabe44bd388567c356350fb
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, jcristau
bugs1278199
milestone52.0a2
Bug 1278199 - Reset viewport offset on SetDimensions and clamp to MAX_VIEWPORT_DIMS. r=jgilbert, a=jcristau
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLContextValidate.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1074,16 +1074,17 @@ WebGLContext::SetDimensions(int32_t sign
     mOptions.antialias = gl->Caps().antialias;
 
     //////
     // Initial setup.
 
     MakeContextCurrent();
 
     gl->fViewport(0, 0, mWidth, mHeight);
+    mViewportX = mViewportY = 0;
     mViewportWidth = mWidth;
     mViewportHeight = mHeight;
 
     gl->fScissor(0, 0, mWidth, mHeight);
     gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
 
     //////
     // Check everything
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1441,16 +1441,18 @@ protected:
 
     // What is supported:
     uint32_t mGLMaxColorAttachments;
     uint32_t mGLMaxDrawBuffers;
     // What we're allowing:
     uint32_t mImplMaxColorAttachments;
     uint32_t mImplMaxDrawBuffers;
 
+    uint32_t mImplMaxViewportDims[2];
+
 public:
     GLenum LastColorAttachmentEnum() const {
         return LOCAL_GL_COLOR_ATTACHMENT0 + mImplMaxColorAttachments - 1;
     }
 
     const decltype(mOptions)& Options() const { return mOptions; }
 
 protected:
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -2135,16 +2135,19 @@ void
 WebGLContext::Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
 {
     if (IsContextLost())
         return;
 
     if (width < 0 || height < 0)
         return ErrorInvalidValue("viewport: negative size");
 
+    width = std::min(width, (GLsizei)mImplMaxViewportDims[0]);
+    height = std::min(height, (GLsizei)mImplMaxViewportDims[1]);
+
     MakeContextCurrent();
     gl->fViewport(x, y, width, height);
 
     mViewportX = x;
     mViewportY = y;
     mViewportWidth = width;
     mViewportHeight = height;
 }
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -568,16 +568,18 @@ WebGLContext::InitAndValidateGL(FailureR
     }
 
     mBound2DTextures.SetLength(mGLMaxTextureUnits);
     mBoundCubeMapTextures.SetLength(mGLMaxTextureUnits);
     mBound3DTextures.SetLength(mGLMaxTextureUnits);
     mBound2DArrayTextures.SetLength(mGLMaxTextureUnits);
     mBoundSamplers.SetLength(mGLMaxTextureUnits);
 
+    gl->fGetIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, (GLint*)mImplMaxViewportDims);
+
     ////////////////
 
     if (MinCapabilityMode()) {
         mImplMaxTextureSize = MINVALUE_GL_MAX_TEXTURE_SIZE;
         mImplMaxCubeMapTextureSize = MINVALUE_GL_MAX_CUBE_MAP_TEXTURE_SIZE;
         mImplMaxRenderbufferSize = MINVALUE_GL_MAX_RENDERBUFFER_SIZE;
 
         mImplMax3DTextureSize = MINVALUE_GL_MAX_3D_TEXTURE_SIZE;