Index: Source/core/html/canvas/WebGL2RenderingContextBase.cpp |
diff --git a/Source/core/html/canvas/WebGL2RenderingContextBase.cpp b/Source/core/html/canvas/WebGL2RenderingContextBase.cpp |
index b7f4c18bfc6acc0154ef08ed625f80ad26cbaa0a..498f5a7b5d67a671820ae0d6447865e77ccafb67 100644 |
--- a/Source/core/html/canvas/WebGL2RenderingContextBase.cpp |
+++ b/Source/core/html/canvas/WebGL2RenderingContextBase.cpp |
@@ -1343,6 +1343,31 @@ void WebGL2RenderingContextBase::bindFramebuffer(GLenum target, WebGLFramebuffer |
setFramebuffer(target, buffer); |
} |
+void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) |
+{ |
+ if (!deleteObject(framebuffer)) |
+ return; |
+ GLenum target = 0; |
+ if (framebuffer == m_framebufferBinding) { |
+ if (framebuffer == m_readFramebufferBinding) { |
+ target = GL_FRAMEBUFFER; |
+ m_framebufferBinding = nullptr; |
+ m_readFramebufferBinding = nullptr; |
+ } else { |
+ target = GL_DRAW_FRAMEBUFFER; |
+ m_framebufferBinding = nullptr; |
+ } |
+ } else if (framebuffer == m_readFramebufferBinding) { |
+ target = GL_READ_FRAMEBUFFER; |
+ m_readFramebufferBinding = nullptr; |
+ } |
+ if (target) { |
+ drawingBuffer()->setFramebufferBinding(0, target); |
+ // 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.
|
+ drawingBuffer()->bind(target); |
+ } |
+} |
+ |
ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, GLenum pname) |
{ |
if (isContextLost()) |
@@ -1712,4 +1737,29 @@ ScriptValue WebGL2RenderingContextBase::getTexParameter(ScriptState* scriptState |
} |
} |
+void WebGL2RenderingContextBase::restoreCurrentFramebuffer() |
+{ |
+ bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_framebufferBinding.get()); |
+ bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding.get()); |
+} |
+ |
+GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
+{ |
+ GLenum colorFormat = 0, readColorFormat = 0, defaultColorFormat = GL_RGB; |
+ if (m_requestedAttributes.alpha()) |
+ defaultColorFormat = GL_RGBA; |
+ if (m_framebufferBinding && m_framebufferBinding->object()) |
+ colorFormat = m_framebufferBinding->colorBufferFormat(); |
+ if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
+ readColorFormat = m_readFramebufferBinding->colorBufferFormat(); |
+ // Both read and draw framebuffer are bound to FBO |
+ if (colorFormat != 0 && readColorFormat != 0) |
+ 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
|
+ // Either read or draw framebuffe is bound to FBO |
+ if (colorFormat != 0 || readColorFormat != 0) |
+ return colorFormat & defaultColorFormat; |
+ // No framebuffer is bound to FBO |
+ return defaultColorFormat; |
+} |
+ |
} // namespace blink |