Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1129 | 1129 |
| 1130 m_defaultVertexArrayObject = WebGLVertexArrayObject::create( | 1130 m_defaultVertexArrayObject = WebGLVertexArrayObject::create( |
| 1131 this, WebGLVertexArrayObjectBase::VaoTypeDefault); | 1131 this, WebGLVertexArrayObjectBase::VaoTypeDefault); |
| 1132 addContextObject(m_defaultVertexArrayObject.get()); | 1132 addContextObject(m_defaultVertexArrayObject.get()); |
| 1133 | 1133 |
| 1134 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 1134 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 1135 | 1135 |
| 1136 m_vertexAttribType.resize(m_maxVertexAttribs); | 1136 m_vertexAttribType.resize(m_maxVertexAttribs); |
| 1137 | 1137 |
| 1138 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1138 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 1139 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1139 m_scissorBox[0] = m_scissorBox[1] = 0; |
| 1140 m_scissorBox[2] = drawingBufferWidth(); | |
| 1141 m_scissorBox[3] = drawingBufferHeight(); | |
| 1142 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2], | |
| 1143 m_scissorBox[3]); | |
| 1140 | 1144 |
| 1141 drawingBuffer()->contextProvider()->setLostContextCallback( | 1145 drawingBuffer()->contextProvider()->setLostContextCallback( |
| 1142 convertToBaseCallback(WTF::bind( | 1146 convertToBaseCallback(WTF::bind( |
| 1143 &WebGLRenderingContextBase::forceLostContext, | 1147 &WebGLRenderingContextBase::forceLostContext, |
| 1144 wrapWeakPersistent(this), WebGLRenderingContextBase::RealLostContext, | 1148 wrapWeakPersistent(this), WebGLRenderingContextBase::RealLostContext, |
| 1145 WebGLRenderingContextBase::Auto))); | 1149 WebGLRenderingContextBase::Auto))); |
| 1146 drawingBuffer()->contextProvider()->setErrorMessageCallback( | 1150 drawingBuffer()->contextProvider()->setErrorMessageCallback( |
| 1147 convertToBaseCallback( | 1151 convertToBaseCallback( |
| 1148 WTF::bind(&WebGLRenderingContextBase::onErrorMessage, | 1152 WTF::bind(&WebGLRenderingContextBase::onErrorMessage, |
| 1149 wrapWeakPersistent(this)))); | 1153 wrapWeakPersistent(this)))); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1363 !drawingBuffer()->defaultBufferRequiresAlphaChannelToBePreserved()); | 1367 !drawingBuffer()->defaultBufferRequiresAlphaChannelToBePreserved()); |
| 1364 drawingBuffer()->clearFramebuffers(clearMask); | 1368 drawingBuffer()->clearFramebuffers(clearMask); |
| 1365 | 1369 |
| 1366 restoreStateAfterClear(); | 1370 restoreStateAfterClear(); |
| 1367 drawingBuffer()->restoreFramebufferBindings(); | 1371 drawingBuffer()->restoreFramebufferBindings(); |
| 1368 drawingBuffer()->setBufferClearNeeded(false); | 1372 drawingBuffer()->setBufferClearNeeded(false); |
| 1369 | 1373 |
| 1370 return combinedClear ? CombinedClear : JustClear; | 1374 return combinedClear ? CombinedClear : JustClear; |
| 1371 } | 1375 } |
| 1372 | 1376 |
| 1373 void WebGLRenderingContextBase::restoreStateAfterClear() { | 1377 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.
| |
| 1374 if (isContextLost()) | 1378 if (isContextLost()) |
| 1375 return; | 1379 return; |
| 1376 | 1380 |
| 1377 // Restore the state that the context set. | 1381 if (stateMask & StateScissorEnabled) { |
| 1378 if (m_scissorEnabled) | 1382 if (m_scissorEnabled) { |
| 1379 contextGL()->Enable(GL_SCISSOR_TEST); | 1383 contextGL()->Enable(GL_SCISSOR_TEST); |
| 1380 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], | 1384 } else { |
| 1381 m_clearColor[3]); | 1385 contextGL()->Disable(GL_SCISSOR_TEST); |
| 1382 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], | 1386 } |
| 1383 m_colorMask[3]); | 1387 } |
| 1384 contextGL()->ClearDepthf(m_clearDepth); | 1388 |
| 1385 contextGL()->ClearStencil(m_clearStencil); | 1389 if (stateMask & StateScissorBox) { |
| 1386 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); | 1390 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2], |
| 1387 contextGL()->DepthMask(m_depthMask); | 1391 m_scissorBox[3]); |
| 1392 } | |
| 1393 | |
| 1394 if (stateMask & StateClearColor) { | |
| 1395 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], | |
| 1396 m_clearColor[3]); | |
| 1397 } | |
| 1398 | |
| 1399 if (stateMask & StateColorMask) { | |
| 1400 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], | |
| 1401 m_colorMask[3]); | |
| 1402 } | |
| 1403 | |
| 1404 if (stateMask & StateClearDepthf) { | |
| 1405 contextGL()->ClearDepthf(m_clearDepth); | |
| 1406 } | |
| 1407 | |
| 1408 if (stateMask & StateClearStencil) { | |
| 1409 contextGL()->ClearStencil(m_clearStencil); | |
| 1410 } | |
| 1411 | |
| 1412 if (stateMask & StateStencilMaskSeparate) { | |
| 1413 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); | |
| 1414 } | |
| 1415 | |
| 1416 if (stateMask & StateDepthMask) { | |
| 1417 contextGL()->DepthMask(m_depthMask); | |
| 1418 } | |
| 1419 } | |
| 1420 | |
| 1421 void WebGLRenderingContextBase::restoreStateAfterClear() { | |
| 1422 // Restore clear-related state items back to what the context had set. | |
| 1423 restoreStateFromContext(StateScissorEnabled | StateClearColor | | |
| 1424 StateColorMask | StateClearDepthf | | |
| 1425 StateClearStencil | StateStencilMaskSeparate | | |
| 1426 StateDepthMask); | |
| 1388 } | 1427 } |
| 1389 | 1428 |
| 1390 void WebGLRenderingContextBase::markLayerComposited() { | 1429 void WebGLRenderingContextBase::markLayerComposited() { |
| 1391 if (!isContextLost()) | 1430 if (!isContextLost()) |
| 1392 drawingBuffer()->setBufferClearNeeded(true); | 1431 drawingBuffer()->setBufferClearNeeded(true); |
| 1393 } | 1432 } |
| 1394 | 1433 |
| 1395 void WebGLRenderingContextBase::setIsHidden(bool hidden) { | 1434 void WebGLRenderingContextBase::setIsHidden(bool hidden) { |
| 1396 m_isHidden = hidden; | 1435 m_isHidden = hidden; |
| 1397 if (drawingBuffer()) | 1436 if (drawingBuffer()) |
| (...skipping 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4149 return; | 4188 return; |
| 4150 contextGL()->SampleCoverage(value, invert); | 4189 contextGL()->SampleCoverage(value, invert); |
| 4151 } | 4190 } |
| 4152 | 4191 |
| 4153 void WebGLRenderingContextBase::scissor(GLint x, | 4192 void WebGLRenderingContextBase::scissor(GLint x, |
| 4154 GLint y, | 4193 GLint y, |
| 4155 GLsizei width, | 4194 GLsizei width, |
| 4156 GLsizei height) { | 4195 GLsizei height) { |
| 4157 if (isContextLost()) | 4196 if (isContextLost()) |
| 4158 return; | 4197 return; |
| 4198 m_scissorBox[0] = x; | |
| 4199 m_scissorBox[1] = y; | |
| 4200 m_scissorBox[2] = width; | |
| 4201 m_scissorBox[3] = height; | |
| 4159 contextGL()->Scissor(x, y, width, height); | 4202 contextGL()->Scissor(x, y, width, height); |
| 4160 } | 4203 } |
| 4161 | 4204 |
| 4162 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, | 4205 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, |
| 4163 const String& string) { | 4206 const String& string) { |
| 4164 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) | 4207 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) |
| 4165 return; | 4208 return; |
| 4166 String stringWithoutComments = StripComments(string).result(); | 4209 String stringWithoutComments = StripComments(string).result(); |
| 4167 // TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 S trings) | 4210 // TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 S trings) |
| 4168 // so we don't need to use StringUTF8Adaptor. | 4211 // so we don't need to use StringUTF8Adaptor. |
| (...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7428 | 7471 |
| 7429 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7472 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7430 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7473 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7431 if (canvas()) | 7474 if (canvas()) |
| 7432 result.setHTMLCanvasElement(canvas()); | 7475 result.setHTMLCanvasElement(canvas()); |
| 7433 else | 7476 else |
| 7434 result.setOffscreenCanvas(getOffscreenCanvas()); | 7477 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 7435 } | 7478 } |
| 7436 | 7479 |
| 7437 } // namespace blink | 7480 } // namespace blink |
| OLD | NEW |