OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/html/canvas/WebGL2RenderingContextBase.h" | 6 #include "core/html/canvas/WebGL2RenderingContextBase.h" |
7 | 7 |
8 #include "bindings/core/v8/WebGLAny.h" | 8 #include "bindings/core/v8/WebGLAny.h" |
9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 m_readFramebufferBinding = buffer; | 1336 m_readFramebufferBinding = buffer; |
1337 break; | 1337 break; |
1338 default: | 1338 default: |
1339 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 1339 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
1340 return; | 1340 return; |
1341 } | 1341 } |
1342 | 1342 |
1343 setFramebuffer(target, buffer); | 1343 setFramebuffer(target, buffer); |
1344 } | 1344 } |
1345 | 1345 |
1346 void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer ) | |
1347 { | |
1348 if (!deleteObject(framebuffer)) | |
1349 return; | |
1350 GLenum target = 0; | |
1351 if (framebuffer == m_framebufferBinding) { | |
1352 if (framebuffer == m_readFramebufferBinding) { | |
1353 target = GL_FRAMEBUFFER; | |
1354 m_framebufferBinding = nullptr; | |
1355 m_readFramebufferBinding = nullptr; | |
1356 } else { | |
1357 target = GL_DRAW_FRAMEBUFFER; | |
1358 m_framebufferBinding = nullptr; | |
1359 } | |
1360 } else if (framebuffer == m_readFramebufferBinding) { | |
1361 target = GL_READ_FRAMEBUFFER; | |
1362 m_readFramebufferBinding = nullptr; | |
1363 } | |
1364 if (target) { | |
1365 drawingBuffer()->setFramebufferBinding(0, target); | |
1366 // Have to call bindFramebuffer here to bind back to internal fbo. | |
bajones
2015/05/06 17:47:53
Comment doesn't match associated line. Should be /
yunchao
2015/05/22 09:54:35
Acknowledged.
| |
1367 drawingBuffer()->bind(target); | |
1368 } | |
1369 } | |
1370 | |
1346 ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, G Lenum pname) | 1371 ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, G Lenum pname) |
1347 { | 1372 { |
1348 if (isContextLost()) | 1373 if (isContextLost()) |
1349 return ScriptValue::createNull(scriptState); | 1374 return ScriptValue::createNull(scriptState); |
1350 switch (pname) { | 1375 switch (pname) { |
1351 case GL_SHADING_LANGUAGE_VERSION: | 1376 case GL_SHADING_LANGUAGE_VERSION: |
1352 return WebGLAny(scriptState, "WebGL GLSL ES 2.0 (" + String(webContext() ->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); | 1377 return WebGLAny(scriptState, "WebGL GLSL ES 2.0 (" + String(webContext() ->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); |
1353 case GL_VERSION: | 1378 case GL_VERSION: |
1354 return WebGLAny(scriptState, "WebGL 2.0 (" + String(webContext()->getStr ing(GL_VERSION)) + ")"); | 1379 return WebGLAny(scriptState, "WebGL 2.0 (" + String(webContext()->getStr ing(GL_VERSION)) + ")"); |
1355 | 1380 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1705 { | 1730 { |
1706 GLfloat value = 0.f; | 1731 GLfloat value = 0.f; |
1707 webContext()->getTexParameterfv(target, pname, &value); | 1732 webContext()->getTexParameterfv(target, pname, &value); |
1708 return WebGLAny(scriptState, value); | 1733 return WebGLAny(scriptState, value); |
1709 } | 1734 } |
1710 default: | 1735 default: |
1711 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p name); | 1736 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p name); |
1712 } | 1737 } |
1713 } | 1738 } |
1714 | 1739 |
1740 void WebGL2RenderingContextBase::restoreCurrentFramebuffer() | |
1741 { | |
1742 bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_framebufferBinding.get()); | |
1743 bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding.get()); | |
1744 } | |
1745 | |
1746 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | |
1747 { | |
1748 GLenum colorFormat = 0, readColorFormat = 0, defaultColorFormat = GL_RGB; | |
1749 if (m_requestedAttributes.alpha()) | |
1750 defaultColorFormat = GL_RGBA; | |
1751 if (m_framebufferBinding && m_framebufferBinding->object()) | |
1752 colorFormat = m_framebufferBinding->colorBufferFormat(); | |
1753 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | |
1754 readColorFormat = m_readFramebufferBinding->colorBufferFormat(); | |
1755 // Both read and draw framebuffer are bound to FBO | |
1756 if (colorFormat != 0 && readColorFormat != 0) | |
1757 return colorFormat & readColorFormat; | |
Ken Russell (switch to Gerrit)
2015/05/06 21:17:33
I don't understand what this code is attempting to
yunchao
2015/05/22 09:54:35
I thought that both the read buffer and the draw b
| |
1758 // Either read or draw framebuffe is bound to FBO | |
1759 if (colorFormat != 0 || readColorFormat != 0) | |
1760 return colorFormat & defaultColorFormat; | |
1761 // No framebuffer is bound to FBO | |
1762 return defaultColorFormat; | |
1763 } | |
1764 | |
1715 } // namespace blink | 1765 } // namespace blink |
OLD | NEW |