Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
index 4c2ebadfd568aebe2fd11d95476bb8508c0a495a..a3781a2f04863db3093cf152391bfe0ff80e13e2 100644 |
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
@@ -1136,7 +1136,11 @@ void WebGLRenderingContextBase::initializeNewContext() { |
m_vertexAttribType.resize(m_maxVertexAttribs); |
contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
- contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
+ m_scissorBox[0] = m_scissorBox[1] = 0; |
+ m_scissorBox[2] = drawingBufferWidth(); |
+ m_scissorBox[3] = drawingBufferHeight(); |
+ contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2], |
+ m_scissorBox[3]); |
drawingBuffer()->contextProvider()->setLostContextCallback( |
convertToBaseCallback(WTF::bind( |
@@ -1370,21 +1374,56 @@ WebGLRenderingContextBase::clearIfComposited(GLbitfield mask) { |
return combinedClear ? CombinedClear : JustClear; |
} |
-void WebGLRenderingContextBase::restoreStateAfterClear() { |
+void WebGLRenderingContextBase::restoreStateFromContext(int stateMask) { |
mthiesse
2016/10/04 21:19:17
Rather than a single restoreStateFromContext funct
klausw
2016/10/04 23:08:14
You convinced me, done.
|
if (isContextLost()) |
return; |
- // Restore the state that the context set. |
- if (m_scissorEnabled) |
- contextGL()->Enable(GL_SCISSOR_TEST); |
- contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], |
- m_clearColor[3]); |
- contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], |
- m_colorMask[3]); |
- contextGL()->ClearDepthf(m_clearDepth); |
- contextGL()->ClearStencil(m_clearStencil); |
- contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); |
- contextGL()->DepthMask(m_depthMask); |
+ if (stateMask & StateScissorEnabled) { |
+ if (m_scissorEnabled) { |
+ contextGL()->Enable(GL_SCISSOR_TEST); |
+ } else { |
+ contextGL()->Disable(GL_SCISSOR_TEST); |
+ } |
+ } |
+ |
+ if (stateMask & StateScissorBox) { |
+ contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2], |
+ m_scissorBox[3]); |
+ } |
+ |
+ if (stateMask & StateClearColor) { |
+ contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], |
+ m_clearColor[3]); |
+ } |
+ |
+ if (stateMask & StateColorMask) { |
+ contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], |
+ m_colorMask[3]); |
+ } |
+ |
+ if (stateMask & StateClearDepthf) { |
+ contextGL()->ClearDepthf(m_clearDepth); |
+ } |
+ |
+ if (stateMask & StateClearStencil) { |
+ contextGL()->ClearStencil(m_clearStencil); |
+ } |
+ |
+ if (stateMask & StateStencilMaskSeparate) { |
+ contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); |
+ } |
+ |
+ if (stateMask & StateDepthMask) { |
+ contextGL()->DepthMask(m_depthMask); |
+ } |
+} |
+ |
+void WebGLRenderingContextBase::restoreStateAfterClear() { |
+ // Restore clear-related state items back to what the context had set. |
+ restoreStateFromContext(StateScissorEnabled | StateClearColor | |
+ StateColorMask | StateClearDepthf | |
+ StateClearStencil | StateStencilMaskSeparate | |
+ StateDepthMask); |
} |
void WebGLRenderingContextBase::markLayerComposited() { |
@@ -4156,6 +4195,10 @@ void WebGLRenderingContextBase::scissor(GLint x, |
GLsizei height) { |
if (isContextLost()) |
return; |
+ m_scissorBox[0] = x; |
+ m_scissorBox[1] = y; |
+ m_scissorBox[2] = width; |
+ m_scissorBox[3] = height; |
contextGL()->Scissor(x, y, width, height); |
} |