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 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 m_readFramebufferBinding = buffer; | 1552 m_readFramebufferBinding = buffer; |
1553 break; | 1553 break; |
1554 default: | 1554 default: |
1555 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 1555 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
1556 return; | 1556 return; |
1557 } | 1557 } |
1558 | 1558 |
1559 setFramebuffer(target, buffer); | 1559 setFramebuffer(target, buffer); |
1560 } | 1560 } |
1561 | 1561 |
1562 void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer ) | |
1563 { | |
1564 if (!deleteObject(framebuffer)) | |
1565 return; | |
1566 GLenum target = 0; | |
1567 if (framebuffer == m_framebufferBinding) { | |
1568 if (framebuffer == m_readFramebufferBinding) { | |
1569 target = GL_FRAMEBUFFER; | |
1570 m_framebufferBinding = nullptr; | |
1571 m_readFramebufferBinding = nullptr; | |
1572 } else { | |
1573 target = GL_DRAW_FRAMEBUFFER; | |
1574 m_framebufferBinding = nullptr; | |
1575 } | |
1576 } else if (framebuffer == m_readFramebufferBinding) { | |
1577 target = GL_READ_FRAMEBUFFER; | |
Zhenyao Mo
2015/06/09 20:29:50
As I mentioned in another place, no need for drawi
yunchao
2015/06/10 08:21:24
seems that there is no problem.
| |
1578 m_readFramebufferBinding = nullptr; | |
1579 } | |
1580 if (target) { | |
1581 drawingBuffer()->setFramebufferBinding(target, 0); | |
1582 // Have to call drawingBuffer()->bind() here to bind back to internal fb o. | |
1583 drawingBuffer()->bind(target); | |
1584 } | |
1585 } | |
1586 | |
1562 ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, G Lenum pname) | 1587 ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, G Lenum pname) |
1563 { | 1588 { |
1564 if (isContextLost()) | 1589 if (isContextLost()) |
1565 return ScriptValue::createNull(scriptState); | 1590 return ScriptValue::createNull(scriptState); |
1566 switch (pname) { | 1591 switch (pname) { |
1567 case GL_SHADING_LANGUAGE_VERSION: | 1592 case GL_SHADING_LANGUAGE_VERSION: |
1568 return WebGLAny(scriptState, "WebGL GLSL ES 3.00 (" + String(webContext( )->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); | 1593 return WebGLAny(scriptState, "WebGL GLSL ES 3.00 (" + String(webContext( )->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); |
1569 case GL_VERSION: | 1594 case GL_VERSION: |
1570 return WebGLAny(scriptState, "WebGL 2.0 (" + String(webContext()->getStr ing(GL_VERSION)) + ")"); | 1595 return WebGLAny(scriptState, "WebGL 2.0 (" + String(webContext()->getStr ing(GL_VERSION)) + ")"); |
1571 | 1596 |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2075 if (m_boundPixelUnpackBuffer == buffer) | 2100 if (m_boundPixelUnpackBuffer == buffer) |
2076 m_boundPixelUnpackBuffer = nullptr; | 2101 m_boundPixelUnpackBuffer = nullptr; |
2077 if (m_boundTransformFeedbackBuffer == buffer) | 2102 if (m_boundTransformFeedbackBuffer == buffer) |
2078 m_boundTransformFeedbackBuffer = nullptr; | 2103 m_boundTransformFeedbackBuffer = nullptr; |
2079 if (m_boundUniformBuffer == buffer) | 2104 if (m_boundUniformBuffer == buffer) |
2080 m_boundUniformBuffer = nullptr; | 2105 m_boundUniformBuffer = nullptr; |
2081 | 2106 |
2082 WebGLRenderingContextBase::removeBoundBuffer(buffer); | 2107 WebGLRenderingContextBase::removeBoundBuffer(buffer); |
2083 } | 2108 } |
2084 | 2109 |
2110 void WebGL2RenderingContextBase::restoreCurrentFramebuffer() | |
2111 { | |
2112 bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_framebufferBinding.get()); | |
2113 bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding.get()); | |
2114 } | |
2115 | |
2116 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | |
2117 { | |
2118 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | |
2119 return m_readFramebufferBinding->colorBufferFormat(); | |
2120 if (m_requestedAttributes.alpha()) | |
2121 return GL_RGBA; | |
2122 return GL_RGB; | |
2123 } | |
2124 | |
2085 } // namespace blink | 2125 } // namespace blink |
OLD | NEW |