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::restoreScissorEnabled() { |
1374 if (isContextLost()) | 1378 if (isContextLost()) |
1375 return; | 1379 return; |
1376 | 1380 |
1377 // Restore the state that the context set. | 1381 if (m_scissorEnabled) { |
1378 if (m_scissorEnabled) | |
1379 contextGL()->Enable(GL_SCISSOR_TEST); | 1382 contextGL()->Enable(GL_SCISSOR_TEST); |
| 1383 } else { |
| 1384 contextGL()->Disable(GL_SCISSOR_TEST); |
| 1385 } |
| 1386 } |
| 1387 |
| 1388 void WebGLRenderingContextBase::restoreScissorBox() { |
| 1389 if (isContextLost()) |
| 1390 return; |
| 1391 |
| 1392 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2], |
| 1393 m_scissorBox[3]); |
| 1394 } |
| 1395 |
| 1396 void WebGLRenderingContextBase::restoreClearColor() { |
| 1397 if (isContextLost()) |
| 1398 return; |
| 1399 |
1380 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], | 1400 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], |
1381 m_clearColor[3]); | 1401 m_clearColor[3]); |
| 1402 } |
| 1403 |
| 1404 void WebGLRenderingContextBase::restoreClearDepthf() { |
| 1405 if (isContextLost()) |
| 1406 return; |
| 1407 |
| 1408 contextGL()->ClearDepthf(m_clearDepth); |
| 1409 } |
| 1410 |
| 1411 void WebGLRenderingContextBase::restoreClearStencil() { |
| 1412 if (isContextLost()) |
| 1413 return; |
| 1414 |
| 1415 contextGL()->ClearStencil(m_clearStencil); |
| 1416 } |
| 1417 |
| 1418 void WebGLRenderingContextBase::restoreStencilMaskSeparate() { |
| 1419 if (isContextLost()) |
| 1420 return; |
| 1421 |
| 1422 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); |
| 1423 } |
| 1424 |
| 1425 void WebGLRenderingContextBase::restoreColorMask() { |
| 1426 if (isContextLost()) |
| 1427 return; |
| 1428 |
1382 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], | 1429 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], |
1383 m_colorMask[3]); | 1430 m_colorMask[3]); |
1384 contextGL()->ClearDepthf(m_clearDepth); | 1431 } |
1385 contextGL()->ClearStencil(m_clearStencil); | 1432 |
1386 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); | 1433 void WebGLRenderingContextBase::restoreDepthMask() { |
| 1434 if (isContextLost()) |
| 1435 return; |
| 1436 |
1387 contextGL()->DepthMask(m_depthMask); | 1437 contextGL()->DepthMask(m_depthMask); |
1388 } | 1438 } |
1389 | 1439 |
| 1440 void WebGLRenderingContextBase::restoreStateAfterClear() { |
| 1441 // Restore clear-related state items back to what the context had set. |
| 1442 restoreScissorEnabled(); |
| 1443 restoreClearColor(); |
| 1444 restoreColorMask(); |
| 1445 restoreClearDepthf(); |
| 1446 restoreClearStencil(); |
| 1447 restoreStencilMaskSeparate(); |
| 1448 restoreDepthMask(); |
| 1449 } |
| 1450 |
1390 void WebGLRenderingContextBase::markLayerComposited() { | 1451 void WebGLRenderingContextBase::markLayerComposited() { |
1391 if (!isContextLost()) | 1452 if (!isContextLost()) |
1392 drawingBuffer()->setBufferClearNeeded(true); | 1453 drawingBuffer()->setBufferClearNeeded(true); |
1393 } | 1454 } |
1394 | 1455 |
1395 void WebGLRenderingContextBase::setIsHidden(bool hidden) { | 1456 void WebGLRenderingContextBase::setIsHidden(bool hidden) { |
1396 m_isHidden = hidden; | 1457 m_isHidden = hidden; |
1397 if (drawingBuffer()) | 1458 if (drawingBuffer()) |
1398 drawingBuffer()->setIsHidden(hidden); | 1459 drawingBuffer()->setIsHidden(hidden); |
1399 | 1460 |
(...skipping 2749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4149 return; | 4210 return; |
4150 contextGL()->SampleCoverage(value, invert); | 4211 contextGL()->SampleCoverage(value, invert); |
4151 } | 4212 } |
4152 | 4213 |
4153 void WebGLRenderingContextBase::scissor(GLint x, | 4214 void WebGLRenderingContextBase::scissor(GLint x, |
4154 GLint y, | 4215 GLint y, |
4155 GLsizei width, | 4216 GLsizei width, |
4156 GLsizei height) { | 4217 GLsizei height) { |
4157 if (isContextLost()) | 4218 if (isContextLost()) |
4158 return; | 4219 return; |
| 4220 m_scissorBox[0] = x; |
| 4221 m_scissorBox[1] = y; |
| 4222 m_scissorBox[2] = width; |
| 4223 m_scissorBox[3] = height; |
4159 contextGL()->Scissor(x, y, width, height); | 4224 contextGL()->Scissor(x, y, width, height); |
4160 } | 4225 } |
4161 | 4226 |
4162 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, | 4227 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, |
4163 const String& string) { | 4228 const String& string) { |
4164 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) | 4229 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) |
4165 return; | 4230 return; |
4166 String stringWithoutComments = StripComments(string).result(); | 4231 String stringWithoutComments = StripComments(string).result(); |
4167 // TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 S
trings) | 4232 // TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 S
trings) |
4168 // so we don't need to use StringUTF8Adaptor. | 4233 // so we don't need to use StringUTF8Adaptor. |
(...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7428 | 7493 |
7429 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7494 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7430 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7495 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7431 if (canvas()) | 7496 if (canvas()) |
7432 result.setHTMLCanvasElement(canvas()); | 7497 result.setHTMLCanvasElement(canvas()); |
7433 else | 7498 else |
7434 result.setOffscreenCanvas(getOffscreenCanvas()); | 7499 result.setOffscreenCanvas(getOffscreenCanvas()); |
7435 } | 7500 } |
7436 | 7501 |
7437 } // namespace blink | 7502 } // namespace blink |
OLD | NEW |