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 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 | 1132 |
1133 m_defaultVertexArrayObject = WebGLVertexArrayObject::create( | 1133 m_defaultVertexArrayObject = WebGLVertexArrayObject::create( |
1134 this, WebGLVertexArrayObjectBase::VaoTypeDefault); | 1134 this, WebGLVertexArrayObjectBase::VaoTypeDefault); |
1135 addContextObject(m_defaultVertexArrayObject.get()); | 1135 addContextObject(m_defaultVertexArrayObject.get()); |
1136 | 1136 |
1137 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 1137 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
1138 | 1138 |
1139 m_vertexAttribType.resize(m_maxVertexAttribs); | 1139 m_vertexAttribType.resize(m_maxVertexAttribs); |
1140 | 1140 |
1141 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1141 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
1142 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1142 m_scissorBox[0] = m_scissorBox[1] = 0; |
| 1143 m_scissorBox[2] = drawingBufferWidth(); |
| 1144 m_scissorBox[3] = drawingBufferHeight(); |
| 1145 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2], |
| 1146 m_scissorBox[3]); |
1143 | 1147 |
1144 drawingBuffer()->contextProvider()->setLostContextCallback( | 1148 drawingBuffer()->contextProvider()->setLostContextCallback( |
1145 convertToBaseCallback(WTF::bind( | 1149 convertToBaseCallback(WTF::bind( |
1146 &WebGLRenderingContextBase::forceLostContext, | 1150 &WebGLRenderingContextBase::forceLostContext, |
1147 wrapWeakPersistent(this), WebGLRenderingContextBase::RealLostContext, | 1151 wrapWeakPersistent(this), WebGLRenderingContextBase::RealLostContext, |
1148 WebGLRenderingContextBase::Auto))); | 1152 WebGLRenderingContextBase::Auto))); |
1149 drawingBuffer()->contextProvider()->setErrorMessageCallback( | 1153 drawingBuffer()->contextProvider()->setErrorMessageCallback( |
1150 convertToBaseCallback( | 1154 convertToBaseCallback( |
1151 WTF::bind(&WebGLRenderingContextBase::onErrorMessage, | 1155 WTF::bind(&WebGLRenderingContextBase::onErrorMessage, |
1152 wrapWeakPersistent(this)))); | 1156 wrapWeakPersistent(this)))); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 !drawingBuffer()->defaultBufferRequiresAlphaChannelToBePreserved()); | 1375 !drawingBuffer()->defaultBufferRequiresAlphaChannelToBePreserved()); |
1372 drawingBuffer()->clearFramebuffers(clearMask); | 1376 drawingBuffer()->clearFramebuffers(clearMask); |
1373 | 1377 |
1374 restoreStateAfterClear(); | 1378 restoreStateAfterClear(); |
1375 drawingBuffer()->restoreFramebufferBindings(); | 1379 drawingBuffer()->restoreFramebufferBindings(); |
1376 drawingBuffer()->setBufferClearNeeded(false); | 1380 drawingBuffer()->setBufferClearNeeded(false); |
1377 | 1381 |
1378 return combinedClear ? CombinedClear : JustClear; | 1382 return combinedClear ? CombinedClear : JustClear; |
1379 } | 1383 } |
1380 | 1384 |
1381 void WebGLRenderingContextBase::restoreStateAfterClear() { | 1385 void WebGLRenderingContextBase::restoreScissorEnabled() { |
1382 if (isContextLost()) | 1386 if (isContextLost()) |
1383 return; | 1387 return; |
1384 | 1388 |
1385 // Restore the state that the context set. | 1389 if (m_scissorEnabled) { |
1386 if (m_scissorEnabled) | |
1387 contextGL()->Enable(GL_SCISSOR_TEST); | 1390 contextGL()->Enable(GL_SCISSOR_TEST); |
| 1391 } else { |
| 1392 contextGL()->Disable(GL_SCISSOR_TEST); |
| 1393 } |
| 1394 } |
| 1395 |
| 1396 void WebGLRenderingContextBase::restoreScissorBox() { |
| 1397 if (isContextLost()) |
| 1398 return; |
| 1399 |
| 1400 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2], |
| 1401 m_scissorBox[3]); |
| 1402 } |
| 1403 |
| 1404 void WebGLRenderingContextBase::restoreClearColor() { |
| 1405 if (isContextLost()) |
| 1406 return; |
| 1407 |
1388 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], | 1408 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], |
1389 m_clearColor[3]); | 1409 m_clearColor[3]); |
| 1410 } |
| 1411 |
| 1412 void WebGLRenderingContextBase::restoreClearDepthf() { |
| 1413 if (isContextLost()) |
| 1414 return; |
| 1415 |
| 1416 contextGL()->ClearDepthf(m_clearDepth); |
| 1417 } |
| 1418 |
| 1419 void WebGLRenderingContextBase::restoreClearStencil() { |
| 1420 if (isContextLost()) |
| 1421 return; |
| 1422 |
| 1423 contextGL()->ClearStencil(m_clearStencil); |
| 1424 } |
| 1425 |
| 1426 void WebGLRenderingContextBase::restoreStencilMaskSeparate() { |
| 1427 if (isContextLost()) |
| 1428 return; |
| 1429 |
| 1430 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); |
| 1431 } |
| 1432 |
| 1433 void WebGLRenderingContextBase::restoreColorMask() { |
| 1434 if (isContextLost()) |
| 1435 return; |
| 1436 |
1390 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], | 1437 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], |
1391 m_colorMask[3]); | 1438 m_colorMask[3]); |
1392 contextGL()->ClearDepthf(m_clearDepth); | 1439 } |
1393 contextGL()->ClearStencil(m_clearStencil); | 1440 |
1394 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); | 1441 void WebGLRenderingContextBase::restoreDepthMask() { |
| 1442 if (isContextLost()) |
| 1443 return; |
| 1444 |
1395 contextGL()->DepthMask(m_depthMask); | 1445 contextGL()->DepthMask(m_depthMask); |
1396 } | 1446 } |
1397 | 1447 |
| 1448 void WebGLRenderingContextBase::restoreStateAfterClear() { |
| 1449 // Restore clear-related state items back to what the context had set. |
| 1450 restoreScissorEnabled(); |
| 1451 restoreClearColor(); |
| 1452 restoreColorMask(); |
| 1453 restoreClearDepthf(); |
| 1454 restoreClearStencil(); |
| 1455 restoreStencilMaskSeparate(); |
| 1456 restoreDepthMask(); |
| 1457 } |
| 1458 |
1398 void WebGLRenderingContextBase::markLayerComposited() { | 1459 void WebGLRenderingContextBase::markLayerComposited() { |
1399 if (!isContextLost()) | 1460 if (!isContextLost()) |
1400 drawingBuffer()->setBufferClearNeeded(true); | 1461 drawingBuffer()->setBufferClearNeeded(true); |
1401 } | 1462 } |
1402 | 1463 |
1403 void WebGLRenderingContextBase::setIsHidden(bool hidden) { | 1464 void WebGLRenderingContextBase::setIsHidden(bool hidden) { |
1404 m_isHidden = hidden; | 1465 m_isHidden = hidden; |
1405 if (drawingBuffer()) | 1466 if (drawingBuffer()) |
1406 drawingBuffer()->setIsHidden(hidden); | 1467 drawingBuffer()->setIsHidden(hidden); |
1407 | 1468 |
(...skipping 2727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4135 return; | 4196 return; |
4136 contextGL()->SampleCoverage(value, invert); | 4197 contextGL()->SampleCoverage(value, invert); |
4137 } | 4198 } |
4138 | 4199 |
4139 void WebGLRenderingContextBase::scissor(GLint x, | 4200 void WebGLRenderingContextBase::scissor(GLint x, |
4140 GLint y, | 4201 GLint y, |
4141 GLsizei width, | 4202 GLsizei width, |
4142 GLsizei height) { | 4203 GLsizei height) { |
4143 if (isContextLost()) | 4204 if (isContextLost()) |
4144 return; | 4205 return; |
| 4206 m_scissorBox[0] = x; |
| 4207 m_scissorBox[1] = y; |
| 4208 m_scissorBox[2] = width; |
| 4209 m_scissorBox[3] = height; |
4145 contextGL()->Scissor(x, y, width, height); | 4210 contextGL()->Scissor(x, y, width, height); |
4146 } | 4211 } |
4147 | 4212 |
4148 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, | 4213 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, |
4149 const String& string) { | 4214 const String& string) { |
4150 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) | 4215 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) |
4151 return; | 4216 return; |
4152 String stringWithoutComments = StripComments(string).result(); | 4217 String stringWithoutComments = StripComments(string).result(); |
4153 // TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 | 4218 // TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 |
4154 // Strings) so we don't need to use StringUTF8Adaptor. | 4219 // Strings) so we don't need to use StringUTF8Adaptor. |
(...skipping 3286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7441 | 7506 |
7442 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7507 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7443 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7508 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7444 if (canvas()) | 7509 if (canvas()) |
7445 result.setHTMLCanvasElement(canvas()); | 7510 result.setHTMLCanvasElement(canvas()); |
7446 else | 7511 else |
7447 result.setOffscreenCanvas(getOffscreenCanvas()); | 7512 result.setOffscreenCanvas(getOffscreenCanvas()); |
7448 } | 7513 } |
7449 | 7514 |
7450 } // namespace blink | 7515 } // namespace blink |
OLD | NEW |